@typespec/html-program-viewer 0.67.0-dev.3 → 0.67.0-dev.5
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/emitter/index.js +2 -10
- package/dist/{manifest-IEQ_iGDm.js → manifest-CrFWPTea.js} +1 -1
- package/dist/react/index.js +634 -598
- package/dist/react/type-config.d.ts +2 -2
- package/dist/react/type-config.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/emitter.d.ts +0 -20
- package/dist/emitter.d.ts.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
package/dist/react/index.js
CHANGED
|
@@ -17882,233 +17882,6 @@ function normalizeSlashes(path) {
|
|
|
17882
17882
|
return path.replace(backslashRegExp, directorySeparator);
|
|
17883
17883
|
}
|
|
17884
17884
|
|
|
17885
|
-
function createSourceFile(text, path) {
|
|
17886
|
-
let lineStarts = undefined;
|
|
17887
|
-
return {
|
|
17888
|
-
text,
|
|
17889
|
-
path,
|
|
17890
|
-
getLineStarts,
|
|
17891
|
-
getLineAndCharacterOfPosition,
|
|
17892
|
-
};
|
|
17893
|
-
function getLineStarts() {
|
|
17894
|
-
return (lineStarts = lineStarts ?? scanLineStarts(text));
|
|
17895
|
-
}
|
|
17896
|
-
function getLineAndCharacterOfPosition(position) {
|
|
17897
|
-
const starts = getLineStarts();
|
|
17898
|
-
let line = binarySearch(starts, position);
|
|
17899
|
-
// When binarySearch returns < 0 indicating that the value was not found, it
|
|
17900
|
-
// returns the bitwise complement of the index where the value would need to
|
|
17901
|
-
// be inserted to keep the array sorted. So flipping the bits back to this
|
|
17902
|
-
// positive index tells us what the line number would be if we were to
|
|
17903
|
-
// create a new line starting at the given position, and subtracting 1 from
|
|
17904
|
-
// that therefore gives us the line number we're after.
|
|
17905
|
-
if (line < 0) {
|
|
17906
|
-
line = ~line - 1;
|
|
17907
|
-
}
|
|
17908
|
-
return {
|
|
17909
|
-
line,
|
|
17910
|
-
character: position - starts[line],
|
|
17911
|
-
};
|
|
17912
|
-
}
|
|
17913
|
-
}
|
|
17914
|
-
function scanLineStarts(text) {
|
|
17915
|
-
const starts = [];
|
|
17916
|
-
let start = 0;
|
|
17917
|
-
let pos = 0;
|
|
17918
|
-
while (pos < text.length) {
|
|
17919
|
-
const ch = text.charCodeAt(pos);
|
|
17920
|
-
pos++;
|
|
17921
|
-
switch (ch) {
|
|
17922
|
-
case 13 /* CharCode.CarriageReturn */:
|
|
17923
|
-
if (text.charCodeAt(pos) === 10 /* CharCode.LineFeed */) {
|
|
17924
|
-
pos++;
|
|
17925
|
-
}
|
|
17926
|
-
// fallthrough
|
|
17927
|
-
case 10 /* CharCode.LineFeed */:
|
|
17928
|
-
starts.push(start);
|
|
17929
|
-
start = pos;
|
|
17930
|
-
break;
|
|
17931
|
-
}
|
|
17932
|
-
}
|
|
17933
|
-
starts.push(start);
|
|
17934
|
-
return starts;
|
|
17935
|
-
}
|
|
17936
|
-
/**
|
|
17937
|
-
* Search sorted array of numbers for the given value. If found, return index
|
|
17938
|
-
* in array where value was found. If not found, return a negative number that
|
|
17939
|
-
* is the bitwise complement of the index where value would need to be inserted
|
|
17940
|
-
* to keep the array sorted.
|
|
17941
|
-
*/
|
|
17942
|
-
function binarySearch(array, value) {
|
|
17943
|
-
let low = 0;
|
|
17944
|
-
let high = array.length - 1;
|
|
17945
|
-
while (low <= high) {
|
|
17946
|
-
const middle = low + ((high - low) >> 1);
|
|
17947
|
-
const v = array[middle];
|
|
17948
|
-
if (v < value) {
|
|
17949
|
-
low = middle + 1;
|
|
17950
|
-
}
|
|
17951
|
-
else if (v > value) {
|
|
17952
|
-
high = middle - 1;
|
|
17953
|
-
}
|
|
17954
|
-
else {
|
|
17955
|
-
return middle;
|
|
17956
|
-
}
|
|
17957
|
-
}
|
|
17958
|
-
return ~low;
|
|
17959
|
-
}
|
|
17960
|
-
|
|
17961
|
-
var ResolutionResultFlags;
|
|
17962
|
-
(function (ResolutionResultFlags) {
|
|
17963
|
-
ResolutionResultFlags[ResolutionResultFlags["None"] = 0] = "None";
|
|
17964
|
-
ResolutionResultFlags[ResolutionResultFlags["Resolved"] = 2] = "Resolved";
|
|
17965
|
-
ResolutionResultFlags[ResolutionResultFlags["Unknown"] = 4] = "Unknown";
|
|
17966
|
-
ResolutionResultFlags[ResolutionResultFlags["Ambiguous"] = 8] = "Ambiguous";
|
|
17967
|
-
ResolutionResultFlags[ResolutionResultFlags["NotFound"] = 16] = "NotFound";
|
|
17968
|
-
ResolutionResultFlags[ResolutionResultFlags["ResolutionFailed"] = 28] = "ResolutionFailed";
|
|
17969
|
-
})(ResolutionResultFlags || (ResolutionResultFlags = {}));
|
|
17970
|
-
/**
|
|
17971
|
-
* AST types
|
|
17972
|
-
*/
|
|
17973
|
-
var SyntaxKind;
|
|
17974
|
-
(function (SyntaxKind) {
|
|
17975
|
-
SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
|
|
17976
|
-
SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
|
|
17977
|
-
SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
|
|
17978
|
-
SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
|
|
17979
|
-
SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
|
|
17980
|
-
SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
|
|
17981
|
-
SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
|
|
17982
|
-
SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
|
|
17983
|
-
SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
|
|
17984
|
-
SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
|
|
17985
|
-
SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
|
|
17986
|
-
SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
|
|
17987
|
-
SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
|
|
17988
|
-
SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
|
|
17989
|
-
SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
|
|
17990
|
-
SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
|
|
17991
|
-
SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
|
|
17992
|
-
SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
|
|
17993
|
-
SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
|
|
17994
|
-
SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
|
|
17995
|
-
SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
|
|
17996
|
-
SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
|
|
17997
|
-
SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
|
|
17998
|
-
SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
|
|
17999
|
-
SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
|
|
18000
|
-
SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
|
|
18001
|
-
SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
|
|
18002
|
-
SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
|
|
18003
|
-
SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
|
|
18004
|
-
SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
|
|
18005
|
-
SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
|
|
18006
|
-
SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
|
|
18007
|
-
SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
|
|
18008
|
-
SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
|
|
18009
|
-
SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
|
|
18010
|
-
SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
|
|
18011
|
-
SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
|
|
18012
|
-
SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
|
|
18013
|
-
SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
|
|
18014
|
-
SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
|
|
18015
|
-
SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
|
|
18016
|
-
SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
|
|
18017
|
-
SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
|
|
18018
|
-
SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
|
|
18019
|
-
SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
|
|
18020
|
-
SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
|
|
18021
|
-
SyntaxKind[SyntaxKind["ProjectionReference"] = 46] = "ProjectionReference";
|
|
18022
|
-
SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 47] = "TemplateParameterDeclaration";
|
|
18023
|
-
SyntaxKind[SyntaxKind["EmptyStatement"] = 48] = "EmptyStatement";
|
|
18024
|
-
SyntaxKind[SyntaxKind["InvalidStatement"] = 49] = "InvalidStatement";
|
|
18025
|
-
SyntaxKind[SyntaxKind["LineComment"] = 50] = "LineComment";
|
|
18026
|
-
SyntaxKind[SyntaxKind["BlockComment"] = 51] = "BlockComment";
|
|
18027
|
-
SyntaxKind[SyntaxKind["Doc"] = 52] = "Doc";
|
|
18028
|
-
SyntaxKind[SyntaxKind["DocText"] = 53] = "DocText";
|
|
18029
|
-
SyntaxKind[SyntaxKind["DocParamTag"] = 54] = "DocParamTag";
|
|
18030
|
-
SyntaxKind[SyntaxKind["DocPropTag"] = 55] = "DocPropTag";
|
|
18031
|
-
SyntaxKind[SyntaxKind["DocReturnsTag"] = 56] = "DocReturnsTag";
|
|
18032
|
-
SyntaxKind[SyntaxKind["DocErrorsTag"] = 57] = "DocErrorsTag";
|
|
18033
|
-
SyntaxKind[SyntaxKind["DocTemplateTag"] = 58] = "DocTemplateTag";
|
|
18034
|
-
SyntaxKind[SyntaxKind["DocUnknownTag"] = 59] = "DocUnknownTag";
|
|
18035
|
-
SyntaxKind[SyntaxKind["Projection"] = 60] = "Projection";
|
|
18036
|
-
SyntaxKind[SyntaxKind["ProjectionParameterDeclaration"] = 61] = "ProjectionParameterDeclaration";
|
|
18037
|
-
SyntaxKind[SyntaxKind["ProjectionModelSelector"] = 62] = "ProjectionModelSelector";
|
|
18038
|
-
SyntaxKind[SyntaxKind["ProjectionModelPropertySelector"] = 63] = "ProjectionModelPropertySelector";
|
|
18039
|
-
SyntaxKind[SyntaxKind["ProjectionScalarSelector"] = 64] = "ProjectionScalarSelector";
|
|
18040
|
-
SyntaxKind[SyntaxKind["ProjectionOperationSelector"] = 65] = "ProjectionOperationSelector";
|
|
18041
|
-
SyntaxKind[SyntaxKind["ProjectionUnionSelector"] = 66] = "ProjectionUnionSelector";
|
|
18042
|
-
SyntaxKind[SyntaxKind["ProjectionUnionVariantSelector"] = 67] = "ProjectionUnionVariantSelector";
|
|
18043
|
-
SyntaxKind[SyntaxKind["ProjectionInterfaceSelector"] = 68] = "ProjectionInterfaceSelector";
|
|
18044
|
-
SyntaxKind[SyntaxKind["ProjectionEnumSelector"] = 69] = "ProjectionEnumSelector";
|
|
18045
|
-
SyntaxKind[SyntaxKind["ProjectionEnumMemberSelector"] = 70] = "ProjectionEnumMemberSelector";
|
|
18046
|
-
SyntaxKind[SyntaxKind["ProjectionExpressionStatement"] = 71] = "ProjectionExpressionStatement";
|
|
18047
|
-
SyntaxKind[SyntaxKind["ProjectionIfExpression"] = 72] = "ProjectionIfExpression";
|
|
18048
|
-
SyntaxKind[SyntaxKind["ProjectionBlockExpression"] = 73] = "ProjectionBlockExpression";
|
|
18049
|
-
SyntaxKind[SyntaxKind["ProjectionMemberExpression"] = 74] = "ProjectionMemberExpression";
|
|
18050
|
-
SyntaxKind[SyntaxKind["ProjectionLogicalExpression"] = 75] = "ProjectionLogicalExpression";
|
|
18051
|
-
SyntaxKind[SyntaxKind["ProjectionEqualityExpression"] = 76] = "ProjectionEqualityExpression";
|
|
18052
|
-
SyntaxKind[SyntaxKind["ProjectionUnaryExpression"] = 77] = "ProjectionUnaryExpression";
|
|
18053
|
-
SyntaxKind[SyntaxKind["ProjectionRelationalExpression"] = 78] = "ProjectionRelationalExpression";
|
|
18054
|
-
SyntaxKind[SyntaxKind["ProjectionArithmeticExpression"] = 79] = "ProjectionArithmeticExpression";
|
|
18055
|
-
SyntaxKind[SyntaxKind["ProjectionCallExpression"] = 80] = "ProjectionCallExpression";
|
|
18056
|
-
SyntaxKind[SyntaxKind["ProjectionLambdaExpression"] = 81] = "ProjectionLambdaExpression";
|
|
18057
|
-
SyntaxKind[SyntaxKind["ProjectionLambdaParameterDeclaration"] = 82] = "ProjectionLambdaParameterDeclaration";
|
|
18058
|
-
SyntaxKind[SyntaxKind["ProjectionModelExpression"] = 83] = "ProjectionModelExpression";
|
|
18059
|
-
SyntaxKind[SyntaxKind["ProjectionModelProperty"] = 84] = "ProjectionModelProperty";
|
|
18060
|
-
SyntaxKind[SyntaxKind["ProjectionModelSpreadProperty"] = 85] = "ProjectionModelSpreadProperty";
|
|
18061
|
-
SyntaxKind[SyntaxKind["ProjectionSpreadProperty"] = 86] = "ProjectionSpreadProperty";
|
|
18062
|
-
SyntaxKind[SyntaxKind["ProjectionTupleExpression"] = 87] = "ProjectionTupleExpression";
|
|
18063
|
-
SyntaxKind[SyntaxKind["ProjectionStatement"] = 88] = "ProjectionStatement";
|
|
18064
|
-
SyntaxKind[SyntaxKind["ProjectionDecoratorReferenceExpression"] = 89] = "ProjectionDecoratorReferenceExpression";
|
|
18065
|
-
SyntaxKind[SyntaxKind["Return"] = 90] = "Return";
|
|
18066
|
-
SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 91] = "JsNamespaceDeclaration";
|
|
18067
|
-
SyntaxKind[SyntaxKind["TemplateArgument"] = 92] = "TemplateArgument";
|
|
18068
|
-
SyntaxKind[SyntaxKind["TypeOfExpression"] = 93] = "TypeOfExpression";
|
|
18069
|
-
SyntaxKind[SyntaxKind["ObjectLiteral"] = 94] = "ObjectLiteral";
|
|
18070
|
-
SyntaxKind[SyntaxKind["ObjectLiteralProperty"] = 95] = "ObjectLiteralProperty";
|
|
18071
|
-
SyntaxKind[SyntaxKind["ObjectLiteralSpreadProperty"] = 96] = "ObjectLiteralSpreadProperty";
|
|
18072
|
-
SyntaxKind[SyntaxKind["ArrayLiteral"] = 97] = "ArrayLiteral";
|
|
18073
|
-
SyntaxKind[SyntaxKind["ConstStatement"] = 98] = "ConstStatement";
|
|
18074
|
-
SyntaxKind[SyntaxKind["CallExpression"] = 99] = "CallExpression";
|
|
18075
|
-
SyntaxKind[SyntaxKind["ScalarConstructor"] = 100] = "ScalarConstructor";
|
|
18076
|
-
})(SyntaxKind || (SyntaxKind = {}));
|
|
18077
|
-
var IdentifierKind;
|
|
18078
|
-
(function (IdentifierKind) {
|
|
18079
|
-
IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
|
|
18080
|
-
IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
|
|
18081
|
-
IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
|
|
18082
|
-
IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
|
|
18083
|
-
IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
|
|
18084
|
-
IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
|
|
18085
|
-
IdentifierKind[IdentifierKind["ModelExpressionProperty"] = 6] = "ModelExpressionProperty";
|
|
18086
|
-
IdentifierKind[IdentifierKind["ModelStatementProperty"] = 7] = "ModelStatementProperty";
|
|
18087
|
-
IdentifierKind[IdentifierKind["ObjectLiteralProperty"] = 8] = "ObjectLiteralProperty";
|
|
18088
|
-
IdentifierKind[IdentifierKind["Other"] = 9] = "Other";
|
|
18089
|
-
})(IdentifierKind || (IdentifierKind = {}));
|
|
18090
|
-
/** Used to explicitly specify that a diagnostic has no target. */
|
|
18091
|
-
const NoTarget = Symbol.for("NoTarget");
|
|
18092
|
-
var ListenerFlow;
|
|
18093
|
-
(function (ListenerFlow) {
|
|
18094
|
-
/**
|
|
18095
|
-
* Do not navigate any containing or referenced type.
|
|
18096
|
-
*/
|
|
18097
|
-
ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
|
|
18098
|
-
})(ListenerFlow || (ListenerFlow = {}));
|
|
18099
|
-
|
|
18100
|
-
let manifest;
|
|
18101
|
-
try {
|
|
18102
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18103
|
-
// @ts-ignore
|
|
18104
|
-
manifest = (await import('../manifest-IEQ_iGDm.js')).default;
|
|
18105
|
-
}
|
|
18106
|
-
catch {
|
|
18107
|
-
const name = "../dist/manifest.js";
|
|
18108
|
-
manifest = (await import(/* @vite-ignore */ /* webpackIgnore: true */ name)).default;
|
|
18109
|
-
}
|
|
18110
|
-
manifest.version;
|
|
18111
|
-
|
|
18112
17885
|
/**
|
|
18113
17886
|
* Recursively calls Object.freeze such that all objects and arrays
|
|
18114
17887
|
* referenced are frozen.
|
|
@@ -18419,7 +18192,6 @@ const diagnostics = {
|
|
|
18419
18192
|
unexpected: paramMessage `Unexpected token ${"token"}`,
|
|
18420
18193
|
numericOrStringLiteral: "Expected numeric or string literal.",
|
|
18421
18194
|
identifier: "Identifier expected.",
|
|
18422
|
-
projectionDirection: "from or to expected.",
|
|
18423
18195
|
expression: "Expression expected.",
|
|
18424
18196
|
statement: "Statement expected.",
|
|
18425
18197
|
property: "Property expected.",
|
|
@@ -18458,6 +18230,7 @@ const diagnostics = {
|
|
|
18458
18230
|
severity: "error",
|
|
18459
18231
|
messages: {
|
|
18460
18232
|
default: "Keyword cannot be used as identifier.",
|
|
18233
|
+
future: paramMessage `${"name"} is a reserved keyword`,
|
|
18461
18234
|
},
|
|
18462
18235
|
},
|
|
18463
18236
|
"invalid-directive-location": {
|
|
@@ -18472,15 +18245,6 @@ const diagnostics = {
|
|
|
18472
18245
|
default: paramMessage `Cannot decorate ${"nodeName"}.`,
|
|
18473
18246
|
},
|
|
18474
18247
|
},
|
|
18475
|
-
"invalid-projection": {
|
|
18476
|
-
severity: "error",
|
|
18477
|
-
messages: {
|
|
18478
|
-
default: "Invalid projection",
|
|
18479
|
-
wrongType: "Non-projection can't be used to project",
|
|
18480
|
-
noTo: "Projection missing to projection",
|
|
18481
|
-
projectionError: paramMessage `An error occurred when projecting this type: ${"message"}`,
|
|
18482
|
-
},
|
|
18483
|
-
},
|
|
18484
18248
|
"default-required": {
|
|
18485
18249
|
severity: "error",
|
|
18486
18250
|
messages: {
|
|
@@ -18675,7 +18439,8 @@ const diagnostics = {
|
|
|
18675
18439
|
messages: {
|
|
18676
18440
|
default: paramMessage `${"name"} refers to a type, but is being used as a value here.`,
|
|
18677
18441
|
model: paramMessage `${"name"} refers to a model type, but is being used as a value here. Use #{} to create an object value.`,
|
|
18678
|
-
|
|
18442
|
+
modelExpression: `Is a model expression type, but is being used as a value here. Use #{} to create an object value.`,
|
|
18443
|
+
tuple: `Is a tuple type, but is being used as a value here. Use #[] to create an array value.`,
|
|
18679
18444
|
templateConstraint: paramMessage `${"name"} template parameter can be a type but is being used as a value here.`,
|
|
18680
18445
|
},
|
|
18681
18446
|
},
|
|
@@ -18820,6 +18585,12 @@ const diagnostics = {
|
|
|
18820
18585
|
default: "A function declaration must be prefixed with the 'extern' modifier.",
|
|
18821
18586
|
},
|
|
18822
18587
|
},
|
|
18588
|
+
"function-unsupported": {
|
|
18589
|
+
severity: "error",
|
|
18590
|
+
messages: {
|
|
18591
|
+
default: "Function are currently not supported.",
|
|
18592
|
+
},
|
|
18593
|
+
},
|
|
18823
18594
|
"missing-implementation": {
|
|
18824
18595
|
severity: "error",
|
|
18825
18596
|
messages: {
|
|
@@ -28271,45 +28042,229 @@ function findYamlNode(file, path, kind = "value") {
|
|
|
28271
28042
|
return current ?? undefined;
|
|
28272
28043
|
}
|
|
28273
28044
|
|
|
28274
|
-
function
|
|
28275
|
-
|
|
28276
|
-
|
|
28277
|
-
|
|
28278
|
-
|
|
28279
|
-
|
|
28045
|
+
function createSourceFile(text, path) {
|
|
28046
|
+
let lineStarts = undefined;
|
|
28047
|
+
return {
|
|
28048
|
+
text,
|
|
28049
|
+
path,
|
|
28050
|
+
getLineStarts,
|
|
28051
|
+
getLineAndCharacterOfPosition,
|
|
28052
|
+
};
|
|
28053
|
+
function getLineStarts() {
|
|
28054
|
+
return (lineStarts = lineStarts ?? scanLineStarts(text));
|
|
28280
28055
|
}
|
|
28281
|
-
|
|
28282
|
-
|
|
28283
|
-
|
|
28284
|
-
|
|
28285
|
-
|
|
28286
|
-
//
|
|
28287
|
-
|
|
28288
|
-
|
|
28289
|
-
|
|
28290
|
-
if (
|
|
28291
|
-
|
|
28056
|
+
function getLineAndCharacterOfPosition(position) {
|
|
28057
|
+
const starts = getLineStarts();
|
|
28058
|
+
let line = binarySearch(starts, position);
|
|
28059
|
+
// When binarySearch returns < 0 indicating that the value was not found, it
|
|
28060
|
+
// returns the bitwise complement of the index where the value would need to
|
|
28061
|
+
// be inserted to keep the array sorted. So flipping the bits back to this
|
|
28062
|
+
// positive index tells us what the line number would be if we were to
|
|
28063
|
+
// create a new line starting at the given position, and subtracting 1 from
|
|
28064
|
+
// that therefore gives us the line number we're after.
|
|
28065
|
+
if (line < 0) {
|
|
28066
|
+
line = ~line - 1;
|
|
28292
28067
|
}
|
|
28293
|
-
return
|
|
28294
|
-
|
|
28295
|
-
|
|
28296
|
-
|
|
28297
|
-
return getSourceLocationOfNode(target, options);
|
|
28068
|
+
return {
|
|
28069
|
+
line,
|
|
28070
|
+
character: position - starts[line],
|
|
28071
|
+
};
|
|
28298
28072
|
}
|
|
28299
|
-
|
|
28300
|
-
|
|
28301
|
-
|
|
28302
|
-
|
|
28303
|
-
|
|
28073
|
+
}
|
|
28074
|
+
function scanLineStarts(text) {
|
|
28075
|
+
const starts = [];
|
|
28076
|
+
let start = 0;
|
|
28077
|
+
let pos = 0;
|
|
28078
|
+
while (pos < text.length) {
|
|
28079
|
+
const ch = text.charCodeAt(pos);
|
|
28080
|
+
pos++;
|
|
28081
|
+
switch (ch) {
|
|
28082
|
+
case 13 /* CharCode.CarriageReturn */:
|
|
28083
|
+
if (text.charCodeAt(pos) === 10 /* CharCode.LineFeed */) {
|
|
28084
|
+
pos++;
|
|
28085
|
+
}
|
|
28086
|
+
// fallthrough
|
|
28087
|
+
case 10 /* CharCode.LineFeed */:
|
|
28088
|
+
starts.push(start);
|
|
28089
|
+
start = pos;
|
|
28090
|
+
break;
|
|
28304
28091
|
}
|
|
28305
|
-
return createSyntheticSourceLocation();
|
|
28306
28092
|
}
|
|
28093
|
+
starts.push(start);
|
|
28094
|
+
return starts;
|
|
28307
28095
|
}
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
|
|
28312
|
-
|
|
28096
|
+
/**
|
|
28097
|
+
* Search sorted array of numbers for the given value. If found, return index
|
|
28098
|
+
* in array where value was found. If not found, return a negative number that
|
|
28099
|
+
* is the bitwise complement of the index where value would need to be inserted
|
|
28100
|
+
* to keep the array sorted.
|
|
28101
|
+
*/
|
|
28102
|
+
function binarySearch(array, value) {
|
|
28103
|
+
let low = 0;
|
|
28104
|
+
let high = array.length - 1;
|
|
28105
|
+
while (low <= high) {
|
|
28106
|
+
const middle = low + ((high - low) >> 1);
|
|
28107
|
+
const v = array[middle];
|
|
28108
|
+
if (v < value) {
|
|
28109
|
+
low = middle + 1;
|
|
28110
|
+
}
|
|
28111
|
+
else if (v > value) {
|
|
28112
|
+
high = middle - 1;
|
|
28113
|
+
}
|
|
28114
|
+
else {
|
|
28115
|
+
return middle;
|
|
28116
|
+
}
|
|
28117
|
+
}
|
|
28118
|
+
return ~low;
|
|
28119
|
+
}
|
|
28120
|
+
|
|
28121
|
+
var ResolutionResultFlags;
|
|
28122
|
+
(function (ResolutionResultFlags) {
|
|
28123
|
+
ResolutionResultFlags[ResolutionResultFlags["None"] = 0] = "None";
|
|
28124
|
+
ResolutionResultFlags[ResolutionResultFlags["Resolved"] = 2] = "Resolved";
|
|
28125
|
+
ResolutionResultFlags[ResolutionResultFlags["Unknown"] = 4] = "Unknown";
|
|
28126
|
+
ResolutionResultFlags[ResolutionResultFlags["Ambiguous"] = 8] = "Ambiguous";
|
|
28127
|
+
ResolutionResultFlags[ResolutionResultFlags["NotFound"] = 16] = "NotFound";
|
|
28128
|
+
ResolutionResultFlags[ResolutionResultFlags["ResolutionFailed"] = 28] = "ResolutionFailed";
|
|
28129
|
+
})(ResolutionResultFlags || (ResolutionResultFlags = {}));
|
|
28130
|
+
/**
|
|
28131
|
+
* AST types
|
|
28132
|
+
*/
|
|
28133
|
+
var SyntaxKind;
|
|
28134
|
+
(function (SyntaxKind) {
|
|
28135
|
+
SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
|
|
28136
|
+
SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
|
|
28137
|
+
SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
|
|
28138
|
+
SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
|
|
28139
|
+
SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
|
|
28140
|
+
SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
|
|
28141
|
+
SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
|
|
28142
|
+
SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
|
|
28143
|
+
SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
|
|
28144
|
+
SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
|
|
28145
|
+
SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
|
|
28146
|
+
SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
|
|
28147
|
+
SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
|
|
28148
|
+
SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
|
|
28149
|
+
SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
|
|
28150
|
+
SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
|
|
28151
|
+
SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
|
|
28152
|
+
SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
|
|
28153
|
+
SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
|
|
28154
|
+
SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
|
|
28155
|
+
SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
|
|
28156
|
+
SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
|
|
28157
|
+
SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
|
|
28158
|
+
SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
|
|
28159
|
+
SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
|
|
28160
|
+
SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
|
|
28161
|
+
SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
|
|
28162
|
+
SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
|
|
28163
|
+
SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
|
|
28164
|
+
SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
|
|
28165
|
+
SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
|
|
28166
|
+
SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
|
|
28167
|
+
SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
|
|
28168
|
+
SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
|
|
28169
|
+
SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
|
|
28170
|
+
SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
|
|
28171
|
+
SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
|
|
28172
|
+
SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
|
|
28173
|
+
SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
|
|
28174
|
+
SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
|
|
28175
|
+
SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
|
|
28176
|
+
SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
|
|
28177
|
+
SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
|
|
28178
|
+
SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
|
|
28179
|
+
SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
|
|
28180
|
+
SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
|
|
28181
|
+
SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 46] = "TemplateParameterDeclaration";
|
|
28182
|
+
SyntaxKind[SyntaxKind["EmptyStatement"] = 47] = "EmptyStatement";
|
|
28183
|
+
SyntaxKind[SyntaxKind["InvalidStatement"] = 48] = "InvalidStatement";
|
|
28184
|
+
SyntaxKind[SyntaxKind["LineComment"] = 49] = "LineComment";
|
|
28185
|
+
SyntaxKind[SyntaxKind["BlockComment"] = 50] = "BlockComment";
|
|
28186
|
+
SyntaxKind[SyntaxKind["Doc"] = 51] = "Doc";
|
|
28187
|
+
SyntaxKind[SyntaxKind["DocText"] = 52] = "DocText";
|
|
28188
|
+
SyntaxKind[SyntaxKind["DocParamTag"] = 53] = "DocParamTag";
|
|
28189
|
+
SyntaxKind[SyntaxKind["DocPropTag"] = 54] = "DocPropTag";
|
|
28190
|
+
SyntaxKind[SyntaxKind["DocReturnsTag"] = 55] = "DocReturnsTag";
|
|
28191
|
+
SyntaxKind[SyntaxKind["DocErrorsTag"] = 56] = "DocErrorsTag";
|
|
28192
|
+
SyntaxKind[SyntaxKind["DocTemplateTag"] = 57] = "DocTemplateTag";
|
|
28193
|
+
SyntaxKind[SyntaxKind["DocUnknownTag"] = 58] = "DocUnknownTag";
|
|
28194
|
+
SyntaxKind[SyntaxKind["Return"] = 59] = "Return";
|
|
28195
|
+
SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 60] = "JsNamespaceDeclaration";
|
|
28196
|
+
SyntaxKind[SyntaxKind["TemplateArgument"] = 61] = "TemplateArgument";
|
|
28197
|
+
SyntaxKind[SyntaxKind["TypeOfExpression"] = 62] = "TypeOfExpression";
|
|
28198
|
+
SyntaxKind[SyntaxKind["ObjectLiteral"] = 63] = "ObjectLiteral";
|
|
28199
|
+
SyntaxKind[SyntaxKind["ObjectLiteralProperty"] = 64] = "ObjectLiteralProperty";
|
|
28200
|
+
SyntaxKind[SyntaxKind["ObjectLiteralSpreadProperty"] = 65] = "ObjectLiteralSpreadProperty";
|
|
28201
|
+
SyntaxKind[SyntaxKind["ArrayLiteral"] = 66] = "ArrayLiteral";
|
|
28202
|
+
SyntaxKind[SyntaxKind["ConstStatement"] = 67] = "ConstStatement";
|
|
28203
|
+
SyntaxKind[SyntaxKind["CallExpression"] = 68] = "CallExpression";
|
|
28204
|
+
SyntaxKind[SyntaxKind["ScalarConstructor"] = 69] = "ScalarConstructor";
|
|
28205
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
28206
|
+
var IdentifierKind;
|
|
28207
|
+
(function (IdentifierKind) {
|
|
28208
|
+
IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
|
|
28209
|
+
IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
|
|
28210
|
+
IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
|
|
28211
|
+
IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
|
|
28212
|
+
IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
|
|
28213
|
+
IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
|
|
28214
|
+
IdentifierKind[IdentifierKind["ModelExpressionProperty"] = 6] = "ModelExpressionProperty";
|
|
28215
|
+
IdentifierKind[IdentifierKind["ModelStatementProperty"] = 7] = "ModelStatementProperty";
|
|
28216
|
+
IdentifierKind[IdentifierKind["ObjectLiteralProperty"] = 8] = "ObjectLiteralProperty";
|
|
28217
|
+
IdentifierKind[IdentifierKind["Other"] = 9] = "Other";
|
|
28218
|
+
})(IdentifierKind || (IdentifierKind = {}));
|
|
28219
|
+
/** Used to explicitly specify that a diagnostic has no target. */
|
|
28220
|
+
const NoTarget = Symbol.for("NoTarget");
|
|
28221
|
+
var ListenerFlow;
|
|
28222
|
+
(function (ListenerFlow) {
|
|
28223
|
+
/**
|
|
28224
|
+
* Do not navigate any containing or referenced type.
|
|
28225
|
+
*/
|
|
28226
|
+
ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
|
|
28227
|
+
})(ListenerFlow || (ListenerFlow = {}));
|
|
28228
|
+
|
|
28229
|
+
function getSourceLocation(target, options = {}) {
|
|
28230
|
+
if (target === NoTarget || target === undefined) {
|
|
28231
|
+
return undefined;
|
|
28232
|
+
}
|
|
28233
|
+
if ("file" in target) {
|
|
28234
|
+
return target;
|
|
28235
|
+
}
|
|
28236
|
+
if (!("kind" in target) && !("entityKind" in target)) {
|
|
28237
|
+
// TemplateInstanceTarget
|
|
28238
|
+
if (!("declarations" in target)) {
|
|
28239
|
+
return getSourceLocationOfNode(target.node, options);
|
|
28240
|
+
}
|
|
28241
|
+
// symbol
|
|
28242
|
+
if (target.flags & 8192 /* SymbolFlags.Using */) {
|
|
28243
|
+
target = target.symbolSource;
|
|
28244
|
+
}
|
|
28245
|
+
if (!target.declarations[0]) {
|
|
28246
|
+
return createSyntheticSourceLocation();
|
|
28247
|
+
}
|
|
28248
|
+
return getSourceLocationOfNode(target.declarations[0], options);
|
|
28249
|
+
}
|
|
28250
|
+
else if ("kind" in target && typeof target.kind === "number") {
|
|
28251
|
+
// node
|
|
28252
|
+
return getSourceLocationOfNode(target, options);
|
|
28253
|
+
}
|
|
28254
|
+
else {
|
|
28255
|
+
// type
|
|
28256
|
+
const targetNode = target.node;
|
|
28257
|
+
if (targetNode) {
|
|
28258
|
+
return getSourceLocationOfNode(targetNode, options);
|
|
28259
|
+
}
|
|
28260
|
+
return createSyntheticSourceLocation();
|
|
28261
|
+
}
|
|
28262
|
+
}
|
|
28263
|
+
function createSyntheticSourceLocation(loc = "<unknown location>") {
|
|
28264
|
+
return {
|
|
28265
|
+
file: createSourceFile("", loc),
|
|
28266
|
+
pos: 0,
|
|
28267
|
+
end: 0,
|
|
28313
28268
|
isSynthetic: true,
|
|
28314
28269
|
};
|
|
28315
28270
|
}
|
|
@@ -29230,9 +29185,7 @@ function getVisibilityForClass(program, property, visibilityClass) {
|
|
|
29230
29185
|
// #endregion
|
|
29231
29186
|
|
|
29232
29187
|
function isIntrinsicType(program, type, kind) {
|
|
29233
|
-
return ignoreDiagnostics(program.checker.isTypeAssignableTo(
|
|
29234
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
29235
|
-
type.projectionBase ?? type, program.checker.getStdType(kind), type));
|
|
29188
|
+
return ignoreDiagnostics(program.checker.isTypeAssignableTo(type, program.checker.getStdType(kind), type));
|
|
29236
29189
|
}
|
|
29237
29190
|
|
|
29238
29191
|
const deprecatedKey = createStateSymbol("deprecated");
|
|
@@ -29361,61 +29314,170 @@ function getDiscriminator(program, entity) {
|
|
|
29361
29314
|
const [getDiscriminatedOptions, setDiscriminatedOptions] = useStateMap(createStateSymbol("discriminated"));
|
|
29362
29315
|
// #endregion
|
|
29363
29316
|
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
|
|
29367
|
-
|
|
29368
|
-
|
|
29317
|
+
function getDiscriminatedUnion(typeOrProgram, typeOrDiscriminator) {
|
|
29318
|
+
return getDiscriminatedUnionForUnion(typeOrProgram, typeOrDiscriminator);
|
|
29319
|
+
}
|
|
29320
|
+
function getDiscriminatedUnionForUnion(program, type) {
|
|
29321
|
+
const options = getDiscriminatedOptions(program, type);
|
|
29322
|
+
const diagnostics = [];
|
|
29323
|
+
if (options === undefined) {
|
|
29324
|
+
return [undefined, []];
|
|
29369
29325
|
}
|
|
29370
|
-
const
|
|
29371
|
-
|
|
29372
|
-
|
|
29326
|
+
const variants = new Map();
|
|
29327
|
+
let defaultVariant;
|
|
29328
|
+
// If there is not envelope then every variant needs to be a model.
|
|
29329
|
+
for (const variant of type.variants.values()) {
|
|
29330
|
+
if (typeof variant.name !== "string") {
|
|
29331
|
+
if (defaultVariant) {
|
|
29332
|
+
diagnostics.push(createDiagnostic({
|
|
29333
|
+
code: "invalid-discriminated-union-variant",
|
|
29334
|
+
messageId: "duplicateDefaultVariant",
|
|
29335
|
+
target: variant,
|
|
29336
|
+
}));
|
|
29337
|
+
}
|
|
29338
|
+
else {
|
|
29339
|
+
defaultVariant = variant.type;
|
|
29340
|
+
}
|
|
29341
|
+
continue;
|
|
29342
|
+
}
|
|
29343
|
+
variants.set(variant.name, variant.type);
|
|
29344
|
+
if (options.envelope === "none") {
|
|
29345
|
+
if (variant.type.kind !== "Model") {
|
|
29346
|
+
diagnostics.push(createDiagnostic({
|
|
29347
|
+
code: "invalid-discriminated-union-variant",
|
|
29348
|
+
messageId: "noEnvelopeModel",
|
|
29349
|
+
format: { name: variant.name.toString() },
|
|
29350
|
+
target: variant,
|
|
29351
|
+
}));
|
|
29352
|
+
continue;
|
|
29353
|
+
}
|
|
29354
|
+
const prop = variant.type.properties.get(options.discriminatorPropertyName);
|
|
29355
|
+
if (prop !== undefined) {
|
|
29356
|
+
const key = getStringValue(prop.type);
|
|
29357
|
+
if (key !== variant.name) {
|
|
29358
|
+
diagnostics.push(createDiagnostic({
|
|
29359
|
+
code: "invalid-discriminated-union-variant",
|
|
29360
|
+
messageId: "discriminantMismatch",
|
|
29361
|
+
format: {
|
|
29362
|
+
name: variant.name.toString(),
|
|
29363
|
+
discriminant: options.discriminatorPropertyName,
|
|
29364
|
+
propertyValue: key,
|
|
29365
|
+
variantName: String(variant.name),
|
|
29366
|
+
},
|
|
29367
|
+
target: variant.type,
|
|
29368
|
+
}));
|
|
29369
|
+
}
|
|
29370
|
+
}
|
|
29371
|
+
}
|
|
29372
|
+
}
|
|
29373
|
+
return [
|
|
29374
|
+
{
|
|
29375
|
+
type,
|
|
29376
|
+
options,
|
|
29377
|
+
variants,
|
|
29378
|
+
},
|
|
29379
|
+
diagnostics,
|
|
29380
|
+
];
|
|
29381
|
+
}
|
|
29382
|
+
function getDiscriminatedUnionFromInheritance(type, discriminator) {
|
|
29383
|
+
const variants = new Map();
|
|
29384
|
+
const diagnostics = [];
|
|
29385
|
+
const duplicates = new DuplicateTracker();
|
|
29386
|
+
function checkForVariantsIn(current) {
|
|
29387
|
+
for (const derivedModel of current.derivedModels) {
|
|
29388
|
+
if (isTemplateDeclarationOrInstance(derivedModel)) {
|
|
29389
|
+
continue; // Skip template instances as they should be used with `model is`
|
|
29390
|
+
}
|
|
29391
|
+
const keys = getDiscriminatorValues(derivedModel, discriminator, diagnostics);
|
|
29392
|
+
if (keys === undefined) {
|
|
29393
|
+
if (derivedModel.derivedModels.length === 0) {
|
|
29394
|
+
diagnostics.push(createDiagnostic({
|
|
29395
|
+
code: "missing-discriminator-property",
|
|
29396
|
+
format: { discriminator: discriminator.propertyName },
|
|
29397
|
+
target: derivedModel,
|
|
29398
|
+
}));
|
|
29399
|
+
}
|
|
29400
|
+
else {
|
|
29401
|
+
checkForVariantsIn(derivedModel);
|
|
29402
|
+
}
|
|
29403
|
+
}
|
|
29404
|
+
else {
|
|
29405
|
+
for (const key of keys) {
|
|
29406
|
+
duplicates.track(key, derivedModel);
|
|
29407
|
+
variants.set(key, derivedModel);
|
|
29408
|
+
}
|
|
29409
|
+
}
|
|
29410
|
+
}
|
|
29411
|
+
}
|
|
29412
|
+
checkForVariantsIn(type);
|
|
29413
|
+
reportDuplicateDiscriminatorValues(duplicates, diagnostics);
|
|
29414
|
+
const discriminatedUnion = {
|
|
29415
|
+
kind: "legacy",
|
|
29416
|
+
propertyName: discriminator.propertyName,
|
|
29417
|
+
variants,
|
|
29373
29418
|
};
|
|
29374
|
-
return
|
|
29419
|
+
return [discriminatedUnion, diagnostics];
|
|
29375
29420
|
}
|
|
29376
|
-
function
|
|
29377
|
-
|
|
29378
|
-
|
|
29379
|
-
|
|
29380
|
-
|
|
29421
|
+
function reportDuplicateDiscriminatorValues(duplicates, diagnostics) {
|
|
29422
|
+
for (const [duplicateKey, models] of duplicates.entries()) {
|
|
29423
|
+
for (const model of models) {
|
|
29424
|
+
diagnostics.push(createDiagnostic({
|
|
29425
|
+
code: "invalid-discriminator-value",
|
|
29426
|
+
messageId: "duplicate",
|
|
29427
|
+
format: { discriminator: duplicateKey },
|
|
29428
|
+
target: model,
|
|
29429
|
+
}));
|
|
29430
|
+
}
|
|
29431
|
+
}
|
|
29381
29432
|
}
|
|
29382
|
-
|
|
29383
|
-
const
|
|
29384
|
-
|
|
29385
|
-
|
|
29386
|
-
|
|
29433
|
+
function getDiscriminatorProperty(model, discriminator, diagnostics) {
|
|
29434
|
+
const prop = model.properties.get(discriminator.propertyName);
|
|
29435
|
+
if (prop && prop.optional) {
|
|
29436
|
+
diagnostics.push(createDiagnostic({
|
|
29437
|
+
code: "invalid-discriminator-value",
|
|
29438
|
+
messageId: "required",
|
|
29439
|
+
target: prop,
|
|
29440
|
+
}));
|
|
29441
|
+
}
|
|
29442
|
+
return prop;
|
|
29443
|
+
}
|
|
29444
|
+
function getDiscriminatorValues(model, discriminator, diagnostics) {
|
|
29445
|
+
const prop = getDiscriminatorProperty(model, discriminator, diagnostics);
|
|
29446
|
+
if (!prop)
|
|
29387
29447
|
return undefined;
|
|
29448
|
+
const keys = getStringValues(prop.type);
|
|
29449
|
+
if (keys.length === 0) {
|
|
29450
|
+
diagnostics.push(createDiagnostic({
|
|
29451
|
+
code: "invalid-discriminator-value",
|
|
29452
|
+
format: { kind: prop.type.kind },
|
|
29453
|
+
target: prop,
|
|
29454
|
+
}));
|
|
29388
29455
|
}
|
|
29389
|
-
|
|
29390
|
-
? `${mimeTypeObj.type}/${mimeTypeObj.suffix}`
|
|
29391
|
-
: mimeType;
|
|
29392
|
-
return getEncodedNamesMap(program, target)?.get(resolvedMimeType);
|
|
29456
|
+
return keys;
|
|
29393
29457
|
}
|
|
29394
|
-
|
|
29395
|
-
|
|
29396
|
-
|
|
29397
|
-
|
|
29398
|
-
|
|
29399
|
-
|
|
29400
|
-
|
|
29401
|
-
|
|
29402
|
-
|
|
29403
|
-
|
|
29404
|
-
|
|
29405
|
-
|
|
29406
|
-
|
|
29407
|
-
|
|
29408
|
-
|
|
29409
|
-
|
|
29410
|
-
|
|
29411
|
-
|
|
29412
|
-
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
function resolveEncodedName(program, target, mimeType) {
|
|
29418
|
-
return getEncodedName(program, target, mimeType) ?? target.name;
|
|
29458
|
+
function getStringValues(type) {
|
|
29459
|
+
switch (type.kind) {
|
|
29460
|
+
case "String":
|
|
29461
|
+
return [type.value];
|
|
29462
|
+
case "Union":
|
|
29463
|
+
return [...type.variants.values()].flatMap((x) => getStringValues(x.type)).filter(isDefined);
|
|
29464
|
+
case "EnumMember":
|
|
29465
|
+
return typeof type.value !== "number" ? [type.value ?? type.name] : [];
|
|
29466
|
+
case "UnionVariant":
|
|
29467
|
+
return getStringValues(type.type);
|
|
29468
|
+
default:
|
|
29469
|
+
return [];
|
|
29470
|
+
}
|
|
29471
|
+
}
|
|
29472
|
+
function getStringValue(type) {
|
|
29473
|
+
switch (type.kind) {
|
|
29474
|
+
case "String":
|
|
29475
|
+
return type.value;
|
|
29476
|
+
case "EnumMember":
|
|
29477
|
+
return typeof type.value !== "number" ? (type.value ?? type.name) : undefined;
|
|
29478
|
+
default:
|
|
29479
|
+
return undefined;
|
|
29480
|
+
}
|
|
29419
29481
|
}
|
|
29420
29482
|
|
|
29421
29483
|
//
|
|
@@ -30304,7 +30366,42 @@ var Token;
|
|
|
30304
30366
|
// Add new non-statement keyword above
|
|
30305
30367
|
/** @internal */ Token[Token["__EndKeyword"] = 80] = "__EndKeyword";
|
|
30306
30368
|
///////////////////////////////////////////////////////////////
|
|
30307
|
-
/** @internal */ Token[Token["
|
|
30369
|
+
/** @internal */ Token[Token["__StartReservedKeyword"] = 80] = "__StartReservedKeyword";
|
|
30370
|
+
///////////////////////////////////////////////////////////////
|
|
30371
|
+
// List of keywords that have special meaning in the language but are reserved for future use
|
|
30372
|
+
Token[Token["StatemachineKeyword"] = 80] = "StatemachineKeyword";
|
|
30373
|
+
Token[Token["MacroKeyword"] = 81] = "MacroKeyword";
|
|
30374
|
+
Token[Token["PackageKeyword"] = 82] = "PackageKeyword";
|
|
30375
|
+
Token[Token["MetadataKeyword"] = 83] = "MetadataKeyword";
|
|
30376
|
+
Token[Token["EnvKeyword"] = 84] = "EnvKeyword";
|
|
30377
|
+
Token[Token["ArgKeyword"] = 85] = "ArgKeyword";
|
|
30378
|
+
Token[Token["DeclareKeyword"] = 86] = "DeclareKeyword";
|
|
30379
|
+
Token[Token["ArrayKeyword"] = 87] = "ArrayKeyword";
|
|
30380
|
+
Token[Token["StructKeyword"] = 88] = "StructKeyword";
|
|
30381
|
+
Token[Token["RecordKeyword"] = 89] = "RecordKeyword";
|
|
30382
|
+
Token[Token["ModuleKeyword"] = 90] = "ModuleKeyword";
|
|
30383
|
+
Token[Token["TraitKeyword"] = 91] = "TraitKeyword";
|
|
30384
|
+
Token[Token["ThisKeyword"] = 92] = "ThisKeyword";
|
|
30385
|
+
Token[Token["SelfKeyword"] = 93] = "SelfKeyword";
|
|
30386
|
+
Token[Token["SuperKeyword"] = 94] = "SuperKeyword";
|
|
30387
|
+
Token[Token["KeyofKeyword"] = 95] = "KeyofKeyword";
|
|
30388
|
+
Token[Token["WithKeyword"] = 96] = "WithKeyword";
|
|
30389
|
+
Token[Token["ImplementsKeyword"] = 97] = "ImplementsKeyword";
|
|
30390
|
+
Token[Token["ImplKeyword"] = 98] = "ImplKeyword";
|
|
30391
|
+
Token[Token["SatisfiesKeyword"] = 99] = "SatisfiesKeyword";
|
|
30392
|
+
Token[Token["FlagKeyword"] = 100] = "FlagKeyword";
|
|
30393
|
+
Token[Token["AutoKeyword"] = 101] = "AutoKeyword";
|
|
30394
|
+
Token[Token["PartialKeyword"] = 102] = "PartialKeyword";
|
|
30395
|
+
Token[Token["PrivateKeyword"] = 103] = "PrivateKeyword";
|
|
30396
|
+
Token[Token["PublicKeyword"] = 104] = "PublicKeyword";
|
|
30397
|
+
Token[Token["ProtectedKeyword"] = 105] = "ProtectedKeyword";
|
|
30398
|
+
Token[Token["InternalKeyword"] = 106] = "InternalKeyword";
|
|
30399
|
+
Token[Token["SealedKeyword"] = 107] = "SealedKeyword";
|
|
30400
|
+
Token[Token["LocalKeyword"] = 108] = "LocalKeyword";
|
|
30401
|
+
Token[Token["AsyncKeyword"] = 109] = "AsyncKeyword";
|
|
30402
|
+
/** @internal */ Token[Token["__EndReservedKeyword"] = 110] = "__EndReservedKeyword";
|
|
30403
|
+
///////////////////////////////////////////////////////////////
|
|
30404
|
+
/** @internal */ Token[Token["__Count"] = 110] = "__Count";
|
|
30308
30405
|
})(Token || (Token = {}));
|
|
30309
30406
|
/** @internal */
|
|
30310
30407
|
getTokenDisplayTable([
|
|
@@ -30388,6 +30485,37 @@ getTokenDisplayTable([
|
|
|
30388
30485
|
[Token.NeverKeyword, "'never'"],
|
|
30389
30486
|
[Token.UnknownKeyword, "'unknown'"],
|
|
30390
30487
|
[Token.ExternKeyword, "'extern'"],
|
|
30488
|
+
// Reserved keywords
|
|
30489
|
+
[Token.StatemachineKeyword, "'statemachine'"],
|
|
30490
|
+
[Token.MacroKeyword, "'macro'"],
|
|
30491
|
+
[Token.PackageKeyword, "'package'"],
|
|
30492
|
+
[Token.MetadataKeyword, "'metadata'"],
|
|
30493
|
+
[Token.EnvKeyword, "'env'"],
|
|
30494
|
+
[Token.ArgKeyword, "'arg'"],
|
|
30495
|
+
[Token.DeclareKeyword, "'declare'"],
|
|
30496
|
+
[Token.ArrayKeyword, "'array'"],
|
|
30497
|
+
[Token.StructKeyword, "'struct'"],
|
|
30498
|
+
[Token.RecordKeyword, "'record'"],
|
|
30499
|
+
[Token.ModuleKeyword, "'module'"],
|
|
30500
|
+
[Token.TraitKeyword, "'trait'"],
|
|
30501
|
+
[Token.ThisKeyword, "'this'"],
|
|
30502
|
+
[Token.SelfKeyword, "'self'"],
|
|
30503
|
+
[Token.SuperKeyword, "'super'"],
|
|
30504
|
+
[Token.KeyofKeyword, "'keyof'"],
|
|
30505
|
+
[Token.WithKeyword, "'with'"],
|
|
30506
|
+
[Token.ImplementsKeyword, "'implements'"],
|
|
30507
|
+
[Token.ImplKeyword, "'impl'"],
|
|
30508
|
+
[Token.SatisfiesKeyword, "'satisfies'"],
|
|
30509
|
+
[Token.FlagKeyword, "'flag'"],
|
|
30510
|
+
[Token.AutoKeyword, "'auto'"],
|
|
30511
|
+
[Token.PartialKeyword, "'partial'"],
|
|
30512
|
+
[Token.PrivateKeyword, "'private'"],
|
|
30513
|
+
[Token.PublicKeyword, "'public'"],
|
|
30514
|
+
[Token.ProtectedKeyword, "'protected'"],
|
|
30515
|
+
[Token.InternalKeyword, "'internal'"],
|
|
30516
|
+
[Token.SealedKeyword, "'sealed'"],
|
|
30517
|
+
[Token.LocalKeyword, "'local'"],
|
|
30518
|
+
[Token.AsyncKeyword, "'async'"],
|
|
30391
30519
|
]);
|
|
30392
30520
|
/** @internal */
|
|
30393
30521
|
const Keywords = new Map([
|
|
@@ -30419,6 +30547,71 @@ const Keywords = new Map([
|
|
|
30419
30547
|
["never", Token.NeverKeyword],
|
|
30420
30548
|
["unknown", Token.UnknownKeyword],
|
|
30421
30549
|
["extern", Token.ExternKeyword],
|
|
30550
|
+
// Reserved keywords
|
|
30551
|
+
["statemachine", Token.StatemachineKeyword],
|
|
30552
|
+
["macro", Token.MacroKeyword],
|
|
30553
|
+
["package", Token.PackageKeyword],
|
|
30554
|
+
["metadata", Token.MetadataKeyword],
|
|
30555
|
+
["env", Token.EnvKeyword],
|
|
30556
|
+
["arg", Token.ArgKeyword],
|
|
30557
|
+
["declare", Token.DeclareKeyword],
|
|
30558
|
+
["array", Token.ArrayKeyword],
|
|
30559
|
+
["struct", Token.StructKeyword],
|
|
30560
|
+
["record", Token.RecordKeyword],
|
|
30561
|
+
["module", Token.ModuleKeyword],
|
|
30562
|
+
["trait", Token.TraitKeyword],
|
|
30563
|
+
["this", Token.ThisKeyword],
|
|
30564
|
+
["self", Token.SelfKeyword],
|
|
30565
|
+
["super", Token.SuperKeyword],
|
|
30566
|
+
["keyof", Token.KeyofKeyword],
|
|
30567
|
+
["with", Token.WithKeyword],
|
|
30568
|
+
["implements", Token.ImplementsKeyword],
|
|
30569
|
+
["impl", Token.ImplKeyword],
|
|
30570
|
+
["satisfies", Token.SatisfiesKeyword],
|
|
30571
|
+
["flag", Token.FlagKeyword],
|
|
30572
|
+
["auto", Token.AutoKeyword],
|
|
30573
|
+
["partial", Token.PartialKeyword],
|
|
30574
|
+
["private", Token.PrivateKeyword],
|
|
30575
|
+
["public", Token.PublicKeyword],
|
|
30576
|
+
["protected", Token.ProtectedKeyword],
|
|
30577
|
+
["internal", Token.InternalKeyword],
|
|
30578
|
+
["sealed", Token.SealedKeyword],
|
|
30579
|
+
["local", Token.LocalKeyword],
|
|
30580
|
+
["async", Token.AsyncKeyword],
|
|
30581
|
+
]);
|
|
30582
|
+
/** @internal */
|
|
30583
|
+
const ReservedKeywords = new Map([
|
|
30584
|
+
// Reserved keywords
|
|
30585
|
+
["statemachine", Token.StatemachineKeyword],
|
|
30586
|
+
["macro", Token.MacroKeyword],
|
|
30587
|
+
["package", Token.PackageKeyword],
|
|
30588
|
+
["metadata", Token.MetadataKeyword],
|
|
30589
|
+
["env", Token.EnvKeyword],
|
|
30590
|
+
["arg", Token.ArgKeyword],
|
|
30591
|
+
["declare", Token.DeclareKeyword],
|
|
30592
|
+
["array", Token.ArrayKeyword],
|
|
30593
|
+
["struct", Token.StructKeyword],
|
|
30594
|
+
["record", Token.RecordKeyword],
|
|
30595
|
+
["module", Token.ModuleKeyword],
|
|
30596
|
+
["trait", Token.TraitKeyword],
|
|
30597
|
+
["this", Token.ThisKeyword],
|
|
30598
|
+
["self", Token.SelfKeyword],
|
|
30599
|
+
["super", Token.SuperKeyword],
|
|
30600
|
+
["keyof", Token.KeyofKeyword],
|
|
30601
|
+
["with", Token.WithKeyword],
|
|
30602
|
+
["implements", Token.ImplementsKeyword],
|
|
30603
|
+
["impl", Token.ImplKeyword],
|
|
30604
|
+
["satisfies", Token.SatisfiesKeyword],
|
|
30605
|
+
["flag", Token.FlagKeyword],
|
|
30606
|
+
["auto", Token.AutoKeyword],
|
|
30607
|
+
["partial", Token.PartialKeyword],
|
|
30608
|
+
["private", Token.PrivateKeyword],
|
|
30609
|
+
["public", Token.PublicKeyword],
|
|
30610
|
+
["protected", Token.ProtectedKeyword],
|
|
30611
|
+
["internal", Token.InternalKeyword],
|
|
30612
|
+
["sealed", Token.SealedKeyword],
|
|
30613
|
+
["local", Token.LocalKeyword],
|
|
30614
|
+
["async", Token.AsyncKeyword],
|
|
30422
30615
|
]);
|
|
30423
30616
|
var TokenFlags;
|
|
30424
30617
|
(function (TokenFlags) {
|
|
@@ -30454,8 +30647,9 @@ function getTokenDisplayTable(entries) {
|
|
|
30454
30647
|
* printIdentifier("foo bar") // `foo bar`
|
|
30455
30648
|
* ```
|
|
30456
30649
|
*/
|
|
30457
|
-
function printIdentifier(sv
|
|
30458
|
-
|
|
30650
|
+
function printIdentifier(sv,
|
|
30651
|
+
/** @internal */ context = "disallow-reserved") {
|
|
30652
|
+
if (needBacktick(sv, context)) {
|
|
30459
30653
|
const escapedString = sv
|
|
30460
30654
|
.replace(/\\/g, "\\\\")
|
|
30461
30655
|
.replace(/\n/g, "\\n")
|
|
@@ -30468,10 +30662,13 @@ function printIdentifier(sv) {
|
|
|
30468
30662
|
return sv;
|
|
30469
30663
|
}
|
|
30470
30664
|
}
|
|
30471
|
-
function needBacktick(sv) {
|
|
30665
|
+
function needBacktick(sv, context) {
|
|
30472
30666
|
if (sv.length === 0) {
|
|
30473
30667
|
return false;
|
|
30474
30668
|
}
|
|
30669
|
+
if (context === "allow-reserved" && ReservedKeywords.has(sv)) {
|
|
30670
|
+
return false;
|
|
30671
|
+
}
|
|
30475
30672
|
if (Keywords.has(sv)) {
|
|
30476
30673
|
return true;
|
|
30477
30674
|
}
|
|
@@ -30678,11 +30875,76 @@ function getOperationName(op, options) {
|
|
|
30678
30875
|
function getIdentifierName(name, options) {
|
|
30679
30876
|
return options?.printable ? printIdentifier(name) : name;
|
|
30680
30877
|
}
|
|
30681
|
-
function getStringTemplateName(type) {
|
|
30682
|
-
if (type.stringValue) {
|
|
30683
|
-
return `"${type.stringValue}"`;
|
|
30878
|
+
function getStringTemplateName(type) {
|
|
30879
|
+
if (type.stringValue) {
|
|
30880
|
+
return `"${type.stringValue}"`;
|
|
30881
|
+
}
|
|
30882
|
+
return "string";
|
|
30883
|
+
}
|
|
30884
|
+
|
|
30885
|
+
const regex = /^(application|audio|font|example|image|message|model|multipart|text|video|x-(?:[0-9A-Za-z!#$%&'*+.^_`|~-]+))\/([0-9A-Za-z!#$%&'*+.^_`|~-]+)$/;
|
|
30886
|
+
function parseMimeType(mimeType) {
|
|
30887
|
+
const match = mimeType.match(regex);
|
|
30888
|
+
if (match == null) {
|
|
30889
|
+
return undefined;
|
|
30890
|
+
}
|
|
30891
|
+
const type = {
|
|
30892
|
+
type: match[1],
|
|
30893
|
+
...parseSubType(match[2]),
|
|
30894
|
+
};
|
|
30895
|
+
return type;
|
|
30896
|
+
}
|
|
30897
|
+
function parseSubType(value) {
|
|
30898
|
+
if (!value.includes("+"))
|
|
30899
|
+
return { subtype: value };
|
|
30900
|
+
const [subtype, suffix] = value.split("+", 2);
|
|
30901
|
+
return { subtype, suffix };
|
|
30902
|
+
}
|
|
30903
|
+
|
|
30904
|
+
const [getEncodedNamesMap, setEncodedNamesMap, getEncodedNamesStateMap] = useStateMap(createStateSymbol("encodedName"));
|
|
30905
|
+
function getEncodedName(program, target, mimeType) {
|
|
30906
|
+
const mimeTypeObj = parseMimeType(mimeType);
|
|
30907
|
+
if (mimeTypeObj === undefined) {
|
|
30908
|
+
return undefined;
|
|
30909
|
+
}
|
|
30910
|
+
const resolvedMimeType = mimeTypeObj?.suffix
|
|
30911
|
+
? `${mimeTypeObj.type}/${mimeTypeObj.suffix}`
|
|
30912
|
+
: mimeType;
|
|
30913
|
+
return getEncodedNamesMap(program, target)?.get(resolvedMimeType);
|
|
30914
|
+
}
|
|
30915
|
+
/**
|
|
30916
|
+
* Resolve the encoded name for the given type when serialized to the given mime type.
|
|
30917
|
+
* If a specific value was provided by `@encodedName` decorator for that mime type it will return that otherwise it will return the name of the type.
|
|
30918
|
+
*
|
|
30919
|
+
* @example
|
|
30920
|
+
*
|
|
30921
|
+
* For the given
|
|
30922
|
+
* ```tsp
|
|
30923
|
+
* model Certificate {
|
|
30924
|
+
* @encodedName("application/json", "exp")
|
|
30925
|
+
* @encodedName("application/xml", "expiry")
|
|
30926
|
+
* expireAt: utcDateTime;
|
|
30927
|
+
*
|
|
30928
|
+
* }
|
|
30929
|
+
* ```
|
|
30930
|
+
*
|
|
30931
|
+
* ```ts
|
|
30932
|
+
* resolveEncodedName(program, type, "application/json") // exp
|
|
30933
|
+
* resolveEncodedName(program, type, "application/merge-patch+json") // exp
|
|
30934
|
+
* resolveEncodedName(program, type, "application/xml") // expireAt
|
|
30935
|
+
* resolveEncodedName(program, type, "application/yaml") // expiry
|
|
30936
|
+
* ```
|
|
30937
|
+
*/
|
|
30938
|
+
function resolveEncodedName(program, target, mimeType) {
|
|
30939
|
+
return getEncodedName(program, target, mimeType) ?? target.name;
|
|
30940
|
+
}
|
|
30941
|
+
|
|
30942
|
+
function getLocationContext(program, type) {
|
|
30943
|
+
const sourceLocation = getSourceLocation(type);
|
|
30944
|
+
if (sourceLocation.isSynthetic) {
|
|
30945
|
+
return { type: "synthetic" };
|
|
30684
30946
|
}
|
|
30685
|
-
return
|
|
30947
|
+
return program.getSourceFileLocationContext(sourceLocation.file);
|
|
30686
30948
|
}
|
|
30687
30949
|
|
|
30688
30950
|
/**
|
|
@@ -30842,6 +31104,13 @@ defineKit({
|
|
|
30842
31104
|
}
|
|
30843
31105
|
return undefined;
|
|
30844
31106
|
},
|
|
31107
|
+
getDiscriminatedUnion(model) {
|
|
31108
|
+
const discriminator = getDiscriminator(this.program, model);
|
|
31109
|
+
if (!discriminator) {
|
|
31110
|
+
return undefined;
|
|
31111
|
+
}
|
|
31112
|
+
return ignoreDiagnostics(getDiscriminatedUnionFromInheritance(model, discriminator));
|
|
31113
|
+
},
|
|
30845
31114
|
},
|
|
30846
31115
|
});
|
|
30847
31116
|
|
|
@@ -30984,228 +31253,6 @@ function extendsStdType(typeName) {
|
|
|
30984
31253
|
};
|
|
30985
31254
|
}
|
|
30986
31255
|
|
|
30987
|
-
function getDiscriminatedUnion(typeOrProgram, typeOrDiscriminator) {
|
|
30988
|
-
if ("propertyName" in typeOrDiscriminator) {
|
|
30989
|
-
const type = typeOrProgram;
|
|
30990
|
-
switch (type.kind) {
|
|
30991
|
-
case "Model":
|
|
30992
|
-
return getDiscriminatedUnionFromInheritance(type, typeOrDiscriminator);
|
|
30993
|
-
case "Union":
|
|
30994
|
-
return getDiscriminatedUnionForUnionLegacy(type, typeOrDiscriminator);
|
|
30995
|
-
}
|
|
30996
|
-
}
|
|
30997
|
-
else {
|
|
30998
|
-
return getDiscriminatedUnionForUnion(typeOrProgram, typeOrDiscriminator);
|
|
30999
|
-
}
|
|
31000
|
-
}
|
|
31001
|
-
function getDiscriminatedUnionForUnion(program, type) {
|
|
31002
|
-
const options = getDiscriminatedOptions(program, type);
|
|
31003
|
-
const diagnostics = [];
|
|
31004
|
-
if (options === undefined) {
|
|
31005
|
-
return [undefined, []];
|
|
31006
|
-
}
|
|
31007
|
-
const variants = new Map();
|
|
31008
|
-
let defaultVariant;
|
|
31009
|
-
// If there is not envelope then every variant needs to be a model.
|
|
31010
|
-
for (const variant of type.variants.values()) {
|
|
31011
|
-
if (typeof variant.name !== "string") {
|
|
31012
|
-
if (defaultVariant) {
|
|
31013
|
-
diagnostics.push(createDiagnostic({
|
|
31014
|
-
code: "invalid-discriminated-union-variant",
|
|
31015
|
-
messageId: "duplicateDefaultVariant",
|
|
31016
|
-
target: variant,
|
|
31017
|
-
}));
|
|
31018
|
-
}
|
|
31019
|
-
else {
|
|
31020
|
-
defaultVariant = variant.type;
|
|
31021
|
-
}
|
|
31022
|
-
continue;
|
|
31023
|
-
}
|
|
31024
|
-
variants.set(variant.name, variant.type);
|
|
31025
|
-
if (options.envelope === "none") {
|
|
31026
|
-
if (variant.type.kind !== "Model") {
|
|
31027
|
-
diagnostics.push(createDiagnostic({
|
|
31028
|
-
code: "invalid-discriminated-union-variant",
|
|
31029
|
-
messageId: "noEnvelopeModel",
|
|
31030
|
-
format: { name: variant.name.toString() },
|
|
31031
|
-
target: variant,
|
|
31032
|
-
}));
|
|
31033
|
-
continue;
|
|
31034
|
-
}
|
|
31035
|
-
const prop = variant.type.properties.get(options.discriminatorPropertyName);
|
|
31036
|
-
if (prop !== undefined) {
|
|
31037
|
-
const key = getStringValue(prop.type);
|
|
31038
|
-
if (key !== variant.name) {
|
|
31039
|
-
diagnostics.push(createDiagnostic({
|
|
31040
|
-
code: "invalid-discriminated-union-variant",
|
|
31041
|
-
messageId: "discriminantMismatch",
|
|
31042
|
-
format: {
|
|
31043
|
-
name: variant.name.toString(),
|
|
31044
|
-
discriminant: options.discriminatorPropertyName,
|
|
31045
|
-
propertyValue: key,
|
|
31046
|
-
variantName: String(variant.name),
|
|
31047
|
-
},
|
|
31048
|
-
target: variant.type,
|
|
31049
|
-
}));
|
|
31050
|
-
}
|
|
31051
|
-
}
|
|
31052
|
-
}
|
|
31053
|
-
}
|
|
31054
|
-
return [
|
|
31055
|
-
{
|
|
31056
|
-
type,
|
|
31057
|
-
options,
|
|
31058
|
-
variants,
|
|
31059
|
-
},
|
|
31060
|
-
diagnostics,
|
|
31061
|
-
];
|
|
31062
|
-
}
|
|
31063
|
-
function getDiscriminatedUnionForUnionLegacy(type, discriminator) {
|
|
31064
|
-
const variants = new Map();
|
|
31065
|
-
const diagnostics = [];
|
|
31066
|
-
const duplicates = new DuplicateTracker();
|
|
31067
|
-
for (const variant of type.variants.values()) {
|
|
31068
|
-
if (variant.type.kind !== "Model") {
|
|
31069
|
-
diagnostics.push(createDiagnostic({
|
|
31070
|
-
code: "invalid-discriminated-union-variant",
|
|
31071
|
-
format: { name: variant.name.toString() },
|
|
31072
|
-
target: variant,
|
|
31073
|
-
}));
|
|
31074
|
-
continue;
|
|
31075
|
-
}
|
|
31076
|
-
const prop = getDiscriminatorProperty(variant.type, discriminator, diagnostics);
|
|
31077
|
-
if (prop === undefined) {
|
|
31078
|
-
diagnostics.push(createDiagnostic({
|
|
31079
|
-
code: "invalid-discriminated-union-variant",
|
|
31080
|
-
messageId: "noDiscriminant",
|
|
31081
|
-
format: { name: variant.name.toString(), discriminant: discriminator.propertyName },
|
|
31082
|
-
target: variant,
|
|
31083
|
-
}));
|
|
31084
|
-
continue;
|
|
31085
|
-
}
|
|
31086
|
-
const key = getStringValue(prop.type);
|
|
31087
|
-
if (key) {
|
|
31088
|
-
duplicates.track(key, variant.type);
|
|
31089
|
-
variants.set(key, variant.type);
|
|
31090
|
-
}
|
|
31091
|
-
else {
|
|
31092
|
-
diagnostics.push(createDiagnostic({
|
|
31093
|
-
code: "invalid-discriminated-union-variant",
|
|
31094
|
-
messageId: "wrongDiscriminantType",
|
|
31095
|
-
format: { name: variant.name.toString(), discriminant: discriminator.propertyName },
|
|
31096
|
-
target: variant.type,
|
|
31097
|
-
}));
|
|
31098
|
-
}
|
|
31099
|
-
}
|
|
31100
|
-
reportDuplicateDiscriminatorValues(duplicates, diagnostics);
|
|
31101
|
-
const discriminatedUnion = {
|
|
31102
|
-
kind: "legacy",
|
|
31103
|
-
propertyName: discriminator.propertyName,
|
|
31104
|
-
variants,
|
|
31105
|
-
};
|
|
31106
|
-
return [discriminatedUnion, diagnostics];
|
|
31107
|
-
}
|
|
31108
|
-
function getDiscriminatedUnionFromInheritance(type, discriminator) {
|
|
31109
|
-
const variants = new Map();
|
|
31110
|
-
const diagnostics = [];
|
|
31111
|
-
const duplicates = new DuplicateTracker();
|
|
31112
|
-
function checkForVariantsIn(current) {
|
|
31113
|
-
for (const derivedModel of current.derivedModels) {
|
|
31114
|
-
if (isTemplateDeclarationOrInstance(derivedModel)) {
|
|
31115
|
-
continue; // Skip template instances as they should be used with `model is`
|
|
31116
|
-
}
|
|
31117
|
-
const keys = getDiscriminatorValues(derivedModel, discriminator, diagnostics);
|
|
31118
|
-
if (keys === undefined) {
|
|
31119
|
-
if (derivedModel.derivedModels.length === 0) {
|
|
31120
|
-
diagnostics.push(createDiagnostic({
|
|
31121
|
-
code: "missing-discriminator-property",
|
|
31122
|
-
format: { discriminator: discriminator.propertyName },
|
|
31123
|
-
target: derivedModel,
|
|
31124
|
-
}));
|
|
31125
|
-
}
|
|
31126
|
-
else {
|
|
31127
|
-
checkForVariantsIn(derivedModel);
|
|
31128
|
-
}
|
|
31129
|
-
}
|
|
31130
|
-
else {
|
|
31131
|
-
for (const key of keys) {
|
|
31132
|
-
duplicates.track(key, derivedModel);
|
|
31133
|
-
variants.set(key, derivedModel);
|
|
31134
|
-
}
|
|
31135
|
-
}
|
|
31136
|
-
}
|
|
31137
|
-
}
|
|
31138
|
-
checkForVariantsIn(type);
|
|
31139
|
-
reportDuplicateDiscriminatorValues(duplicates, diagnostics);
|
|
31140
|
-
const discriminatedUnion = {
|
|
31141
|
-
kind: "legacy",
|
|
31142
|
-
propertyName: discriminator.propertyName,
|
|
31143
|
-
variants,
|
|
31144
|
-
};
|
|
31145
|
-
return [discriminatedUnion, diagnostics];
|
|
31146
|
-
}
|
|
31147
|
-
function reportDuplicateDiscriminatorValues(duplicates, diagnostics) {
|
|
31148
|
-
for (const [duplicateKey, models] of duplicates.entries()) {
|
|
31149
|
-
for (const model of models) {
|
|
31150
|
-
diagnostics.push(createDiagnostic({
|
|
31151
|
-
code: "invalid-discriminator-value",
|
|
31152
|
-
messageId: "duplicate",
|
|
31153
|
-
format: { discriminator: duplicateKey },
|
|
31154
|
-
target: model,
|
|
31155
|
-
}));
|
|
31156
|
-
}
|
|
31157
|
-
}
|
|
31158
|
-
}
|
|
31159
|
-
function getDiscriminatorProperty(model, discriminator, diagnostics) {
|
|
31160
|
-
const prop = model.properties.get(discriminator.propertyName);
|
|
31161
|
-
if (prop && prop.optional) {
|
|
31162
|
-
diagnostics.push(createDiagnostic({
|
|
31163
|
-
code: "invalid-discriminator-value",
|
|
31164
|
-
messageId: "required",
|
|
31165
|
-
target: prop,
|
|
31166
|
-
}));
|
|
31167
|
-
}
|
|
31168
|
-
return prop;
|
|
31169
|
-
}
|
|
31170
|
-
function getDiscriminatorValues(model, discriminator, diagnostics) {
|
|
31171
|
-
const prop = getDiscriminatorProperty(model, discriminator, diagnostics);
|
|
31172
|
-
if (!prop)
|
|
31173
|
-
return undefined;
|
|
31174
|
-
const keys = getStringValues(prop.type);
|
|
31175
|
-
if (keys.length === 0) {
|
|
31176
|
-
diagnostics.push(createDiagnostic({
|
|
31177
|
-
code: "invalid-discriminator-value",
|
|
31178
|
-
format: { kind: prop.type.kind },
|
|
31179
|
-
target: prop,
|
|
31180
|
-
}));
|
|
31181
|
-
}
|
|
31182
|
-
return keys;
|
|
31183
|
-
}
|
|
31184
|
-
function getStringValues(type) {
|
|
31185
|
-
switch (type.kind) {
|
|
31186
|
-
case "String":
|
|
31187
|
-
return [type.value];
|
|
31188
|
-
case "Union":
|
|
31189
|
-
return [...type.variants.values()].flatMap((x) => getStringValues(x.type)).filter(isDefined);
|
|
31190
|
-
case "EnumMember":
|
|
31191
|
-
return typeof type.value !== "number" ? [type.value ?? type.name] : [];
|
|
31192
|
-
case "UnionVariant":
|
|
31193
|
-
return getStringValues(type.type);
|
|
31194
|
-
default:
|
|
31195
|
-
return [];
|
|
31196
|
-
}
|
|
31197
|
-
}
|
|
31198
|
-
function getStringValue(type) {
|
|
31199
|
-
switch (type.kind) {
|
|
31200
|
-
case "String":
|
|
31201
|
-
return type.value;
|
|
31202
|
-
case "EnumMember":
|
|
31203
|
-
return typeof type.value !== "number" ? (type.value ?? type.name) : undefined;
|
|
31204
|
-
default:
|
|
31205
|
-
return undefined;
|
|
31206
|
-
}
|
|
31207
|
-
}
|
|
31208
|
-
|
|
31209
31256
|
/**
|
|
31210
31257
|
* Get a plausible name for the given type.
|
|
31211
31258
|
* @experimental
|
|
@@ -31271,15 +31318,12 @@ defineKit({
|
|
|
31271
31318
|
instantiationParameters: type.instantiationParameters
|
|
31272
31319
|
? [...type.instantiationParameters]
|
|
31273
31320
|
: undefined,
|
|
31274
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
31275
|
-
projections: [...type.projections],
|
|
31276
31321
|
models: copyMap(type.models),
|
|
31277
31322
|
decoratorDeclarations: copyMap(type.decoratorDeclarations),
|
|
31278
31323
|
enums: copyMap(type.enums),
|
|
31279
31324
|
unions: copyMap(type.unions),
|
|
31280
31325
|
operations: copyMap(type.operations),
|
|
31281
31326
|
interfaces: copyMap(type.interfaces),
|
|
31282
|
-
functionDeclarations: copyMap(type.functionDeclarations),
|
|
31283
31327
|
namespaces: copyMap(type.namespaces),
|
|
31284
31328
|
scalars: copyMap(type.scalars),
|
|
31285
31329
|
});
|
|
@@ -31318,11 +31362,18 @@ defineKit({
|
|
|
31318
31362
|
return getPlausibleName(type);
|
|
31319
31363
|
},
|
|
31320
31364
|
getDiscriminator(type) {
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31365
|
+
let discriminator;
|
|
31366
|
+
if ($$1.model.is(type)) {
|
|
31367
|
+
discriminator = getDiscriminator(this.program, type);
|
|
31368
|
+
}
|
|
31369
|
+
else {
|
|
31370
|
+
const unionDiscriminator = ignoreDiagnostics(getDiscriminatedUnion(this.program, type));
|
|
31371
|
+
const propertyName = unionDiscriminator?.options.discriminatorPropertyName;
|
|
31372
|
+
if (propertyName) {
|
|
31373
|
+
discriminator = { propertyName };
|
|
31374
|
+
}
|
|
31375
|
+
}
|
|
31376
|
+
return discriminator;
|
|
31326
31377
|
},
|
|
31327
31378
|
maxValue(type) {
|
|
31328
31379
|
return getMaxValue(this.program, type);
|
|
@@ -31446,6 +31497,9 @@ defineKit({
|
|
|
31446
31497
|
isExpression(type) {
|
|
31447
31498
|
return type.name === undefined || type.name === "";
|
|
31448
31499
|
},
|
|
31500
|
+
getDiscriminatedUnion(type) {
|
|
31501
|
+
return ignoreDiagnostics(getDiscriminatedUnion(this.program, type));
|
|
31502
|
+
},
|
|
31449
31503
|
},
|
|
31450
31504
|
});
|
|
31451
31505
|
|
|
@@ -31842,14 +31896,6 @@ class Realm {
|
|
|
31842
31896
|
}
|
|
31843
31897
|
_a = Realm;
|
|
31844
31898
|
|
|
31845
|
-
function getLocationContext(program, type) {
|
|
31846
|
-
const sourceLocation = getSourceLocation(type);
|
|
31847
|
-
if (sourceLocation.isSynthetic) {
|
|
31848
|
-
return { type: "synthetic" };
|
|
31849
|
-
}
|
|
31850
|
-
return program.getSourceFileLocationContext(sourceLocation.file);
|
|
31851
|
-
}
|
|
31852
|
-
|
|
31853
31899
|
/**
|
|
31854
31900
|
* The fixed set of options for each of the kinds of delimited lists in TypeSpec.
|
|
31855
31901
|
*/
|
|
@@ -31968,18 +32014,6 @@ var ListKind;
|
|
|
31968
32014
|
close: Token.CloseParen,
|
|
31969
32015
|
invalidAnnotationTarget: "expression",
|
|
31970
32016
|
};
|
|
31971
|
-
ListKind.ProjectionExpression = {
|
|
31972
|
-
...ExpresionsBase,
|
|
31973
|
-
allowEmpty: true,
|
|
31974
|
-
open: Token.OpenParen,
|
|
31975
|
-
close: Token.CloseParen,
|
|
31976
|
-
};
|
|
31977
|
-
ListKind.ProjectionParameter = {
|
|
31978
|
-
...ExpresionsBase,
|
|
31979
|
-
allowEmpty: true,
|
|
31980
|
-
open: Token.OpenParen,
|
|
31981
|
-
close: Token.CloseParen,
|
|
31982
|
-
};
|
|
31983
32017
|
})(ListKind || (ListKind = {}));
|
|
31984
32018
|
|
|
31985
32019
|
/**
|
|
@@ -32011,7 +32045,6 @@ var ListKind;
|
|
|
32011
32045
|
],
|
|
32012
32046
|
});
|
|
32013
32047
|
|
|
32014
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
32015
32048
|
var Related;
|
|
32016
32049
|
(function (Related) {
|
|
32017
32050
|
Related[Related["false"] = 0] = "false";
|
|
@@ -32020,7 +32053,6 @@ var Related;
|
|
|
32020
32053
|
})(Related || (Related = {}));
|
|
32021
32054
|
// #endregion
|
|
32022
32055
|
|
|
32023
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
32024
32056
|
/**
|
|
32025
32057
|
* Find all named models that could have been the source of the given
|
|
32026
32058
|
* property. This includes the named parents of all property sources in a
|
|
@@ -33521,11 +33553,6 @@ var CommentCheckFlags;
|
|
|
33521
33553
|
CommentCheckFlags[CommentCheckFlags["Last"] = 256] = "Last";
|
|
33522
33554
|
})(CommentCheckFlags || (CommentCheckFlags = {}));
|
|
33523
33555
|
|
|
33524
|
-
const globalLibraryUrlsLoadedSym = Symbol.for("TYPESPEC_LIBRARY_URLS_LOADED");
|
|
33525
|
-
if (globalThis[globalLibraryUrlsLoadedSym] === undefined) {
|
|
33526
|
-
globalThis[globalLibraryUrlsLoadedSym] = new Set();
|
|
33527
|
-
}
|
|
33528
|
-
|
|
33529
33556
|
// prettier-ignore
|
|
33530
33557
|
var UsageFlags;
|
|
33531
33558
|
(function (UsageFlags) {
|
|
@@ -33534,8 +33561,25 @@ var UsageFlags;
|
|
|
33534
33561
|
UsageFlags[UsageFlags["Output"] = 4] = "Output";
|
|
33535
33562
|
})(UsageFlags || (UsageFlags = {}));
|
|
33536
33563
|
|
|
33564
|
+
const globalLibraryUrlsLoadedSym = Symbol.for("TYPESPEC_LIBRARY_URLS_LOADED");
|
|
33565
|
+
if (globalThis[globalLibraryUrlsLoadedSym] === undefined) {
|
|
33566
|
+
globalThis[globalLibraryUrlsLoadedSym] = new Set();
|
|
33567
|
+
}
|
|
33568
|
+
|
|
33537
33569
|
const CompilerPackageRoot = undefined;
|
|
33538
33570
|
|
|
33571
|
+
let manifest;
|
|
33572
|
+
try {
|
|
33573
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
33574
|
+
// @ts-ignore
|
|
33575
|
+
manifest = (await import('../manifest-CrFWPTea.js')).default;
|
|
33576
|
+
}
|
|
33577
|
+
catch {
|
|
33578
|
+
const name = "../dist/manifest.js";
|
|
33579
|
+
manifest = (await import(/* @vite-ignore */ /* webpackIgnore: true */ name)).default;
|
|
33580
|
+
}
|
|
33581
|
+
manifest.version;
|
|
33582
|
+
|
|
33539
33583
|
var main$4 = {};
|
|
33540
33584
|
|
|
33541
33585
|
var api$2 = {};
|
|
@@ -44671,8 +44715,7 @@ const TypeConfig = {
|
|
|
44671
44715
|
operations: "nested",
|
|
44672
44716
|
unions: "nested",
|
|
44673
44717
|
enums: "nested",
|
|
44674
|
-
decoratorDeclarations: "nested"
|
|
44675
|
-
functionDeclarations: "nested"
|
|
44718
|
+
decoratorDeclarations: "nested"
|
|
44676
44719
|
},
|
|
44677
44720
|
Interface: {
|
|
44678
44721
|
operations: "nested",
|
|
@@ -44757,10 +44800,7 @@ const TypeConfig = {
|
|
|
44757
44800
|
default: "value"
|
|
44758
44801
|
},
|
|
44759
44802
|
// Don't want to expose those for now
|
|
44760
|
-
|
|
44761
|
-
Object: null,
|
|
44762
|
-
Intrinsic: null,
|
|
44763
|
-
Projection: null
|
|
44803
|
+
Intrinsic: null
|
|
44764
44804
|
};
|
|
44765
44805
|
const CommonPropsConfig = {
|
|
44766
44806
|
namespace: "parent"
|
|
@@ -44776,11 +44816,7 @@ const HiddenProps = [
|
|
|
44776
44816
|
"templateMapper",
|
|
44777
44817
|
"instantiationParameters",
|
|
44778
44818
|
"decorators",
|
|
44779
|
-
"projectionBase",
|
|
44780
|
-
"projectionsByName",
|
|
44781
|
-
"projectionSource",
|
|
44782
44819
|
"projector",
|
|
44783
|
-
"projections",
|
|
44784
44820
|
"isFinished"
|
|
44785
44821
|
];
|
|
44786
44822
|
new Set(HiddenProps);
|
|
@@ -44839,7 +44875,7 @@ function computeReferences(node) {
|
|
|
44839
44875
|
return { pathToNode, typeToPath };
|
|
44840
44876
|
}
|
|
44841
44877
|
function computeTree(program) {
|
|
44842
|
-
const root = program.
|
|
44878
|
+
const root = program.getGlobalNamespaceType();
|
|
44843
44879
|
const namespaces = expandNamespaces(root);
|
|
44844
44880
|
return {
|
|
44845
44881
|
kind: "list",
|