diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index d6dc1dabe8f5861327a15642290ec318d8f7d9ce..607f2ff7558a72a21975b0047206325dc08dc3e6 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -51,6 +51,7 @@ export function createLanguageService(rootFileNames: string[]): ts.LanguageServi const compilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions; Object.assign(compilerOptions, { + 'allowJs': false, 'moduleResolution': ts.ModuleResolutionKind.NodeJs, 'target': ts.ScriptTarget.ES2017, 'baseUrl': path.resolve(projectConfig.projectPath), diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 7a4825d35028727de7def4b84ecb779af5c7a630..7d49579513091c3c51abb05ea69389dce3769dd0 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -290,8 +290,8 @@ export function collectExtend(collectionSet: Map>, component } } -function isExtendFunction(node: ts.FunctionDeclaration): string { - if (node.decorators && node.decorators[0].expression && +export function isExtendFunction(node: ts.FunctionDeclaration): string { + if (node.decorators && node.decorators[0].expression && node.decorators[0].expression.expression && node.decorators[0].expression.expression.escapedText.toString() === CHECK_COMPONENT_EXTEND_DECORATOR && node.decorators[0].expression.arguments) { return node.decorators[0].expression.arguments[0].escapedText.toString(); diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 882859c5f0cbc29211065eecae0c43a63725413a..a5d545c3f805af0ae689b0fe4440c117a2319130 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -62,6 +62,7 @@ import { import { projectConfig } from '../main'; import { collectExtend } from './process_ui_syntax'; import { importModuleCollection } from "./ets_checker"; +import { isExtendFunction } from "./process_ui_syntax"; export interface ComponentCollection { entryComponent: string; @@ -300,6 +301,10 @@ function visitAllNode(node: ts.Node, sourceFileNode: ts.SourceFile, allComponent if (ts.isMethodDeclaration(node) && hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) { CUSTOM_BUILDER_METHOD.add(node.name.getText()); } + if (ts.isFunctionDeclaration(node) && isExtendFunction(node)) { + let componentName: string = isExtendFunction(node); + collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.getText()); + } node.getChildren().forEach((item: ts.Node) => visitAllNode(item, sourceFileNode, allComponentNames, log)); }