@formspec/build 0.1.0-alpha.59 → 0.1.0-alpha.63
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/class-analyzer.d.ts +1 -1
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/jsdoc-constraints.d.ts +0 -6
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +2 -5
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +2 -1
- package/dist/build-beta.d.ts +2 -1
- package/dist/build-internal.d.ts +18 -15
- package/dist/build.d.ts +2 -1
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +2 -1
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -1
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +2 -1
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -1
- package/dist/cli.cjs +45 -316
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +48 -319
- package/dist/cli.js.map +1 -1
- package/dist/extensions/registry.d.ts +2 -2
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/generators/method-schema.d.ts +3 -2
- package/dist/generators/method-schema.d.ts.map +1 -1
- package/dist/index.cjs +44 -315
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -318
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +44 -315
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +47 -318
- package/dist/internals.js.map +1 -1
- package/dist/metadata/index.d.ts +1 -4
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/policy.d.ts +2 -6
- package/dist/metadata/policy.d.ts.map +1 -1
- package/dist/metadata/resolve.d.ts +3 -2
- package/dist/metadata/resolve.d.ts.map +1 -1
- package/dist/ui-schema/schema.d.ts +11 -28
- package/dist/ui-schema/schema.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/internals.cjs
CHANGED
|
@@ -971,152 +971,35 @@ var import_internal2 = require("@formspec/analysis/internal");
|
|
|
971
971
|
|
|
972
972
|
// src/analyzer/tsdoc-parser.ts
|
|
973
973
|
var import_internal4 = require("@formspec/analysis/internal");
|
|
974
|
-
function sharedTagValueOptions(options) {
|
|
974
|
+
function sharedTagValueOptions(options, pathResolvedCustomTypeId) {
|
|
975
975
|
return {
|
|
976
976
|
...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
|
|
977
|
-
...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {}
|
|
977
|
+
...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {},
|
|
978
|
+
...pathResolvedCustomTypeId !== void 0 ? { pathResolvedCustomTypeId } : {}
|
|
978
979
|
};
|
|
979
980
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
return new Set(
|
|
986
|
-
registry.extensions.flatMap(
|
|
987
|
-
(ext) => (ext.types ?? []).flatMap((t) => t.tsTypeNames ?? [t.typeName])
|
|
988
|
-
)
|
|
989
|
-
);
|
|
981
|
+
function customTypeIdForResolvedType(resolvedType, checker, registry) {
|
|
982
|
+
if (registry === void 0) return void 0;
|
|
983
|
+
const lookup = resolveCustomTypeFromTsType(resolvedType, checker, registry);
|
|
984
|
+
return lookup === null ? void 0 : customTypeIdFromLookup(lookup);
|
|
990
985
|
}
|
|
991
|
-
function
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
if (clause.name !== void 0) {
|
|
997
|
-
importedNames.add(clause.name.text);
|
|
998
|
-
}
|
|
999
|
-
if (clause.namedBindings !== void 0) {
|
|
1000
|
-
if (ts3.isNamedImports(clause.namedBindings)) {
|
|
1001
|
-
for (const specifier of clause.namedBindings.elements) {
|
|
1002
|
-
importedNames.add(specifier.name.text);
|
|
1003
|
-
}
|
|
1004
|
-
} else if (ts3.isNamespaceImport(clause.namedBindings)) {
|
|
1005
|
-
importedNames.add(clause.namedBindings.name.text);
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
continue;
|
|
1009
|
-
}
|
|
1010
|
-
if (ts3.isImportEqualsDeclaration(statement)) {
|
|
1011
|
-
importedNames.add(statement.name.text);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
return importedNames;
|
|
1015
|
-
}
|
|
1016
|
-
function isNonReferenceIdentifier(node) {
|
|
1017
|
-
const parent = node.parent;
|
|
1018
|
-
if ((ts3.isBindingElement(parent) || ts3.isClassDeclaration(parent) || ts3.isEnumDeclaration(parent) || ts3.isEnumMember(parent) || ts3.isFunctionDeclaration(parent) || ts3.isFunctionExpression(parent) || ts3.isImportClause(parent) || ts3.isImportEqualsDeclaration(parent) || ts3.isImportSpecifier(parent) || ts3.isInterfaceDeclaration(parent) || ts3.isMethodDeclaration(parent) || ts3.isMethodSignature(parent) || ts3.isModuleDeclaration(parent) || ts3.isNamespaceExport(parent) || ts3.isNamespaceImport(parent) || ts3.isParameter(parent) || ts3.isPropertyDeclaration(parent) || ts3.isPropertySignature(parent) || ts3.isSetAccessorDeclaration(parent) || ts3.isGetAccessorDeclaration(parent) || ts3.isTypeAliasDeclaration(parent) || ts3.isTypeParameterDeclaration(parent) || ts3.isVariableDeclaration(parent)) && parent.name === node) {
|
|
1019
|
-
return true;
|
|
1020
|
-
}
|
|
1021
|
-
if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
|
|
1022
|
-
return true;
|
|
1023
|
-
}
|
|
1024
|
-
if (ts3.isQualifiedName(parent) && parent.right === node) {
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
|
-
return false;
|
|
1028
|
-
}
|
|
1029
|
-
function astReferencesImportedName(root, importedNames) {
|
|
1030
|
-
if (importedNames.size === 0) {
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
let found = false;
|
|
1034
|
-
const visit = (node) => {
|
|
1035
|
-
if (found) return;
|
|
1036
|
-
if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1037
|
-
found = true;
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
ts3.forEachChild(node, visit);
|
|
1041
|
-
};
|
|
1042
|
-
visit(root);
|
|
1043
|
-
return found;
|
|
1044
|
-
}
|
|
1045
|
-
function getObjectMembers(statement) {
|
|
1046
|
-
if (ts3.isInterfaceDeclaration(statement)) {
|
|
1047
|
-
return statement.members;
|
|
1048
|
-
}
|
|
1049
|
-
if (ts3.isTypeLiteralNode(statement.type)) {
|
|
1050
|
-
return statement.type.members;
|
|
1051
|
-
}
|
|
1052
|
-
return void 0;
|
|
1053
|
-
}
|
|
1054
|
-
function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
|
|
1055
|
-
const members = getObjectMembers(statement);
|
|
1056
|
-
if (members === void 0) {
|
|
1057
|
-
return null;
|
|
1058
|
-
}
|
|
1059
|
-
const replacements = [];
|
|
1060
|
-
for (const member of members) {
|
|
1061
|
-
if (!ts3.isPropertySignature(member)) {
|
|
1062
|
-
if (astReferencesImportedName(member, importedNames)) {
|
|
1063
|
-
return null;
|
|
1064
|
-
}
|
|
1065
|
-
continue;
|
|
1066
|
-
}
|
|
1067
|
-
const typeAnnotation = member.type;
|
|
1068
|
-
if (typeAnnotation === void 0) continue;
|
|
1069
|
-
if (astReferencesImportedName(typeAnnotation, importedNames)) {
|
|
1070
|
-
replacements.push({
|
|
1071
|
-
start: typeAnnotation.getStart(sourceFile),
|
|
1072
|
-
end: typeAnnotation.getEnd()
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
if (replacements.length === 0) {
|
|
1077
|
-
return statement.getText(sourceFile);
|
|
1078
|
-
}
|
|
1079
|
-
const stmtStart = statement.getStart(sourceFile);
|
|
1080
|
-
let result = statement.getText(sourceFile);
|
|
1081
|
-
for (const { start, end } of [...replacements].reverse()) {
|
|
1082
|
-
result = result.slice(0, start - stmtStart) + "unknown" + result.slice(end - stmtStart);
|
|
986
|
+
function resolvePathTargetCustomTypeId(parsedTag, subjectType, checker, registry) {
|
|
987
|
+
if (parsedTag === null) return void 0;
|
|
988
|
+
const target = parsedTag.target;
|
|
989
|
+
if (target?.kind !== "path" || !target.valid || target.path === null) {
|
|
990
|
+
return void 0;
|
|
1083
991
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
|
|
1087
|
-
const importedNames = collectImportedNames(sourceFile);
|
|
1088
|
-
const importedNamesToSkip = new Set(
|
|
1089
|
-
[...importedNames].filter((name) => !extensionTypeNames.has(name))
|
|
1090
|
-
);
|
|
1091
|
-
const result = [];
|
|
1092
|
-
for (const statement of sourceFile.statements) {
|
|
1093
|
-
if (ts3.isImportDeclaration(statement)) continue;
|
|
1094
|
-
if (ts3.isImportEqualsDeclaration(statement)) continue;
|
|
1095
|
-
if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
|
|
1096
|
-
if (!astReferencesImportedName(statement, importedNamesToSkip)) {
|
|
1097
|
-
result.push(statement.getText(sourceFile));
|
|
1098
|
-
continue;
|
|
1099
|
-
}
|
|
1100
|
-
if (ts3.isInterfaceDeclaration(statement) || ts3.isTypeAliasDeclaration(statement)) {
|
|
1101
|
-
const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
|
|
1102
|
-
if (rewritten !== null) {
|
|
1103
|
-
result.push(rewritten);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
992
|
+
if (subjectType === void 0 || checker === void 0) {
|
|
993
|
+
return void 0;
|
|
1106
994
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
for (const diagnostic of additions) {
|
|
1111
|
-
if ((diagnostic.code === "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" || diagnostic.code === "SYNTHETIC_SETUP_FAILURE") && target.some(
|
|
1112
|
-
(existing) => existing.code === diagnostic.code && existing.message === diagnostic.message
|
|
1113
|
-
)) {
|
|
1114
|
-
continue;
|
|
1115
|
-
}
|
|
1116
|
-
target.push(diagnostic);
|
|
995
|
+
const resolution = (0, import_internal3.resolvePathTargetType)(subjectType, checker, target.path.segments);
|
|
996
|
+
if (resolution.kind !== "resolved") {
|
|
997
|
+
return void 0;
|
|
1117
998
|
}
|
|
999
|
+
return customTypeIdForResolvedType(resolution.type, checker, registry);
|
|
1118
1000
|
}
|
|
1119
|
-
|
|
1001
|
+
var TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
1002
|
+
function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, options, constraints, diagnostics) {
|
|
1120
1003
|
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
1121
1004
|
node,
|
|
1122
1005
|
sourceFile,
|
|
@@ -1124,74 +1007,30 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
|
|
|
1124
1007
|
parsedTag,
|
|
1125
1008
|
text,
|
|
1126
1009
|
provenance,
|
|
1127
|
-
supportingDeclarations,
|
|
1128
1010
|
options
|
|
1129
1011
|
);
|
|
1130
1012
|
if (compilerDiagnostics.length > 0) {
|
|
1131
|
-
|
|
1013
|
+
diagnostics.push(...compilerDiagnostics);
|
|
1132
1014
|
return;
|
|
1133
1015
|
}
|
|
1016
|
+
const pathResolvedCustomTypeId = resolvePathTargetCustomTypeId(
|
|
1017
|
+
parsedTag,
|
|
1018
|
+
options?.subjectType,
|
|
1019
|
+
options?.checker,
|
|
1020
|
+
options?.extensionRegistry
|
|
1021
|
+
);
|
|
1134
1022
|
const constraintNode = (0, import_internal3.parseConstraintTagValue)(
|
|
1135
1023
|
tagName,
|
|
1136
1024
|
text,
|
|
1137
1025
|
provenance,
|
|
1138
|
-
sharedTagValueOptions(options)
|
|
1026
|
+
sharedTagValueOptions(options, pathResolvedCustomTypeId)
|
|
1139
1027
|
);
|
|
1140
1028
|
if (constraintNode) {
|
|
1141
1029
|
constraints.push(constraintNode);
|
|
1142
1030
|
}
|
|
1143
1031
|
}
|
|
1144
|
-
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
1145
|
-
const trimmed = argumentText.trim();
|
|
1146
|
-
if (trimmed === "") {
|
|
1147
|
-
return null;
|
|
1148
|
-
}
|
|
1149
|
-
switch (valueKind) {
|
|
1150
|
-
case "number":
|
|
1151
|
-
case "integer":
|
|
1152
|
-
case "signedInteger":
|
|
1153
|
-
if (trimmed === "Infinity" || trimmed === "-Infinity" || trimmed === "NaN") {
|
|
1154
|
-
return trimmed;
|
|
1155
|
-
}
|
|
1156
|
-
return Number.isFinite(Number(trimmed)) ? trimmed : JSON.stringify(trimmed);
|
|
1157
|
-
case "string":
|
|
1158
|
-
return JSON.stringify(argumentText);
|
|
1159
|
-
case "json":
|
|
1160
|
-
try {
|
|
1161
|
-
JSON.parse(trimmed);
|
|
1162
|
-
return `(${trimmed})`;
|
|
1163
|
-
} catch {
|
|
1164
|
-
return JSON.stringify(trimmed);
|
|
1165
|
-
}
|
|
1166
|
-
case "boolean":
|
|
1167
|
-
return trimmed === "true" || trimmed === "false" ? trimmed : JSON.stringify(trimmed);
|
|
1168
|
-
case "condition":
|
|
1169
|
-
return "undefined as unknown as FormSpecCondition";
|
|
1170
|
-
case null:
|
|
1171
|
-
return null;
|
|
1172
|
-
default: {
|
|
1173
|
-
return String(valueKind);
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
function getArrayElementType(type, checker) {
|
|
1178
|
-
if (!checker.isArrayType(type)) {
|
|
1179
|
-
return null;
|
|
1180
|
-
}
|
|
1181
|
-
return checker.getTypeArguments(type)[0] ?? null;
|
|
1182
|
-
}
|
|
1183
1032
|
function supportsConstraintCapability(type, checker, capability) {
|
|
1184
|
-
|
|
1185
|
-
return true;
|
|
1186
|
-
}
|
|
1187
|
-
if ((0, import_internal3.hasTypeSemanticCapability)(type, checker, capability)) {
|
|
1188
|
-
return true;
|
|
1189
|
-
}
|
|
1190
|
-
if (capability === "string-like") {
|
|
1191
|
-
const itemType = getArrayElementType(type, checker);
|
|
1192
|
-
return itemType !== null && (0, import_internal3.hasTypeSemanticCapability)(itemType, checker, capability);
|
|
1193
|
-
}
|
|
1194
|
-
return false;
|
|
1033
|
+
return (0, import_internal3._supportsConstraintCapability)(capability, type, checker);
|
|
1195
1034
|
}
|
|
1196
1035
|
var MAX_HINT_CANDIDATES = 5;
|
|
1197
1036
|
var MAX_HINT_DEPTH = 3;
|
|
@@ -1318,53 +1157,11 @@ function placementLabel(placement) {
|
|
|
1318
1157
|
}
|
|
1319
1158
|
}
|
|
1320
1159
|
}
|
|
1321
|
-
function capabilityLabel(capability) {
|
|
1322
|
-
switch (capability) {
|
|
1323
|
-
case "numeric-comparable":
|
|
1324
|
-
return "number";
|
|
1325
|
-
case "string-like":
|
|
1326
|
-
return "string";
|
|
1327
|
-
case "array-like":
|
|
1328
|
-
return "array";
|
|
1329
|
-
case "enum-member-addressable":
|
|
1330
|
-
return "enum";
|
|
1331
|
-
case "json-like":
|
|
1332
|
-
return "JSON-compatible";
|
|
1333
|
-
case "object-like":
|
|
1334
|
-
return "object";
|
|
1335
|
-
case "condition-like":
|
|
1336
|
-
return "conditional";
|
|
1337
|
-
case void 0:
|
|
1338
|
-
return "compatible";
|
|
1339
|
-
default:
|
|
1340
|
-
return capability;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
function getBroadenedCustomTypeId(fieldType) {
|
|
1344
|
-
if (fieldType?.kind === "custom") {
|
|
1345
|
-
return fieldType.typeId;
|
|
1346
|
-
}
|
|
1347
|
-
if (fieldType?.kind !== "union") {
|
|
1348
|
-
return void 0;
|
|
1349
|
-
}
|
|
1350
|
-
const customMembers = fieldType.members.filter(
|
|
1351
|
-
(member) => member.kind === "custom"
|
|
1352
|
-
);
|
|
1353
|
-
if (customMembers.length !== 1) {
|
|
1354
|
-
return void 0;
|
|
1355
|
-
}
|
|
1356
|
-
const nonCustomMembers = fieldType.members.filter((member) => member.kind !== "custom");
|
|
1357
|
-
const allOtherMembersAreNull = nonCustomMembers.every(
|
|
1358
|
-
(member) => member.kind === "primitive" && member.primitiveKind === "null"
|
|
1359
|
-
);
|
|
1360
|
-
const customMember = customMembers[0];
|
|
1361
|
-
return allOtherMembersAreNull && customMember !== void 0 ? customMember.typeId : void 0;
|
|
1362
|
-
}
|
|
1363
1160
|
function hasBuiltinConstraintBroadening(tagName, options) {
|
|
1364
|
-
const broadenedTypeId = getBroadenedCustomTypeId(options?.fieldType);
|
|
1161
|
+
const broadenedTypeId = (0, import_internal3.getBroadenedCustomTypeId)(options?.fieldType);
|
|
1365
1162
|
return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
|
|
1366
1163
|
}
|
|
1367
|
-
function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance,
|
|
1164
|
+
function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance, options) {
|
|
1368
1165
|
if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
|
|
1369
1166
|
return [];
|
|
1370
1167
|
}
|
|
@@ -1384,16 +1181,14 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1384
1181
|
const nonNullPlacement = placement;
|
|
1385
1182
|
const log = (0, import_internal4.getBuildLogger)();
|
|
1386
1183
|
const broadeningLog = (0, import_internal4.getBroadeningLogger)();
|
|
1387
|
-
const syntheticLog = (0, import_internal4.getSyntheticLogger)();
|
|
1388
1184
|
const typedParserLog = (0, import_internal4.getTypedParserLogger)();
|
|
1389
1185
|
const logsEnabled = log !== import_core.noopLogger || broadeningLog !== import_core.noopLogger;
|
|
1390
|
-
const syntheticTraceEnabled = syntheticLog !== import_core.noopLogger;
|
|
1391
1186
|
const typedParserTraceEnabled = typedParserLog !== import_core.noopLogger;
|
|
1392
1187
|
const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
|
|
1393
1188
|
const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
|
|
1394
|
-
function emit(outcome,
|
|
1189
|
+
function emit(outcome, result) {
|
|
1395
1190
|
if (!logsEnabled) {
|
|
1396
|
-
return
|
|
1191
|
+
return result;
|
|
1397
1192
|
}
|
|
1398
1193
|
const entry = {
|
|
1399
1194
|
consumer: "build",
|
|
@@ -1407,7 +1202,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1407
1202
|
if (outcome === "bypass" || outcome === "D1" || outcome === "D2") {
|
|
1408
1203
|
(0, import_internal4.logTagApplication)(broadeningLog, entry);
|
|
1409
1204
|
}
|
|
1410
|
-
return
|
|
1205
|
+
return result;
|
|
1411
1206
|
}
|
|
1412
1207
|
if (!definition.placements.includes(placement)) {
|
|
1413
1208
|
return emit("A-reject", [
|
|
@@ -1451,7 +1246,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1451
1246
|
]);
|
|
1452
1247
|
}
|
|
1453
1248
|
if (resolution.kind === "unresolvable") {
|
|
1454
|
-
const actualType = checker.typeToString(resolution.type, node,
|
|
1249
|
+
const actualType = checker.typeToString(resolution.type, node, TYPE_FORMAT_FLAGS);
|
|
1455
1250
|
return emit("B-reject", [
|
|
1456
1251
|
makeDiagnostic(
|
|
1457
1252
|
"TYPE_MISMATCH",
|
|
@@ -1465,21 +1260,21 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1465
1260
|
}
|
|
1466
1261
|
const hasBroadening = (() => {
|
|
1467
1262
|
if (target === null) {
|
|
1468
|
-
if ((0, import_internal2._isIntegerBrandedType)((0, import_internal3.stripNullishUnion)(subjectType)) && definition.capabilities
|
|
1263
|
+
if ((0, import_internal2._isIntegerBrandedType)((0, import_internal3.stripNullishUnion)(subjectType)) && definition.capabilities[0] === "numeric-comparable") {
|
|
1469
1264
|
return true;
|
|
1470
1265
|
}
|
|
1471
1266
|
return hasBuiltinConstraintBroadening(tagName, options);
|
|
1472
1267
|
}
|
|
1473
1268
|
const registry = options?.extensionRegistry;
|
|
1474
1269
|
if (registry === void 0) return false;
|
|
1475
|
-
const
|
|
1476
|
-
return
|
|
1270
|
+
const typeId = customTypeIdForResolvedType(evaluatedType, checker, registry);
|
|
1271
|
+
return typeId !== void 0 && registry.findBuiltinConstraintBroadening(typeId, tagName) !== void 0;
|
|
1477
1272
|
})();
|
|
1478
1273
|
if (!hasBroadening) {
|
|
1479
1274
|
const requiredCapability = definition.capabilities[0];
|
|
1480
1275
|
if (requiredCapability !== void 0 && !supportsConstraintCapability(evaluatedType, checker, requiredCapability)) {
|
|
1481
|
-
const actualType = checker.typeToString(evaluatedType, node,
|
|
1482
|
-
const baseMessage = `Target "${targetLabel}": constraint "${tagName}" is only valid on ${
|
|
1276
|
+
const actualType = checker.typeToString(evaluatedType, node, TYPE_FORMAT_FLAGS);
|
|
1277
|
+
const baseMessage = `Target "${targetLabel}": constraint "${tagName}" is only valid on ${(0, import_internal3._capabilityLabel)(requiredCapability)} targets, but field type is "${actualType}"`;
|
|
1483
1278
|
const hint = target === null ? buildPathTargetHint(
|
|
1484
1279
|
subjectType,
|
|
1485
1280
|
checker,
|
|
@@ -1527,68 +1322,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1527
1322
|
valueKind: typedParseResult.value.kind
|
|
1528
1323
|
});
|
|
1529
1324
|
}
|
|
1530
|
-
|
|
1531
|
-
definition.valueKind,
|
|
1532
|
-
effectiveArgumentText
|
|
1533
|
-
);
|
|
1534
|
-
const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
|
|
1535
|
-
const hostType = options?.hostType ?? subjectType;
|
|
1536
|
-
const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
|
|
1537
|
-
if (syntheticTraceEnabled) {
|
|
1538
|
-
syntheticLog.trace("invoking synthetic checker", {
|
|
1539
|
-
consumer: "build",
|
|
1540
|
-
tag: tagName,
|
|
1541
|
-
placement,
|
|
1542
|
-
subjectTypeKind,
|
|
1543
|
-
subjectTypeText
|
|
1544
|
-
});
|
|
1545
|
-
}
|
|
1546
|
-
const result = (0, import_internal3.checkSyntheticTagApplication)({
|
|
1547
|
-
tagName,
|
|
1548
|
-
placement,
|
|
1549
|
-
hostType: hostTypeText,
|
|
1550
|
-
subjectType: subjectTypeText,
|
|
1551
|
-
...target?.kind === "path" ? { target: { kind: "path", text: target.rawText } } : {},
|
|
1552
|
-
...argumentExpression !== null ? { argumentExpression } : {},
|
|
1553
|
-
supportingDeclarations,
|
|
1554
|
-
...options?.extensionRegistry !== void 0 ? {
|
|
1555
|
-
extensions: options.extensionRegistry.extensions.map((extension) => ({
|
|
1556
|
-
extensionId: extension.extensionId,
|
|
1557
|
-
...extension.constraintTags !== void 0 ? {
|
|
1558
|
-
constraintTags: extension.constraintTags.map((tag) => ({ tagName: tag.tagName }))
|
|
1559
|
-
} : {},
|
|
1560
|
-
...extension.metadataSlots !== void 0 ? {
|
|
1561
|
-
metadataSlots: extension.metadataSlots
|
|
1562
|
-
} : {},
|
|
1563
|
-
...extension.types !== void 0 ? {
|
|
1564
|
-
customTypes: extension.types.map((t) => ({
|
|
1565
|
-
tsTypeNames: t.tsTypeNames ?? [t.typeName]
|
|
1566
|
-
}))
|
|
1567
|
-
} : {}
|
|
1568
|
-
}))
|
|
1569
|
-
} : {}
|
|
1570
|
-
});
|
|
1571
|
-
if (result.diagnostics.length === 0) {
|
|
1572
|
-
return emit("D-pass", []);
|
|
1573
|
-
}
|
|
1574
|
-
const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
|
|
1575
|
-
if (setupDiagnostic !== void 0) {
|
|
1576
|
-
return emit("C-reject", [
|
|
1577
|
-
makeDiagnostic(
|
|
1578
|
-
(0, import_internal4._mapSetupDiagnosticCode)(setupDiagnostic.kind),
|
|
1579
|
-
setupDiagnostic.message,
|
|
1580
|
-
provenance
|
|
1581
|
-
)
|
|
1582
|
-
]);
|
|
1583
|
-
}
|
|
1584
|
-
const expectedLabel = definition.valueKind === null ? "compatible argument" : capabilityLabel(definition.valueKind);
|
|
1585
|
-
return emit("C-reject", [
|
|
1586
|
-
makeDiagnostic(
|
|
1587
|
-
"TYPE_MISMATCH",
|
|
1588
|
-
`Tag "@${tagName}" received an invalid argument for ${expectedLabel}.`,
|
|
1589
|
-
provenance
|
|
1590
|
-
)
|
|
1591
|
-
]);
|
|
1325
|
+
return emit("C-pass", []);
|
|
1592
1326
|
}
|
|
1593
1327
|
var parseResultCache = /* @__PURE__ */ new Map();
|
|
1594
1328
|
function getExtensionTagNames(options) {
|
|
@@ -1632,8 +1366,8 @@ function getParseCacheKey(node, file, options) {
|
|
|
1632
1366
|
start: node.getFullStart(),
|
|
1633
1367
|
end: node.getEnd(),
|
|
1634
1368
|
fieldType: options?.fieldType ?? null,
|
|
1635
|
-
subjectType: checker !== void 0 && options?.subjectType !== void 0 ? checker.typeToString(options.subjectType, node,
|
|
1636
|
-
hostType: checker !== void 0 && options?.hostType !== void 0 ? checker.typeToString(options.hostType, node,
|
|
1369
|
+
subjectType: checker !== void 0 && options?.subjectType !== void 0 ? checker.typeToString(options.subjectType, node, TYPE_FORMAT_FLAGS) : null,
|
|
1370
|
+
hostType: checker !== void 0 && options?.hostType !== void 0 ? checker.typeToString(options.hostType, node, TYPE_FORMAT_FLAGS) : null,
|
|
1637
1371
|
extensions: getExtensionRegistryCacheKey(options?.extensionRegistry)
|
|
1638
1372
|
});
|
|
1639
1373
|
}
|
|
@@ -1662,8 +1396,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1662
1396
|
let placeholderProvenance;
|
|
1663
1397
|
const sourceFile = node.getSourceFile();
|
|
1664
1398
|
const sourceText = sourceFile.getFullText();
|
|
1665
|
-
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
1666
|
-
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
1667
1399
|
const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
1668
1400
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
1669
1401
|
const extensionTagNames = getExtensionTagNames(options);
|
|
@@ -1728,7 +1460,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1728
1460
|
provenance2,
|
|
1729
1461
|
node,
|
|
1730
1462
|
sourceFile,
|
|
1731
|
-
supportingDeclarations,
|
|
1732
1463
|
options,
|
|
1733
1464
|
constraints,
|
|
1734
1465
|
diagnostics
|
|
@@ -1746,7 +1477,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1746
1477
|
provenance,
|
|
1747
1478
|
node,
|
|
1748
1479
|
sourceFile,
|
|
1749
|
-
supportingDeclarations,
|
|
1750
1480
|
options,
|
|
1751
1481
|
constraints,
|
|
1752
1482
|
diagnostics
|
|
@@ -1810,7 +1540,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1810
1540
|
provenance,
|
|
1811
1541
|
node,
|
|
1812
1542
|
sourceFile,
|
|
1813
|
-
supportingDeclarations,
|
|
1814
1543
|
options,
|
|
1815
1544
|
constraints,
|
|
1816
1545
|
diagnostics
|
|
@@ -5479,7 +5208,7 @@ function buildConstraintTagSources(extensions) {
|
|
|
5479
5208
|
}));
|
|
5480
5209
|
}
|
|
5481
5210
|
function createExtensionRegistry(extensions) {
|
|
5482
|
-
const registryLog = (0, import_internal6.
|
|
5211
|
+
const registryLog = (0, import_internal6.getRegistryLogger)();
|
|
5483
5212
|
registryLog.debug("createExtensionRegistry: constructing", {
|
|
5484
5213
|
extensionCount: extensions.length,
|
|
5485
5214
|
extensionIds: extensions.map((e) => e.extensionId)
|