File: indexSignaturesInferentialTyping.symbols

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 1,824 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
=== tests/cases/compiler/indexSignaturesInferentialTyping.ts ===
function foo<T>(items: { [index: number]: T }): T { return undefined; }
>foo : Symbol(foo, Decl(indexSignaturesInferentialTyping.ts, 0, 0))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 0, 13))
>items : Symbol(items, Decl(indexSignaturesInferentialTyping.ts, 0, 16))
>index : Symbol(index, Decl(indexSignaturesInferentialTyping.ts, 0, 26))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 0, 13))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 0, 13))
>undefined : Symbol(undefined)

function bar<T>(items: { [index: string]: T }): T { return undefined; }
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 1, 13))
>items : Symbol(items, Decl(indexSignaturesInferentialTyping.ts, 1, 16))
>index : Symbol(index, Decl(indexSignaturesInferentialTyping.ts, 1, 26))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 1, 13))
>T : Symbol(T, Decl(indexSignaturesInferentialTyping.ts, 1, 13))
>undefined : Symbol(undefined)

var x1 = foo({ 0: 0, 1: 1 });       // type should be number
>x1 : Symbol(x1, Decl(indexSignaturesInferentialTyping.ts, 3, 3))
>foo : Symbol(foo, Decl(indexSignaturesInferentialTyping.ts, 0, 0))

var x2 = bar({ 0: 0, 1: 1 });
>x2 : Symbol(x2, Decl(indexSignaturesInferentialTyping.ts, 4, 3))
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))

var x3 = bar({ zero: 0, one: 1 });  // type should be number
>x3 : Symbol(x3, Decl(indexSignaturesInferentialTyping.ts, 5, 3))
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))
>zero : Symbol(zero, Decl(indexSignaturesInferentialTyping.ts, 5, 14))
>one : Symbol(one, Decl(indexSignaturesInferentialTyping.ts, 5, 23))