@@ -3,10 +3,6 @@ import { posix } from 'path';
3
3
import * as ts from 'typescript' ;
4
4
import { factory , PropertyAssignment } from 'typescript' ;
5
5
import { ApiHideProperty , ApiProperty } from '../../decorators' ;
6
- import {
7
- decoratorsProperties ,
8
- decoratorsPropertiesMappingType
9
- } from '../../services/decorators-properties' ;
10
6
import { PluginOptions } from '../merge-options' ;
11
7
import { METADATA_FACTORY_NAME } from '../plugin-constants' ;
12
8
import { pluginDebugLogger } from '../plugin-debug-logger' ;
@@ -20,10 +16,6 @@ import {
20
16
getTsDocTagsOfNode ,
21
17
isEnum
22
18
} from '../utils/ast-utils' ;
23
- import {
24
- getExternalImports ,
25
- replaceExternalImportsInTypeReference
26
- } from '../utils/external-imports.util' ;
27
19
import {
28
20
canReferenceNode ,
29
21
convertPath ,
@@ -36,6 +28,14 @@ import {
36
28
} from '../utils/plugin-utils' ;
37
29
import { typeReferenceToIdentifier } from '../utils/type-reference-to-identifier.util' ;
38
30
import { AbstractFileVisitor } from './abstract.visitor' ;
31
+ import {
32
+ getExternalImports ,
33
+ replaceExternalImportsInTypeReference
34
+ } from '../utils/external-imports.util' ;
35
+ import {
36
+ decoratorsProperties ,
37
+ decoratorsPropertiesMappingType
38
+ } from '../../services/decorators-properties' ;
39
39
40
40
type ClassMetadata = Record < string , ts . ObjectLiteralExpression > ;
41
41
@@ -72,7 +72,6 @@ export class ModelClassVisitor extends AbstractFileVisitor {
72
72
) {
73
73
const externalImports = getExternalImports ( sourceFile ) ;
74
74
const typeChecker = program . getTypeChecker ( ) ;
75
- const compilerOptionsPaths = program . getCompilerOptions ( ) . paths ?? { } ;
76
75
sourceFile = this . updateImports ( sourceFile , ctx . factory , program ) ;
77
76
78
77
const propertyNodeVisitorFactory =
@@ -87,8 +86,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
87
86
options ,
88
87
sourceFile ,
89
88
metadata ,
90
- externalImports ,
91
- compilerOptionsPaths
89
+ externalImports
92
90
) ;
93
91
} else if (
94
92
options . parameterProperties &&
@@ -100,8 +98,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
100
98
options ,
101
99
sourceFile ,
102
100
metadata ,
103
- externalImports ,
104
- compilerOptionsPaths
101
+ externalImports
105
102
) ;
106
103
}
107
104
return node ;
@@ -168,8 +165,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
168
165
options : PluginOptions ,
169
166
sourceFile : ts . SourceFile ,
170
167
metadata : ClassMetadata ,
171
- externalImports : Record < string , string > ,
172
- compilerOptionsPaths : ts . MapLike < string [ ] >
168
+ externalImports : Record < string , string >
173
169
) {
174
170
const isPropertyStatic = ( node . modifiers || [ ] ) . some (
175
171
( modifier : ts . Modifier ) => modifier . kind === ts . SyntaxKind . StaticKeyword
@@ -217,8 +213,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
217
213
sourceFile . fileName ,
218
214
sourceFile ,
219
215
metadata ,
220
- externalImports ,
221
- compilerOptionsPaths
216
+ externalImports
222
217
) ;
223
218
} catch ( err ) {
224
219
return node ;
@@ -231,8 +226,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
231
226
options : PluginOptions ,
232
227
sourceFile : ts . SourceFile ,
233
228
metadata : ClassMetadata ,
234
- externalImports : Record < string , string > ,
235
- compilerOptionsPaths : ts . MapLike < string [ ] >
229
+ externalImports : Record < string , string >
236
230
) {
237
231
constructorNode . forEachChild ( ( node ) => {
238
232
if (
@@ -254,8 +248,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
254
248
options ,
255
249
sourceFile . fileName ,
256
250
sourceFile ,
257
- externalImports ,
258
- compilerOptionsPaths
251
+ externalImports
259
252
) ;
260
253
261
254
const propertyName = node . name . getText ( ) ;
@@ -322,8 +315,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
322
315
hostFilename : string ,
323
316
sourceFile : ts . SourceFile ,
324
317
metadata : ClassMetadata ,
325
- externalImports : Record < string , string > ,
326
- compilerOptionsPaths : ts . MapLike < string [ ] >
318
+ externalImports : Record < string , string >
327
319
) {
328
320
const objectLiteralExpr = this . createDecoratorObjectLiteralExpr (
329
321
factory ,
@@ -333,8 +325,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
333
325
options ,
334
326
hostFilename ,
335
327
sourceFile ,
336
- externalImports ,
337
- compilerOptionsPaths
328
+ externalImports
338
329
) ;
339
330
this . addClassMetadata (
340
331
compilerNode ,
@@ -355,8 +346,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
355
346
options : PluginOptions = { } ,
356
347
hostFilename = '' ,
357
348
sourceFile ?: ts . SourceFile ,
358
- externalImports : Record < string , string > = { } ,
359
- compilerOptionsPaths : ts . MapLike < string [ ] > = { }
349
+ externalImports : Record < string , string > = { }
360
350
) : ts . ObjectLiteralExpression {
361
351
const isRequired = ! node . questionToken ;
362
352
@@ -373,9 +363,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
373
363
typeChecker ,
374
364
existingProperties ,
375
365
hostFilename ,
376
- options ,
377
- externalImports ,
378
- compilerOptionsPaths
366
+ options
379
367
) ,
380
368
...this . createDescriptionAndTsDocTagPropertyAssignments (
381
369
factory ,
@@ -398,8 +386,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
398
386
existingProperties ,
399
387
hostFilename ,
400
388
options ,
401
- externalImports ,
402
- compilerOptionsPaths
389
+ externalImports
403
390
)
404
391
] ;
405
392
if (
@@ -424,9 +411,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
424
411
typeChecker : ts . TypeChecker ,
425
412
existingProperties : ts . NodeArray < ts . PropertyAssignment > ,
426
413
hostFilename : string ,
427
- options : PluginOptions ,
428
- externalImports : Record < string , string > ,
429
- compilerOptionsPaths : ts . MapLike < string [ ] >
414
+ options : PluginOptions
430
415
) : ts . PropertyAssignment [ ] {
431
416
const key = 'type' ;
432
417
if ( hasPropertyKey ( key , existingProperties ) ) {
@@ -441,9 +426,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
441
426
typeChecker ,
442
427
existingProperties ,
443
428
hostFilename ,
444
- options ,
445
- externalImports ,
446
- compilerOptionsPaths
429
+ options
447
430
) ;
448
431
return [ factory . createPropertyAssignment ( key , initializer ) ] ;
449
432
} else if ( ts . isUnionTypeNode ( node ) ) {
@@ -460,9 +443,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
460
443
typeChecker ,
461
444
existingProperties ,
462
445
hostFilename ,
463
- options ,
464
- externalImports ,
465
- compilerOptionsPaths
446
+ options
466
447
) ;
467
448
if ( ! isNullable ) {
468
449
return propertyAssignments ;
@@ -494,8 +475,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
494
475
options ,
495
476
factory ,
496
477
type ,
497
- this . _typeImports ,
498
- compilerOptionsPaths
478
+ this . _typeImports
499
479
) ;
500
480
501
481
const initializer = factory . createArrowFunction (
@@ -515,9 +495,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
515
495
typeChecker : ts . TypeChecker ,
516
496
existingProperties : ts . NodeArray < ts . PropertyAssignment > ,
517
497
hostFilename : string ,
518
- options : PluginOptions ,
519
- externalImports : Record < string , string > ,
520
- compilerOptionsPaths : ts . MapLike < string [ ] >
498
+ options : PluginOptions
521
499
) {
522
500
const propertyAssignments = Array . from ( node . members || [ ] ) . map ( ( member ) => {
523
501
const literalExpr = this . createDecoratorObjectLiteralExpr (
@@ -526,10 +504,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
526
504
typeChecker ,
527
505
existingProperties ,
528
506
options ,
529
- hostFilename ,
530
- undefined ,
531
- externalImports ,
532
- compilerOptionsPaths
507
+ hostFilename
533
508
) ;
534
509
return factory . createPropertyAssignment (
535
510
factory . createIdentifier ( member . name . getText ( ) ) ,
@@ -569,8 +544,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
569
544
existingProperties : ts . NodeArray < ts . PropertyAssignment > ,
570
545
hostFilename : string ,
571
546
options : PluginOptions ,
572
- externalImports : Record < string , string > ,
573
- compilerOptionsPaths : ts . MapLike < string [ ] >
547
+ externalImports : Record < string , string >
574
548
) {
575
549
const key = 'enum' ;
576
550
if ( hasPropertyKey ( key , existingProperties ) ) {
@@ -618,8 +592,7 @@ export class ModelClassVisitor extends AbstractFileVisitor {
618
592
options ,
619
593
factory ,
620
594
type ,
621
- this . _typeImports ,
622
- compilerOptionsPaths
595
+ this . _typeImports
623
596
) ;
624
597
625
598
const enumProperty = factory . createPropertyAssignment ( key , enumIdentifier ) ;
0 commit comments