diff --git a/arkoala/ets-plugin/src/PropertyTranslators.ts b/arkoala/ets-plugin/src/PropertyTranslators.ts index 7b956e0bc46d557d3e865dfe4fdef1f90bdec480..f293554b3211d8592b49e66aa8c6e2bf601c266b 100644 --- a/arkoala/ets-plugin/src/PropertyTranslators.ts +++ b/arkoala/ets-plugin/src/PropertyTranslators.ts @@ -120,7 +120,7 @@ export abstract class PropertyTranslator { if (!type) { reportError( MessageCode.EXPECTED_STRUCT_FIELD__TO_BE_EXPLICITLY_TYPED, - `Expected struct field to be explicitly typed in arkts 2.0 app: ${node.getText()}`, + `Expected struct field to be explicitly typed in arkts 2.0 app: ${node.getText(this.context.sourceFile)}`, node, this.context.sourceFile, this.context.extras diff --git a/arkoala/ets-plugin/src/StructTransformer.ts b/arkoala/ets-plugin/src/StructTransformer.ts index 9cedcda754f5f1d3b32b559c4a77d10e3bdda790..3bde629ad65a9c5685b4ae564eeaa5b0f530a64d 100644 --- a/arkoala/ets-plugin/src/StructTransformer.ts +++ b/arkoala/ets-plugin/src/StructTransformer.ts @@ -126,7 +126,7 @@ export class StructTransformer extends AbstractVisitor { const oldLiteral = oldModuleSpecifier.text if (isOhosImport(oldLiteral)) { - const oldDefaultName = node.importClause!.name ? ts.idText(node.importClause!.name) : "" + const oldDefaultName = node.importClause?.name ? ts.idText(node.importClause!.name) : "" return this.importer.translateOhosImport(node, oldLiteral, oldDefaultName) }