-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unresolved any
behaves different from any
#58960
Comments
If you're |
Any way to detect if a type exists? |
Even though it is not a defect, I'm very curious which PR caused this change. 👀 |
I think this is fair. My example abuses However, TypeScript uses a type that looks like The following mechanism appears to work between TypeScript versions to check whether a type is interface Fallback {
fallback: string
}
type Preferred = any
export type Wanted = void extends Preferred ? Fallback : Preferred |
This solution solves an upstream regression and is backwards compatible for our use case. Refs microsoft/TypeScript#58960
This solution solves an upstream regression and is backwards compatible for our use case. Refs microsoft/TypeScript#58960
This solution solves an upstream regression and is backwards compatible for our use case. Refs microsoft/TypeScript#58960
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
“unresolved any”
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?&filetype=ts#code/PTAEBcE8AcFNQAoCcD20DOoC8oCGA7SAKCjlADEUVtFUMiSZ4BZAEQA0BhFfcWX5Gkw4AFAAZQsAB598AE0wBGUADIKVUAH5QAbwC+oAFzqUASiJA
💻 Code
🙁 Actual behavior
The type of
MDXContentProps
isany
🙂 Expected behavior
The type of
MDXContentProps
is{}
Additional information about the issue
When you hover over a type that doesn’t exist, the editor shows
/*unresolved*/ any
. In TypeScript 5.4, this type was equivalent toany
. In TypeScript 5.5, it behaves slightly different. This can be seen in the playground by toggling the linetype Props = any
and hovering theMDXContentProps
type.If an unresolved
any
is assigned to another type, that type becomes equivalent to an unresolvedany
, except the/*unresolved*/
label is gone when hovering over it.I use this pattern in MDX analyzer (https://github.com/mdx-js/mdx-analyzer/blob/[email protected]/packages/language-service/lib/virtual-code.js#L96). This allows users to optionally define props for their MDX file. This used to work great, but now everything is just inferred to
any
.If there’s a better way to detect whether a type is defined, I would love to hear about it.
The text was updated successfully, but these errors were encountered: