chore(core): ts报错修改

This commit is contained in:
parisma 2022-09-28 16:04:35 +08:00 committed by jia000
parent 551da1a64b
commit 040d679b7f
2 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,7 @@ interface EventCache {
class App extends EventEmitter {
public env;
public codeDsl: CodeBlockDSL;
public codeDsl: CodeBlockDSL | undefined;
public pages = new Map<Id, Page>();
public page: Page | undefined;

View File

@ -85,9 +85,9 @@ class Node extends EventEmitter {
}
private async runCodeBlock(hook: string) {
if (!Array.isArray(this.data[hook]) || isEmpty(this.app?.codeDsl)) return;
if (!Array.isArray(this.data[hook]) || !this.app.codeDsl || isEmpty(this.app?.codeDsl)) return;
for (const codeId of this.data[hook]) {
if (this.app?.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') {
if (this.app.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') {
await this.app.codeDsl[codeId].content(this);
}
}