mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
164 lines
7.5 KiB
Plaintext
164 lines
7.5 KiB
Plaintext
//// [tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload4.tsx] ////
|
|
|
|
=== file.tsx ===
|
|
/// <reference path="react.d.ts" />
|
|
|
|
import React = require('react')
|
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
|
|
|
declare function OneThing(): JSX.Element;
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
declare function OneThing(l: {yy: number, yy1: string}): JSX.Element;
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>l : Symbol(l, Decl(file.tsx, 4, 26))
|
|
>yy : Symbol(yy, Decl(file.tsx, 4, 30))
|
|
>yy1 : Symbol(yy1, Decl(file.tsx, 4, 41))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
let obj = {
|
|
>obj : Symbol(obj, Decl(file.tsx, 6, 3))
|
|
|
|
yy: 10,
|
|
>yy : Symbol(yy, Decl(file.tsx, 6, 11))
|
|
|
|
yy1: "hello"
|
|
>yy1 : Symbol(yy1, Decl(file.tsx, 7, 11))
|
|
}
|
|
let obj2: any;
|
|
>obj2 : Symbol(obj2, Decl(file.tsx, 10, 3))
|
|
|
|
// Error
|
|
const c0 = <OneThing extraProp />; // extra property;
|
|
>c0 : Symbol(c0, Decl(file.tsx, 13, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>extraProp : Symbol(extraProp, Decl(file.tsx, 13, 20))
|
|
|
|
const c1 = <OneThing yy={10}/>; // missing property;
|
|
>c1 : Symbol(c1, Decl(file.tsx, 14, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>yy : Symbol(yy, Decl(file.tsx, 14, 20))
|
|
|
|
const c2 = <OneThing {...obj} yy1 />; // type incompatible;
|
|
>c2 : Symbol(c2, Decl(file.tsx, 15, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj : Symbol(obj, Decl(file.tsx, 6, 3))
|
|
>yy1 : Symbol(yy1, Decl(file.tsx, 15, 29))
|
|
|
|
const c3 = <OneThing {...obj} {...{extra: "extra attr"}} />; // This is OK because all attribute are spread
|
|
>c3 : Symbol(c3, Decl(file.tsx, 16, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj : Symbol(obj, Decl(file.tsx, 6, 3))
|
|
>extra : Symbol(extra, Decl(file.tsx, 16, 35))
|
|
|
|
const c4 = <OneThing {...obj} y1={10000} />; // extra property;
|
|
>c4 : Symbol(c4, Decl(file.tsx, 17, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj : Symbol(obj, Decl(file.tsx, 6, 3))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 17, 29))
|
|
|
|
const c5 = <OneThing {...obj} {...{yy: true}} />; // type incompatible;
|
|
>c5 : Symbol(c5, Decl(file.tsx, 18, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj : Symbol(obj, Decl(file.tsx, 6, 3))
|
|
>yy : Symbol(yy, Decl(file.tsx, 18, 35))
|
|
|
|
const c6 = <OneThing {...obj2} {...{extra: "extra attr"}} />; // Should error as there is extra attribute that doesn't match any. Current it is not
|
|
>c6 : Symbol(c6, Decl(file.tsx, 19, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj2 : Symbol(obj2, Decl(file.tsx, 10, 3))
|
|
>extra : Symbol(extra, Decl(file.tsx, 19, 36))
|
|
|
|
const c7 = <OneThing {...obj2} yy />; // Should error as there is extra attribute that doesn't match any. Current it is not
|
|
>c7 : Symbol(c7, Decl(file.tsx, 20, 5))
|
|
>OneThing : Symbol(OneThing, Decl(file.tsx, 2, 31), Decl(file.tsx, 3, 41))
|
|
>obj2 : Symbol(obj2, Decl(file.tsx, 10, 3))
|
|
>yy : Symbol(yy, Decl(file.tsx, 20, 30))
|
|
|
|
declare function TestingOneThing(j: {"extra-data": string}): JSX.Element;
|
|
>TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 20, 37), Decl(file.tsx, 22, 73))
|
|
>j : Symbol(j, Decl(file.tsx, 22, 33))
|
|
>"extra-data" : Symbol("extra-data", Decl(file.tsx, 22, 37))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
declare function TestingOneThing(n: {yy: string, direction?: number}): JSX.Element;
|
|
>TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 20, 37), Decl(file.tsx, 22, 73))
|
|
>n : Symbol(n, Decl(file.tsx, 23, 33))
|
|
>yy : Symbol(yy, Decl(file.tsx, 23, 37))
|
|
>direction : Symbol(direction, Decl(file.tsx, 23, 48))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
// Error
|
|
const d1 = <TestingOneThing extra-data />
|
|
>d1 : Symbol(d1, Decl(file.tsx, 26, 5))
|
|
>TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 20, 37), Decl(file.tsx, 22, 73))
|
|
>extra-data : Symbol(extra-data, Decl(file.tsx, 26, 27))
|
|
|
|
const d2 = <TestingOneThing yy="hello" direction="left" />
|
|
>d2 : Symbol(d2, Decl(file.tsx, 27, 5))
|
|
>TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 20, 37), Decl(file.tsx, 22, 73))
|
|
>yy : Symbol(yy, Decl(file.tsx, 27, 27))
|
|
>direction : Symbol(direction, Decl(file.tsx, 27, 38))
|
|
|
|
declare function TestingOptional(a: {y1?: string, y2?: number}): JSX.Element;
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>a : Symbol(a, Decl(file.tsx, 29, 33))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 29, 37))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 29, 49))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
declare function TestingOptional(a: {y1?: string, y2?: number, children: JSX.Element}): JSX.Element;
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>a : Symbol(a, Decl(file.tsx, 30, 33))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 30, 37))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 30, 49))
|
|
>children : Symbol(children, Decl(file.tsx, 30, 62))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
declare function TestingOptional(a: {y1: boolean, y2?: number, y3: boolean}): JSX.Element;
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>a : Symbol(a, Decl(file.tsx, 31, 33))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 31, 37))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 31, 49))
|
|
>y3 : Symbol(y3, Decl(file.tsx, 31, 62))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
// Error
|
|
const e1 = <TestingOptional y1 y3="hello"/>
|
|
>e1 : Symbol(e1, Decl(file.tsx, 34, 5))
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 34, 27))
|
|
>y3 : Symbol(y3, Decl(file.tsx, 34, 30))
|
|
|
|
const e2 = <TestingOptional y1="hello" y2={1000} y3 />
|
|
>e2 : Symbol(e2, Decl(file.tsx, 35, 5))
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 35, 27))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 35, 38))
|
|
>y3 : Symbol(y3, Decl(file.tsx, 35, 48))
|
|
|
|
const e3 = <TestingOptional y1="hello" y2={1000} children="hi" />
|
|
>e3 : Symbol(e3, Decl(file.tsx, 36, 5))
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 36, 27))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 36, 38))
|
|
>children : Symbol(children, Decl(file.tsx, 36, 48))
|
|
|
|
const e4 = <TestingOptional y1="hello" y2={1000}>Hi</TestingOptional>
|
|
>e4 : Symbol(e4, Decl(file.tsx, 37, 5))
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
>y1 : Symbol(y1, Decl(file.tsx, 37, 27))
|
|
>y2 : Symbol(y2, Decl(file.tsx, 37, 38))
|
|
>TestingOptional : Symbol(TestingOptional, Decl(file.tsx, 27, 58), Decl(file.tsx, 29, 77), Decl(file.tsx, 30, 100))
|
|
|