孤立声明
🌐 Isolated Declarations Emit
Oxc 转换器支持在启用 isolated declarations 的项目中,在不使用 TypeScript 编译器的情况下生成 TypeScript 声明。
🌐 Oxc transformer supports emitting TypeScript declarations without using the TypeScript compiler for projects with isolated declarations enabled.
示例
🌐 Example
输入:
ts
export function foo(a: number, b: string): number {
return a + Number(b);
}
export enum Bar {
a,
b,
}输出:
ts
export declare function foo(a: number, b: string): number;
export declare enum Bar {
a = 0,
b = 1,
}用法
🌐 Usage
ts
import { isolatedDeclaration } from "oxc-transform";
const result = await isolatedDeclaration("lib.ts", sourceCode, {
sourcemap: false,
stripInternal: false,
});