* In getSymbolAtLocation, return undefined instead of unknownSymbol * Update check in completions to look for undefined instead of unknownSymbol
66 lines
2.3 KiB
Plaintext
66 lines
2.3 KiB
Plaintext
=== 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))
|
|
|
|
|