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
|
=== tests/cases/compiler/input.js ===
/** @typedef {{ color: "red" | "blue" }} MyComponentProps */
/**
* @template P
* @typedef {{ (): any; defaultProps?: Partial<P> }} StatelessComponent */
/**
* @type {StatelessComponent<MyComponentProps>}
*/
const MyComponent = () => /* @type {any} */(null);
>MyComponent : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; }
>() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; }
>(null) : null
>null : null
MyComponent.defaultProps = {
>MyComponent.defaultProps = { color: "red"} : { color: "red"; }
>MyComponent.defaultProps : Partial<{ color: "red" | "blue"; }>
>MyComponent : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; }
>defaultProps : Partial<{ color: "red" | "blue"; }>
>{ color: "red"} : { color: "red"; }
color: "red"
>color : "red"
>"red" : "red"
};
const MyComponent2 = () => null;
>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; }
>() => null : { (): any; defaultProps: { color: "red" | "blue"; }; }
>null : null
/**
* @type {MyComponentProps}
*/
MyComponent2.defaultProps = {
>MyComponent2.defaultProps = { color: "red"} : { color: "red"; }
>MyComponent2.defaultProps : { color: "red" | "blue"; }
>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; }
>defaultProps : { color: "red" | "blue"; }
>{ color: "red"} : { color: "red"; }
color: "red"
>color : "red"
>"red" : "red"
}
/**
* @type {StatelessComponent<MyComponentProps>}
*/
const check = MyComponent2;
>check : { (): any; defaultProps?: Partial<{ color: "red" | "blue"; }>; }
>MyComponent2 : { (): any; defaultProps: { color: "red" | "blue"; }; }
/**
*
* @param {{ props: MyComponentProps }} p
*/
function expectLiteral(p) {}
>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void
>p : { props: { color: "red" | "blue"; }; }
function foo() {
>foo : typeof foo
/**
* @type {MyComponentProps}
*/
this.props = { color: "red" };
>this.props = { color: "red" } : { color: "red"; }
>this.props : any
>this : any
>props : any
>{ color: "red" } : { color: "red"; }
>color : "red"
>"red" : "red"
expectLiteral(this);
>expectLiteral(this) : void
>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void
>this : any
}
/**
* @type {MyComponentProps}
*/
module.exports = {
>module.exports = { color: "red"} : { color: "red" | "blue"; }
>module.exports : { color: "red" | "blue"; }
>module : { "tests/cases/compiler/input": { color: "red" | "blue"; }; }
>exports : { color: "red" | "blue"; }
>{ color: "red"} : { color: "red"; }
color: "red"
>color : "red"
>"red" : "red"
}
expectLiteral({ props: module.exports });
>expectLiteral({ props: module.exports }) : void
>expectLiteral : (p: { props: { color: "red" | "blue"; }; }) => void
>{ props: module.exports } : { props: { color: "red" | "blue"; }; }
>props : { color: "red" | "blue"; }
>module.exports : { color: "red" | "blue"; }
>module : { "tests/cases/compiler/input": { color: "red" | "blue"; }; }
>exports : { color: "red" | "blue"; }
|