oxc/napi/transform/test/id.test.mjs
Boshen a0ccc26c12 feat(napi/transform): add lang option to change source type (#6309)
part of #6274 and #6156

```
    /// Treat the source text as `js`, `jsx`, `ts`, or `tsx`.
    #[napi(ts_type = "'js' | 'jsx' | 'ts' | 'tsx'")]
    pub lang: Option<String>,
```
2024-10-06 04:53:47 +00:00

40 lines
804 B
JavaScript

import { assert, describe, it } from 'vitest';
import oxc from './index.js';
describe('isolated declaration', () => {
const code = `
/**
* jsdoc 1
*/
export class A {
/**
* jsdoc 2
*/
foo = "bar";
}
`;
it('matches output', () => {
const ret = oxc.isolatedDeclaration('test.ts', code, { sourcemap: true });
assert.deepEqual(ret, {
code: '/**\n' +
'* jsdoc 1\n' +
'*/\n' +
'export declare class A {\n' +
'\t/**\n' +
'\t* jsdoc 2\n' +
'\t*/\n' +
'\tfoo: string;\n' +
'}\n',
map: {
mappings: ';;;AAIE,OAAO,cAAM,EAAE;;;;CAIb;AACD',
names: [],
sources: ['test.ts'],
sourcesContent: [code],
version: 3,
},
errors: [],
});
});
});