diff --git a/lib/plugin/visitors/model-class.visitor.ts b/lib/plugin/visitors/model-class.visitor.ts index c86108b6e..f2fa69edf 100644 --- a/lib/plugin/visitors/model-class.visitor.ts +++ b/lib/plugin/visitors/model-class.visitor.ts @@ -269,9 +269,10 @@ export class ModelClassVisitor { sourceFile: ts.SourceFile, pathsToImport: string[], ): ts.SourceFile { + const [major, minor] = ts.versionMajorMinor?.split('.').map((x) => +x); const IMPORT_PREFIX = 'eager_import_'; const importDeclarations = pathsToImport.map((path, index) => { - if (ts.createImportEqualsDeclaration.length === 5) { + if (major == 4 && minor >= 2) { // support TS v4.2+ return (ts.createImportEqualsDeclaration as any)( undefined,