最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - No Typescript error for unresolved types in .d.ts files? - Stack Overflow

programmeradmin1浏览0评论

For as long as I can remember, Typescript didn't warn about unresolved/undefined types in .d.ts files. I could run tsc and it wouldn't have any errors. I already have noImplicitAny enabled. This file is also in my tsconfig's include. Is this expected or is there an issue with my setup? Is there a way to make this an error?

Here's a related question specifically about VS Code (Is there a way to make VSCode show errors for unresolved types in .d.ts files?), I'm experiencing the same issue in VS Code, but even tsc has the issue.

For as long as I can remember, Typescript didn't warn about unresolved/undefined types in .d.ts files. I could run tsc and it wouldn't have any errors. I already have noImplicitAny enabled. This file is also in my tsconfig's include. Is this expected or is there an issue with my setup? Is there a way to make this an error?

Here's a related question specifically about VS Code (Is there a way to make VSCode show errors for unresolved types in .d.ts files?), I'm experiencing the same issue in VS Code, but even tsc has the issue.

Share Improve this question asked Mar 31, 2022 at 23:17 Leo JiangLeo Jiang 26.1k58 gold badges176 silver badges327 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

I was looking for an answer to the same question. In my case, it turned out that I was using a framework (SvelteKit) that had skipLibCheck: true in the default tsconfig.json. So it wasn't just the imports: there was no type checking at all in my .d.ts files. Maybe this is the same for you?

Note that setting skipLibCheck: false (the default if it's not set) can have some other consequences relating to performance and possible conflicts between .d.ts files in your node_modules. See the documentation on skipLibCheck.

发布评论

评论列表(0)

  1. 暂无评论