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
|
=== tests/cases/conformance/types/contextualTypes/jsxAttributes/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: (k: "left" | "right") => void;
>onClick : Symbol(ButtonProps.onClick, Decl(file.tsx, 7, 53))
>k : Symbol(k, Decl(file.tsx, 8, 14))
}
export interface LinkProps extends ClickableProps {
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 9, 1))
>ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31))
goTo: "home" | "contact";
>goTo : Symbol(LinkProps.goTo, Decl(file.tsx, 11, 51))
}
export function MainButton(buttonProps: ButtonProps): JSX.Element;
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>buttonProps : Symbol(buttonProps, Decl(file.tsx, 15, 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, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>linkProps : Symbol(linkProps, Decl(file.tsx, 16, 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(props: ButtonProps | LinkProps): JSX.Element {
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>props : Symbol(props, Decl(file.tsx, 17, 27))
>ButtonProps : Symbol(ButtonProps, Decl(file.tsx, 5, 1))
>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))
const linkProps = props as LinkProps;
>linkProps : Symbol(linkProps, Decl(file.tsx, 18, 9))
>props : Symbol(props, Decl(file.tsx, 17, 27))
>LinkProps : Symbol(LinkProps, Decl(file.tsx, 9, 1))
if(linkProps.goTo) {
>linkProps.goTo : Symbol(LinkProps.goTo, Decl(file.tsx, 11, 51))
>linkProps : Symbol(linkProps, Decl(file.tsx, 18, 9))
>goTo : Symbol(LinkProps.goTo, Decl(file.tsx, 11, 51))
return this._buildMainLink(props);
>props : Symbol(props, Decl(file.tsx, 17, 27))
}
return this._buildMainButton(props);
>props : Symbol(props, Decl(file.tsx, 17, 27))
}
const b0 = <MainButton {...{onClick: (k) => {console.log(k)}}} extra />; // k has type "left" | "right"
>b0 : Symbol(b0, Decl(file.tsx, 26, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>onClick : Symbol(onClick, Decl(file.tsx, 26, 28))
>k : Symbol(k, Decl(file.tsx, 26, 38))
>console.log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>console : Symbol(console, Decl(lib.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>k : Symbol(k, Decl(file.tsx, 26, 38))
>extra : Symbol(extra, Decl(file.tsx, 26, 62))
const b2 = <MainButton onClick={(k)=>{console.log(k)}} extra />; // k has type "left" | "right"
>b2 : Symbol(b2, Decl(file.tsx, 27, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>onClick : Symbol(onClick, Decl(file.tsx, 27, 22))
>k : Symbol(k, Decl(file.tsx, 27, 33))
>console.log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>console : Symbol(console, Decl(lib.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>k : Symbol(k, Decl(file.tsx, 27, 33))
>extra : Symbol(extra, Decl(file.tsx, 27, 54))
const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "contact"
>b3 : Symbol(b3, Decl(file.tsx, 28, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>goTo : Symbol(goTo, Decl(file.tsx, 28, 28))
>extra : Symbol(extra, Decl(file.tsx, 28, 41))
const b4 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact"
>b4 : Symbol(b4, Decl(file.tsx, 29, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 13, 1), Decl(file.tsx, 15, 66), Decl(file.tsx, 16, 62))
>goTo : Symbol(goTo, Decl(file.tsx, 29, 22))
>extra : Symbol(extra, Decl(file.tsx, 29, 34))
export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
>NoOverload : Symbol(NoOverload, Decl(file.tsx, 29, 44))
>buttonProps : Symbol(buttonProps, Decl(file.tsx, 31, 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))
>undefined : Symbol(undefined)
const c1 = <NoOverload {...{onClick: (k) => {console.log(k)}}} extra />; // k has type any
>c1 : Symbol(c1, Decl(file.tsx, 32, 5))
>NoOverload : Symbol(NoOverload, Decl(file.tsx, 29, 44))
>onClick : Symbol(onClick, Decl(file.tsx, 32, 29))
>k : Symbol(k, Decl(file.tsx, 32, 39))
>console.log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>console : Symbol(console, Decl(lib.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.d.ts, --, --))
>k : Symbol(k, Decl(file.tsx, 32, 39))
>extra : Symbol(extra, Decl(file.tsx, 32, 63))
export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined }
>NoOverload1 : Symbol(NoOverload1, Decl(file.tsx, 32, 73))
>linkProps : Symbol(linkProps, Decl(file.tsx, 34, 28))
>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))
>undefined : Symbol(undefined)
const d1 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" | "contact"
>d1 : Symbol(d1, Decl(file.tsx, 35, 5))
>NoOverload1 : Symbol(NoOverload1, Decl(file.tsx, 32, 73))
>goTo : Symbol(goTo, Decl(file.tsx, 35, 29))
>extra : Symbol(extra, Decl(file.tsx, 35, 42))
|