mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
184 lines
8.2 KiB
Plaintext
184 lines
8.2 KiB
Plaintext
//// [tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload5.tsx] ////
|
|
|
|
=== file.tsx ===
|
|
/// <reference path="react.d.ts" />
|
|
|
|
import React = require('react')
|
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
|
|
|
export interface ClickableProps {
|
|
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 2, 31))
|
|
|
|
children?: string;
|
|
>children : Symbol(ClickableProps.children, Decl(file.tsx, 4, 33))
|
|
|
|
className?: string;
|
|
>className : Symbol(ClickableProps.className, Decl(file.tsx, 5, 22))
|
|
}
|
|
|
|
export interface ButtonProps extends ClickableProps {
|
|
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 7, 1))
|
|
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 2, 31))
|
|
|
|
onClick: React.MouseEventHandler<any>;
|
|
>onClick : Symbol(ButtonProps.onClick, Decl(file.tsx, 9, 53))
|
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
|
>MouseEventHandler : Symbol(React.MouseEventHandler, Decl(react.d.ts, 389, 66))
|
|
}
|
|
|
|
export interface LinkProps extends ClickableProps {
|
|
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 11, 1))
|
|
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 2, 31))
|
|
|
|
to: string;
|
|
>to : Symbol(LinkProps.to, Decl(file.tsx, 13, 51))
|
|
}
|
|
|
|
export interface HyphenProps extends ClickableProps {
|
|
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 15, 1))
|
|
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 2, 31))
|
|
|
|
"data-format": string;
|
|
>"data-format" : Symbol(HyphenProps["data-format"], Decl(file.tsx, 17, 53))
|
|
}
|
|
|
|
let obj0 = {
|
|
>obj0 : Symbol(obj0, Decl(file.tsx, 21, 3))
|
|
|
|
to: "world"
|
|
>to : Symbol(to, Decl(file.tsx, 21, 12))
|
|
|
|
};
|
|
|
|
let obj1 = {
|
|
>obj1 : Symbol(obj1, Decl(file.tsx, 25, 3))
|
|
|
|
children: "hi",
|
|
>children : Symbol(children, Decl(file.tsx, 25, 12))
|
|
|
|
to: "boo"
|
|
>to : Symbol(to, Decl(file.tsx, 26, 19))
|
|
}
|
|
|
|
let obj2 = {
|
|
>obj2 : Symbol(obj2, Decl(file.tsx, 30, 3))
|
|
|
|
onClick: ()=>{}
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 30, 12))
|
|
}
|
|
|
|
let obj3: any;
|
|
>obj3 : Symbol(obj3, Decl(file.tsx, 34, 3))
|
|
|
|
export function MainButton(buttonProps: ButtonProps): JSX.Element;
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>buttonProps : Symbol(buttonProps, Decl(file.tsx, 36, 27))
|
|
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 7, 1))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
export function MainButton(linkProps: LinkProps): JSX.Element;
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>linkProps : Symbol(linkProps, Decl(file.tsx, 37, 27))
|
|
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 11, 1))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
export function MainButton(hyphenProps: HyphenProps): JSX.Element;
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>hyphenProps : Symbol(hyphenProps, Decl(file.tsx, 38, 27))
|
|
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 15, 1))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
export function MainButton(props: ButtonProps | LinkProps | HyphenProps): JSX.Element {
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>props : Symbol(props, Decl(file.tsx, 39, 27))
|
|
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 7, 1))
|
|
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 11, 1))
|
|
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 15, 1))
|
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
|
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
|
|
|
|
const linkProps = props as LinkProps;
|
|
>linkProps : Symbol(linkProps, Decl(file.tsx, 40, 9))
|
|
>props : Symbol(props, Decl(file.tsx, 39, 27))
|
|
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 11, 1))
|
|
|
|
if(linkProps.to) {
|
|
>linkProps.to : Symbol(LinkProps.to, Decl(file.tsx, 13, 51))
|
|
>linkProps : Symbol(linkProps, Decl(file.tsx, 40, 9))
|
|
>to : Symbol(LinkProps.to, Decl(file.tsx, 13, 51))
|
|
|
|
return this._buildMainLink(props);
|
|
>props : Symbol(props, Decl(file.tsx, 39, 27))
|
|
}
|
|
|
|
return this._buildMainButton(props);
|
|
>props : Symbol(props, Decl(file.tsx, 39, 27))
|
|
}
|
|
|
|
// Error
|
|
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
|
|
>b0 : Symbol(b0, Decl(file.tsx, 49, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>to : Symbol(to, Decl(file.tsx, 49, 22))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 49, 38))
|
|
>e : Symbol(e, Decl(file.tsx, 49, 49))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
|
|
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
|
|
>b1 : Symbol(b1, Decl(file.tsx, 50, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 50, 22))
|
|
>e : Symbol(e, Decl(file.tsx, 50, 33))
|
|
>obj0 : Symbol(obj0, Decl(file.tsx, 21, 3))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
|
|
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
|
|
>b2 : Symbol(b2, Decl(file.tsx, 51, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>to : Symbol(to, Decl(file.tsx, 51, 28))
|
|
>obj2 : Symbol(obj2, Decl(file.tsx, 30, 3))
|
|
|
|
const b3 = <MainButton {...{to: "10000"}} {...{onClick: (k) => {}}} />; // extra property
|
|
>b3 : Symbol(b3, Decl(file.tsx, 52, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>to : Symbol(to, Decl(file.tsx, 52, 28))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 52, 47))
|
|
>k : Symbol(k, Decl(file.tsx, 52, 57))
|
|
|
|
const b4 = <MainButton {...obj3} to />; // Should error because Incorrect type; but attributes are any so everything is allowed
|
|
>b4 : Symbol(b4, Decl(file.tsx, 53, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>obj3 : Symbol(obj3, Decl(file.tsx, 34, 3))
|
|
>to : Symbol(to, Decl(file.tsx, 53, 32))
|
|
|
|
const b5 = <MainButton {...{ onClick(e: any) { } }} {...obj0} />; // Spread retain method declaration (see GitHub #13365), so now there is an extra attributes
|
|
>b5 : Symbol(b5, Decl(file.tsx, 54, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 54, 28))
|
|
>e : Symbol(e, Decl(file.tsx, 54, 37))
|
|
>obj0 : Symbol(obj0, Decl(file.tsx, 21, 3))
|
|
|
|
const b6 = <MainButton {...{ onClick(e: any){} }} children={10} />; // incorrect type for optional attribute
|
|
>b6 : Symbol(b6, Decl(file.tsx, 55, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 55, 28))
|
|
>e : Symbol(e, Decl(file.tsx, 55, 37))
|
|
>children : Symbol(children, Decl(file.tsx, 55, 49))
|
|
|
|
const b7 = <MainButton {...{ onClick(e: any){} }} children="hello" className />; // incorrect type for optional attribute
|
|
>b7 : Symbol(b7, Decl(file.tsx, 56, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>onClick : Symbol(onClick, Decl(file.tsx, 56, 28))
|
|
>e : Symbol(e, Decl(file.tsx, 56, 37))
|
|
>children : Symbol(children, Decl(file.tsx, 56, 49))
|
|
>className : Symbol(className, Decl(file.tsx, 56, 66))
|
|
|
|
const b8 = <MainButton data-format />; // incorrect type for specified hyphanated name
|
|
>b8 : Symbol(b8, Decl(file.tsx, 57, 5))
|
|
>MainButton : Symbol(MainButton, Decl(file.tsx, 34, 14), Decl(file.tsx, 36, 66), Decl(file.tsx, 37, 62), Decl(file.tsx, 38, 66))
|
|
>data-format : Symbol(data-format, Decl(file.tsx, 57, 22))
|
|
|