TypeScript/tests/baselines/reference/moduleExportDuplicateAlias.js
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

33 lines
704 B
TypeScript

//// [tests/cases/conformance/salsa/moduleExportDuplicateAlias.ts] ////
//// [moduleExportAliasDuplicateAlias.js]
exports.apply = undefined;
function a() { }
exports.apply()
exports.apply = a;
exports.apply()
//// [test.js]
const { apply } = require('./moduleExportAliasDuplicateAlias')
apply()
//// [moduleExportAliasDuplicateAlias.js]
"use strict";
exports.apply = undefined;
function a() { }
exports.apply();
exports.apply = a;
exports.apply();
//// [test.js]
"use strict";
var apply = require('./moduleExportAliasDuplicateAlias').apply;
apply();
//// [moduleExportAliasDuplicateAlias.d.ts]
export { a as apply };
declare function a(): void;
//// [test.d.ts]
export {};