Do not skipLibCheck
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:
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.
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
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)
So – ran into this again in type-fest: https://github.com/sindresorhus/type-fest/pull/785
Whenever one handcrafts .d.ts files one should really keep skipLibCheck turned off.