Skip to content

Commit

Permalink
feat: proxy all ts program apis on vue-tsc
Browse files Browse the repository at this point in the history
close #1375
  • Loading branch information
johnsoncodehk committed Jun 1, 2022
1 parent e5e7a54 commit f4baefa
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/vue-tsc/src/proxy.ts
Expand Up @@ -60,15 +60,14 @@ export function createProgramProxy(
});
tsRuntime.update(); // must update before getProgram() to update virtual scripts

const tsProgram = tsRuntime.getTsLs().getProgram();
if (!tsProgram)
throw '!tsProgram';

const proxyApis = apis.register(ts, tsRuntime);
const program = new Proxy<ts.Program>(tsProgram, {
get: (target: any, property: keyof typeof proxyApis) => {
const program = new Proxy<ts.Program>({} as ts.Program, {
get: (_, property: keyof ts.Program) => {
tsRuntime.update();
return proxyApis[property] || target[property];
if (property in proxyApis) {
return proxyApis[property as keyof typeof proxyApis];
}
return tsRuntime.getTsLs().getProgram()![property];
},
});

Expand Down

0 comments on commit f4baefa

Please sign in to comment.