Skip to content

Revert "Use NonNullable<T> in more scenarios" #49381

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 91 additions & 70 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/baselines/reference/discriminatedUnionJsxElement.types
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>
>data : IData<MenuItemVariant>

const listItemVariant = data.menuItemsVariant ?? ListItemVariant.OneLine;
>listItemVariant : ListItemVariant.OneLine | MenuItemVariant
>data.menuItemsVariant ?? ListItemVariant.OneLine : ListItemVariant.OneLine | MenuItemVariant
>listItemVariant : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
>data.menuItemsVariant ?? ListItemVariant.OneLine : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
>data.menuItemsVariant : MenuItemVariant | undefined
>data : IData<MenuItemVariant>
>menuItemsVariant : MenuItemVariant | undefined
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/mappedTypes4.types
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function boxify<T>(obj: T): Boxified<T> {
>obj : (T & null) | (T & object)

result[k] = { value: obj[k] };
>result[k] = { value: obj[k] } : { value: (T & object)[Extract<keyof T, string>]; }
>result[k] = { value: obj[k] } : { value: NonNullable<T & object>[Extract<keyof T, string>]; }
>result[k] : Boxified<T>[Extract<keyof T, string>]
>result : Boxified<T>
>k : Extract<keyof T, string>
>{ value: obj[k] } : { value: (T & object)[Extract<keyof T, string>]; }
>value : (T & object)[Extract<keyof T, string>]
>obj[k] : (T & object)[Extract<keyof T, string>]
>obj : T & object
>{ value: obj[k] } : { value: NonNullable<T & object>[Extract<keyof T, string>]; }
>value : NonNullable<T & object>[Extract<keyof T, string>]
>obj[k] : NonNullable<T & object>[Extract<keyof T, string>]
>obj : NonNullable<T & object>
>k : Extract<keyof T, string>
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/neverType.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ declare function infiniteLoop1(): void;
declare function infiniteLoop2(): never;
declare function move1(direction: "up" | "down"): 1 | -1;
declare function move2(direction: "up" | "down"): 1 | -1;
declare function check<T>(x: T | undefined): NonNullable<T>;
declare function check<T>(x: T | undefined): T;
declare class C {
void1(): void;
void2(): void;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/neverType.types
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ function move2(direction: "up" | "down") {
}

function check<T>(x: T | undefined) {
>check : <T>(x: T | undefined) => NonNullable<T>
>check : <T>(x: T | undefined) => T
>x : T | undefined

return x || error("Undefined value");
>x || error("Undefined value") : NonNullable<T>
>x || error("Undefined value") : T
>x : T | undefined
>error("Undefined value") : never
>error : (message: string) => never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function fn<T extends string | undefined, U extends string>(one: T, two: U) {
foo(two!);
>foo(two!) : void
>foo : (p: string) => void
>two! : U
>two! : NonNullable<U>
>two : U

foo(three!); // this line is the important one
Expand Down
85 changes: 0 additions & 85 deletions tests/baselines/reference/nonNullableTypes1.js

This file was deleted.

89 changes: 0 additions & 89 deletions tests/baselines/reference/nonNullableTypes1.symbols

This file was deleted.

95 changes: 0 additions & 95 deletions tests/baselines/reference/nonNullableTypes1.types

This file was deleted.

4 changes: 2 additions & 2 deletions tests/baselines/reference/nullishCoalescingOperator2.types
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const aa6 = a6 ?? 'whatever'
>'whatever' : "whatever"

const aa7 = a7 ?? 'whatever'
>aa7 : {}
>a7 ?? 'whatever' : {}
>aa7 : unknown
>a7 ?? 'whatever' : unknown
>a7 : unknown
>'whatever' : "whatever"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const aa6 = a6 ?? 'whatever'
>'whatever' : "whatever"

const aa7 = a7 ?? 'whatever'
>aa7 : {}
>a7 ?? 'whatever' : {}
>aa7 : unknown
>a7 ?? 'whatever' : unknown
>a7 : unknown
>'whatever' : "whatever"

Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/privateIdentifierChain.1.types
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class A {

this?.getA().#b; // Error
>this?.getA().#b : A | undefined
>this?.getA() : A
>this?.getA : () => A
>this?.getA() : A | undefined
>this?.getA : (() => A) | undefined
>this : this
>getA : () => A
>getA : (() => A) | undefined
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function JustConditional<T>(): ConditionalType<T> {
>JustConditional : <T>() => ConditionalType<T>

return ConditionalOrUndefined<T>()!; // shouldn't error
>ConditionalOrUndefined<T>()! : ConditionalType<T>
>ConditionalOrUndefined<T>()! : NonNullable<ConditionalType<T>>
>ConditionalOrUndefined<T>() : ConditionalType<T> | undefined
>ConditionalOrUndefined : <T>() => ConditionalType<T> | undefined
}
Expand Down
Loading