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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react')
>React : Symbol(React, Decl(file.tsx, 0, 0))
export interface ClickableProps {
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31))
children?: string;
>children : Symbol(ClickableProps.children, Decl(file.tsx, 2, 33))
className?: string;
>className : Symbol(ClickableProps.className, Decl(file.tsx, 3, 22))
}
export interface ButtonProps extends ClickableProps {
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 5, 1))
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31))
onClick: React.MouseEventHandler<any>;
>onClick : Symbol(ButtonProps.onClick, Decl(file.tsx, 7, 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, 9, 1))
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31))
to: string;
>to : Symbol(LinkProps.to, Decl(file.tsx, 11, 51))
}
export interface HyphenProps extends ClickableProps {
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 13, 1))
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31))
"data-format": string;
>"data-format" : Symbol(HyphenProps["data-format"], Decl(file.tsx, 15, 53))
}
let obj0 = {
>obj0 : Symbol(obj0, Decl(file.tsx, 19, 3))
to: "world"
>to : Symbol(to, Decl(file.tsx, 19, 12))
};
let obj1 = {
>obj1 : Symbol(obj1, Decl(file.tsx, 23, 3))
children: "hi",
>children : Symbol(children, Decl(file.tsx, 23, 12))
to: "boo"
>to : Symbol(to, Decl(file.tsx, 24, 19))
}
let obj2 = {
>obj2 : Symbol(obj2, Decl(file.tsx, 28, 3))
onClick: ()=>{}
>onClick : Symbol(onClick, Decl(file.tsx, 28, 12))
}
let obj3: any;
>obj3 : Symbol(obj3, Decl(file.tsx, 32, 3))
export function MainButton(buttonProps: ButtonProps): JSX.Element;
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>buttonProps : Symbol(buttonProps, Decl(file.tsx, 34, 27))
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 5, 1))
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
export function MainButton(linkProps: LinkProps): JSX.Element;
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>linkProps : Symbol(linkProps, Decl(file.tsx, 35, 27))
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 9, 1))
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
export function MainButton(hyphenProps: HyphenProps): JSX.Element;
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>hyphenProps : Symbol(hyphenProps, Decl(file.tsx, 36, 27))
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 13, 1))
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
export function MainButton(props: ButtonProps | LinkProps | HyphenProps): JSX.Element {
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>props : Symbol(props, Decl(file.tsx, 37, 27))
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 5, 1))
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 9, 1))
>HyphenProps : Symbol(HyphenProps, Decl(file.tsx, 13, 1))
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
const linkProps = props as LinkProps;
>linkProps : Symbol(linkProps, Decl(file.tsx, 38, 9))
>props : Symbol(props, Decl(file.tsx, 37, 27))
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 9, 1))
if(linkProps.to) {
>linkProps.to : Symbol(LinkProps.to, Decl(file.tsx, 11, 51))
>linkProps : Symbol(linkProps, Decl(file.tsx, 38, 9))
>to : Symbol(LinkProps.to, Decl(file.tsx, 11, 51))
return this._buildMainLink(props);
>props : Symbol(props, Decl(file.tsx, 37, 27))
}
return this._buildMainButton(props);
>props : Symbol(props, Decl(file.tsx, 37, 27))
}
// Error
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
>b0 : Symbol(b0, Decl(file.tsx, 47, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>to : Symbol(to, Decl(file.tsx, 47, 22))
>onClick : Symbol(onClick, Decl(file.tsx, 47, 38))
>e : Symbol(e, Decl(file.tsx, 47, 49))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
>b1 : Symbol(b1, Decl(file.tsx, 48, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>onClick : Symbol(onClick, Decl(file.tsx, 48, 22))
>e : Symbol(e, Decl(file.tsx, 48, 33))
>obj0 : Symbol(obj0, Decl(file.tsx, 19, 3))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
>b2 : Symbol(b2, Decl(file.tsx, 49, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>to : Symbol(to, Decl(file.tsx, 49, 28))
>obj2 : Symbol(obj2, Decl(file.tsx, 28, 3))
const b3 = <MainButton {...{to: "10000"}} {...{onClick: (k) => {}}} />; // extra property
>b3 : Symbol(b3, Decl(file.tsx, 50, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>to : Symbol(to, Decl(file.tsx, 50, 28))
>onClick : Symbol(onClick, Decl(file.tsx, 50, 47))
>k : Symbol(k, Decl(file.tsx, 50, 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, 51, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>obj3 : Symbol(obj3, Decl(file.tsx, 32, 3))
>to : Symbol(to, Decl(file.tsx, 51, 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, 52, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>onClick : Symbol(onClick, Decl(file.tsx, 52, 28))
>e : Symbol(e, Decl(file.tsx, 52, 37))
>obj0 : Symbol(obj0, Decl(file.tsx, 19, 3))
const b6 = <MainButton {...{ onClick(e: any){} }} children={10} />; // incorrect type for optional attribute
>b6 : Symbol(b6, Decl(file.tsx, 53, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>onClick : Symbol(onClick, Decl(file.tsx, 53, 28))
>e : Symbol(e, Decl(file.tsx, 53, 37))
>children : Symbol(children, Decl(file.tsx, 53, 49))
const b7 = <MainButton {...{ onClick(e: any){} }} children="hello" className />; // incorrect type for optional attribute
>b7 : Symbol(b7, Decl(file.tsx, 54, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>onClick : Symbol(onClick, Decl(file.tsx, 54, 28))
>e : Symbol(e, Decl(file.tsx, 54, 37))
>children : Symbol(children, Decl(file.tsx, 54, 49))
>className : Symbol(className, Decl(file.tsx, 54, 66))
const b8 = <MainButton data-format />; // incorrect type for specified hyphanated name
>b8 : Symbol(b8, Decl(file.tsx, 55, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 32, 14), Decl(file.tsx, 34, 66), Decl(file.tsx, 35, 62), Decl(file.tsx, 36, 66))
>data-format : Symbol(data-format, Decl(file.tsx, 55, 22))
|