@formspec/build 0.1.0-alpha.51 → 0.1.0-alpha.53
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/analyzer/builtin-brands.d.ts +13 -0
- package/dist/analyzer/builtin-brands.d.ts.map +1 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +17 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +8 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +19 -0
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +21 -0
- package/dist/build-beta.d.ts +21 -0
- package/dist/build-internal.d.ts +21 -0
- package/dist/build.d.ts +21 -0
- package/dist/cli/logger.d.ts +22 -0
- package/dist/cli/logger.d.ts.map +1 -0
- package/dist/cli.cjs +326 -214
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +314 -205
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +274 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +277 -205
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +219 -172
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +220 -172
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +6 -1
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/generator.d.ts +6 -1
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/package.json +11 -5
package/dist/internals.js
CHANGED
|
@@ -791,21 +791,21 @@ function wrapInConditional(field, layout, provenance) {
|
|
|
791
791
|
}
|
|
792
792
|
|
|
793
793
|
// src/analyzer/program.ts
|
|
794
|
-
import * as
|
|
794
|
+
import * as ts7 from "typescript";
|
|
795
795
|
import * as path from "path";
|
|
796
796
|
|
|
797
797
|
// src/analyzer/class-analyzer.ts
|
|
798
|
-
import * as
|
|
798
|
+
import * as ts6 from "typescript";
|
|
799
799
|
import {
|
|
800
800
|
analyzeMetadataForNodeWithChecker,
|
|
801
801
|
parseCommentBlock
|
|
802
802
|
} from "@formspec/analysis/internal";
|
|
803
803
|
|
|
804
804
|
// src/analyzer/jsdoc-constraints.ts
|
|
805
|
-
import * as
|
|
805
|
+
import * as ts5 from "typescript";
|
|
806
806
|
|
|
807
807
|
// src/analyzer/tsdoc-parser.ts
|
|
808
|
-
import * as
|
|
808
|
+
import * as ts4 from "typescript";
|
|
809
809
|
import {
|
|
810
810
|
checkSyntheticTagApplication,
|
|
811
811
|
choosePreferredPayloadText,
|
|
@@ -813,6 +813,7 @@ import {
|
|
|
813
813
|
getTagDefinition,
|
|
814
814
|
hasTypeSemanticCapability,
|
|
815
815
|
normalizeFormSpecTagName,
|
|
816
|
+
stripNullishUnion as stripNullishUnion2,
|
|
816
817
|
parseConstraintTagValue,
|
|
817
818
|
parseDefaultValueTagValue,
|
|
818
819
|
parseTagSyntax,
|
|
@@ -945,6 +946,14 @@ function customTypeIdFromLookup(result) {
|
|
|
945
946
|
return `${result.extensionId}/${result.registration.typeName}`;
|
|
946
947
|
}
|
|
947
948
|
|
|
949
|
+
// src/analyzer/builtin-brands.ts
|
|
950
|
+
import * as ts3 from "typescript";
|
|
951
|
+
function isIntegerBrandedType(type) {
|
|
952
|
+
if (!type.isIntersection()) return false;
|
|
953
|
+
if (!type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number))) return false;
|
|
954
|
+
return collectBrandIdentifiers(type).includes("__integerBrand");
|
|
955
|
+
}
|
|
956
|
+
|
|
948
957
|
// src/analyzer/tsdoc-parser.ts
|
|
949
958
|
function sharedTagValueOptions(options) {
|
|
950
959
|
return {
|
|
@@ -952,7 +961,7 @@ function sharedTagValueOptions(options) {
|
|
|
952
961
|
...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {}
|
|
953
962
|
};
|
|
954
963
|
}
|
|
955
|
-
var SYNTHETIC_TYPE_FORMAT_FLAGS =
|
|
964
|
+
var SYNTHETIC_TYPE_FORMAT_FLAGS = ts4.TypeFormatFlags.NoTruncation | ts4.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
956
965
|
function getExtensionTypeNames(registry) {
|
|
957
966
|
if (registry === void 0) {
|
|
958
967
|
return /* @__PURE__ */ new Set();
|
|
@@ -966,23 +975,23 @@ function getExtensionTypeNames(registry) {
|
|
|
966
975
|
function collectImportedNames(sourceFile) {
|
|
967
976
|
const importedNames = /* @__PURE__ */ new Set();
|
|
968
977
|
for (const statement of sourceFile.statements) {
|
|
969
|
-
if (
|
|
978
|
+
if (ts4.isImportDeclaration(statement) && statement.importClause !== void 0) {
|
|
970
979
|
const clause = statement.importClause;
|
|
971
980
|
if (clause.name !== void 0) {
|
|
972
981
|
importedNames.add(clause.name.text);
|
|
973
982
|
}
|
|
974
983
|
if (clause.namedBindings !== void 0) {
|
|
975
|
-
if (
|
|
984
|
+
if (ts4.isNamedImports(clause.namedBindings)) {
|
|
976
985
|
for (const specifier of clause.namedBindings.elements) {
|
|
977
986
|
importedNames.add(specifier.name.text);
|
|
978
987
|
}
|
|
979
|
-
} else if (
|
|
988
|
+
} else if (ts4.isNamespaceImport(clause.namedBindings)) {
|
|
980
989
|
importedNames.add(clause.namedBindings.name.text);
|
|
981
990
|
}
|
|
982
991
|
}
|
|
983
992
|
continue;
|
|
984
993
|
}
|
|
985
|
-
if (
|
|
994
|
+
if (ts4.isImportEqualsDeclaration(statement)) {
|
|
986
995
|
importedNames.add(statement.name.text);
|
|
987
996
|
}
|
|
988
997
|
}
|
|
@@ -990,50 +999,96 @@ function collectImportedNames(sourceFile) {
|
|
|
990
999
|
}
|
|
991
1000
|
function isNonReferenceIdentifier(node) {
|
|
992
1001
|
const parent = node.parent;
|
|
993
|
-
if ((
|
|
1002
|
+
if ((ts4.isBindingElement(parent) || ts4.isClassDeclaration(parent) || ts4.isEnumDeclaration(parent) || ts4.isEnumMember(parent) || ts4.isFunctionDeclaration(parent) || ts4.isFunctionExpression(parent) || ts4.isImportClause(parent) || ts4.isImportEqualsDeclaration(parent) || ts4.isImportSpecifier(parent) || ts4.isInterfaceDeclaration(parent) || ts4.isMethodDeclaration(parent) || ts4.isMethodSignature(parent) || ts4.isModuleDeclaration(parent) || ts4.isNamespaceExport(parent) || ts4.isNamespaceImport(parent) || ts4.isParameter(parent) || ts4.isPropertyDeclaration(parent) || ts4.isPropertySignature(parent) || ts4.isSetAccessorDeclaration(parent) || ts4.isGetAccessorDeclaration(parent) || ts4.isTypeAliasDeclaration(parent) || ts4.isTypeParameterDeclaration(parent) || ts4.isVariableDeclaration(parent)) && parent.name === node) {
|
|
994
1003
|
return true;
|
|
995
1004
|
}
|
|
996
|
-
if ((
|
|
1005
|
+
if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyAccessExpression(parent)) && parent.name === node) {
|
|
997
1006
|
return true;
|
|
998
1007
|
}
|
|
999
|
-
if (
|
|
1008
|
+
if (ts4.isQualifiedName(parent) && parent.right === node) {
|
|
1000
1009
|
return true;
|
|
1001
1010
|
}
|
|
1002
1011
|
return false;
|
|
1003
1012
|
}
|
|
1004
|
-
function
|
|
1013
|
+
function astReferencesImportedName(root, importedNames) {
|
|
1005
1014
|
if (importedNames.size === 0) {
|
|
1006
1015
|
return false;
|
|
1007
1016
|
}
|
|
1008
|
-
let
|
|
1017
|
+
let found = false;
|
|
1009
1018
|
const visit = (node) => {
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1014
|
-
referencesImportedName = true;
|
|
1019
|
+
if (found) return;
|
|
1020
|
+
if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1021
|
+
found = true;
|
|
1015
1022
|
return;
|
|
1016
1023
|
}
|
|
1017
|
-
|
|
1024
|
+
ts4.forEachChild(node, visit);
|
|
1018
1025
|
};
|
|
1019
|
-
visit(
|
|
1020
|
-
return
|
|
1026
|
+
visit(root);
|
|
1027
|
+
return found;
|
|
1028
|
+
}
|
|
1029
|
+
function getObjectMembers(statement) {
|
|
1030
|
+
if (ts4.isInterfaceDeclaration(statement)) {
|
|
1031
|
+
return statement.members;
|
|
1032
|
+
}
|
|
1033
|
+
if (ts4.isTypeLiteralNode(statement.type)) {
|
|
1034
|
+
return statement.type.members;
|
|
1035
|
+
}
|
|
1036
|
+
return void 0;
|
|
1037
|
+
}
|
|
1038
|
+
function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
|
|
1039
|
+
const members = getObjectMembers(statement);
|
|
1040
|
+
if (members === void 0) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
const replacements = [];
|
|
1044
|
+
for (const member of members) {
|
|
1045
|
+
if (!ts4.isPropertySignature(member)) {
|
|
1046
|
+
if (astReferencesImportedName(member, importedNames)) {
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
const typeAnnotation = member.type;
|
|
1052
|
+
if (typeAnnotation === void 0) continue;
|
|
1053
|
+
if (astReferencesImportedName(typeAnnotation, importedNames)) {
|
|
1054
|
+
replacements.push({
|
|
1055
|
+
start: typeAnnotation.getStart(sourceFile),
|
|
1056
|
+
end: typeAnnotation.getEnd()
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
if (replacements.length === 0) {
|
|
1061
|
+
return statement.getText(sourceFile);
|
|
1062
|
+
}
|
|
1063
|
+
const stmtStart = statement.getStart(sourceFile);
|
|
1064
|
+
let result = statement.getText(sourceFile);
|
|
1065
|
+
for (const { start, end } of [...replacements].reverse()) {
|
|
1066
|
+
result = result.slice(0, start - stmtStart) + "unknown" + result.slice(end - stmtStart);
|
|
1067
|
+
}
|
|
1068
|
+
return result;
|
|
1021
1069
|
}
|
|
1022
1070
|
function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
|
|
1023
1071
|
const importedNames = collectImportedNames(sourceFile);
|
|
1024
1072
|
const importedNamesToSkip = new Set(
|
|
1025
1073
|
[...importedNames].filter((name) => !extensionTypeNames.has(name))
|
|
1026
1074
|
);
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
if (
|
|
1030
|
-
if (
|
|
1031
|
-
|
|
1032
|
-
if (
|
|
1033
|
-
|
|
1075
|
+
const result = [];
|
|
1076
|
+
for (const statement of sourceFile.statements) {
|
|
1077
|
+
if (ts4.isImportDeclaration(statement)) continue;
|
|
1078
|
+
if (ts4.isImportEqualsDeclaration(statement)) continue;
|
|
1079
|
+
if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
|
|
1080
|
+
if (!astReferencesImportedName(statement, importedNamesToSkip)) {
|
|
1081
|
+
result.push(statement.getText(sourceFile));
|
|
1082
|
+
continue;
|
|
1034
1083
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1084
|
+
if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
|
|
1085
|
+
const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
|
|
1086
|
+
if (rewritten !== null) {
|
|
1087
|
+
result.push(rewritten);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
return result;
|
|
1037
1092
|
}
|
|
1038
1093
|
function pushUniqueCompilerDiagnostics(target, additions) {
|
|
1039
1094
|
for (const diagnostic of additions) {
|
|
@@ -1125,7 +1180,7 @@ function stripHintNullishUnion(type) {
|
|
|
1125
1180
|
return type;
|
|
1126
1181
|
}
|
|
1127
1182
|
const nonNullish = type.types.filter(
|
|
1128
|
-
(member) => (member.flags & (
|
|
1183
|
+
(member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
|
|
1129
1184
|
);
|
|
1130
1185
|
if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
|
|
1131
1186
|
return nonNullish[0];
|
|
@@ -1141,10 +1196,10 @@ function isUserEmittableHintProperty(property, declaration) {
|
|
|
1141
1196
|
}
|
|
1142
1197
|
if ("name" in declaration && declaration.name !== void 0) {
|
|
1143
1198
|
const name = declaration.name;
|
|
1144
|
-
if (
|
|
1199
|
+
if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
|
|
1145
1200
|
return false;
|
|
1146
1201
|
}
|
|
1147
|
-
if (!
|
|
1202
|
+
if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
|
|
1148
1203
|
return false;
|
|
1149
1204
|
}
|
|
1150
1205
|
}
|
|
@@ -1362,6 +1417,9 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1362
1417
|
}
|
|
1363
1418
|
const hasBroadening = (() => {
|
|
1364
1419
|
if (target === null) {
|
|
1420
|
+
if (isIntegerBrandedType(stripNullishUnion2(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
|
|
1421
|
+
return true;
|
|
1422
|
+
}
|
|
1365
1423
|
return hasBuiltinConstraintBroadening(tagName, options);
|
|
1366
1424
|
}
|
|
1367
1425
|
const registry = options?.extensionRegistry;
|
|
@@ -1514,12 +1572,12 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1514
1572
|
const sourceText = sourceFile.getFullText();
|
|
1515
1573
|
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
1516
1574
|
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
1517
|
-
const commentRanges =
|
|
1575
|
+
const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
1518
1576
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
1519
1577
|
const extensionTagNames = getExtensionTagNames(options);
|
|
1520
1578
|
if (commentRanges) {
|
|
1521
1579
|
for (const range of commentRanges) {
|
|
1522
|
-
if (range.kind !==
|
|
1580
|
+
if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
|
|
1523
1581
|
continue;
|
|
1524
1582
|
}
|
|
1525
1583
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
@@ -1676,10 +1734,10 @@ function extractDisplayNameMetadata(node) {
|
|
|
1676
1734
|
const memberDisplayNames = /* @__PURE__ */ new Map();
|
|
1677
1735
|
const sourceFile = node.getSourceFile();
|
|
1678
1736
|
const sourceText = sourceFile.getFullText();
|
|
1679
|
-
const commentRanges =
|
|
1737
|
+
const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
1680
1738
|
if (commentRanges) {
|
|
1681
1739
|
for (const range of commentRanges) {
|
|
1682
|
-
if (range.kind !==
|
|
1740
|
+
if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
1683
1741
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
1684
1742
|
if (!commentText.startsWith("/**")) continue;
|
|
1685
1743
|
const unified = parseUnifiedComment(commentText);
|
|
@@ -1704,7 +1762,7 @@ function extractDisplayNameMetadata(node) {
|
|
|
1704
1762
|
}
|
|
1705
1763
|
function collectRawTextFallbacks(node, file) {
|
|
1706
1764
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
1707
|
-
for (const tag of
|
|
1765
|
+
for (const tag of ts4.getJSDocTags(node)) {
|
|
1708
1766
|
const tagName = normalizeConstraintTagName(tag.tagName.text);
|
|
1709
1767
|
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1710
1768
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
@@ -1759,7 +1817,7 @@ function getTagCommentText(tag) {
|
|
|
1759
1817
|
if (typeof tag.comment === "string") {
|
|
1760
1818
|
return tag.comment;
|
|
1761
1819
|
}
|
|
1762
|
-
return
|
|
1820
|
+
return ts4.getTextOfJSDocComment(tag.comment);
|
|
1763
1821
|
}
|
|
1764
1822
|
|
|
1765
1823
|
// src/analyzer/jsdoc-constraints.ts
|
|
@@ -1777,18 +1835,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
|
|
|
1777
1835
|
function extractDefaultValueAnnotation(initializer, file = "") {
|
|
1778
1836
|
if (!initializer) return null;
|
|
1779
1837
|
let value;
|
|
1780
|
-
if (
|
|
1838
|
+
if (ts5.isStringLiteral(initializer)) {
|
|
1781
1839
|
value = initializer.text;
|
|
1782
|
-
} else if (
|
|
1840
|
+
} else if (ts5.isNumericLiteral(initializer)) {
|
|
1783
1841
|
value = Number(initializer.text);
|
|
1784
|
-
} else if (initializer.kind ===
|
|
1842
|
+
} else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
|
|
1785
1843
|
value = true;
|
|
1786
|
-
} else if (initializer.kind ===
|
|
1844
|
+
} else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
|
|
1787
1845
|
value = false;
|
|
1788
|
-
} else if (initializer.kind ===
|
|
1846
|
+
} else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
|
|
1789
1847
|
value = null;
|
|
1790
|
-
} else if (
|
|
1791
|
-
if (initializer.operator ===
|
|
1848
|
+
} else if (ts5.isPrefixUnaryExpression(initializer)) {
|
|
1849
|
+
if (initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
|
|
1792
1850
|
value = -Number(initializer.operand.text);
|
|
1793
1851
|
}
|
|
1794
1852
|
}
|
|
@@ -1810,38 +1868,28 @@ function extractDefaultValueAnnotation(initializer, file = "") {
|
|
|
1810
1868
|
|
|
1811
1869
|
// src/analyzer/class-analyzer.ts
|
|
1812
1870
|
function isObjectType(type) {
|
|
1813
|
-
return !!(type.flags &
|
|
1871
|
+
return !!(type.flags & ts6.TypeFlags.Object);
|
|
1814
1872
|
}
|
|
1815
1873
|
function isIntersectionType(type) {
|
|
1816
|
-
return !!(type.flags &
|
|
1817
|
-
}
|
|
1818
|
-
function isIntegerBrandedType(type) {
|
|
1819
|
-
if (!type.isIntersection()) {
|
|
1820
|
-
return false;
|
|
1821
|
-
}
|
|
1822
|
-
const hasNumberBase = type.types.some((member) => !!(member.flags & ts5.TypeFlags.Number));
|
|
1823
|
-
if (!hasNumberBase) {
|
|
1824
|
-
return false;
|
|
1825
|
-
}
|
|
1826
|
-
return collectBrandIdentifiers(type).includes("__integerBrand");
|
|
1874
|
+
return !!(type.flags & ts6.TypeFlags.Intersection);
|
|
1827
1875
|
}
|
|
1828
1876
|
function isResolvableObjectLikeAliasTypeNode(typeNode) {
|
|
1829
|
-
if (
|
|
1877
|
+
if (ts6.isParenthesizedTypeNode(typeNode)) {
|
|
1830
1878
|
return isResolvableObjectLikeAliasTypeNode(typeNode.type);
|
|
1831
1879
|
}
|
|
1832
|
-
if (
|
|
1880
|
+
if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
|
|
1833
1881
|
return true;
|
|
1834
1882
|
}
|
|
1835
|
-
return
|
|
1883
|
+
return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
|
|
1836
1884
|
}
|
|
1837
1885
|
function isSemanticallyPlainObjectLikeType(type, checker) {
|
|
1838
1886
|
if (isIntersectionType(type)) {
|
|
1839
1887
|
return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
|
|
1840
1888
|
}
|
|
1841
|
-
return isObjectType(type) && checker.getSignaturesOfType(type,
|
|
1889
|
+
return isObjectType(type) && checker.getSignaturesOfType(type, ts6.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts6.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
|
|
1842
1890
|
}
|
|
1843
1891
|
function isTypeReference(type) {
|
|
1844
|
-
return !!(type.flags &
|
|
1892
|
+
return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
|
|
1845
1893
|
}
|
|
1846
1894
|
var RESOLVING_TYPE_PLACEHOLDER = {
|
|
1847
1895
|
kind: "object",
|
|
@@ -1906,7 +1954,7 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
|
|
|
1906
1954
|
function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
|
|
1907
1955
|
const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
|
|
1908
1956
|
const declarationType = checker.getTypeAtLocation(declaration);
|
|
1909
|
-
const logicalName =
|
|
1957
|
+
const logicalName = ts6.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
|
|
1910
1958
|
const docResult = extractJSDocParseResult(
|
|
1911
1959
|
declaration,
|
|
1912
1960
|
file,
|
|
@@ -1954,7 +2002,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
|
|
|
1954
2002
|
const instanceMethods = [];
|
|
1955
2003
|
const staticMethods = [];
|
|
1956
2004
|
for (const member of classDecl.members) {
|
|
1957
|
-
if (
|
|
2005
|
+
if (ts6.isPropertyDeclaration(member)) {
|
|
1958
2006
|
const fieldNode = analyzeFieldToIR(
|
|
1959
2007
|
member,
|
|
1960
2008
|
checker,
|
|
@@ -1970,10 +2018,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
|
|
|
1970
2018
|
fields.push(fieldNode);
|
|
1971
2019
|
fieldLayouts.push({});
|
|
1972
2020
|
}
|
|
1973
|
-
} else if (
|
|
2021
|
+
} else if (ts6.isMethodDeclaration(member)) {
|
|
1974
2022
|
const methodInfo = analyzeMethod(member, checker);
|
|
1975
2023
|
if (methodInfo) {
|
|
1976
|
-
const isStatic = member.modifiers?.some((m) => m.kind ===
|
|
2024
|
+
const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
|
|
1977
2025
|
if (isStatic) {
|
|
1978
2026
|
staticMethods.push(methodInfo);
|
|
1979
2027
|
} else {
|
|
@@ -2036,7 +2084,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
|
|
|
2036
2084
|
diagnostics.push(...interfaceDoc.diagnostics);
|
|
2037
2085
|
const visiting = /* @__PURE__ */ new Set();
|
|
2038
2086
|
for (const member of interfaceDecl.members) {
|
|
2039
|
-
if (
|
|
2087
|
+
if (ts6.isPropertySignature(member)) {
|
|
2040
2088
|
const fieldNode = analyzeInterfacePropertyToIR(
|
|
2041
2089
|
member,
|
|
2042
2090
|
checker,
|
|
@@ -2094,7 +2142,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
|
|
|
2094
2142
|
if (members === null) {
|
|
2095
2143
|
const sourceFile = typeAlias.getSourceFile();
|
|
2096
2144
|
const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
|
|
2097
|
-
const kindDesc =
|
|
2145
|
+
const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
|
|
2098
2146
|
return {
|
|
2099
2147
|
ok: false,
|
|
2100
2148
|
kind: "not-object-like",
|
|
@@ -2129,7 +2177,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
|
|
|
2129
2177
|
diagnostics.push(...typeAliasDoc.diagnostics);
|
|
2130
2178
|
const visiting = /* @__PURE__ */ new Set();
|
|
2131
2179
|
for (const member of members) {
|
|
2132
|
-
if (
|
|
2180
|
+
if (ts6.isPropertySignature(member)) {
|
|
2133
2181
|
const fieldNode = analyzeInterfacePropertyToIR(
|
|
2134
2182
|
member,
|
|
2135
2183
|
checker,
|
|
@@ -2196,13 +2244,13 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
|
|
|
2196
2244
|
function getLeadingParsedTags(node) {
|
|
2197
2245
|
const sourceFile = node.getSourceFile();
|
|
2198
2246
|
const sourceText = sourceFile.getFullText();
|
|
2199
|
-
const commentRanges =
|
|
2247
|
+
const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
2200
2248
|
if (commentRanges === void 0) {
|
|
2201
2249
|
return [];
|
|
2202
2250
|
}
|
|
2203
2251
|
const parsedTags = [];
|
|
2204
2252
|
for (const range of commentRanges) {
|
|
2205
|
-
if (range.kind !==
|
|
2253
|
+
if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
|
|
2206
2254
|
continue;
|
|
2207
2255
|
}
|
|
2208
2256
|
const commentText = sourceText.slice(range.pos, range.end);
|
|
@@ -2220,19 +2268,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
|
|
|
2220
2268
|
return null;
|
|
2221
2269
|
}
|
|
2222
2270
|
const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
|
|
2223
|
-
(candidate) =>
|
|
2271
|
+
(candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
|
|
2224
2272
|
) ?? propertySymbol.declarations?.[0];
|
|
2225
2273
|
return {
|
|
2226
2274
|
declaration,
|
|
2227
2275
|
type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
|
|
2228
|
-
optional: !!(propertySymbol.flags &
|
|
2276
|
+
optional: !!(propertySymbol.flags & ts6.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
|
|
2229
2277
|
};
|
|
2230
2278
|
}
|
|
2231
2279
|
function isLocalTypeParameterName(node, typeParameterName) {
|
|
2232
2280
|
return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
|
|
2233
2281
|
}
|
|
2234
2282
|
function isNullishSemanticType(type) {
|
|
2235
|
-
if (type.flags & (
|
|
2283
|
+
if (type.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined | ts6.TypeFlags.Void | ts6.TypeFlags.Unknown | ts6.TypeFlags.Any)) {
|
|
2236
2284
|
return true;
|
|
2237
2285
|
}
|
|
2238
2286
|
return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
|
|
@@ -2242,7 +2290,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
|
|
|
2242
2290
|
return false;
|
|
2243
2291
|
}
|
|
2244
2292
|
seen.add(type);
|
|
2245
|
-
if (type.flags &
|
|
2293
|
+
if (type.flags & ts6.TypeFlags.StringLike) {
|
|
2246
2294
|
return true;
|
|
2247
2295
|
}
|
|
2248
2296
|
if (type.isUnion()) {
|
|
@@ -2255,13 +2303,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
|
|
|
2255
2303
|
return false;
|
|
2256
2304
|
}
|
|
2257
2305
|
function getObjectLikeTypeAliasMembers(typeNode) {
|
|
2258
|
-
if (
|
|
2306
|
+
if (ts6.isParenthesizedTypeNode(typeNode)) {
|
|
2259
2307
|
return getObjectLikeTypeAliasMembers(typeNode.type);
|
|
2260
2308
|
}
|
|
2261
|
-
if (
|
|
2309
|
+
if (ts6.isTypeLiteralNode(typeNode)) {
|
|
2262
2310
|
return [...typeNode.members];
|
|
2263
2311
|
}
|
|
2264
|
-
if (
|
|
2312
|
+
if (ts6.isIntersectionTypeNode(typeNode)) {
|
|
2265
2313
|
const members = [];
|
|
2266
2314
|
for (const intersectionMember of typeNode.types) {
|
|
2267
2315
|
const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
|
|
@@ -2424,7 +2472,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
|
|
|
2424
2472
|
}
|
|
2425
2473
|
if (propertyType.isUnion()) {
|
|
2426
2474
|
const nonNullMembers = propertyType.types.filter(
|
|
2427
|
-
(member) => !(member.flags & (
|
|
2475
|
+
(member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
|
|
2428
2476
|
);
|
|
2429
2477
|
if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
|
|
2430
2478
|
diagnostics.push(
|
|
@@ -2473,13 +2521,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
|
|
|
2473
2521
|
seen.add(type);
|
|
2474
2522
|
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
2475
2523
|
if (symbol !== void 0) {
|
|
2476
|
-
const aliased = symbol.flags &
|
|
2524
|
+
const aliased = symbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
|
|
2477
2525
|
const targetSymbol = aliased ?? symbol;
|
|
2478
2526
|
const declaration = targetSymbol.declarations?.find(
|
|
2479
|
-
(candidate) =>
|
|
2527
|
+
(candidate) => ts6.isClassDeclaration(candidate) || ts6.isInterfaceDeclaration(candidate) || ts6.isTypeAliasDeclaration(candidate) || ts6.isEnumDeclaration(candidate)
|
|
2480
2528
|
);
|
|
2481
2529
|
if (declaration !== void 0) {
|
|
2482
|
-
if (
|
|
2530
|
+
if (ts6.isTypeAliasDeclaration(declaration) && ts6.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
|
|
2483
2531
|
return resolveNamedDiscriminatorDeclaration(
|
|
2484
2532
|
checker.getTypeFromTypeNode(declaration.type),
|
|
2485
2533
|
checker,
|
|
@@ -2507,7 +2555,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
|
|
|
2507
2555
|
}
|
|
2508
2556
|
if (boundType.isUnion()) {
|
|
2509
2557
|
const nonNullMembers = boundType.types.filter(
|
|
2510
|
-
(member) => !(member.flags & (
|
|
2558
|
+
(member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
|
|
2511
2559
|
);
|
|
2512
2560
|
if (nonNullMembers.every((member) => member.isStringLiteral())) {
|
|
2513
2561
|
diagnostics.push(
|
|
@@ -2552,7 +2600,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
|
|
|
2552
2600
|
return null;
|
|
2553
2601
|
}
|
|
2554
2602
|
function getDeclarationName(node) {
|
|
2555
|
-
if (
|
|
2603
|
+
if (ts6.isClassDeclaration(node) || ts6.isInterfaceDeclaration(node) || ts6.isTypeAliasDeclaration(node) || ts6.isEnumDeclaration(node)) {
|
|
2556
2604
|
return node.name?.text ?? "anonymous";
|
|
2557
2605
|
}
|
|
2558
2606
|
return "anonymous";
|
|
@@ -2607,11 +2655,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
|
|
|
2607
2655
|
if (sourceTypeNode === void 0) {
|
|
2608
2656
|
return [];
|
|
2609
2657
|
}
|
|
2610
|
-
const unwrapParentheses = (typeNode) =>
|
|
2658
|
+
const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
|
|
2611
2659
|
const directTypeNode = unwrapParentheses(sourceTypeNode);
|
|
2612
|
-
const referenceTypeNode =
|
|
2660
|
+
const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
|
|
2613
2661
|
const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
|
|
2614
|
-
return
|
|
2662
|
+
return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
|
|
2615
2663
|
})();
|
|
2616
2664
|
if (referenceTypeNode?.typeArguments === void 0) {
|
|
2617
2665
|
return [];
|
|
@@ -2666,7 +2714,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
|
|
|
2666
2714
|
);
|
|
2667
2715
|
}
|
|
2668
2716
|
function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
|
|
2669
|
-
if (!
|
|
2717
|
+
if (!ts6.isIdentifier(prop.name)) {
|
|
2670
2718
|
return null;
|
|
2671
2719
|
}
|
|
2672
2720
|
const name = prop.name.text;
|
|
@@ -2793,7 +2841,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
|
|
|
2793
2841
|
const seen = /* @__PURE__ */ new Set();
|
|
2794
2842
|
const duplicates = /* @__PURE__ */ new Set();
|
|
2795
2843
|
for (const member of members) {
|
|
2796
|
-
if (!
|
|
2844
|
+
if (!ts6.isPropertySignature(member)) {
|
|
2797
2845
|
continue;
|
|
2798
2846
|
}
|
|
2799
2847
|
const name = getAnalyzableObjectLikePropertyName(member.name);
|
|
@@ -2809,7 +2857,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
|
|
|
2809
2857
|
return [...duplicates].sort();
|
|
2810
2858
|
}
|
|
2811
2859
|
function getAnalyzableObjectLikePropertyName(name) {
|
|
2812
|
-
if (
|
|
2860
|
+
if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
|
|
2813
2861
|
return name.text;
|
|
2814
2862
|
}
|
|
2815
2863
|
return null;
|
|
@@ -2907,25 +2955,25 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
2907
2955
|
if (isIntegerBrandedType(type)) {
|
|
2908
2956
|
return { kind: "primitive", primitiveKind: "integer" };
|
|
2909
2957
|
}
|
|
2910
|
-
if (type.flags &
|
|
2958
|
+
if (type.flags & ts6.TypeFlags.String) {
|
|
2911
2959
|
return { kind: "primitive", primitiveKind: "string" };
|
|
2912
2960
|
}
|
|
2913
|
-
if (type.flags &
|
|
2961
|
+
if (type.flags & ts6.TypeFlags.Number) {
|
|
2914
2962
|
return { kind: "primitive", primitiveKind: "number" };
|
|
2915
2963
|
}
|
|
2916
|
-
if (type.flags & (
|
|
2964
|
+
if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
|
|
2917
2965
|
return { kind: "primitive", primitiveKind: "bigint" };
|
|
2918
2966
|
}
|
|
2919
|
-
if (type.flags &
|
|
2967
|
+
if (type.flags & ts6.TypeFlags.Boolean) {
|
|
2920
2968
|
return { kind: "primitive", primitiveKind: "boolean" };
|
|
2921
2969
|
}
|
|
2922
|
-
if (type.flags &
|
|
2970
|
+
if (type.flags & ts6.TypeFlags.Null) {
|
|
2923
2971
|
return { kind: "primitive", primitiveKind: "null" };
|
|
2924
2972
|
}
|
|
2925
|
-
if (type.flags &
|
|
2973
|
+
if (type.flags & ts6.TypeFlags.Undefined) {
|
|
2926
2974
|
return { kind: "primitive", primitiveKind: "null" };
|
|
2927
2975
|
}
|
|
2928
|
-
if (type.flags &
|
|
2976
|
+
if (type.flags & ts6.TypeFlags.Void) {
|
|
2929
2977
|
return { kind: "primitive", primitiveKind: "null" };
|
|
2930
2978
|
}
|
|
2931
2979
|
if (type.isStringLiteral()) {
|
|
@@ -3012,10 +3060,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
3012
3060
|
return { kind: "primitive", primitiveKind: "string" };
|
|
3013
3061
|
}
|
|
3014
3062
|
function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
|
|
3015
|
-
if (!(type.flags & (
|
|
3063
|
+
if (!(type.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
|
|
3016
3064
|
return null;
|
|
3017
3065
|
}
|
|
3018
|
-
const aliasDecl = type.aliasSymbol?.declarations?.find(
|
|
3066
|
+
const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
|
|
3019
3067
|
if (!aliasDecl) {
|
|
3020
3068
|
return null;
|
|
3021
3069
|
}
|
|
@@ -3065,14 +3113,14 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
|
|
|
3065
3113
|
return { kind: "reference", name: aliasName, typeArguments: [] };
|
|
3066
3114
|
}
|
|
3067
3115
|
function getReferencedTypeAliasDeclaration(sourceNode, checker) {
|
|
3068
|
-
const typeNode = sourceNode && (
|
|
3069
|
-
if (!typeNode || !
|
|
3116
|
+
const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
|
|
3117
|
+
if (!typeNode || !ts6.isTypeReferenceNode(typeNode)) {
|
|
3070
3118
|
return void 0;
|
|
3071
3119
|
}
|
|
3072
3120
|
return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
|
|
3073
3121
|
}
|
|
3074
3122
|
function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
|
|
3075
|
-
if (!
|
|
3123
|
+
if (!ts6.isTypeReferenceNode(typeNode)) {
|
|
3076
3124
|
return false;
|
|
3077
3125
|
}
|
|
3078
3126
|
const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
|
|
@@ -3080,10 +3128,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
|
|
|
3080
3128
|
return false;
|
|
3081
3129
|
}
|
|
3082
3130
|
const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
|
|
3083
|
-
return !!(resolved.flags & (
|
|
3131
|
+
return !!(resolved.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null));
|
|
3084
3132
|
}
|
|
3085
3133
|
function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
|
|
3086
|
-
const nestedAliasDecl = type.aliasSymbol?.declarations?.find(
|
|
3134
|
+
const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
|
|
3087
3135
|
if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
|
|
3088
3136
|
visitedAliases.add(nestedAliasDecl);
|
|
3089
3137
|
return resolveAliasedPrimitiveTarget(
|
|
@@ -3101,19 +3149,19 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
|
|
|
3101
3149
|
if (isIntegerBrandedType(type)) {
|
|
3102
3150
|
return { kind: "primitive", primitiveKind: "integer" };
|
|
3103
3151
|
}
|
|
3104
|
-
if (type.flags &
|
|
3152
|
+
if (type.flags & ts6.TypeFlags.String) {
|
|
3105
3153
|
return { kind: "primitive", primitiveKind: "string" };
|
|
3106
3154
|
}
|
|
3107
|
-
if (type.flags &
|
|
3155
|
+
if (type.flags & ts6.TypeFlags.Number) {
|
|
3108
3156
|
return { kind: "primitive", primitiveKind: "number" };
|
|
3109
3157
|
}
|
|
3110
|
-
if (type.flags & (
|
|
3158
|
+
if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
|
|
3111
3159
|
return { kind: "primitive", primitiveKind: "bigint" };
|
|
3112
3160
|
}
|
|
3113
|
-
if (type.flags &
|
|
3161
|
+
if (type.flags & ts6.TypeFlags.Boolean) {
|
|
3114
3162
|
return { kind: "primitive", primitiveKind: "boolean" };
|
|
3115
3163
|
}
|
|
3116
|
-
if (type.flags &
|
|
3164
|
+
if (type.flags & ts6.TypeFlags.Null) {
|
|
3117
3165
|
return { kind: "primitive", primitiveKind: "null" };
|
|
3118
3166
|
}
|
|
3119
3167
|
return resolveTypeNode(
|
|
@@ -3140,13 +3188,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
|
|
|
3140
3188
|
(memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
|
|
3141
3189
|
);
|
|
3142
3190
|
const nonNullTypes = allTypes.filter(
|
|
3143
|
-
(memberType) => !(memberType.flags & (
|
|
3191
|
+
(memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
|
|
3144
3192
|
);
|
|
3145
3193
|
const nonNullMembers = nonNullTypes.map((memberType, index) => ({
|
|
3146
3194
|
memberType,
|
|
3147
3195
|
sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
|
|
3148
3196
|
}));
|
|
3149
|
-
const hasNull = allTypes.some((t) => t.flags &
|
|
3197
|
+
const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
|
|
3150
3198
|
const memberDisplayNames = /* @__PURE__ */ new Map();
|
|
3151
3199
|
if (namedDecl) {
|
|
3152
3200
|
for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
|
|
@@ -3189,7 +3237,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
|
|
|
3189
3237
|
const displayName = memberDisplayNames.get(String(value));
|
|
3190
3238
|
return displayName !== void 0 ? { value, displayName } : { value };
|
|
3191
3239
|
});
|
|
3192
|
-
const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags &
|
|
3240
|
+
const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts6.TypeFlags.BooleanLiteral);
|
|
3193
3241
|
if (isBooleanUnion2) {
|
|
3194
3242
|
const boolNode = { kind: "primitive", primitiveKind: "boolean" };
|
|
3195
3243
|
const result = hasNull ? {
|
|
@@ -3281,7 +3329,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
|
|
|
3281
3329
|
if (type.getProperties().length > 0) {
|
|
3282
3330
|
return null;
|
|
3283
3331
|
}
|
|
3284
|
-
const indexInfo = checker.getIndexInfoOfType(type,
|
|
3332
|
+
const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
|
|
3285
3333
|
if (!indexInfo) {
|
|
3286
3334
|
return null;
|
|
3287
3335
|
}
|
|
@@ -3329,10 +3377,10 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
|
3329
3377
|
}
|
|
3330
3378
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
3331
3379
|
const name = declaration.name;
|
|
3332
|
-
if (
|
|
3380
|
+
if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
|
|
3333
3381
|
return false;
|
|
3334
3382
|
}
|
|
3335
|
-
if (!
|
|
3383
|
+
if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
|
|
3336
3384
|
return false;
|
|
3337
3385
|
}
|
|
3338
3386
|
}
|
|
@@ -3458,7 +3506,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
|
|
|
3458
3506
|
if (!declaration) continue;
|
|
3459
3507
|
if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
|
|
3460
3508
|
const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
|
|
3461
|
-
const optional = !!(prop.flags &
|
|
3509
|
+
const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
|
|
3462
3510
|
const propTypeNode = resolveTypeNode(
|
|
3463
3511
|
propType,
|
|
3464
3512
|
checker,
|
|
@@ -3471,7 +3519,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
|
|
|
3471
3519
|
collectedDiagnostics
|
|
3472
3520
|
);
|
|
3473
3521
|
const fieldNodeInfo = fieldInfoMap?.get(prop.name);
|
|
3474
|
-
const inlineFieldNodeInfo = fieldNodeInfo === void 0 ?
|
|
3522
|
+
const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
|
|
3475
3523
|
declaration,
|
|
3476
3524
|
checker,
|
|
3477
3525
|
file,
|
|
@@ -3481,7 +3529,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
|
|
|
3481
3529
|
type,
|
|
3482
3530
|
metadataPolicy,
|
|
3483
3531
|
extensionRegistry
|
|
3484
|
-
) :
|
|
3532
|
+
) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
|
|
3485
3533
|
declaration,
|
|
3486
3534
|
checker,
|
|
3487
3535
|
file,
|
|
@@ -3509,7 +3557,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
|
|
|
3509
3557
|
visiting.delete(type);
|
|
3510
3558
|
const objectNode = {
|
|
3511
3559
|
kind: "object",
|
|
3512
|
-
properties: namedDecl !== void 0 && (
|
|
3560
|
+
properties: namedDecl !== void 0 && (ts6.isClassDeclaration(namedDecl) || ts6.isInterfaceDeclaration(namedDecl) || ts6.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
|
|
3513
3561
|
properties,
|
|
3514
3562
|
namedDecl,
|
|
3515
3563
|
type,
|
|
@@ -3557,12 +3605,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
|
|
|
3557
3605
|
for (const symbol of symbols) {
|
|
3558
3606
|
const declarations = symbol.declarations;
|
|
3559
3607
|
if (!declarations) continue;
|
|
3560
|
-
const classDecl = declarations.find(
|
|
3608
|
+
const classDecl = declarations.find(ts6.isClassDeclaration);
|
|
3561
3609
|
if (classDecl) {
|
|
3562
3610
|
const map = /* @__PURE__ */ new Map();
|
|
3563
3611
|
const hostType = checker.getTypeAtLocation(classDecl);
|
|
3564
3612
|
for (const member of classDecl.members) {
|
|
3565
|
-
if (
|
|
3613
|
+
if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
|
|
3566
3614
|
const fieldNode = analyzeFieldToIR(
|
|
3567
3615
|
member,
|
|
3568
3616
|
checker,
|
|
@@ -3586,7 +3634,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
|
|
|
3586
3634
|
}
|
|
3587
3635
|
return map;
|
|
3588
3636
|
}
|
|
3589
|
-
const interfaceDecl = declarations.find(
|
|
3637
|
+
const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
|
|
3590
3638
|
if (interfaceDecl) {
|
|
3591
3639
|
return buildFieldNodeInfoMap(
|
|
3592
3640
|
interfaceDecl.members,
|
|
@@ -3600,7 +3648,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
|
|
|
3600
3648
|
extensionRegistry
|
|
3601
3649
|
);
|
|
3602
3650
|
}
|
|
3603
|
-
const typeAliasDecl = declarations.find(
|
|
3651
|
+
const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
|
|
3604
3652
|
const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
|
|
3605
3653
|
if (typeAliasDecl && typeAliasMembers !== null) {
|
|
3606
3654
|
return buildFieldNodeInfoMap(
|
|
@@ -3624,10 +3672,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
|
|
|
3624
3672
|
return void 0;
|
|
3625
3673
|
}
|
|
3626
3674
|
const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
|
|
3627
|
-
if (
|
|
3675
|
+
if (ts6.isArrayTypeNode(resolvedTypeNode)) {
|
|
3628
3676
|
return resolvedTypeNode.elementType;
|
|
3629
3677
|
}
|
|
3630
|
-
if (
|
|
3678
|
+
if (ts6.isTypeReferenceNode(resolvedTypeNode) && ts6.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
|
|
3631
3679
|
return resolvedTypeNode.typeArguments[0];
|
|
3632
3680
|
}
|
|
3633
3681
|
return void 0;
|
|
@@ -3638,13 +3686,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
|
|
|
3638
3686
|
return [];
|
|
3639
3687
|
}
|
|
3640
3688
|
const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
|
|
3641
|
-
return
|
|
3689
|
+
return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
|
|
3642
3690
|
}
|
|
3643
3691
|
function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
|
|
3644
|
-
if (
|
|
3692
|
+
if (ts6.isParenthesizedTypeNode(typeNode)) {
|
|
3645
3693
|
return resolveAliasedTypeNode(typeNode.type, checker, visited);
|
|
3646
3694
|
}
|
|
3647
|
-
if (!
|
|
3695
|
+
if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
|
|
3648
3696
|
return typeNode;
|
|
3649
3697
|
}
|
|
3650
3698
|
const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
|
|
@@ -3655,15 +3703,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
|
|
|
3655
3703
|
return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
|
|
3656
3704
|
}
|
|
3657
3705
|
function isNullishTypeNode(typeNode) {
|
|
3658
|
-
if (typeNode.kind ===
|
|
3706
|
+
if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
|
|
3659
3707
|
return true;
|
|
3660
3708
|
}
|
|
3661
|
-
return
|
|
3709
|
+
return ts6.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts6.SyntaxKind.NullKeyword || typeNode.literal.kind === ts6.SyntaxKind.UndefinedKeyword);
|
|
3662
3710
|
}
|
|
3663
3711
|
function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
|
|
3664
3712
|
const map = /* @__PURE__ */ new Map();
|
|
3665
3713
|
for (const member of members) {
|
|
3666
|
-
if (
|
|
3714
|
+
if (ts6.isPropertySignature(member)) {
|
|
3667
3715
|
const fieldNode = analyzeInterfacePropertyToIR(
|
|
3668
3716
|
member,
|
|
3669
3717
|
checker,
|
|
@@ -3689,7 +3737,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
|
|
|
3689
3737
|
}
|
|
3690
3738
|
var MAX_ALIAS_CHAIN_DEPTH = 8;
|
|
3691
3739
|
function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
|
|
3692
|
-
if (!
|
|
3740
|
+
if (!ts6.isTypeReferenceNode(typeNode)) return [];
|
|
3693
3741
|
if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
|
|
3694
3742
|
const aliasName = typeNode.typeName.getText();
|
|
3695
3743
|
throw new Error(
|
|
@@ -3698,7 +3746,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
|
|
|
3698
3746
|
}
|
|
3699
3747
|
const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
|
|
3700
3748
|
if (!aliasDecl) return [];
|
|
3701
|
-
if (
|
|
3749
|
+
if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
|
|
3702
3750
|
const aliasFieldType = resolveTypeNode(
|
|
3703
3751
|
checker.getTypeAtLocation(aliasDecl.type),
|
|
3704
3752
|
checker,
|
|
@@ -3742,14 +3790,14 @@ function getNamedTypeName(type) {
|
|
|
3742
3790
|
const symbol = type.getSymbol();
|
|
3743
3791
|
if (symbol?.declarations) {
|
|
3744
3792
|
const decl = symbol.declarations[0];
|
|
3745
|
-
if (decl && (
|
|
3746
|
-
const name =
|
|
3793
|
+
if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
|
|
3794
|
+
const name = ts6.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
|
|
3747
3795
|
if (name) return name;
|
|
3748
3796
|
}
|
|
3749
3797
|
}
|
|
3750
3798
|
const aliasSymbol = type.aliasSymbol;
|
|
3751
3799
|
if (aliasSymbol?.declarations) {
|
|
3752
|
-
const aliasDecl = aliasSymbol.declarations.find(
|
|
3800
|
+
const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
|
|
3753
3801
|
if (aliasDecl) {
|
|
3754
3802
|
return aliasDecl.name.text;
|
|
3755
3803
|
}
|
|
@@ -3760,24 +3808,24 @@ function getNamedTypeDeclaration(type) {
|
|
|
3760
3808
|
const symbol = type.getSymbol();
|
|
3761
3809
|
if (symbol?.declarations) {
|
|
3762
3810
|
const decl = symbol.declarations[0];
|
|
3763
|
-
if (decl && (
|
|
3811
|
+
if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
|
|
3764
3812
|
return decl;
|
|
3765
3813
|
}
|
|
3766
3814
|
}
|
|
3767
3815
|
const aliasSymbol = type.aliasSymbol;
|
|
3768
3816
|
if (aliasSymbol?.declarations) {
|
|
3769
|
-
return aliasSymbol.declarations.find(
|
|
3817
|
+
return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
|
|
3770
3818
|
}
|
|
3771
3819
|
return void 0;
|
|
3772
3820
|
}
|
|
3773
3821
|
function analyzeMethod(method, checker) {
|
|
3774
|
-
if (!
|
|
3822
|
+
if (!ts6.isIdentifier(method.name)) {
|
|
3775
3823
|
return null;
|
|
3776
3824
|
}
|
|
3777
3825
|
const name = method.name.text;
|
|
3778
3826
|
const parameters = [];
|
|
3779
3827
|
for (const param of method.parameters) {
|
|
3780
|
-
if (
|
|
3828
|
+
if (ts6.isIdentifier(param.name)) {
|
|
3781
3829
|
const paramInfo = analyzeParameter(param, checker);
|
|
3782
3830
|
parameters.push(paramInfo);
|
|
3783
3831
|
}
|
|
@@ -3788,7 +3836,7 @@ function analyzeMethod(method, checker) {
|
|
|
3788
3836
|
return { name, parameters, returnTypeNode, returnType };
|
|
3789
3837
|
}
|
|
3790
3838
|
function analyzeParameter(param, checker) {
|
|
3791
|
-
const name =
|
|
3839
|
+
const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
|
|
3792
3840
|
const typeNode = param.type;
|
|
3793
3841
|
const type = checker.getTypeAtLocation(param);
|
|
3794
3842
|
const formSpecExportName = detectFormSpecReference(typeNode);
|
|
@@ -3797,15 +3845,15 @@ function analyzeParameter(param, checker) {
|
|
|
3797
3845
|
}
|
|
3798
3846
|
function detectFormSpecReference(typeNode) {
|
|
3799
3847
|
if (!typeNode) return null;
|
|
3800
|
-
if (!
|
|
3801
|
-
const typeName =
|
|
3848
|
+
if (!ts6.isTypeReferenceNode(typeNode)) return null;
|
|
3849
|
+
const typeName = ts6.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts6.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
|
|
3802
3850
|
if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
|
|
3803
3851
|
const typeArg = typeNode.typeArguments?.[0];
|
|
3804
|
-
if (!typeArg || !
|
|
3805
|
-
if (
|
|
3852
|
+
if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
|
|
3853
|
+
if (ts6.isIdentifier(typeArg.exprName)) {
|
|
3806
3854
|
return typeArg.exprName.text;
|
|
3807
3855
|
}
|
|
3808
|
-
if (
|
|
3856
|
+
if (ts6.isQualifiedName(typeArg.exprName)) {
|
|
3809
3857
|
return typeArg.exprName.right.text;
|
|
3810
3858
|
}
|
|
3811
3859
|
return null;
|
|
@@ -3827,23 +3875,23 @@ function createProgramContextFromProgram(program, filePath) {
|
|
|
3827
3875
|
function createProgramContext(filePath, additionalFiles) {
|
|
3828
3876
|
const absolutePath = path.resolve(filePath);
|
|
3829
3877
|
const fileDir = path.dirname(absolutePath);
|
|
3830
|
-
const configPath =
|
|
3878
|
+
const configPath = ts7.findConfigFile(fileDir, ts7.sys.fileExists.bind(ts7.sys), "tsconfig.json");
|
|
3831
3879
|
let compilerOptions;
|
|
3832
3880
|
let fileNames;
|
|
3833
3881
|
if (configPath) {
|
|
3834
|
-
const configFile =
|
|
3882
|
+
const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
|
|
3835
3883
|
if (configFile.error) {
|
|
3836
3884
|
throw new Error(
|
|
3837
|
-
`Error reading tsconfig.json: ${
|
|
3885
|
+
`Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
|
|
3838
3886
|
);
|
|
3839
3887
|
}
|
|
3840
|
-
const parsed =
|
|
3888
|
+
const parsed = ts7.parseJsonConfigFileContent(
|
|
3841
3889
|
configFile.config,
|
|
3842
|
-
|
|
3890
|
+
ts7.sys,
|
|
3843
3891
|
path.dirname(configPath)
|
|
3844
3892
|
);
|
|
3845
3893
|
if (parsed.errors.length > 0) {
|
|
3846
|
-
const errorMessages = parsed.errors.map((e) =>
|
|
3894
|
+
const errorMessages = parsed.errors.map((e) => ts7.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
|
|
3847
3895
|
throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
|
|
3848
3896
|
}
|
|
3849
3897
|
compilerOptions = parsed.options;
|
|
@@ -3851,9 +3899,9 @@ function createProgramContext(filePath, additionalFiles) {
|
|
|
3851
3899
|
fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
|
|
3852
3900
|
} else {
|
|
3853
3901
|
compilerOptions = {
|
|
3854
|
-
target:
|
|
3855
|
-
module:
|
|
3856
|
-
moduleResolution:
|
|
3902
|
+
target: ts7.ScriptTarget.ES2022,
|
|
3903
|
+
module: ts7.ModuleKind.NodeNext,
|
|
3904
|
+
moduleResolution: ts7.ModuleResolutionKind.NodeNext,
|
|
3857
3905
|
strict: true,
|
|
3858
3906
|
skipLibCheck: true,
|
|
3859
3907
|
declaration: true
|
|
@@ -3861,7 +3909,7 @@ function createProgramContext(filePath, additionalFiles) {
|
|
|
3861
3909
|
const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
|
|
3862
3910
|
fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
|
|
3863
3911
|
}
|
|
3864
|
-
const program =
|
|
3912
|
+
const program = ts7.createProgram(fileNames, compilerOptions);
|
|
3865
3913
|
const sourceFile = program.getSourceFile(absolutePath);
|
|
3866
3914
|
if (!sourceFile) {
|
|
3867
3915
|
throw new Error(`Could not find source file: ${absolutePath}`);
|
|
@@ -3880,19 +3928,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
|
|
|
3880
3928
|
result = node;
|
|
3881
3929
|
return;
|
|
3882
3930
|
}
|
|
3883
|
-
|
|
3931
|
+
ts7.forEachChild(node, visit);
|
|
3884
3932
|
}
|
|
3885
3933
|
visit(sourceFile);
|
|
3886
3934
|
return result;
|
|
3887
3935
|
}
|
|
3888
3936
|
function findClassByName(sourceFile, className) {
|
|
3889
|
-
return findNodeByName(sourceFile, className,
|
|
3937
|
+
return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
|
|
3890
3938
|
}
|
|
3891
3939
|
function findInterfaceByName(sourceFile, interfaceName) {
|
|
3892
|
-
return findNodeByName(sourceFile, interfaceName,
|
|
3940
|
+
return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
|
|
3893
3941
|
}
|
|
3894
3942
|
function findTypeAliasByName(sourceFile, aliasName) {
|
|
3895
|
-
return findNodeByName(sourceFile, aliasName,
|
|
3943
|
+
return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
|
|
3896
3944
|
}
|
|
3897
3945
|
function getResolvedObjectRootType(rootType, typeRegistry) {
|
|
3898
3946
|
if (rootType.kind === "object") {
|
|
@@ -3932,22 +3980,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
|
|
|
3932
3980
|
};
|
|
3933
3981
|
}
|
|
3934
3982
|
function containsTypeReferenceInObjectLikeAlias(typeNode) {
|
|
3935
|
-
if (
|
|
3983
|
+
if (ts7.isParenthesizedTypeNode(typeNode)) {
|
|
3936
3984
|
return containsTypeReferenceInObjectLikeAlias(typeNode.type);
|
|
3937
3985
|
}
|
|
3938
|
-
if (
|
|
3986
|
+
if (ts7.isTypeReferenceNode(typeNode)) {
|
|
3939
3987
|
return true;
|
|
3940
3988
|
}
|
|
3941
|
-
return
|
|
3989
|
+
return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
|
|
3942
3990
|
}
|
|
3943
3991
|
function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
|
|
3944
|
-
if (
|
|
3992
|
+
if (ts7.isParenthesizedTypeNode(typeNode)) {
|
|
3945
3993
|
return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
|
|
3946
3994
|
}
|
|
3947
|
-
if (
|
|
3995
|
+
if (ts7.isTypeLiteralNode(typeNode)) {
|
|
3948
3996
|
const propertyNames = [];
|
|
3949
3997
|
for (const member of typeNode.members) {
|
|
3950
|
-
if (!
|
|
3998
|
+
if (!ts7.isPropertySignature(member)) {
|
|
3951
3999
|
continue;
|
|
3952
4000
|
}
|
|
3953
4001
|
const propertyName = getAnalyzableObjectLikePropertyName(member.name);
|
|
@@ -3957,13 +4005,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
|
|
|
3957
4005
|
}
|
|
3958
4006
|
return propertyNames;
|
|
3959
4007
|
}
|
|
3960
|
-
if (
|
|
4008
|
+
if (ts7.isTypeReferenceNode(typeNode)) {
|
|
3961
4009
|
return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
|
|
3962
4010
|
}
|
|
3963
4011
|
return null;
|
|
3964
4012
|
}
|
|
3965
4013
|
function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
|
|
3966
|
-
if (!
|
|
4014
|
+
if (!ts7.isIntersectionTypeNode(typeNode)) {
|
|
3967
4015
|
return [];
|
|
3968
4016
|
}
|
|
3969
4017
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -4153,7 +4201,7 @@ function makeFileProvenance(filePath) {
|
|
|
4153
4201
|
}
|
|
4154
4202
|
|
|
4155
4203
|
// src/generators/class-schema.ts
|
|
4156
|
-
import * as
|
|
4204
|
+
import * as ts9 from "typescript";
|
|
4157
4205
|
|
|
4158
4206
|
// src/metadata/collision-guards.ts
|
|
4159
4207
|
function assertUniqueSerializedNames(entries, scope) {
|
|
@@ -5153,7 +5201,7 @@ function createExtensionRegistry(extensions) {
|
|
|
5153
5201
|
}
|
|
5154
5202
|
|
|
5155
5203
|
// src/extensions/symbol-registry.ts
|
|
5156
|
-
import * as
|
|
5204
|
+
import * as ts8 from "typescript";
|
|
5157
5205
|
import * as path2 from "path";
|
|
5158
5206
|
|
|
5159
5207
|
// src/ui-schema/schema.ts
|