Open
Description
Suggestion
π Search Terms
unknown instead of any error
β Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
currently, when a type fails to resolve, there's an error in an external lib suppressed by skipLibCheck
, or an error suppressed by @ts-expect-error
/@ts-ignore
, the type falls back to any
it would be nice if there was a compiler option that changes this behavior to unknown
instead of any
. it would make this feature even more useful too
π Motivating Example
currently, @ts-ignore
and @ts-expect-error
comments aren't exposed in .d.ts
files. one of the concerns with changing this functionality seems to be that it can result in any
leaking into the codebase (see #38628 (comment)).
π» Use Cases
- makes it safer to use
skipLibCheck
, for example if a lib was compiled using a different version of typescript which causes errors on the version you're using - makes it a little bit safer to use
@ts-expect-error