@teambit/typescript 1.0.551 → 1.0.552
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/dist/identifier.d.ts +2 -0
- package/dist/identifier.js +22 -7
- package/dist/identifier.js.map +1 -1
- package/dist/{preview-1740194344610.js → preview-1740280818215.js} +2 -2
- package/dist/schema-extractor-context.d.ts +43 -1
- package/dist/schema-extractor-context.js +164 -13
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/transformers/export-declaration.js +1 -1
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-like.js +1 -1
- package/dist/transformers/function-like.js.map +1 -1
- package/dist/transformers/type-query.js +1 -1
- package/dist/transformers/type-query.js.map +1 -1
- package/dist/transformers/type-reference.js +1 -1
- package/dist/transformers/type-reference.js.map +1 -1
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +21 -2
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/typescript.extractor.js +1 -1
- package/dist/typescript.extractor.js.map +1 -1
- package/package.json +17 -17
- package/transformers/export-declaration.ts +1 -1
- package/transformers/function-like.ts +1 -1
- package/transformers/type-query.ts +1 -1
- package/transformers/type-reference.ts +1 -1
- package/transformers/utils/jsdoc-to-doc-schema.ts +22 -2
package/dist/identifier.d.ts
CHANGED
@@ -3,7 +3,9 @@ export declare class Identifier {
|
|
3
3
|
readonly filePath: string;
|
4
4
|
readonly aliasId?: string | undefined;
|
5
5
|
readonly sourceFilePath?: string | undefined;
|
6
|
+
readonly normalizedPath: string;
|
6
7
|
constructor(id: string, filePath: string, aliasId?: string | undefined, sourceFilePath?: string | undefined);
|
8
|
+
private static computeNormalizedPath;
|
7
9
|
isEqual(identifier: Identifier): boolean;
|
8
10
|
static isDefault(identifier: Identifier): boolean;
|
9
11
|
}
|
package/dist/identifier.js
CHANGED
@@ -4,21 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Identifier = void 0;
|
7
|
+
function _path() {
|
8
|
+
const data = require("path");
|
9
|
+
_path = function () {
|
10
|
+
return data;
|
11
|
+
};
|
12
|
+
return data;
|
13
|
+
}
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
17
|
class Identifier {
|
8
18
|
constructor(id, filePath, aliasId, sourceFilePath) {
|
9
19
|
this.id = id;
|
10
20
|
this.filePath = filePath;
|
11
21
|
this.aliasId = aliasId;
|
12
22
|
this.sourceFilePath = sourceFilePath;
|
23
|
+
_defineProperty(this, "normalizedPath", void 0);
|
24
|
+
this.normalizedPath = Identifier.computeNormalizedPath(filePath, sourceFilePath);
|
13
25
|
}
|
14
|
-
|
15
|
-
|
16
|
-
if (
|
17
|
-
|
18
|
-
}
|
19
|
-
if (Identifier.isDefault(identifier) || Identifier.isDefault(this)) {
|
20
|
-
return false;
|
26
|
+
static computeNormalizedPath(filePath, sourceFilePath) {
|
27
|
+
let effectivePath = filePath;
|
28
|
+
if (sourceFilePath) {
|
29
|
+
effectivePath = (0, _path().isAbsolute)(sourceFilePath) ? sourceFilePath : (0, _path().resolve)((0, _path().dirname)(filePath), sourceFilePath);
|
21
30
|
}
|
31
|
+
return (0, _path().normalize)(effectivePath).replace(/\\/g, '/');
|
32
|
+
}
|
33
|
+
isEqual(identifier) {
|
34
|
+
if (this.filePath !== identifier.filePath && this.normalizedPath !== identifier.normalizedPath) return false;
|
35
|
+
if (Identifier.isDefault(identifier) && Identifier.isDefault(this)) return true;
|
36
|
+
if (Identifier.isDefault(identifier) || Identifier.isDefault(this)) return false;
|
22
37
|
return this.id === identifier.id;
|
23
38
|
}
|
24
39
|
static isDefault(identifier) {
|
package/dist/identifier.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Identifier","constructor","id","filePath","aliasId","sourceFilePath","isEqual","identifier","isDefault","exports"],"sources":["identifier.ts"],"sourcesContent":["
|
1
|
+
{"version":3,"names":["_path","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Identifier","constructor","id","filePath","aliasId","sourceFilePath","normalizedPath","computeNormalizedPath","effectivePath","isAbsolute","resolve","dirname","normalize","replace","isEqual","identifier","isDefault","exports"],"sources":["identifier.ts"],"sourcesContent":["import { isAbsolute, resolve, dirname, normalize } from 'path';\nexport class Identifier {\n public readonly normalizedPath: string;\n\n constructor(\n readonly id: string,\n readonly filePath: string,\n readonly aliasId?: string,\n readonly sourceFilePath?: string\n ) {\n this.normalizedPath = Identifier.computeNormalizedPath(filePath, sourceFilePath);\n }\n\n private static computeNormalizedPath(filePath: string, sourceFilePath?: string): string {\n let effectivePath = filePath;\n if (sourceFilePath) {\n effectivePath = isAbsolute(sourceFilePath)\n ? sourceFilePath\n : resolve(dirname(filePath), sourceFilePath);\n }\n return normalize(effectivePath).replace(/\\\\/g, '/');\n }\n\n isEqual(identifier: Identifier): boolean {\n if (this.filePath !== identifier.filePath && this.normalizedPath !== identifier.normalizedPath) return false;\n if (Identifier.isDefault(identifier) && Identifier.isDefault(this)) return true;\n if (Identifier.isDefault(identifier) || Identifier.isDefault(this)) return false;\n return this.id === identifier.id;\n }\n\n static isDefault(identifier: Identifier) {\n return identifier.id === 'default';\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+D,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AACxD,MAAMgB,UAAU,CAAC;EAGtBC,WAAWA,CACAC,EAAU,EACVC,QAAgB,EAChBC,OAAgB,EAChBC,cAAuB,EAChC;IAAA,KAJSH,EAAU,GAAVA,EAAU;IAAA,KACVC,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,OAAgB,GAAhBA,OAAgB;IAAA,KAChBC,cAAuB,GAAvBA,cAAuB;IAAAxB,eAAA;IAEhC,IAAI,CAACyB,cAAc,GAAGN,UAAU,CAACO,qBAAqB,CAACJ,QAAQ,EAAEE,cAAc,CAAC;EAClF;EAEA,OAAeE,qBAAqBA,CAACJ,QAAgB,EAAEE,cAAuB,EAAU;IACtF,IAAIG,aAAa,GAAGL,QAAQ;IAC5B,IAAIE,cAAc,EAAE;MAClBG,aAAa,GAAG,IAAAC,kBAAU,EAACJ,cAAc,CAAC,GACtCA,cAAc,GACd,IAAAK,eAAO,EAAC,IAAAC,eAAO,EAACR,QAAQ,CAAC,EAAEE,cAAc,CAAC;IAChD;IACA,OAAO,IAAAO,iBAAS,EAACJ,aAAa,CAAC,CAACK,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACrD;EAEAC,OAAOA,CAACC,UAAsB,EAAW;IACvC,IAAI,IAAI,CAACZ,QAAQ,KAAKY,UAAU,CAACZ,QAAQ,IAAI,IAAI,CAACG,cAAc,KAAKS,UAAU,CAACT,cAAc,EAAE,OAAO,KAAK;IAC5G,IAAIN,UAAU,CAACgB,SAAS,CAACD,UAAU,CAAC,IAAIf,UAAU,CAACgB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI;IAC/E,IAAIhB,UAAU,CAACgB,SAAS,CAACD,UAAU,CAAC,IAAIf,UAAU,CAACgB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK;IAChF,OAAO,IAAI,CAACd,EAAE,KAAKa,UAAU,CAACb,EAAE;EAClC;EAEA,OAAOc,SAASA,CAACD,UAAsB,EAAE;IACvC,OAAOA,UAAU,CAACb,EAAE,KAAK,SAAS;EACpC;AACF;AAACe,OAAA,CAAAjB,UAAA,GAAAA,UAAA","ignoreList":[]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.552/dist/typescript.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.552/dist/typescript.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
@@ -103,14 +103,56 @@ export declare class SchemaExtractorContext {
|
|
103
103
|
* "definition" but it's not clear when/why).
|
104
104
|
*/
|
105
105
|
getDefinition(node: Node): Promise<ts.server.protocol.FileSpanWithContext | undefined>;
|
106
|
+
/**
|
107
|
+
* Handles type resolution for unknown or external types.
|
108
|
+
* Attempts to:
|
109
|
+
* 1. Get type references when possible
|
110
|
+
* 2. Fall back to inference when references can't be found
|
111
|
+
*/
|
106
112
|
private unknownExactType;
|
113
|
+
/**
|
114
|
+
* Check if type is an array type (either T[] or Array<T>)
|
115
|
+
*/
|
116
|
+
private isArrayType;
|
117
|
+
/**
|
118
|
+
* Extract base type from array type
|
119
|
+
*/
|
120
|
+
private getArrayBaseType;
|
121
|
+
/**
|
122
|
+
* Extract return type from method signature
|
123
|
+
*/
|
124
|
+
private extractMethodReturnType;
|
125
|
+
/**
|
126
|
+
* Extract content from generic type
|
127
|
+
*/
|
128
|
+
private extractGenericType;
|
129
|
+
/**
|
130
|
+
* Create schema for method return type, attempting to get type reference
|
131
|
+
*/
|
132
|
+
private createMethodReturnSchema;
|
133
|
+
/**
|
134
|
+
* Create schema for function type, handling params and return type
|
135
|
+
*/
|
136
|
+
private createFunctionSchema;
|
137
|
+
/**
|
138
|
+
* Create parameters for function schema, attempting to get type references for param types
|
139
|
+
*/
|
140
|
+
private createFunctionParameters;
|
141
|
+
/**
|
142
|
+
* Create schema for object literal type
|
143
|
+
*/
|
144
|
+
private createObjectSchema;
|
145
|
+
/**
|
146
|
+
* Create schema for Promise type, attempting to get type reference for the contained type
|
147
|
+
*/
|
148
|
+
private createPromiseSchema;
|
107
149
|
private isDefInSameLocation;
|
108
150
|
/**
|
109
151
|
* resolve a type by a node and its identifier.
|
110
152
|
*/
|
111
153
|
resolveType(node: Node & {
|
112
154
|
type?: TypeNode;
|
113
|
-
}, typeStr: string
|
155
|
+
}, typeStr: string): Promise<SchemaNode>;
|
114
156
|
private getCompIdByPkgName;
|
115
157
|
getTypeRef(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema | undefined>;
|
116
158
|
resolveTypeRef(identifier: Identifier, location: Location, isExportedFromMain?: boolean): Promise<TypeRefSchema>;
|
@@ -420,14 +420,165 @@ class SchemaExtractorContext {
|
|
420
420
|
return headDefinition;
|
421
421
|
}
|
422
422
|
|
423
|
-
|
424
|
-
|
425
|
-
|
423
|
+
/**
|
424
|
+
* Handles type resolution for unknown or external types.
|
425
|
+
* Attempts to:
|
426
|
+
* 1. Get type references when possible
|
427
|
+
* 2. Fall back to inference when references can't be found
|
428
|
+
*/
|
429
|
+
async unknownExactType(node, location, typeStr = 'any') {
|
430
|
+
try {
|
431
|
+
if (this.isArrayType(typeStr)) {
|
432
|
+
const baseType = this.getArrayBaseType(typeStr);
|
433
|
+
const currentFilePath = node.getSourceFile().fileName;
|
434
|
+
const baseTypeRef = await this.getTypeRef(baseType, this.getIdentifierKey(currentFilePath), location);
|
435
|
+
if (baseTypeRef) {
|
436
|
+
return new (_semanticsEntities().TypeArraySchema)(location, baseTypeRef);
|
437
|
+
}
|
438
|
+
return new (_semanticsEntities().TypeArraySchema)(location, new (_semanticsEntities().InferenceTypeSchema)(location, baseType));
|
439
|
+
}
|
440
|
+
const currentFilePath = node.getSourceFile().fileName;
|
441
|
+
const typeRef = await this.getTypeRef(typeStr, this.getIdentifierKey(currentFilePath), location);
|
442
|
+
if (typeRef) {
|
443
|
+
return typeRef;
|
444
|
+
}
|
445
|
+
const info = await this.getQuickInfo(node);
|
446
|
+
if (!info?.body?.displayString) {
|
447
|
+
return new (_semanticsEntities().InferenceTypeSchema)(location, typeStr || 'any');
|
448
|
+
}
|
449
|
+
const {
|
450
|
+
displayString,
|
451
|
+
kind
|
452
|
+
} = info.body;
|
453
|
+
if (kind === 'method') {
|
454
|
+
const returnType = this.extractMethodReturnType(displayString);
|
455
|
+
return await this.createMethodReturnSchema(node, location, returnType);
|
456
|
+
}
|
457
|
+
if (kind === 'function' || displayString.includes('=>')) {
|
458
|
+
return await this.createFunctionSchema(node, location, displayString);
|
459
|
+
}
|
460
|
+
if (displayString.includes('{') && displayString.includes('}')) {
|
461
|
+
return this.createObjectSchema(node, location, displayString);
|
462
|
+
}
|
463
|
+
if (displayString.includes('Promise<')) {
|
464
|
+
const innerType = this.extractGenericType(displayString, 'Promise');
|
465
|
+
return await this.createPromiseSchema(node, location, innerType);
|
466
|
+
}
|
467
|
+
return new (_semanticsEntities().InferenceTypeSchema)(location, typeStr || 'any');
|
468
|
+
} catch {
|
426
469
|
return new (_semanticsEntities().InferenceTypeSchema)(location, typeStr || 'any');
|
427
470
|
}
|
428
|
-
|
429
|
-
|
430
|
-
|
471
|
+
}
|
472
|
+
|
473
|
+
/**
|
474
|
+
* Check if type is an array type (either T[] or Array<T>)
|
475
|
+
*/
|
476
|
+
isArrayType(typeStr) {
|
477
|
+
return typeStr.endsWith('[]') || typeStr.startsWith('Array<');
|
478
|
+
}
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Extract base type from array type
|
482
|
+
*/
|
483
|
+
getArrayBaseType(typeStr) {
|
484
|
+
if (typeStr.endsWith('[]')) {
|
485
|
+
return typeStr.slice(0, -2);
|
486
|
+
}
|
487
|
+
if (typeStr.startsWith('Array<')) {
|
488
|
+
const match = /Array<(.+)>/.exec(typeStr);
|
489
|
+
return match?.[1] || 'any';
|
490
|
+
}
|
491
|
+
return typeStr;
|
492
|
+
}
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Extract return type from method signature
|
496
|
+
*/
|
497
|
+
extractMethodReturnType(displayString) {
|
498
|
+
const returnTypeMatch = displayString.match(/\):\s*(.+)$/);
|
499
|
+
return returnTypeMatch ? returnTypeMatch[1].trim() : 'any';
|
500
|
+
}
|
501
|
+
|
502
|
+
/**
|
503
|
+
* Extract content from generic type
|
504
|
+
*/
|
505
|
+
extractGenericType(type, wrapper) {
|
506
|
+
const match = new RegExp(`${wrapper}<(.+)>`).exec(type);
|
507
|
+
return match ? match[1].trim() : type;
|
508
|
+
}
|
509
|
+
|
510
|
+
/**
|
511
|
+
* Create schema for method return type, attempting to get type reference
|
512
|
+
*/
|
513
|
+
async createMethodReturnSchema(node, location, returnType) {
|
514
|
+
if (this.isArrayType(returnType)) {
|
515
|
+
const baseType = this.getArrayBaseType(returnType);
|
516
|
+
const currentFilePath = node.getSourceFile().fileName;
|
517
|
+
const baseTypeRef = await this.getTypeRef(baseType, this.getIdentifierKey(currentFilePath), location);
|
518
|
+
if (baseTypeRef) {
|
519
|
+
return new (_semanticsEntities().TypeArraySchema)(location, baseTypeRef);
|
520
|
+
}
|
521
|
+
return new (_semanticsEntities().TypeArraySchema)(location, new (_semanticsEntities().InferenceTypeSchema)(location, baseType));
|
522
|
+
}
|
523
|
+
const typeRef = await this.getTypeRef(returnType, this.getIdentifierKeyForNode(node), location);
|
524
|
+
return typeRef || new (_semanticsEntities().InferenceTypeSchema)(location, returnType);
|
525
|
+
}
|
526
|
+
|
527
|
+
/**
|
528
|
+
* Create schema for function type, handling params and return type
|
529
|
+
*/
|
530
|
+
async createFunctionSchema(node, location, signature) {
|
531
|
+
const match = signature.match(/\((.*)\)\s*(?:=>|:)\s*(.+)/);
|
532
|
+
if (!match) {
|
533
|
+
return new (_semanticsEntities().FunctionLikeSchema)(location, 'anonymous', [], new (_semanticsEntities().InferenceTypeSchema)(location, 'any'), signature);
|
534
|
+
}
|
535
|
+
const [, paramsStr, returnTypeStr] = match;
|
536
|
+
const params = await this.createFunctionParameters(node, location, paramsStr);
|
537
|
+
const returnType = await this.createMethodReturnSchema(node, location, returnTypeStr.trim());
|
538
|
+
return new (_semanticsEntities().FunctionLikeSchema)(location, 'anonymous', params, returnType, signature);
|
539
|
+
}
|
540
|
+
|
541
|
+
/**
|
542
|
+
* Create parameters for function schema, attempting to get type references for param types
|
543
|
+
*/
|
544
|
+
async createFunctionParameters(node, location, paramsStr) {
|
545
|
+
if (!paramsStr.trim()) return [];
|
546
|
+
const params = paramsStr.split(',');
|
547
|
+
const paramSchemas = [];
|
548
|
+
for (const param of params) {
|
549
|
+
const [nameWithOptional, type] = param.split(':').map(s => s.trim());
|
550
|
+
const isOptional = nameWithOptional.includes('?');
|
551
|
+
const name = nameWithOptional.replace('?', '');
|
552
|
+
if (!type) {
|
553
|
+
paramSchemas.push(new (_semanticsEntities().ParameterSchema)(location, name, new (_semanticsEntities().InferenceTypeSchema)(location, 'any'), isOptional));
|
554
|
+
continue;
|
555
|
+
}
|
556
|
+
const currentFilePath = node.getSourceFile().fileName;
|
557
|
+
const typeRef = await this.getTypeRef(type, this.getIdentifierKey(currentFilePath), location);
|
558
|
+
paramSchemas.push(new (_semanticsEntities().ParameterSchema)(location, name, typeRef || new (_semanticsEntities().InferenceTypeSchema)(location, type), isOptional));
|
559
|
+
}
|
560
|
+
return paramSchemas;
|
561
|
+
}
|
562
|
+
|
563
|
+
/**
|
564
|
+
* Create schema for object literal type
|
565
|
+
*/
|
566
|
+
createObjectSchema(node, location, displayString) {
|
567
|
+
const objMatch = displayString.match(/{([^}]+)}/);
|
568
|
+
if (!objMatch) {
|
569
|
+
return new (_semanticsEntities().InferenceTypeSchema)(location, 'object');
|
570
|
+
}
|
571
|
+
const objContent = objMatch[1];
|
572
|
+
const properties = objContent.split(';').map(prop => prop.trim()).filter(Boolean).map(prop => new (_semanticsEntities().InferenceTypeSchema)(location, prop));
|
573
|
+
return new (_semanticsEntities().ArrayLiteralExpressionSchema)(properties, location);
|
574
|
+
}
|
575
|
+
|
576
|
+
/**
|
577
|
+
* Create schema for Promise type, attempting to get type reference for the contained type
|
578
|
+
*/
|
579
|
+
async createPromiseSchema(node, location, innerType) {
|
580
|
+
const typeRef = await this.getTypeRef(innerType, this.getIdentifierKeyForNode(node), location);
|
581
|
+
return typeRef || new (_semanticsEntities().InferenceTypeSchema)(location, innerType);
|
431
582
|
}
|
432
583
|
|
433
584
|
// the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location
|
@@ -442,7 +593,7 @@ class SchemaExtractorContext {
|
|
442
593
|
/**
|
443
594
|
* resolve a type by a node and its identifier.
|
444
595
|
*/
|
445
|
-
async resolveType(node, typeStr
|
596
|
+
async resolveType(node, typeStr) {
|
446
597
|
const location = this.getLocation(node);
|
447
598
|
|
448
599
|
// check if internal ref with typeInfo
|
@@ -456,14 +607,14 @@ class SchemaExtractorContext {
|
|
456
607
|
}
|
457
608
|
const definition = await this.getDefinition(node);
|
458
609
|
if (!definition) {
|
459
|
-
return this.unknownExactType(node, location, typeStr
|
610
|
+
return this.unknownExactType(node, location, typeStr);
|
460
611
|
}
|
461
612
|
if (this.isDefInSameLocation(node, definition)) {
|
462
|
-
return this.unknownExactType(node, location, typeStr
|
613
|
+
return this.unknownExactType(node, location, typeStr);
|
463
614
|
}
|
464
615
|
const definitionNode = await this.definition(definition);
|
465
616
|
if (!definitionNode) {
|
466
|
-
return this.unknownExactType(node, location, typeStr
|
617
|
+
return this.unknownExactType(node, location, typeStr);
|
467
618
|
}
|
468
619
|
const definitionNodeName = definitionNode?.getText();
|
469
620
|
|
@@ -474,11 +625,11 @@ class SchemaExtractorContext {
|
|
474
625
|
if (transformer === undefined) {
|
475
626
|
const file = this.findFileInComponent(definition.file);
|
476
627
|
if (!file) return this.getTypeRefForExternalPath(typeStr, definition.file, location);
|
477
|
-
return this.unknownExactType(node, location, typeStr
|
628
|
+
return this.unknownExactType(node, location, typeStr);
|
478
629
|
}
|
479
630
|
const schemaNode = await this.visit(definitionNode);
|
480
631
|
if (!schemaNode) {
|
481
|
-
return this.unknownExactType(node, location, typeStr
|
632
|
+
return this.unknownExactType(node, location, typeStr);
|
482
633
|
}
|
483
634
|
const apiTransformer = this.extractor.getAPITransformer(schemaNode);
|
484
635
|
let transformedApi = apiTransformer ? await apiTransformer.transform(schemaNode, this) : schemaNode;
|
@@ -503,7 +654,7 @@ class SchemaExtractorContext {
|
|
503
654
|
if (!parsedNodeIdentifier) return undefined;
|
504
655
|
const internalRef = !isExportedFromMain;
|
505
656
|
if (internalRef) {
|
506
|
-
this.setInternalIdentifiers(
|
657
|
+
this.setInternalIdentifiers(parsedNodeIdentifier.normalizedPath, new (_identifierList().IdentifierList)([parsedNodeIdentifier]));
|
507
658
|
}
|
508
659
|
return this.resolveTypeRef(parsedNodeIdentifier, location, isExportedFromMain);
|
509
660
|
}
|