TypeScript/tests/baselines/reference/moduleExportDuplicateAlias.types
Nathan Shively-Sanders dd1ef88d01
Use control flow to type CommonJS exports (#42751)
* Allow redeclaring CommonJS alias with initial undefined

This allows us to read our own output, plus the times when people
manually write exactly the same pattern.

Fixes #40555

* Use control flow to type commonjs exports

1. Could probably use a *lot* more tests.
2. getTypeOfAlias redoes some work from resolveAlias because it needs to
not resolve the alias completely, just to its export.

* fix lint, improve jsdoc

* Add tests, improve+fix control flow

1. Update the module.exports test to match the exports ones.
2. Add a test of evolving commonjs type.
3. Add a test of assignment as last statement.

(1) exposed a bug that required a better synthetic reference. (3)
exposed a bug that was most easily fixed by giving source files a
`endFlowNode` like functions and setting it in the binder.

* fix lint
2021-04-06 17:07:35 -07:00

42 lines
1.3 KiB
Plaintext

=== tests/cases/conformance/salsa/test.js ===
const { apply } = require('./moduleExportAliasDuplicateAlias')
>apply : () => void
>require('./moduleExportAliasDuplicateAlias') : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
>require : any
>'./moduleExportAliasDuplicateAlias' : "./moduleExportAliasDuplicateAlias"
apply()
>apply() : void
>apply : () => void
=== tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js ===
exports.apply = undefined;
>exports.apply = undefined : undefined
>exports.apply : any
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
>apply : any
>undefined : undefined
function a() { }
>a : () => void
exports.apply()
>exports.apply() : any
>exports.apply : undefined
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
>apply : undefined
exports.apply = a;
>exports.apply = a : () => void
>exports.apply : any
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
>apply : any
>a : () => void
exports.apply()
>exports.apply() : void
>exports.apply : () => void
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
>apply : () => void