Reported at #46011 (comment)
Repro steps
Run declaration emit on this JS
/** @typedef {string} S *//** @type {any} */module.exports="";Expected behavior
declareconst_exports: any;export=_exports;declarenamespace_exports{export{S};}typeS=string;The declaration file is error-free.
Actual behavior
declareconst_exports: any;export=_exports;exporttypeS=string;
The declaration file errors with An export assignment cannot be used in a module with other exported elements.
Additional info
Declaration emit works as expected if module.exports is assigned to an identifier that doesn’t necessitate the _exports temp variable synthesis:
/** @typedef {string} S *//** @type {any} */constx="";module.exports=x;produces:
export=x;/** @typedef {string} S *//** @type {any} */declareconstx: any;declarenamespacex{export{S};}typeS=string;
Reported at #46011 (comment)
Repro steps
Run declaration emit on this JS
Expected behavior
The declaration file is error-free.
Actual behavior
The declaration file errors with
An export assignment cannot be used in a module with other exported elements.Additional info
Declaration emit works as expected if
module.exportsis assigned to an identifier that doesn’t necessitate the_exportstemp variable synthesis:produces: