Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript doesn't throw error in .d.ts files

I have a *.d.ts files with the following content.

declare var a: SomeType;

I have not declared a type named SomeType anywhere, still, there is no error here instead typescript automatically interprets it as any. Changing the extension of the file from *.d.ts to *.ts there is an error.

Why is that? Is there something I can do so that typescript throws errors in *.d.ts files?

like image 413
Nishant Mittal Avatar asked Oct 23 '25 16:10

Nishant Mittal


2 Answers

In my case, this was happening because I had "skipLibCheck": true in my tsconfig.json. Turning it to false fixed this problem.

like image 82
Nishant Mittal Avatar answered Oct 26 '25 06:10

Nishant Mittal


This is intentional maybe this GitHub Issue will help you to better understand why that happens

like image 38
Zer0 Avatar answered Oct 26 '25 08:10

Zer0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!