Skip to content

Exclude<string, "foo"> is not working #38254

Closed
@frodo821

Description

@frodo821

TypeScript Version: 3.8.3 or earlier

Search Terms: Exclude, Conditional Types

Code

type Foo = Exclude<string, "bar">;

// this should cause an error.
const baz: Foo = "bar";

Expected behavior:
"bar" is not assignable to baz.

Actual behavior:
"bar" is assignable to baz without any errors.

Playground Link: https://www.typescriptlang.org/play/#code/FAFwngDgpgBAYgewTAvDAogDwMYBsCuAJlADwDOIATgJYB2A5gDQwBEARgIaUsB8A3MGDYEtCjE4AvAFzwkqVp24ChIsglxQAdLgT0AFJICUAoA

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions