Reputation: 2197
I love working with TypeScript in VSCode and seeing all the errors automatically pop up with red underlining. I even set "typescript.tsserver.experimental.enableProjectDiagnostics": true
so that I can see any errors pop up on any file and have the file turn red in my tree.
But one thing that feel is sorely missing is the ability to automatically flag (as an error) any unresolved types in the global .d.ts
type files.
Currently, if I write something in a .ts
file like this:
// example.ts
const a: Age | NotADefinedType = "foo";
// ^ This errors bc it's unresolved 👍
Then I get an error and a red squiggly line showing that this is an unresolved type. This is great.
But if I use an unresolved type in a .d.ts
file I don't get any error. For example:
// types.d.ts
type Age = number;
type Quality = Age | NotADefinedType;
// ^ I want this to error, but it doesn't 👎
All this does is turn Quality
into type any
, which can be quite dangerous for the rest of my code. I don't get any warning that the NotADefinedType
is unresolved, except for when I move my mouse over NotADefinedType and I see type NotADefinedType = /* unresolved */ any
in the quick info popup.
Is there a way to turn these kinds of warnings on in .d.ts
files to avoid these errors of accidentally turning types into any
?
Upvotes: 6
Views: 2377
Reputation: 295
I had the same problem. For me it was the skipLibCheck
option. Maybe this is the same for you? Check out my answer on this post for more details
Upvotes: 3