File: optionalParameterRetainsNull.symbols

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (25 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
=== tests/cases/compiler/optionalParameterRetainsNull.ts ===
interface Bar {  bar: number; foo: object | null;  }
>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0))
>bar : Symbol(Bar.bar, Decl(optionalParameterRetainsNull.ts, 0, 15))
>foo : Symbol(Bar.foo, Decl(optionalParameterRetainsNull.ts, 0, 29))

let a = {
>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 2, 3))

  test<K extends keyof Bar> (a: K,  b?: Bar[K]  |  null)  { }
>test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9))
>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7))
>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0))
>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 3, 29))
>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7))
>b : Symbol(b, Decl(optionalParameterRetainsNull.ts, 3, 34))
>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0))
>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7))

};
a.test("bar", null); // ok, null is assignable to number | null | undefined
>a.test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9))
>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 2, 3))
>test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9))