We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
preserve type alias
Playground link with relevant 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> }
test.prop has type boolean | BrandedUnknown<boolean> which lost the connection to Maybe<boolean>
test.prop
boolean | BrandedUnknown<boolean>
Maybe<boolean>
test.prop should have type Maybe<boolean> like in previous versions.
The text was updated successfully, but these errors were encountered:
Simplified repro without the class - seems it has to do with || vs. ??:
||
??
type Brand<K, T> = K & { __brand: T }; type BrandedUnknown<T> = Brand<"unknown", T>; type Maybe<T> = T | BrandedUnknown<T>; // got: boolean | BrandedUnknown<boolean> // expected: Maybe<boolean> const test1 = (undefined as Maybe<boolean> | undefined) || false; // got: Maybe<boolean> const test2 = (undefined as Maybe<boolean> | undefined) ?? false;
Playground
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Bug Report
π Search Terms
preserve type alias
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
test.prop
has typeboolean | BrandedUnknown<boolean>
which lost the connection toMaybe<boolean>
π Expected behavior
test.prop
should have typeMaybe<boolean>
like in previous versions.The text was updated successfully, but these errors were encountered: