Skip to content

Type alias printing regressed in TypeScript 4.2.2Β #43031

Open
@AlCalzone

Description

@AlCalzone

Bug Report

πŸ”Ž Search Terms

preserve type alias

πŸ•— Version & Regression Information

  • This changed between versions 4.1.5 and 4.2.2

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Brand<K, T> = K & { __brand: T };

type BrandedUnknown<T> = Brand<"unknown", T>;
type Maybe<T> = T | BrandedUnknown<T>;

class Foo {
    public readonly maybe: Maybe<boolean> | undefined;
}

declare const foo: Foo;
const test = {
    prop: foo.maybe || false,
    // 4.1.5 (good): Maybe<boolean>
    // 4.2.2  (bad): boolean | BrandedUnknown<boolean> 
}

πŸ™ Actual behavior

test.prop has type boolean | BrandedUnknown<boolean> which lost the connection to Maybe<boolean>

πŸ™‚ Expected behavior

test.prop should have type Maybe<boolean> like in previous versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions