Skip to content

Add NullKeyword to isPartOfTypeNode, mirroring UndefinedKeyword #53025

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

Merged
merged 8 commits into from
Mar 7, 2023
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,7 @@ export function isPartOfTypeNode(node: Node): boolean {
case SyntaxKind.SymbolKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.UndefinedKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.NeverKeyword:
return true;
case SyntaxKind.VoidKeyword:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module Point {

export function Origin() { return null; } //expected duplicate identifier error
>Origin : () => any
>null : null
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module A {
>p : Point

return null;
>null : null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ module A {
>right : Point

} = null;
>null : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module A {
>s : T

return null;
>null : null
}

function fn2(s: string) {
Expand All @@ -31,7 +30,6 @@ module A {
>s : T

return null;
>null : null
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/baselines/reference/accessorsEmit.types
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Test {
>1 : 1

return null;
>null : null
}
}

Expand All @@ -28,6 +27,5 @@ class Test2 {
>1 : 1

return null;
>null : null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,60 @@ var d: Number;
var r1 = null + a;
>r1 : any
>null + a : any
>null : null
>a : boolean

var r2 = null + b;
>r2 : any
>null + b : any
>null : null
>b : Object

var r3 = null + c;
>r3 : any
>null + c : any
>null : null
>c : void

var r4 = a + null;
>r4 : any
>a + null : any
>a : boolean
>null : null

var r5 = b + null;
>r5 : any
>b + null : any
>b : Object
>null : null

var r6 = null + c;
>r6 : any
>null + c : any
>null : null
>c : void

// other cases
var r7 = null + d;
>r7 : any
>null + d : any
>null : null
>d : Number

var r8 = null + true;
>r8 : any
>null + true : any
>null : null
>true : true

var r9 = null + { a: '' };
>r9 : any
>null + { a: '' } : any
>null : null
>{ a: '' } : { a: string; }
>a : string
>'' : ""

var r10 = null + foo();
>r10 : any
>null + foo() : any
>null : null
>foo() : void
>foo : () => void

var r11 = null + (() => { });
>r11 : any
>null + (() => { }) : any
>null : null
>(() => { }) : () => void
>() => { } : () => void

Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,39 @@ var d: string;
var r1: any = null + a;
>r1 : any
>null + a : any
>null : null
>a : any

var r2: any = a + null;
>r2 : any
>a + null : any
>a : any
>null : null

// null + number/enum
var r3 = null + b;
>r3 : any
>null + b : any
>null : null
>b : number

var r4 = null + 1;
>r4 : any
>null + 1 : any
>null : null
>1 : 1

var r5 = null + c;
>r5 : any
>null + c : any
>null : null
>c : E

var r6 = null + E.a;
>r6 : any
>null + E.a : any
>null : null
>E.a : E.a
>E : typeof E
>a : E.a

var r7 = null + E['a'];
>r7 : any
>null + E['a'] : any
>null : null
>E['a'] : E.a
>E : typeof E
>'a' : "a"
Expand All @@ -71,58 +64,49 @@ var r8 = b + null;
>r8 : any
>b + null : any
>b : number
>null : null

var r9 = 1 + null;
>r9 : any
>1 + null : any
>1 : 1
>null : null

var r10 = c + null
>r10 : any
>c + null : any
>c : E
>null : null

var r11 = E.a + null;
>r11 : any
>E.a + null : any
>E.a : E.a
>E : typeof E
>a : E.a
>null : null

var r12 = E['a'] + null;
>r12 : any
>E['a'] + null : any
>E['a'] : E.a
>E : typeof E
>'a' : "a"
>null : null

// null + string
var r13 = null + d;
>r13 : string
>null + d : string
>null : null
>d : string

var r14 = null + '';
>r14 : string
>null + '' : string
>null : null
>'' : ""

var r15 = d + null;
>r15 : string
>d + null : string
>d : string
>null : null

var r16 = '' + null;
>r16 : string
>'' + null : string
>'' : ""
>null : null

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
var r1 = null + null;
>r1 : any
>null + null : any
>null : null
>null : null

var r2 = null + undefined;
>r2 : any
>null + undefined : any
>null : null
>undefined : undefined

var r3 = undefined + null;
>r3 : any
>undefined + null : any
>undefined : undefined
>null : null

var r4 = undefined + undefined;
>r4 : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ function foo<T, U>(t: T, u: U) {
>r15 : any
>t + null : any
>t : T
>null : null

var r16 = t + undefined;
>r16 : any
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/aliasErrors.types
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import o = "s";
import q = null;
>q : any
> : any
>null : null

import r = undefined;
>r : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var r2 = foo({ a: <IHasVisualizationModel>null });
>{ a: <IHasVisualizationModel>null } : { a: IHasVisualizationModel; }
>a : IHasVisualizationModel
><IHasVisualizationModel>null : IHasVisualizationModel
>null : null

=== tests/cases/compiler/aliasUsageInGenericFunction_backbone.ts ===
export class Model {
Expand Down
3 changes: 0 additions & 3 deletions tests/baselines/reference/aliasUsageInOrExpression.types
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ var e: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null || {
><{ x: IHasVisualizationModel }>null || { x: moduleA } : { x: IHasVisualizationModel; }
><{ x: IHasVisualizationModel }>null : { x: IHasVisualizationModel; }
>x : IHasVisualizationModel
>null : null
>{ x: moduleA } : { x: typeof moduleA; }
>x : typeof moduleA
>moduleA : typeof moduleA
Expand All @@ -50,11 +49,9 @@ var f: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null ? { x
><{ x: IHasVisualizationModel }>null ? { x: moduleA } : null : { x: typeof moduleA; }
><{ x: IHasVisualizationModel }>null : { x: IHasVisualizationModel; }
>x : IHasVisualizationModel
>null : null
>{ x: moduleA } : { x: typeof moduleA; }
>x : typeof moduleA
>moduleA : typeof moduleA
>null : null

=== tests/cases/compiler/aliasUsageInOrExpression_backbone.ts ===
export class Model {
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/aliasUsedAsNameValue.types
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ export var id: number;
export function b(a: any): any { return null; }
>b : (a: any) => any
>a : any
>null : null

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ declare class foo{};

function foo() { return null; }
>foo : typeof foo
>null : null

1 change: 0 additions & 1 deletion tests/baselines/reference/ambientWithStatements.types
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ declare module M {

for (x in null) { }
>x : any
>null : null

if (true) { } else { }
>true : true
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/ambiguousGenericAssertion1.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
function f<T>(x: T): T { return null; }
>f : <T>(x: T) => T
>x : T
>null : null

var r = <T>(x: T) => x;
>r : <T>(x: T) => T
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/reference/ambiguousOverload.types
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ var x: number = foof("s", null);
>foof("s", null) : number
>foof : { (bar: string, y: any): number; (bar: string, x: any): string; }
>"s" : "s"
>null : null

var y: string = foof("s", null);
>y : string
>foof("s", null) : number
>foof : { (bar: string, y: any): number; (bar: string, x: any): string; }
>"s" : "s"
>null : null

function foof2(bar: string, x): string;
>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; }
Expand All @@ -48,12 +46,10 @@ var x2: string = foof2("s", null);
>foof2("s", null) : string
>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; }
>"s" : "s"
>null : null

var y2: number = foof2("s", null);
>y2 : number
>foof2("s", null) : string
>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; }
>"s" : "s"
>null : null

Loading