release: v0.2.0 split unlua.d.ts runtime layer and remove examples
This commit is contained in:
1 parent
1f76bca55c
commit
051af4ca74
13 files changed
+118
-401
No files matched your search
+25
-11
@@ -13,12 +13,37 @@ const unluaTypesContent = fs.readFileSync(unluaTypesPath, "utf8");
|
||||
const pluginPath = path.join(projectRoot, "dist", "plugin", "index.js");
|
||||
const { UnLuaDiagnosticCode } = require(pluginPath);
|
||||
|
||||
const VIRTUAL_UE_REFLECTION_DTS = `
|
||||
declare namespace UE {
|
||||
class UObject {
|
||||
GetName(): string;
|
||||
GetClass(): UClass;
|
||||
IsValid(): boolean;
|
||||
IsA(someBase: UClass): boolean;
|
||||
static StaticClass(this: void): UClass;
|
||||
}
|
||||
class UClass extends UObject {}
|
||||
class AActor extends UObject {
|
||||
ReceiveBeginPlay(): void;
|
||||
ReceiveTick(DeltaSeconds: number): void;
|
||||
ReceiveEndPlay(EndPlayReason: number): void;
|
||||
static StaticClass(this: void): UClass;
|
||||
}
|
||||
class UUserWidget extends UObject {
|
||||
Construct(): void;
|
||||
Destruct(): void;
|
||||
static StaticClass(this: void): UClass;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* 在内存中编译一组虚拟 TS 文件并启用 UnLua 插件。
|
||||
*/
|
||||
function transpileWithUnLua(files) {
|
||||
const virtualFiles = {
|
||||
"unlua.d.ts": unluaTypesContent,
|
||||
"ue.generated.d.ts": VIRTUAL_UE_REFLECTION_DTS,
|
||||
...files,
|
||||
};
|
||||
|
||||
@@ -433,14 +458,3 @@ test("forbids multiple @unlua classes in one file, invalid @unlua args, and dire
|
||||
assert.ok(codes.has(UnLuaDiagnosticCode.UnLuaMultipleClassesInFile));
|
||||
assert.ok(codes.has(UnLuaDiagnosticCode.UnLuaForbiddenSuperUsage));
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// 4. 端到端示例工程编译验证
|
||||
// ============================================================
|
||||
|
||||
test("examples/tsconfig.json transpiles cleanly with zero diagnostics", () => {
|
||||
const exampleConfigPath = path.join(projectRoot, "examples", "tsconfig.json");
|
||||
const result = tstl.transpileProject(exampleConfigPath);
|
||||
const errors = result.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error);
|
||||
assert.equal(errors.length, 0, errors.map((e) => ts.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n"));
|
||||
});
|
||||
Reference in new issue
Block a user