diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index fad16c3b04e57abb68d14598206da58a4aaf2692..e784300f49a9ab8ea582cee0c2aaf5c8c0fa3fbd 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -179,7 +179,7 @@ function processInnerComponent(node: ts.ExpressionStatement, index: number, arr: newStatements.push(res.newNode); if (projectConfig.isPreview) { const posOfNode: ts.LineAndCharacter = - transformLog.sourceFile.getLineAndCharacterOfPosition(node.getStart()); + transformLog.sourceFile.getLineAndCharacterOfPosition(getRealNodePos(node)); const projectPath: string = projectConfig.projectPath; const curFileName: string = transformLog.sourceFile.fileName.replace(/.ts$/, ''); const debugInfo: string = @@ -212,6 +212,16 @@ function processInnerComponent(node: ts.ExpressionStatement, index: number, arr: } } +function getRealNodePos(node: ts.Node): number { + // @ts-ignore + if (node.pos === -1 && node.expression) { + // @ts-ignore + return getRealNodePos(node.expression); + } else { + return node.getStart(); + } +} + function processForEachComponent(node: ts.ExpressionStatement, newStatements: ts.Statement[], log: LogInfo[]): void { const popNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(createFunction(