question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

noEmit and skipLibCheck should be on by default in TS compiler options

See original GitHub issue

This is a related issue to #352. The build script works with rollup.js, not tsc, so the noEmit option should be enabled by default. Users running npx tsc shouldn’t expect to have to specify --noEmit, because using tsc is a normal part of TS development. Currently npx tsc will clutter the src directory with transpiled files, which can be difficult to clean up if there are uncommitted changes mixed in.

This is important because without tsc there is no way to do project-wide type checking. The build script will only stop at the first error. The test runner will report errors, but only for files that are tested, and it’s also the wrong place for type checking (#521).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:31 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ortacommented, Mar 12, 2020

This thread winds through a few topics, so I’ll give my ideas in short-form

  • I don’t think skipLibCheck should be enabled for users by default, personally. The flag explicitly breaks some of the type system contracts and is available if you need it, but that should be edge-cases not for everyone.

  • I’m a believer in using babel for transpiling and ts for type-checking when dealing with web. As a pragmatist, you probably already have babel in the tree, and it keeps build tools consistent. I’m personally against having types checking happening in tests, because I wouldn’t want them blocking running a test. Whether using ts-jest or ts-babel is generally

  • WRT incremental / build mode etc - these are useful for when TS is emitting the .js files in composite projects - which probably isn’t happening in your watch mode which needs to go through rollup?

  • the OP on noEmit makes sense to me, given that it would be surprising to me too to see a bunch of ts files.

3reactions
jaredpalmercommented, Mar 11, 2020

This is a really good discussion. Learned a lot about TS!

A bit of history, when I made TSDX I made one change to how Formik’s build system worked: rpts2. OG pre-tsdx Formik used to use a two-step build (because Babel TS didn’t really exist yet). First it would use tsc and emit esnext js to a temp directory. Then rollup would bundle the temp directory to dist (so it could use Babel plugins). It’s very possible that I incorrectly kept around some TS config options that became redundant by switching to rpts2 but never noticed because “it just worked.” — FWIW, my course of action with libraries and apps differs with respect to incorrect dependency types. When writing an app, I will 100% use patch-package to fix the types. I want to check my deps. During dev/watch, I’m fine with foregoing dep checks on large projects, but prefer it if possible. During builds, I want as much type safety as possible. When making a lib, however, I don’t think patch package is acceptable. So I usually will fork the dep and publish my own corrected version or copy it into my libs source (with proper correction) if it’s small enough. Until reading this thread, I never considered skiplibCheck for libs, but maybe I should have. I usually err on the side of strictness and correctness over build performance. —- I think the question we want to answer is what the default behavior should be for novice and intermediate typescript folks. We will obviously have to document this somewhere in an “advanced config” section

cc’ing typescript team for their suggestion @orta

tl;dr we are debating what defaults should be for noEmit, skiplibCheck, incremental builds, and emitDeclaration given how rollup-plugin-typescript2 works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Option: skipLibCheck - TypeScript
TSConfig. skipLibCheck. Skip type checking of declaration files. This can save time during compilation at the expense of type-system accuracy.
Read more >
Usage of the TypeScript compiler argument 'skipLibCheck'
To paraphrase the question tersely: Surely [enabling skipLibCheck] decreases the integrity of the typing of your application? I would agree ...
Read more >
Understanding TypeScript's skipLibCheck Once and For All
TypeScript has many advanced options that can help you fine-tune the ... By default (when skipLibCheck is false), tsc will fail to compile ......
Read more >
TSConfig Reference - TypeScript
Basic Options. Additional Checks Copy ... Generates a sourcemap for each corresponding '.d.ts' file. ... Default, Computed from the list of input files ......
Read more >
Features | Vite
Also, you can add vite/client to compilerOptions.types of your tsconfig : ... For example, to make the default import of *.svg a React...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found