Skip to content

Commit

Permalink
fix(plugin): check version when updating file imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 2, 2021
1 parent 71492eb commit eb4a0c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/plugin/visitors/model-class.visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eb4a0c3

Please sign in to comment.