File: tsxTypeErrors.symbols

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (65 lines) | stat: -rw-r--r-- 2,308 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
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
=== tests/cases/conformance/jsx/tsxTypeErrors.tsx ===
// A built-in element (OK)
var a1 = <div id="foo" />;
>a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 1, 3))
>id : Symbol(id, Decl(tsxTypeErrors.tsx, 1, 13))

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

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

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

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

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

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

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

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

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

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

// 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, 30, 3))
>MyClass : Symbol(MyClass, Decl(tsxTypeErrors.tsx, 11, 31))
>pt : Symbol(pt, Decl(tsxTypeErrors.tsx, 30, 17))
>x : Symbol(x, Decl(tsxTypeErrors.tsx, 30, 23))
>y : Symbol(y, Decl(tsxTypeErrors.tsx, 30, 28))