Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generate TypeScript declarations #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2020
Merged

Generate TypeScript declarations #134

merged 1 commit into from
Nov 12, 2020

Conversation

benmccann
Copy link
Member

@ehrencrona I'm sending this PR against your branch in #121

This builds the type declarations when you build the project

This uses rollup-plugin-typescript2 in some subprojects and @rollup/plugin-typescript in others, which probably isn't ideal, but works well enough for now.

I couldn't get @rollup/plugin-typescript to generate the types. I'm not exactly sure why, but rollup/plugins#247 might be related. I find @rollup/plugin-typescript to be so full of issues I try to avoid it as much as I can

rollup-plugin-typescript2 generated the type declarations without problem once I realized we had "emitDeclarationOnly": true and removed that so that it generated the .js files. It didn't work on a couple of the adapters, so they haven't been switched. The error message was unclear. We should file a bug to request a better error message. I was wondering if it was because of the require statements in adapter-netlify and perhaps TypeScript was expecting import statements instead

You should check that this works end-to-end and gets picked up by the other sub-projects. I wasn't quite sure how to test that all the pieces fit together

@ehrencrona
Copy link
Contributor

ehrencrona commented Nov 12, 2020

That's great! Definitely nice to get rid of that separate build step. Should we maybe add a comment in the rollup.configs explaining why they use a different TS plugin?

@benmccann
Copy link
Member Author

benmccann commented Nov 12, 2020

Ok, I added a TODO to the two that are still using @rollup/plugin-typescript

I didn't add a comment explaining why we're using rollup-plugin-typescript2 because you can't really add comments to package.json and I wasn't sure it was worth repeating the same comment in every single rollup config

@dummdidumm
Copy link
Member

Fine for me, but you should then maybe squash this merge and add a more descriptive commit message on why these changes were made - essentially copying most of what you write in the PR.

@Conduitry
Copy link
Member

On that note, I would love if that were mostly addressed by having PRs themselves squashed as part of merging them. Unfortunately, Rich is physically incapable of remembering to do this unless the 'create a merge commit' way of merging has been disabled for a repo. I imagine most people would be fine if I changed that setting.

@benmccann benmccann changed the base branch from app-util-generate-types to master November 12, 2020 16:34
@dummdidumm
Copy link
Member

Yes please 😄

@benmccann
Copy link
Member Author

Ok, I updated the commit message as suggested. I was originally sending this PR against #121, but just updated it to go against master instead so that we don't lose the commit message by squashing it with the other commits from that PR

I have no objection to squashing by default / removing the merge commit option

…nerate type declarations (.d.ts) with @rollup/plugin-typescript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants