* 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
69 lines
2.5 KiB
Plaintext
69 lines
2.5 KiB
Plaintext
=== tests/cases/conformance/salsa/test.js ===
|
|
const { apply } = require('./moduleExportAliasDuplicateAlias')
|
|
>apply : number
|
|
>require('./moduleExportAliasDuplicateAlias') : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>require : any
|
|
>'./moduleExportAliasDuplicateAlias' : "./moduleExportAliasDuplicateAlias"
|
|
|
|
const result = apply.toFixed()
|
|
>result : string
|
|
>apply.toFixed() : string
|
|
>apply.toFixed : (fractionDigits?: number | undefined) => string
|
|
>apply : number
|
|
>toFixed : (fractionDigits?: number | undefined) => string
|
|
|
|
=== tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js ===
|
|
exports.apply = undefined;
|
|
>exports.apply = undefined : undefined
|
|
>exports.apply : string | number | (() => void) | undefined
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string | number | (() => void) | undefined
|
|
>undefined : undefined
|
|
|
|
exports.apply = undefined;
|
|
>exports.apply = undefined : undefined
|
|
>exports.apply : string | number | (() => void) | undefined
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string | number | (() => void) | undefined
|
|
>undefined : undefined
|
|
|
|
function a() { }
|
|
>a : () => void
|
|
|
|
exports.apply = a;
|
|
>exports.apply = a : () => void
|
|
>exports.apply : string | number | (() => void) | undefined
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string | number | (() => void) | undefined
|
|
>a : () => void
|
|
|
|
exports.apply()
|
|
>exports.apply() : void
|
|
>exports.apply : () => void
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : () => void
|
|
|
|
exports.apply = 'ok'
|
|
>exports.apply = 'ok' : "ok"
|
|
>exports.apply : string | number | (() => void) | undefined
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string | number | (() => void) | undefined
|
|
>'ok' : "ok"
|
|
|
|
var OK = exports.apply.toUpperCase()
|
|
>OK : string
|
|
>exports.apply.toUpperCase() : string
|
|
>exports.apply.toUpperCase : () => string
|
|
>exports.apply : string
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string
|
|
>toUpperCase : () => string
|
|
|
|
exports.apply = 1
|
|
>exports.apply = 1 : 1
|
|
>exports.apply : string | number | (() => void) | undefined
|
|
>exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias")
|
|
>apply : string | number | (() => void) | undefined
|
|
>1 : 1
|
|
|