-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Labels
C-bugCategory - BugCategory - BugP-highPriority - HighPriority - Highneeds-discussionRequires a discussion from the core teamRequires a discussion from the core team
Milestone
Description
Repro
const oxc = require('oxc-transform');
const cases = [
`\
export = function foo (): void {
console.log();
}
`,
];
for (const code of cases) {
console.log('## input code:');
console.log('```ts');
console.log(code);
console.log('```');
for (const sourceType of ['script', 'module']) {
const transformed = oxc.transform('test.cts', code, {
sourceType,
typescript: {
declaration: { stripInternal: true },
onlyRemoveTypeImports: true,
},
});
console.log(`### \`sourceType: '${sourceType}'\``);
console.log('output code:');
console.log('```ts');
console.log(transformed.code);
console.log('```');
console.log('output declaration:');
console.log('```ts');
console.log(transformed.declaration);
console.log('```');
}
console.log('\n\n---------------\n\n');
}input code:
export = function foo (): void {
console.log();
}
sourceType: 'script'
output code:
export {};output declaration:
sourceType: 'module'
output code:
output declaration:
Expected
I'd expect that for sourceType: 'script' OXC would emit something similar to TS, eg:
output code:
"use strict";
module.exports = function foo() {
console.log();
};output declaration:
declare const _default: () => void;
export = _default;And for sourceType: 'module' OXC would crash out because export = is not allowed. TS emits the error Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
Reactions are currently unavailable
Metadata
Metadata
Labels
C-bugCategory - BugCategory - BugP-highPriority - HighPriority - Highneeds-discussionRequires a discussion from the core teamRequires a discussion from the core team
Type
Fields
Give feedbackPriority
None yet