Skip to content

Unresolved any behaves different from any #58960

@remcohaszing

Description

@remcohaszing

🔎 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/[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions