aba932aefa
* Commonjs module:create synthetic exports symbol Previously, the `module` identifier in commonjs modules got a synthetic type with a single property `exports`. The exports property reused the file's symbol, which, for a module file, gives the correct exported properties. However, the name of this symbol was still the filename of the file, not `exports`. This PR creates a synthetic symbol for `exports` by copying in a similar way to esModuleInterop's `default` symbol in `resolveESModuleSymbol` (although the intent there is to strip off signatures from the symbol). * correct parent of synthetic symbol
110 lines
2.8 KiB
Plaintext
110 lines
2.8 KiB
Plaintext
=== 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 : StatelessComponent<MyComponentProps>
|
|
>() => /* @type {any} */(null) : { (): any; defaultProps: Partial<MyComponentProps>; }
|
|
>(null) : null
|
|
>null : null
|
|
|
|
MyComponent.defaultProps = {
|
|
>MyComponent.defaultProps = { color: "red"} : { color: "red"; }
|
|
>MyComponent.defaultProps : Partial<MyComponentProps>
|
|
>MyComponent : StatelessComponent<MyComponentProps>
|
|
>defaultProps : Partial<MyComponentProps>
|
|
>{ color: "red"} : { color: "red"; }
|
|
|
|
color: "red"
|
|
>color : "red"
|
|
>"red" : "red"
|
|
|
|
};
|
|
|
|
const MyComponent2 = () => null;
|
|
>MyComponent2 : { (): any; defaultProps: MyComponentProps; }
|
|
>() => null : { (): any; defaultProps: MyComponentProps; }
|
|
>null : null
|
|
|
|
/**
|
|
* @type {MyComponentProps}
|
|
*/
|
|
MyComponent2.defaultProps = {
|
|
>MyComponent2.defaultProps = { color: "red"} : { color: "red"; }
|
|
>MyComponent2.defaultProps : MyComponentProps
|
|
>MyComponent2 : { (): any; defaultProps: MyComponentProps; }
|
|
>defaultProps : MyComponentProps
|
|
>{ color: "red"} : { color: "red"; }
|
|
|
|
color: "red"
|
|
>color : "red"
|
|
>"red" : "red"
|
|
}
|
|
|
|
/**
|
|
* @type {StatelessComponent<MyComponentProps>}
|
|
*/
|
|
const check = MyComponent2;
|
|
>check : StatelessComponent<MyComponentProps>
|
|
>MyComponent2 : { (): any; defaultProps: MyComponentProps; }
|
|
|
|
/**
|
|
*
|
|
* @param {{ props: MyComponentProps }} p
|
|
*/
|
|
function expectLiteral(p) {}
|
|
>expectLiteral : (p: { props: MyComponentProps;}) => void
|
|
>p : { props: MyComponentProps; }
|
|
|
|
function foo() {
|
|
>foo : typeof foo
|
|
|
|
/**
|
|
* @type {MyComponentProps}
|
|
*/
|
|
this.props = { color: "red" };
|
|
>this.props = { color: "red" } : { color: "red"; }
|
|
>this.props : MyComponentProps
|
|
>this : this
|
|
>props : MyComponentProps
|
|
>{ color: "red" } : { color: "red"; }
|
|
>color : "red"
|
|
>"red" : "red"
|
|
|
|
expectLiteral(this);
|
|
>expectLiteral(this) : void
|
|
>expectLiteral : (p: { props: MyComponentProps; }) => void
|
|
>this : this
|
|
}
|
|
|
|
/**
|
|
* @type {MyComponentProps}
|
|
*/
|
|
module.exports = {
|
|
>module.exports = { color: "red"} : MyComponentProps
|
|
>module.exports : MyComponentProps
|
|
>module : { exports: MyComponentProps; }
|
|
>exports : MyComponentProps
|
|
>{ color: "red"} : { color: "red"; }
|
|
|
|
color: "red"
|
|
>color : "red"
|
|
>"red" : "red"
|
|
}
|
|
|
|
expectLiteral({ props: module.exports });
|
|
>expectLiteral({ props: module.exports }) : void
|
|
>expectLiteral : (p: { props: MyComponentProps; }) => void
|
|
>{ props: module.exports } : { props: MyComponentProps; }
|
|
>props : MyComponentProps
|
|
>module.exports : MyComponentProps
|
|
>module : { exports: MyComponentProps; }
|
|
>exports : MyComponentProps
|
|
|