Skip to content
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

Add prod tsconfig for lib output #430

Merged
merged 1 commit into from
Jan 9, 2021
Merged

Add prod tsconfig for lib output #430

merged 1 commit into from
Jan 9, 2021

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented Jan 9, 2021

@papb this is a pattern I've found useful in a few projects now.

  • Have a tsconfig.json which includes all source code but has noEmit: true so is only used for checking
  • Have a tsconfig.lib.json which only includes src, and extends tsconfig.json with noEmit: false. This is used to produce the actual library output.
  • tsc -p tsconfig.json is part of the lint step. It makes sure all the code in the project is ok. src, test, examples etc.
  • tsc -p tsconfig.lib.json is the build step.

The benefits are:

  • All type errors are caught by npm run lint. Here's an example from another PR of a change I had to just remember about since it wasn't flagged by CI (the file is under examples/*, which wasn't included in tsconfig.json: 435f968
  • IDEs pick up the correct settings. By default VSCode (and others, I believe), search for a tsconfig.json for settings for typescript hints/red squigglies. One example: this project has strictNullChecks: true, but since tsconfig.json was ignoring test, VSCode wasn't showing null errors. ts-jest still caught them, but it's better DX if the IDE knows what's going on.

@mmkal mmkal requested a review from papb January 9, 2021 13:14
Comment on lines +27 to +29
"*.md",
"*.js",
".*.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this config is used for eslint, it needs to include all files that we run the linter on. We're linting README.md, and the various *.config.js, *rc.js files, so need to add them here.

@mmkal mmkal merged commit 92b5d45 into master Jan 9, 2021
@mmkal mmkal deleted the tsconfig-lib branch January 9, 2021 13:22
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.

1 participant