File: tsxTypeErrors.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 (70 lines) | stat: -rw-r--r-- 2,237 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
=== tests/cases/conformance/jsx/tsxTypeErrors.tsx ===

// A built-in element (OK)
var a1 = <div id="foo" />;
>a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 2, 3))
>div : Symbol(unknown)
>id : Symbol(unknown)

// A built-in element with a mistyped property (error)
var a2 = <img srce="foo.jpg" />
>a2 : Symbol(a2, Decl(tsxTypeErrors.tsx, 5, 3))
>img : Symbol(unknown)
>srce : Symbol(unknown)

// A built-in element with a badly-typed attribute value (error)
var thing = { oops: 100 };
>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3))
>oops : Symbol(oops, Decl(tsxTypeErrors.tsx, 8, 13))

var a3 = <div id={thing} />
>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3))
>div : Symbol(unknown)
>id : Symbol(unknown)
>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3))

// Mistyped html name (error)
var e1 = <imag src="bar.jpg" />
>e1 : Symbol(e1, Decl(tsxTypeErrors.tsx, 12, 3))
>imag : Symbol(unknown)
>src : Symbol(unknown)

// A custom type
class MyClass {
>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31))

  props: {
>props : Symbol(MyClass.props, Decl(tsxTypeErrors.tsx, 15, 15))

    pt?: { x: number; y: number; };
>pt : Symbol(pt, Decl(tsxTypeErrors.tsx, 16, 10))
>x : Symbol(x, Decl(tsxTypeErrors.tsx, 17, 10))
>y : Symbol(y, Decl(tsxTypeErrors.tsx, 17, 21))

	name?: string;
>name : Symbol(name, Decl(tsxTypeErrors.tsx, 17, 35))

	reqd: boolean;
>reqd : Symbol(reqd, Decl(tsxTypeErrors.tsx, 18, 15))
  }
}

// Let's use it
// TODO: Error on missing 'reqd'
var b1 = <MyClass reqd={true} />; 
>b1 : Symbol(b1, Decl(tsxTypeErrors.tsx, 25, 3))
>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31))
>reqd : Symbol(unknown)

// Mistyped attribute member
// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'.
//  Types of property 'y' are incompatible.
//    Type 'string' is not assignable to type 'number'.
var b2 = <MyClass pt={{x: 4, y: 'oops'}} />;
>b2 : Symbol(b2, Decl(tsxTypeErrors.tsx, 31, 3))
>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 12, 31))
>pt : Symbol(unknown)
>x : Symbol(x, Decl(tsxTypeErrors.tsx, 31, 23))
>y : Symbol(y, Decl(tsxTypeErrors.tsx, 31, 28))