plutonio
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -33,4 +33,4 @@ "use strict"; | ||
exports.default = plutonio; | ||
// const scanned = plutonio.scanner(); | ||
// const scanned = plutonio.scan(); | ||
// console.log(JSON.stringify(scanned, null, 2)); | ||
//# sourceMappingURL=index.js.map |
@@ -68,2 +68,5 @@ "use strict"; | ||
} | ||
if (source_file.fileName.indexOf(compilerOptions.baseUrl || '') === -1) { | ||
continue; | ||
} | ||
const scanned_source_file = { | ||
@@ -492,2 +495,27 @@ imports: _resolve_source_file_imports(source_file), | ||
const node_type = checker.getTypeAtLocation(type_reference); | ||
/* | ||
* I added this for avoiding infinite loop when defining ENUM as ObjectValue | ||
* of a constant. e.g.: | ||
* | ||
* type ObjectValue<T> = T[keyof T]; | ||
* const VIDEO_CATEGORY = { | ||
* STACK_EXCHANGE: 'stackexchange', | ||
* TIMER: 'timer', | ||
* } as const; | ||
* type VideoCategory = ObjectValue<typeof VIDEO_CATEGORY>; | ||
* | ||
* VideoCategory in this case is a Union: | ||
*/ | ||
if (node_type.isUnion()) { | ||
const values = []; | ||
for (let single_type of node_type.types) { | ||
values.push(single_type.value); | ||
} | ||
let type_attributes = { | ||
primitive: t.PRIMITIVE.ENUM, | ||
original: _resolve_original(node), | ||
values, | ||
}; | ||
return type_attributes; | ||
} | ||
const node_type_node = (_b = (_a = node_type.aliasSymbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]; | ||
@@ -494,0 +522,0 @@ if (node_type_node) { |
{ | ||
"name": "plutonio", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "A typescript library that scans your typescript project and generate a schema of all types and interfaces of the project.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -10,3 +10,3 @@ /** | ||
// const scanned = plutonio.scanner(); | ||
// const scanned = plutonio.scan(); | ||
// console.log(JSON.stringify(scanned, null, 2)); |
@@ -44,2 +44,5 @@ /** | ||
} | ||
if (source_file.fileName.indexOf(compilerOptions.baseUrl || '') === -1) { | ||
continue; | ||
} | ||
const scanned_source_file: t.SourceFile = { | ||
@@ -612,2 +615,29 @@ imports: _resolve_source_file_imports(source_file), | ||
const node_type = checker.getTypeAtLocation(type_reference); | ||
/* | ||
* I added this for avoiding infinite loop when defining ENUM as ObjectValue | ||
* of a constant. e.g.: | ||
* | ||
* type ObjectValue<T> = T[keyof T]; | ||
* const VIDEO_CATEGORY = { | ||
* STACK_EXCHANGE: 'stackexchange', | ||
* TIMER: 'timer', | ||
* } as const; | ||
* type VideoCategory = ObjectValue<typeof VIDEO_CATEGORY>; | ||
* | ||
* VideoCategory in this case is a Union: | ||
*/ | ||
if (node_type.isUnion()) { | ||
const values: t.Values = []; | ||
for (let single_type of node_type.types) { | ||
values.push((single_type as any).value); | ||
} | ||
let type_attributes: t.TypeAttributes = { | ||
primitive: t.PRIMITIVE.ENUM, | ||
original: _resolve_original(node), | ||
values, | ||
}; | ||
return type_attributes; | ||
} | ||
const node_type_node = node_type.aliasSymbol?.declarations?.[0]; | ||
@@ -618,2 +648,3 @@ if (node_type_node) { | ||
} | ||
return _resolve_primitive_type_reference(node_type, type_reference); | ||
@@ -620,0 +651,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
106050
2424