🔎 Search Terms
“unresolved any”
🕗 Version & Regression Information
- This changed between versions 5.4.5 and 5.5.2
⏯ Playground Link
https://www.typescriptlang.org/play/?&filetype=ts#code/PTAEBcE8AcFNQAoCcD20DOoC8oCGA7SAKCjlADEUVtFUMiSZ4BZAEQA0BhFfcWX5Gkw4AFAAZQsAB598AE0wBGUADIKVUAH5QAbwC+oAFzqUASiJA
💻 Code
// type Props = any
type MDXContentProps = (0 extends 1 & Props ? {} : Props)
🙁 Actual behavior
The type of MDXContentProps is any
🙂 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 to any. In TypeScript 5.5, it behaves slightly different. This can be seen in the playground by toggling the line type Props = any and hovering the MDXContentProps type.
If an unresolved any is assigned to another type, that type becomes equivalent to an unresolved any, 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/vscode-mdx@1.8.8/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.
🔎 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
MDXContentPropsisany🙂 Expected behavior
The type of
MDXContentPropsis{}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 = anyand hovering theMDXContentPropstype.If an unresolved
anyis 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/vscode-mdx@1.8.8/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.