Skip to content

Commit c1f4c9c

Browse files
committed
Update baselines
1 parent 2325fda commit c1f4c9c

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ function foo4(x: string | undefined = undefined, b: number) {
2626
x = undefined;
2727
}
2828

29+
type OptionalNullableString = string | null | undefined;
30+
function allowsNull(val: OptionalNullableString = "") {
31+
val = null;
32+
val = 'string and null are both ok';
33+
}
34+
allowsNull(null); // still allows passing null
35+
2936

3037

3138
// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4
@@ -81,6 +88,12 @@ function foo4(x, b) {
8188
x; // should be string | undefined
8289
x = undefined;
8390
}
91+
function allowsNull(val) {
92+
if (val === void 0) { val = ""; }
93+
val = null;
94+
val = 'string and null are both ok';
95+
}
96+
allowsNull(null); // still allows passing null
8497
// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4
8598
foo1(undefined, 1);
8699
foo2(undefined, 1);
@@ -111,6 +124,8 @@ declare function foo1(x: string | undefined, b: number): void;
111124
declare function foo2(x: string | undefined, b: number): void;
112125
declare function foo3(x: string | undefined, b: number): void;
113126
declare function foo4(x: string | undefined, b: number): void;
127+
declare type OptionalNullableString = string | null | undefined;
128+
declare function allowsNull(val?: OptionalNullableString): void;
114129
declare function removeUndefinedButNotFalse(x?: boolean): false | undefined;
115130
declare const cond: boolean;
116131
declare function removeNothing(y?: boolean | undefined): boolean;

tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ function foo4(x: string | undefined = undefined, b: number) {
8686
>undefined : Symbol(undefined)
8787
}
8888

89+
type OptionalNullableString = string | null | undefined;
90+
>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1))
91+
92+
function allowsNull(val: OptionalNullableString = "") {
93+
>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56))
94+
>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20))
95+
>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1))
96+
97+
val = null;
98+
>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20))
99+
100+
val = 'string and null are both ok';
101+
>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20))
102+
}
103+
allowsNull(null); // still allows passing null
104+
>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56))
105+
89106

90107

91108
// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4
@@ -107,35 +124,35 @@ foo4(undefined, 1);
107124

108125

109126
function removeUndefinedButNotFalse(x = true) {
110-
>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 33, 19))
111-
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36))
127+
>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 19))
128+
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36))
112129

113130
if (x === false) {
114-
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36))
131+
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36))
115132

116133
return x;
117-
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36))
134+
>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36))
118135
}
119136
}
120137

121138
declare const cond: boolean;
122-
>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13))
139+
>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13))
123140

124141
function removeNothing(y = cond ? true : undefined) {
125-
>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 28))
126-
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23))
127-
>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13))
142+
>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 28))
143+
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23))
144+
>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13))
128145
>undefined : Symbol(undefined)
129146

130147
if (y !== undefined) {
131-
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23))
148+
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23))
132149
>undefined : Symbol(undefined)
133150

134151
if (y === false) {
135-
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23))
152+
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23))
136153

137154
return y;
138-
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23))
155+
>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23))
139156
}
140157
}
141158
return true;

tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,31 @@ function foo4(x: string | undefined = undefined, b: number) {
116116
>undefined : undefined
117117
}
118118

119+
type OptionalNullableString = string | null | undefined;
120+
>OptionalNullableString : OptionalNullableString
121+
>null : null
122+
123+
function allowsNull(val: OptionalNullableString = "") {
124+
>allowsNull : (val?: OptionalNullableString) => void
125+
>val : OptionalNullableString
126+
>OptionalNullableString : OptionalNullableString
127+
>"" : ""
128+
129+
val = null;
130+
>val = null : null
131+
>val : OptionalNullableString
132+
>null : null
133+
134+
val = 'string and null are both ok';
135+
>val = 'string and null are both ok' : "string and null are both ok"
136+
>val : OptionalNullableString
137+
>'string and null are both ok' : "string and null are both ok"
138+
}
139+
allowsNull(null); // still allows passing null
140+
>allowsNull(null) : void
141+
>allowsNull : (val?: OptionalNullableString) => void
142+
>null : null
143+
119144

120145

121146
// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4

0 commit comments

Comments
 (0)