Skip to content

Commit d0dafef

Browse files
authored
fix playground diagnostics (#70)
1 parent ec9afe7 commit d0dafef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/pages/play/ts.worker.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ const emitHost: tstl.EmitHost = {
2727
const transpiler = new tstl.Transpiler({ emitHost });
2828

2929
export class CustomTypeScriptWorker extends TypeScriptWorker {
30+
private lastResult?: { diagnostics: readonly ts.Diagnostic[]; ast: tstl.File; lua: string; sourceMap: string };
31+
3032
public async getTranspileOutput(fileName: string) {
3133
const { ast, lua, sourceMap } = this.transpileLua(fileName);
3234
return { ast, lua, sourceMap };
3335
}
3436

3537
public async getSemanticDiagnostics(fileName: string) {
3638
const diagnostics = await super.getSemanticDiagnostics(fileName);
37-
const { diagnostics: transpileDiagnostics } = this.transpileLua(fileName);
39+
const { diagnostics: transpileDiagnostics } = this.lastResult ?? this.transpileLua(fileName);
3840
return [
3941
...diagnostics,
4042
...TypeScriptWorker.clearFiles(transpileDiagnostics.map((diag) => ({ ...diag, code: diag.source as any }))),
@@ -79,7 +81,8 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
7981
],
8082
});
8183

82-
return { diagnostics, ast, lua, sourceMap };
84+
this.lastResult = { diagnostics, ast, lua, sourceMap };
85+
return this.lastResult;
8386
}
8487
}
8588

0 commit comments

Comments
 (0)