Skip to content

bug(oxc-transform): JS transform does not export shared names #4504

@lukeed

Description

@lukeed

When a type and a function (example) share names and are exported together, the declarations are exported correctly, but .transform() does not export the function in its JS output.

Example

Input

type test = number;

function test(): test {
  return 123;
}

export { test as Test };

Output

// index.d.ts
type test = number;
declare function test(): test;
export { test as Test };

// index.mjs
function test() {
  return 123;
}
export {};
// Expected: export { test as Test };

Script

import oxc from 'npm:oxc-transform'; // 0.22.0

// ...

let entry = resolve('foo.ts');
let source = await Deno.readTextFile(entry);

let esm = oxc.transform(entry, source);
if (esm.errors.length > 0) bail('transform', esm.errors);

let outfile = join(outdir, 'index.mjs');
console.log('> writing "index.mjs" file');
await Deno.writeTextFile(outfile, esm.sourceText);

let dts = oxc.isolatedDeclaration(entry, source);
if (dts.errors.length > 0) bail('dts', dts.errors);

outfile = join(outdir, 'index.d.ts');
console.log('> writing "index.d.ts" file');
await Deno.writeTextFile(outfile, dts.sourceText);

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions