⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

errorType does not propagate with non-distributive conditional typesΒ #62972

@mizdra

Description

@mizdra

πŸ”Ž Search Terms

non-distributive, conditional type, errorType

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.3#code/C4TwDgpgBAogTnA9nAKuaBeKpKIGZQCuAdgNbGIDuxAagIYA2hEA3ALABQO0AglFvCSp0UCAA9gEYgBMAzkTIVqUAPzY4zKAC4oeRrNacA9EahmAeis7coAIX5QA2oORpIAXVESpcpyXJUxJ5qwBrQOnoMBuwcJmZQlpxAA

πŸ’» Code

type ErrorType = typeof unknownValue;
type A = ErrorType extends unknown ? true : false;
type B = [ErrorType] extends [unknown] ? true : false;

πŸ™ Actual behavior

A is any type, and B is true type.

πŸ™‚ Expected behavior

Both A and B should be any type.

Additional information about the issue

As far as I know, errorType propagates as errorType regardless of the type operation. However, only in the case of non-distributive conditional types, errorType does not propagate. Is this the intended behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions