Skip to content

Preserve union type name within larger union #26106

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

Open
ghost opened this issue Jul 31, 2018 · 2 comments
Open

Preserve union type name within larger union #26106

ghost opened this issue Jul 31, 2018 · 2 comments
Labels
Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@ghost
Copy link

ghost commented Jul 31, 2018

TypeScript Version: 3.1.0-dev.20180731

Code

type Value =
    | { kind: "number", n: number }
    | { kind: "string", s: string };
function f(value: Value | undefined): void {}
f(undefined);

Expected behavior:

Quick info on f shows function f(value: Value | undefined): void

Actual behavior:

Quick info shows:

function f(value: {
    kind: "number";
    n: number;
} | {
    kind: "string";
    s: string;
} | undefined): void

Related Issues: #14662

@ghost ghost added Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info Suggestion An idea for TypeScript labels Jul 31, 2018
@RyanCavanaugh RyanCavanaugh added the In Discussion Not yet reached consensus label Jul 31, 2018
@samijaber
Copy link

Reduced test-case without functions or tagged unions:

type Foo = 'a' | 'b'
declare const a: Foo;
declare const b: Foo;

const value = a // Foo (as expected)

const values1 = [a, b] // Foo[] (as expected)

const values2 = [a, 1] // (number | "a" | "b")[], but expected (number | Foo)[]

@OliverJAsh
Copy link
Contributor

Will be fixed by #42149?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants