We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 672d214 commit 0dc42feCopy full SHA for 0dc42fe
tests/cases/compiler/controlFlowNullTypeAndLiteral.ts
@@ -0,0 +1,25 @@
1
+// @strict: true
2
+
3
+// Repros from #23771
4
5
+const myNull: null = null;
6
+const objWithValMaybeNull: { val: number | null } = { val: 1 };
7
+const addOne = function (num: number) {
8
+ return num + 1;
9
+}
10
11
+if (objWithValMaybeNull.val !== null)
12
+ addOne(objWithValMaybeNull.val);
13
+if (objWithValMaybeNull.val !== myNull)
14
15
16
+if (objWithValMaybeNull.val === null)
17
+ addOne(objWithValMaybeNull.val); // Error
18
+if (objWithValMaybeNull.val === myNull)
19
20
21
+function f(x: number | null) {
22
+ if(x === myNull) {
23
+ const s: string = x; // Error
24
+ }
25
0 commit comments