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

Do not skipLibCheck #15

Closed
fregante opened this issue Sep 3, 2021 · 5 comments
Closed

Do not skipLibCheck #15

fregante opened this issue Sep 3, 2021 · 5 comments

Comments

@fregante
Copy link
Contributor

fregante commented Sep 3, 2021

I'm currently looking into using d.ts files as a way to declare some types using imports from libraries without risking to import the libraries themselves.

Example:

// my.d.ts
import eslint from "eslint"

export type ESLint = typeof esIint;

Did you catch that? TypeScript didn't. The .d.ts file above "passes" tsc validation but typeof eslint is spelled as typeof ESIINT.

Use skipLibCheck: false and it works:

Screen Shot 4

@sindresorhus
Copy link
Owner

But with lib skip off, checking becomes much slower... Is there any way to only check local files and ignore other packages? If not, might be worth opening a TS issue.

@voxpelli
Copy link

voxpelli commented Sep 3, 2021

Skip type checking of declaration files.

I had interpreted / remembered this option as meaning that types within dependencies weren't checked to be correct, only ones defined in ones own project, but the quote above is from the docs, so I agree, it's not good to have. See: https://www.typescriptlang.org/tsconfig#skipLibCheck

@fregante
Copy link
Contributor Author

fregante commented Sep 4, 2021

Yeah I suppose the intended use of d.ts is to share types across libraries rather than locally, hence the skip LIB check.

In the past I enabled this flag (in an attempt) to fix some node_modules issues too, but I don't remember if it was effectively. Disabling it might bring those back (however I disabled it in a couple of large projects without issue)

@voxpelli
Copy link

So – ran into this again in type-fest: sindresorhus/type-fest#785

Whenever one handcrafts .d.ts files one should really keep skipLibCheck turned off.

@voxpelli
Copy link

Another victim of skipLibCheck: octet-stream/form-data-encoder#24

Inadvertently makes got require skipLibCheck or dom types

Would have been caught if this config would disable skipLibCheck

(I’ll report a proper issue in got later on, for now just want to document it as yet another skipLibCheck problem)

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

No branches or pull requests

3 participants