@rxap/ts-morph 1.1.0-dev.0 → 1.1.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/index.d.ts +11 -0
- package/src/index.js +11 -0
- package/src/index.js.map +1 -1
- package/src/lib/angular/coerce-component-import.d.ts +11 -0
- package/src/lib/angular/coerce-component-import.js +31 -0
- package/src/lib/angular/coerce-component-import.js.map +1 -0
- package/src/lib/angular/coerce-component-input.d.ts +18 -0
- package/src/lib/angular/coerce-component-input.js +67 -0
- package/src/lib/angular/coerce-component-input.js.map +1 -0
- package/src/lib/angular/coerce-component.d.ts +2 -2
- package/src/lib/angular/coerce-component.js +33 -20
- package/src/lib/angular/coerce-component.js.map +1 -1
- package/src/lib/angular/get-component-class.d.ts +2 -0
- package/src/lib/angular/get-component-class.js +12 -0
- package/src/lib/angular/get-component-class.js.map +1 -0
- package/src/lib/angular/get-component-decorator-object.d.ts +2 -0
- package/src/lib/angular/get-component-decorator-object.js +19 -0
- package/src/lib/angular/get-component-decorator-object.js.map +1 -0
- package/src/lib/coerce-accessor-declaration.d.ts +19 -0
- package/src/lib/coerce-accessor-declaration.js +38 -0
- package/src/lib/coerce-accessor-declaration.js.map +1 -0
- package/src/lib/coerce-array-element.d.ts +2 -1
- package/src/lib/coerce-array-element.js +14 -2
- package/src/lib/coerce-array-element.js.map +1 -1
- package/src/lib/coerce-class-property.d.ts +3 -0
- package/src/lib/coerce-class-property.js +3 -0
- package/src/lib/coerce-class-property.js.map +1 -1
- package/src/lib/coerce-decorator.js +5 -0
- package/src/lib/coerce-decorator.js.map +1 -1
- package/src/lib/coerce-default-class-export.d.ts +2 -0
- package/src/lib/coerce-default-class-export.js +27 -0
- package/src/lib/coerce-default-class-export.js.map +1 -0
- package/src/lib/coerce-property-declaration.d.ts +3 -0
- package/src/lib/coerce-property-declaration.js +13 -0
- package/src/lib/coerce-property-declaration.js.map +1 -0
- package/src/lib/data-property.d.ts +18 -0
- package/src/lib/data-property.js +82 -0
- package/src/lib/data-property.js.map +1 -0
- package/src/lib/find-function.js +1 -1
- package/src/lib/find-function.js.map +1 -1
- package/src/lib/has-constructor-parameter.d.ts +10 -0
- package/src/lib/has-constructor-parameter.js +17 -0
- package/src/lib/has-constructor-parameter.js.map +1 -0
- package/src/lib/nest/coerce-nest-operation.d.ts +6 -5
- package/src/lib/nest/coerce-nest-operation.js +30 -26
- package/src/lib/nest/coerce-nest-operation.js.map +1 -1
- package/src/lib/nest/operation-id-utilities.d.ts +4 -4
- package/src/lib/nest/operation-id-utilities.js +11 -11
- package/src/lib/nest/operation-id-utilities.js.map +1 -1
- package/src/lib/type-import.d.ts +13 -1
- package/src/lib/type-import.js +56 -1
- package/src/lib/type-import.js.map +1 -1
- package/src/lib/upstream-options.d.ts +45 -0
- package/src/lib/upstream-options.js +54 -0
- package/src/lib/upstream-options.js.map +1 -0
- package/src/lib/write-type.d.ts +18 -0
- package/src/lib/write-type.js +74 -0
- package/src/lib/write-type.js.map +1 -0
package/src/lib/type-import.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeImportToImportStructure = exports.RequiresTypeImport = void 0;
|
|
3
|
+
exports.NormalizeTypeImportList = exports.NormalizeTypeImport = exports.TypeImportToImportStructure = exports.RequiresTypeImport = exports.IsTypeImport = void 0;
|
|
4
|
+
function IsTypeImport(value) {
|
|
5
|
+
return typeof value === 'object' && typeof value.name === 'string';
|
|
6
|
+
}
|
|
7
|
+
exports.IsTypeImport = IsTypeImport;
|
|
4
8
|
function RequiresTypeImport(typeImport) {
|
|
5
9
|
return !!typeImport.moduleSpecifier;
|
|
6
10
|
}
|
|
@@ -27,4 +31,55 @@ function TypeImportToImportStructure(typeImport) {
|
|
|
27
31
|
return structure;
|
|
28
32
|
}
|
|
29
33
|
exports.TypeImportToImportStructure = TypeImportToImportStructure;
|
|
34
|
+
function NormalizeTypeImport(typeImport, defaultType = 'unknown') {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
36
|
+
let name;
|
|
37
|
+
let moduleSpecifier = null;
|
|
38
|
+
let namedImport = null;
|
|
39
|
+
let namespaceImport = null;
|
|
40
|
+
let isTypeOnly = false;
|
|
41
|
+
let defaultImport = null;
|
|
42
|
+
if (!typeImport) {
|
|
43
|
+
if (typeof defaultType === 'string') {
|
|
44
|
+
name = defaultType;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
name = defaultType.name;
|
|
48
|
+
moduleSpecifier = (_a = defaultType.moduleSpecifier) !== null && _a !== void 0 ? _a : moduleSpecifier;
|
|
49
|
+
namedImport = (_b = defaultType.namedImport) !== null && _b !== void 0 ? _b : namedImport;
|
|
50
|
+
namespaceImport = (_c = defaultType.namespaceImport) !== null && _c !== void 0 ? _c : namespaceImport;
|
|
51
|
+
isTypeOnly = (_d = defaultType.isTypeOnly) !== null && _d !== void 0 ? _d : isTypeOnly;
|
|
52
|
+
defaultImport = (_e = defaultType.defaultImport) !== null && _e !== void 0 ? _e : defaultImport;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (typeof typeImport === 'string') {
|
|
56
|
+
// name:moduleSpecifier:namedImport
|
|
57
|
+
// IconConfig:@rxap/utilities
|
|
58
|
+
const fragments = typeImport.split(':');
|
|
59
|
+
name = fragments[0] || 'unknown';
|
|
60
|
+
moduleSpecifier = fragments[1] || null; // use || instead of ?? because the moduleSpecifier can be an empty string
|
|
61
|
+
namedImport = fragments[2] || null; // use || instead of ?? because the namedImport can be an empty string
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
name = typeImport.name;
|
|
65
|
+
moduleSpecifier = (_f = typeImport.moduleSpecifier) !== null && _f !== void 0 ? _f : moduleSpecifier;
|
|
66
|
+
namedImport = (_g = typeImport.namedImport) !== null && _g !== void 0 ? _g : namedImport;
|
|
67
|
+
namespaceImport = (_h = typeImport.namespaceImport) !== null && _h !== void 0 ? _h : namespaceImport;
|
|
68
|
+
isTypeOnly = (_j = typeImport.isTypeOnly) !== null && _j !== void 0 ? _j : isTypeOnly;
|
|
69
|
+
defaultImport = (_k = typeImport.defaultImport) !== null && _k !== void 0 ? _k : defaultImport;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name,
|
|
73
|
+
moduleSpecifier,
|
|
74
|
+
namedImport,
|
|
75
|
+
namespaceImport,
|
|
76
|
+
isTypeOnly,
|
|
77
|
+
defaultImport,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
exports.NormalizeTypeImport = NormalizeTypeImport;
|
|
81
|
+
function NormalizeTypeImportList(typeImportList = [], defaultType = 'unknown') {
|
|
82
|
+
return typeImportList.map(type => NormalizeTypeImport(type, defaultType));
|
|
83
|
+
}
|
|
84
|
+
exports.NormalizeTypeImportList = NormalizeTypeImportList;
|
|
30
85
|
//# sourceMappingURL=type-import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-import.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/type-import.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"type-import.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/type-import.ts"],"names":[],"mappings":";;;AAgBA,SAAgB,YAAY,CAAC,KAAU;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AACrE,CAAC;AAFD,oCAEC;AAED,SAAgB,kBAAkB,CAAC,UAAsB;IACvD,OAAO,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;AACtC,CAAC;AAFD,gDAEC;AAED,SAAgB,2BAA2B,CAAC,UAAsB;IAChE,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC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ilities';
|
|
2
|
+
export declare enum UpstreamOptionsKinds {
|
|
3
|
+
OPEN_API = "open-api"
|
|
4
|
+
}
|
|
5
|
+
export type UpstreamOptions = OpenApiUpstreamOptions | BaseUpstreamOptions;
|
|
6
|
+
export type NormalizedUpstreamOptions = NormalizedOpenApiUpstreamOptions | NormalizedBaseUpstreamOptions;
|
|
7
|
+
export interface BaseUpstreamOptions {
|
|
8
|
+
kind: UpstreamOptionsKinds;
|
|
9
|
+
}
|
|
10
|
+
export interface NormalizedBaseUpstreamOptions extends Readonly<Normalized<BaseUpstreamOptions>> {
|
|
11
|
+
kind: UpstreamOptionsKinds;
|
|
12
|
+
}
|
|
13
|
+
export declare function NormalizeBaseUpstreamOptions(options: BaseUpstreamOptions): NormalizedBaseUpstreamOptions;
|
|
14
|
+
export interface CommandMapper {
|
|
15
|
+
pageIndex?: string;
|
|
16
|
+
pageSize?: string;
|
|
17
|
+
sortBy?: string;
|
|
18
|
+
sortDirection?: string;
|
|
19
|
+
list?: string;
|
|
20
|
+
total?: string;
|
|
21
|
+
value?: string;
|
|
22
|
+
filter?: {
|
|
23
|
+
eq: string;
|
|
24
|
+
join: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface NormalizedCommandMapper extends Readonly<Normalized<CommandMapper>> {
|
|
28
|
+
filter: {
|
|
29
|
+
eq: string;
|
|
30
|
+
join: string;
|
|
31
|
+
} | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function NormalizeCommandMapper(mapper?: CommandMapper | null): NormalizedCommandMapper | null;
|
|
34
|
+
export interface OpenApiUpstreamOptions extends BaseUpstreamOptions {
|
|
35
|
+
operationId: string;
|
|
36
|
+
isService?: boolean;
|
|
37
|
+
scope?: string;
|
|
38
|
+
mapper?: CommandMapper;
|
|
39
|
+
}
|
|
40
|
+
export interface NormalizedOpenApiUpstreamOptions extends Readonly<Normalized<OpenApiUpstreamOptions>> {
|
|
41
|
+
kind: UpstreamOptionsKinds.OPEN_API;
|
|
42
|
+
}
|
|
43
|
+
export declare function NormalizeOpenApiUpstreamOptions(options: OpenApiUpstreamOptions): NormalizedOpenApiUpstreamOptions;
|
|
44
|
+
export declare function IsNormalizedOpenApiUpstreamOptions(options: NormalizedUpstreamOptions): options is NormalizedOpenApiUpstreamOptions;
|
|
45
|
+
export declare function NormalizeUpstreamOptions(options?: UpstreamOptions): NormalizedUpstreamOptions | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NormalizeUpstreamOptions = exports.IsNormalizedOpenApiUpstreamOptions = exports.NormalizeOpenApiUpstreamOptions = exports.NormalizeCommandMapper = exports.NormalizeBaseUpstreamOptions = exports.UpstreamOptionsKinds = void 0;
|
|
4
|
+
var UpstreamOptionsKinds;
|
|
5
|
+
(function (UpstreamOptionsKinds) {
|
|
6
|
+
UpstreamOptionsKinds["OPEN_API"] = "open-api";
|
|
7
|
+
})(UpstreamOptionsKinds || (exports.UpstreamOptionsKinds = UpstreamOptionsKinds = {}));
|
|
8
|
+
function NormalizeBaseUpstreamOptions(options) {
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
kind: options.kind,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.NormalizeBaseUpstreamOptions = NormalizeBaseUpstreamOptions;
|
|
14
|
+
function NormalizeCommandMapper(mapper) {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
|
+
if (!mapper || Object.keys(mapper).length === 0) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
pageIndex: (_a = mapper.pageIndex) !== null && _a !== void 0 ? _a : null,
|
|
21
|
+
pageSize: (_b = mapper.pageSize) !== null && _b !== void 0 ? _b : null,
|
|
22
|
+
sortBy: (_c = mapper.sortBy) !== null && _c !== void 0 ? _c : null,
|
|
23
|
+
list: (_d = mapper.list) !== null && _d !== void 0 ? _d : null,
|
|
24
|
+
total: (_e = mapper.total) !== null && _e !== void 0 ? _e : null,
|
|
25
|
+
value: (_f = mapper.value) !== null && _f !== void 0 ? _f : null,
|
|
26
|
+
sortDirection: (_g = mapper.sortDirection) !== null && _g !== void 0 ? _g : null,
|
|
27
|
+
filter: mapper.filter && Object.keys((_h = mapper.filter) !== null && _h !== void 0 ? _h : {}).length ? {
|
|
28
|
+
eq: mapper.filter.eq,
|
|
29
|
+
join: mapper.filter.join,
|
|
30
|
+
} : null,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.NormalizeCommandMapper = NormalizeCommandMapper;
|
|
34
|
+
function NormalizeOpenApiUpstreamOptions(options) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseUpstreamOptions(options)), { kind: UpstreamOptionsKinds.OPEN_API, operationId: options.operationId, mapper: NormalizeCommandMapper(options.mapper), scope: (_a = options.scope) !== null && _a !== void 0 ? _a : null, isService: (_b = options.isService) !== null && _b !== void 0 ? _b : false }));
|
|
37
|
+
}
|
|
38
|
+
exports.NormalizeOpenApiUpstreamOptions = NormalizeOpenApiUpstreamOptions;
|
|
39
|
+
function IsNormalizedOpenApiUpstreamOptions(options) {
|
|
40
|
+
return options.kind === UpstreamOptionsKinds.OPEN_API;
|
|
41
|
+
}
|
|
42
|
+
exports.IsNormalizedOpenApiUpstreamOptions = IsNormalizedOpenApiUpstreamOptions;
|
|
43
|
+
// endregion
|
|
44
|
+
function NormalizeUpstreamOptions(options) {
|
|
45
|
+
if (!options || Object.keys(options).length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
switch (options.kind) {
|
|
49
|
+
case UpstreamOptionsKinds.OPEN_API:
|
|
50
|
+
return NormalizeOpenApiUpstreamOptions(options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.NormalizeUpstreamOptions = NormalizeUpstreamOptions;
|
|
54
|
+
//# sourceMappingURL=upstream-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream-options.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/upstream-options.ts"],"names":[],"mappings":";;;AAEA,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC9B,6CAAqB,CAAA;AACvB,CAAC,EAFW,oBAAoB,oCAApB,oBAAoB,QAE/B;AAgBD,SAAgB,4BAA4B,CAAC,OAA4B;IACvE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAJD,oEAIC;AA2BD,SAAgB,sBAAsB,CAAC,MAA6B;;IAClE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAI;QACnC,QAAQ,EAAE,MAAA,MAAM,CAAC,QAAQ,mCAAI,IAAI;QACjC,MAAM,EAAE,MAAA,MAAM,CAAC,MAAM,mCAAI,IAAI;QAC7B,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,IAAI;QACzB,KAAK,EAAE,MAAA,MAAM,CAAC,KAAK,mCAAI,IAAI;QAC3B,KAAK,EAAE,MAAA,MAAM,CAAC,KAAK,mCAAI,IAAI;QAC3B,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,IAAI;QAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACjE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;YACpB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;SACzB,CAAC,CAAC,CAAC,IAAI;KACT,CAAC,CAAC;AACL,CAAC;AAjBD,wDAiBC;AAiBD,SAAgB,+BAA+B,CAAC,OAA+B;;IAC7E,OAAO,MAAM,CAAC,MAAM,iCACf,4BAA4B,CAAC,OAAO,CAAC,KACxC,IAAI,EAAE,oBAAoB,CAAC,QAAQ,EACnC,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,MAAM,EAAE,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9C,KAAK,EAAE,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,EAC5B,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,KAAK,IACrC,CAAC;AACL,CAAC;AATD,0EASC;AAED,SAAgB,kCAAkC,CAAC,OAAkC;IACnF,OAAO,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,QAAQ,CAAC;AACxD,CAAC;AAFD,gFAEC;AAED,YAAY;AAEZ,SAAgB,wBAAwB,CAAC,OAAyB;IAChE,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IACD,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,oBAAoB,CAAC,QAAQ;YAChC,OAAO,+BAA+B,CAAC,OAAiC,CAAC,CAAC;KAC7E;AACH,CAAC;AARD,4DAQC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeBlockWriter, SourceFile, WriterFunction } from 'ts-morph';
|
|
2
|
+
import { TypeImport } from './type-import';
|
|
3
|
+
export type WriteType = string | TypeImport | WriterFunction;
|
|
4
|
+
export interface WriteTypeOptions {
|
|
5
|
+
isArray?: boolean | null;
|
|
6
|
+
type: WriteType;
|
|
7
|
+
}
|
|
8
|
+
export declare function IsWriteTypeOptions(value: any): value is WriteTypeOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Uses the CodeBlockWriter to write the type to the AST thereby the value of the property type is evaluated
|
|
11
|
+
* to determine the value that should be written to the AST
|
|
12
|
+
* @param type
|
|
13
|
+
* @param w
|
|
14
|
+
* @constructor
|
|
15
|
+
*/
|
|
16
|
+
export declare function WriteStringType(type: string, w: CodeBlockWriter): void;
|
|
17
|
+
export declare function WriteType(type: WriteType, sourceFile: SourceFile): WriterFunction;
|
|
18
|
+
export declare function WriteType(property: WriteTypeOptions, sourceFile: SourceFile): WriterFunction;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteType = exports.WriteStringType = exports.IsWriteTypeOptions = void 0;
|
|
4
|
+
const coerce_imports_1 = require("./coerce-imports");
|
|
5
|
+
const type_import_1 = require("./type-import");
|
|
6
|
+
function IsWriteTypeOptions(value) {
|
|
7
|
+
return value && typeof value === 'object' && value.type;
|
|
8
|
+
}
|
|
9
|
+
exports.IsWriteTypeOptions = IsWriteTypeOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Uses the CodeBlockWriter to write the type to the AST thereby the value of the property type is evaluated
|
|
12
|
+
* to determine the value that should be written to the AST
|
|
13
|
+
* @param type
|
|
14
|
+
* @param w
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
function WriteStringType(type, w) {
|
|
18
|
+
switch (type) {
|
|
19
|
+
case 'date':
|
|
20
|
+
w.write('Date');
|
|
21
|
+
break;
|
|
22
|
+
case 'uuid':
|
|
23
|
+
w.write('string');
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
w.write(type);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.WriteStringType = WriteStringType;
|
|
31
|
+
function WriteType(propertyOrType, sourceFile) {
|
|
32
|
+
var _a;
|
|
33
|
+
let isArray = false;
|
|
34
|
+
let type;
|
|
35
|
+
if (IsWriteTypeOptions(propertyOrType)) {
|
|
36
|
+
isArray = (_a = propertyOrType.isArray) !== null && _a !== void 0 ? _a : isArray;
|
|
37
|
+
type = propertyOrType.type;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
type = propertyOrType;
|
|
41
|
+
}
|
|
42
|
+
if ((0, type_import_1.IsTypeImport)(type)) {
|
|
43
|
+
if (sourceFile) {
|
|
44
|
+
if ((0, type_import_1.RequiresTypeImport)(type)) {
|
|
45
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, (0, type_import_1.TypeImportToImportStructure)(type));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.warn('WriteType :: No source file provided to coerce imports');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return (w) => {
|
|
53
|
+
if (isArray) {
|
|
54
|
+
w.write('Array<');
|
|
55
|
+
}
|
|
56
|
+
if (typeof type === 'string') {
|
|
57
|
+
WriteStringType(type, w);
|
|
58
|
+
}
|
|
59
|
+
else if (typeof type === 'function') {
|
|
60
|
+
type(w);
|
|
61
|
+
}
|
|
62
|
+
else if ((0, type_import_1.IsTypeImport)(type)) {
|
|
63
|
+
WriteStringType(type.name, w);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new Error('Invalid type');
|
|
67
|
+
}
|
|
68
|
+
if (isArray) {
|
|
69
|
+
w.write('>');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.WriteType = WriteType;
|
|
74
|
+
//# sourceMappingURL=write-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-type.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/write-type.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAMjD,+CAKuB;AASvB,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC;AAC1D,CAAC;AAFD,gDAEC;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