@typespec/prettier-plugin-typespec 0.54.0-dev.1 → 0.54.0-dev.2

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/index.js CHANGED
@@ -1,288 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * AST types
5
- */
6
- var SyntaxKind;
7
- (function (SyntaxKind) {
8
- SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
9
- /** @deprecated Use TypeSpecScript */
10
- SyntaxKind[SyntaxKind["CadlScript"] = 0] = "CadlScript";
11
- SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
12
- SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
13
- SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
14
- SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
15
- SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
16
- SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
17
- SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
18
- SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
19
- SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
20
- SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
21
- SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
22
- SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
23
- SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
24
- SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
25
- SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
26
- SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
27
- SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
28
- SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
29
- SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
30
- SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
31
- SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
32
- SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
33
- SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
34
- SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
35
- SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
36
- SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
37
- SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
38
- SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
39
- SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
40
- SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
41
- SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
42
- SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
43
- SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
44
- SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
45
- SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
46
- SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
47
- SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
48
- SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
49
- SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
50
- SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
51
- SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
52
- SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
53
- SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
54
- SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
55
- SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
56
- SyntaxKind[SyntaxKind["ProjectionReference"] = 46] = "ProjectionReference";
57
- SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 47] = "TemplateParameterDeclaration";
58
- SyntaxKind[SyntaxKind["EmptyStatement"] = 48] = "EmptyStatement";
59
- SyntaxKind[SyntaxKind["InvalidStatement"] = 49] = "InvalidStatement";
60
- SyntaxKind[SyntaxKind["LineComment"] = 50] = "LineComment";
61
- SyntaxKind[SyntaxKind["BlockComment"] = 51] = "BlockComment";
62
- SyntaxKind[SyntaxKind["Doc"] = 52] = "Doc";
63
- SyntaxKind[SyntaxKind["DocText"] = 53] = "DocText";
64
- SyntaxKind[SyntaxKind["DocParamTag"] = 54] = "DocParamTag";
65
- SyntaxKind[SyntaxKind["DocReturnsTag"] = 55] = "DocReturnsTag";
66
- SyntaxKind[SyntaxKind["DocErrorsTag"] = 56] = "DocErrorsTag";
67
- SyntaxKind[SyntaxKind["DocTemplateTag"] = 57] = "DocTemplateTag";
68
- SyntaxKind[SyntaxKind["DocUnknownTag"] = 58] = "DocUnknownTag";
69
- SyntaxKind[SyntaxKind["Projection"] = 59] = "Projection";
70
- SyntaxKind[SyntaxKind["ProjectionParameterDeclaration"] = 60] = "ProjectionParameterDeclaration";
71
- SyntaxKind[SyntaxKind["ProjectionModelSelector"] = 61] = "ProjectionModelSelector";
72
- SyntaxKind[SyntaxKind["ProjectionModelPropertySelector"] = 62] = "ProjectionModelPropertySelector";
73
- SyntaxKind[SyntaxKind["ProjectionOperationSelector"] = 63] = "ProjectionOperationSelector";
74
- SyntaxKind[SyntaxKind["ProjectionUnionSelector"] = 64] = "ProjectionUnionSelector";
75
- SyntaxKind[SyntaxKind["ProjectionUnionVariantSelector"] = 65] = "ProjectionUnionVariantSelector";
76
- SyntaxKind[SyntaxKind["ProjectionInterfaceSelector"] = 66] = "ProjectionInterfaceSelector";
77
- SyntaxKind[SyntaxKind["ProjectionEnumSelector"] = 67] = "ProjectionEnumSelector";
78
- SyntaxKind[SyntaxKind["ProjectionEnumMemberSelector"] = 68] = "ProjectionEnumMemberSelector";
79
- SyntaxKind[SyntaxKind["ProjectionExpressionStatement"] = 69] = "ProjectionExpressionStatement";
80
- SyntaxKind[SyntaxKind["ProjectionIfExpression"] = 70] = "ProjectionIfExpression";
81
- SyntaxKind[SyntaxKind["ProjectionBlockExpression"] = 71] = "ProjectionBlockExpression";
82
- SyntaxKind[SyntaxKind["ProjectionMemberExpression"] = 72] = "ProjectionMemberExpression";
83
- SyntaxKind[SyntaxKind["ProjectionLogicalExpression"] = 73] = "ProjectionLogicalExpression";
84
- SyntaxKind[SyntaxKind["ProjectionEqualityExpression"] = 74] = "ProjectionEqualityExpression";
85
- SyntaxKind[SyntaxKind["ProjectionUnaryExpression"] = 75] = "ProjectionUnaryExpression";
86
- SyntaxKind[SyntaxKind["ProjectionRelationalExpression"] = 76] = "ProjectionRelationalExpression";
87
- SyntaxKind[SyntaxKind["ProjectionArithmeticExpression"] = 77] = "ProjectionArithmeticExpression";
88
- SyntaxKind[SyntaxKind["ProjectionCallExpression"] = 78] = "ProjectionCallExpression";
89
- SyntaxKind[SyntaxKind["ProjectionLambdaExpression"] = 79] = "ProjectionLambdaExpression";
90
- SyntaxKind[SyntaxKind["ProjectionLambdaParameterDeclaration"] = 80] = "ProjectionLambdaParameterDeclaration";
91
- SyntaxKind[SyntaxKind["ProjectionModelExpression"] = 81] = "ProjectionModelExpression";
92
- SyntaxKind[SyntaxKind["ProjectionModelProperty"] = 82] = "ProjectionModelProperty";
93
- SyntaxKind[SyntaxKind["ProjectionModelSpreadProperty"] = 83] = "ProjectionModelSpreadProperty";
94
- SyntaxKind[SyntaxKind["ProjectionSpreadProperty"] = 84] = "ProjectionSpreadProperty";
95
- SyntaxKind[SyntaxKind["ProjectionTupleExpression"] = 85] = "ProjectionTupleExpression";
96
- SyntaxKind[SyntaxKind["ProjectionStatement"] = 86] = "ProjectionStatement";
97
- SyntaxKind[SyntaxKind["ProjectionDecoratorReferenceExpression"] = 87] = "ProjectionDecoratorReferenceExpression";
98
- SyntaxKind[SyntaxKind["Return"] = 88] = "Return";
99
- SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 89] = "JsNamespaceDeclaration";
100
- SyntaxKind[SyntaxKind["TemplateArgument"] = 90] = "TemplateArgument";
101
- })(SyntaxKind || (SyntaxKind = {}));
102
- var IdentifierKind;
103
- (function (IdentifierKind) {
104
- IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
105
- IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
106
- IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
107
- IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
108
- IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
109
- IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
110
- IdentifierKind[IdentifierKind["Other"] = 6] = "Other";
111
- })(IdentifierKind || (IdentifierKind = {}));
112
- /** Used to explicitly specify that a diagnostic has no target. */
113
- const NoTarget = Symbol.for("NoTarget");
114
- var ListenerFlow;
115
- (function (ListenerFlow) {
116
- /**
117
- * Do not navigate any containing or referenced type.
118
- */
119
- ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
120
- })(ListenerFlow || (ListenerFlow = {}));
121
-
122
- function createSourceFile(text, path) {
123
- let lineStarts = undefined;
124
- return {
125
- text,
126
- path,
127
- getLineStarts,
128
- getLineAndCharacterOfPosition,
129
- };
130
- function getLineStarts() {
131
- return (lineStarts = lineStarts !== null && lineStarts !== void 0 ? lineStarts : scanLineStarts(text));
132
- }
133
- function getLineAndCharacterOfPosition(position) {
134
- const starts = getLineStarts();
135
- let line = binarySearch(starts, position);
136
- // When binarySearch returns < 0 indicating that the value was not found, it
137
- // returns the bitwise complement of the index where the value would need to
138
- // be inserted to keep the array sorted. So flipping the bits back to this
139
- // positive index tells us what the line number would be if we were to
140
- // create a new line starting at the given position, and subtracting 1 from
141
- // that therefore gives us the line number we're after.
142
- if (line < 0) {
143
- line = ~line - 1;
144
- }
145
- return {
146
- line,
147
- character: position - starts[line],
148
- };
149
- }
150
- }
151
- function getSourceLocation(target, options = {}) {
152
- if (target === NoTarget || target === undefined) {
153
- return undefined;
154
- }
155
- if ("file" in target) {
156
- return target;
157
- }
158
- if (!("kind" in target)) {
159
- // symbol
160
- if (target.flags & 524288 /* SymbolFlags.Using */) {
161
- target = target.symbolSource;
162
- }
163
- if (!target.declarations[0]) {
164
- return createSyntheticSourceLocation();
165
- }
166
- return getSourceLocationOfNode(target.declarations[0], options);
167
- }
168
- else if (typeof target.kind === "number") {
169
- // node
170
- return getSourceLocationOfNode(target, options);
171
- }
172
- else {
173
- // type
174
- const targetNode = target.node;
175
- if (targetNode) {
176
- return getSourceLocationOfNode(targetNode, options);
177
- }
178
- return createSyntheticSourceLocation();
179
- }
180
- }
181
- function createSyntheticSourceLocation(loc = "<unknown location>") {
182
- return {
183
- file: createSourceFile("", loc),
184
- pos: 0,
185
- end: 0,
186
- isSynthetic: true,
187
- };
188
- }
189
- function getSourceLocationOfNode(node, options) {
190
- let root = node;
191
- while (root.parent !== undefined) {
192
- root = root.parent;
193
- }
194
- if (root.kind !== SyntaxKind.TypeSpecScript && root.kind !== SyntaxKind.JsSourceFile) {
195
- return createSyntheticSourceLocation(node.flags & 8 /* NodeFlags.Synthetic */
196
- ? undefined
197
- : "<unknown location - cannot obtain source location of unbound node - file bug at https://github.com/microsoft/typespec>");
198
- }
199
- if (options.locateId && "id" in node && node.id !== undefined) {
200
- node = node.id;
201
- }
202
- return {
203
- file: root.file,
204
- pos: node.pos,
205
- end: node.end,
206
- };
207
- }
208
- /**
209
- * Use this to report bugs in the compiler, and not errors in the source code
210
- * being compiled.
211
- *
212
- * @param condition Throw if this is not true.
213
- *
214
- * @param message Error message.
215
- *
216
- * @param target Optional location in source code that might give a clue about
217
- * what got the compiler off track.
218
- */
219
- function compilerAssert(condition, message, target) {
220
- if (condition) {
221
- return;
222
- }
223
- if (target) {
224
- let location;
225
- try {
226
- location = getSourceLocation(target);
227
- }
228
- catch (err) { }
229
- if (location) {
230
- const pos = location.file.getLineAndCharacterOfPosition(location.pos);
231
- const file = location.file.path;
232
- const line = pos.line + 1;
233
- const col = pos.character + 1;
234
- message += `\nOccurred while compiling code in ${file} near line ${line}, column ${col}`;
235
- }
236
- }
237
- throw new Error(message);
238
- }
239
- function scanLineStarts(text) {
240
- const starts = [];
241
- let start = 0;
242
- let pos = 0;
243
- while (pos < text.length) {
244
- const ch = text.charCodeAt(pos);
245
- pos++;
246
- switch (ch) {
247
- case 13 /* CharCode.CarriageReturn */:
248
- if (text.charCodeAt(pos) === 10 /* CharCode.LineFeed */) {
249
- pos++;
250
- }
251
- // fallthrough
252
- case 10 /* CharCode.LineFeed */:
253
- starts.push(start);
254
- start = pos;
255
- break;
256
- }
257
- }
258
- starts.push(start);
259
- return starts;
260
- }
261
- /**
262
- * Search sorted array of numbers for the given value. If found, return index
263
- * in array where value was found. If not found, return a negative number that
264
- * is the bitwise complement of the index where value would need to be inserted
265
- * to keep the array sorted.
266
- */
267
- function binarySearch(array, value) {
268
- let low = 0;
269
- let high = array.length - 1;
270
- while (low <= high) {
271
- const middle = low + ((high - low) >> 1);
272
- const v = array[middle];
273
- if (v < value) {
274
- low = middle + 1;
275
- }
276
- else if (v > value) {
277
- high = middle - 1;
278
- }
279
- else {
280
- return middle;
281
- }
282
- }
283
- return ~low;
284
- }
285
-
286
3
  /**
287
4
  * Create a new diagnostics creator.
288
5
  * @param diagnostics Map of the potential diagnostics.
@@ -1135,91 +852,381 @@ const diagnostics = {
1135
852
  },
1136
853
  },
1137
854
  /**
1138
- * Mutator
855
+ * Mutator
856
+ */
857
+ "add-response": {
858
+ severity: "error",
859
+ messages: {
860
+ default: "Cannot add a response to anything except an operation statement.",
861
+ },
862
+ },
863
+ "add-parameter": {
864
+ severity: "error",
865
+ messages: {
866
+ default: "Cannot add a parameter to anything except an operation statement.",
867
+ },
868
+ },
869
+ "add-model-property": {
870
+ severity: "error",
871
+ messages: {
872
+ default: "Cannot add a model property to anything except a model statement.",
873
+ },
874
+ },
875
+ "add-model-property-fail": {
876
+ severity: "error",
877
+ messages: {
878
+ default: paramMessage `Could not add property/parameter "${"propertyName"}" of type "${"propertyTypeName"}"`,
879
+ },
880
+ },
881
+ "add-response-type": {
882
+ severity: "error",
883
+ messages: {
884
+ default: paramMessage `Could not add response type "${"responseTypeName"}" to operation ${"operationName"}"`,
885
+ },
886
+ },
887
+ "circular-base-type": {
888
+ severity: "error",
889
+ messages: {
890
+ default: paramMessage `Type '${"typeName"}' recursively references itself as a base type.`,
891
+ },
892
+ },
893
+ "circular-constraint": {
894
+ severity: "error",
895
+ messages: {
896
+ default: paramMessage `Type parameter '${"typeName"}' has a circular constraint.`,
897
+ },
898
+ },
899
+ "circular-op-signature": {
900
+ severity: "error",
901
+ messages: {
902
+ default: paramMessage `Operation '${"typeName"}' recursively references itself.`,
903
+ },
904
+ },
905
+ "circular-alias-type": {
906
+ severity: "error",
907
+ messages: {
908
+ default: paramMessage `Alias type '${"typeName"}' recursively references itself.`,
909
+ },
910
+ },
911
+ "circular-prop": {
912
+ severity: "error",
913
+ messages: {
914
+ default: paramMessage `Property '${"propName"}' recursively references itself.`,
915
+ },
916
+ },
917
+ "conflict-marker": {
918
+ severity: "error",
919
+ messages: {
920
+ default: "Conflict marker encountered.",
921
+ },
922
+ },
923
+ // #region CLI
924
+ "no-compatible-vs-installed": {
925
+ severity: "error",
926
+ messages: {
927
+ default: "No compatible version of Visual Studio found.",
928
+ },
929
+ },
930
+ "vs-extension-windows-only": {
931
+ severity: "error",
932
+ messages: {
933
+ default: "Visual Studio extension is not supported on non-Windows.",
934
+ },
935
+ },
936
+ "vscode-in-path": {
937
+ severity: "error",
938
+ messages: {
939
+ default: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.",
940
+ osx: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.\nSee instruction for Mac OS here https://code.visualstudio.com/docs/setup/mac",
941
+ },
942
+ },
943
+ // #endregion CLI
944
+ };
945
+ const { createDiagnostic, reportDiagnostic } = createDiagnosticCreator(diagnostics);
946
+
947
+ function createSourceFile(text, path) {
948
+ let lineStarts = undefined;
949
+ return {
950
+ text,
951
+ path,
952
+ getLineStarts,
953
+ getLineAndCharacterOfPosition,
954
+ };
955
+ function getLineStarts() {
956
+ return (lineStarts = lineStarts !== null && lineStarts !== void 0 ? lineStarts : scanLineStarts(text));
957
+ }
958
+ function getLineAndCharacterOfPosition(position) {
959
+ const starts = getLineStarts();
960
+ let line = binarySearch(starts, position);
961
+ // When binarySearch returns < 0 indicating that the value was not found, it
962
+ // returns the bitwise complement of the index where the value would need to
963
+ // be inserted to keep the array sorted. So flipping the bits back to this
964
+ // positive index tells us what the line number would be if we were to
965
+ // create a new line starting at the given position, and subtracting 1 from
966
+ // that therefore gives us the line number we're after.
967
+ if (line < 0) {
968
+ line = ~line - 1;
969
+ }
970
+ return {
971
+ line,
972
+ character: position - starts[line],
973
+ };
974
+ }
975
+ }
976
+ function scanLineStarts(text) {
977
+ const starts = [];
978
+ let start = 0;
979
+ let pos = 0;
980
+ while (pos < text.length) {
981
+ const ch = text.charCodeAt(pos);
982
+ pos++;
983
+ switch (ch) {
984
+ case 13 /* CharCode.CarriageReturn */:
985
+ if (text.charCodeAt(pos) === 10 /* CharCode.LineFeed */) {
986
+ pos++;
987
+ }
988
+ // fallthrough
989
+ case 10 /* CharCode.LineFeed */:
990
+ starts.push(start);
991
+ start = pos;
992
+ break;
993
+ }
994
+ }
995
+ starts.push(start);
996
+ return starts;
997
+ }
998
+ /**
999
+ * Search sorted array of numbers for the given value. If found, return index
1000
+ * in array where value was found. If not found, return a negative number that
1001
+ * is the bitwise complement of the index where value would need to be inserted
1002
+ * to keep the array sorted.
1003
+ */
1004
+ function binarySearch(array, value) {
1005
+ let low = 0;
1006
+ let high = array.length - 1;
1007
+ while (low <= high) {
1008
+ const middle = low + ((high - low) >> 1);
1009
+ const v = array[middle];
1010
+ if (v < value) {
1011
+ low = middle + 1;
1012
+ }
1013
+ else if (v > value) {
1014
+ high = middle - 1;
1015
+ }
1016
+ else {
1017
+ return middle;
1018
+ }
1019
+ }
1020
+ return ~low;
1021
+ }
1022
+
1023
+ /**
1024
+ * AST types
1025
+ */
1026
+ var SyntaxKind;
1027
+ (function (SyntaxKind) {
1028
+ SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
1029
+ /** @deprecated Use TypeSpecScript */
1030
+ SyntaxKind[SyntaxKind["CadlScript"] = 0] = "CadlScript";
1031
+ SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
1032
+ SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
1033
+ SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
1034
+ SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
1035
+ SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
1036
+ SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
1037
+ SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
1038
+ SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
1039
+ SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
1040
+ SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
1041
+ SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
1042
+ SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
1043
+ SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
1044
+ SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
1045
+ SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
1046
+ SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
1047
+ SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
1048
+ SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
1049
+ SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
1050
+ SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
1051
+ SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
1052
+ SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
1053
+ SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
1054
+ SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
1055
+ SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
1056
+ SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
1057
+ SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
1058
+ SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
1059
+ SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
1060
+ SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
1061
+ SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
1062
+ SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
1063
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
1064
+ SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
1065
+ SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
1066
+ SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
1067
+ SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
1068
+ SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
1069
+ SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
1070
+ SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
1071
+ SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
1072
+ SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
1073
+ SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
1074
+ SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
1075
+ SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
1076
+ SyntaxKind[SyntaxKind["ProjectionReference"] = 46] = "ProjectionReference";
1077
+ SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 47] = "TemplateParameterDeclaration";
1078
+ SyntaxKind[SyntaxKind["EmptyStatement"] = 48] = "EmptyStatement";
1079
+ SyntaxKind[SyntaxKind["InvalidStatement"] = 49] = "InvalidStatement";
1080
+ SyntaxKind[SyntaxKind["LineComment"] = 50] = "LineComment";
1081
+ SyntaxKind[SyntaxKind["BlockComment"] = 51] = "BlockComment";
1082
+ SyntaxKind[SyntaxKind["Doc"] = 52] = "Doc";
1083
+ SyntaxKind[SyntaxKind["DocText"] = 53] = "DocText";
1084
+ SyntaxKind[SyntaxKind["DocParamTag"] = 54] = "DocParamTag";
1085
+ SyntaxKind[SyntaxKind["DocReturnsTag"] = 55] = "DocReturnsTag";
1086
+ SyntaxKind[SyntaxKind["DocErrorsTag"] = 56] = "DocErrorsTag";
1087
+ SyntaxKind[SyntaxKind["DocTemplateTag"] = 57] = "DocTemplateTag";
1088
+ SyntaxKind[SyntaxKind["DocUnknownTag"] = 58] = "DocUnknownTag";
1089
+ SyntaxKind[SyntaxKind["Projection"] = 59] = "Projection";
1090
+ SyntaxKind[SyntaxKind["ProjectionParameterDeclaration"] = 60] = "ProjectionParameterDeclaration";
1091
+ SyntaxKind[SyntaxKind["ProjectionModelSelector"] = 61] = "ProjectionModelSelector";
1092
+ SyntaxKind[SyntaxKind["ProjectionModelPropertySelector"] = 62] = "ProjectionModelPropertySelector";
1093
+ SyntaxKind[SyntaxKind["ProjectionOperationSelector"] = 63] = "ProjectionOperationSelector";
1094
+ SyntaxKind[SyntaxKind["ProjectionUnionSelector"] = 64] = "ProjectionUnionSelector";
1095
+ SyntaxKind[SyntaxKind["ProjectionUnionVariantSelector"] = 65] = "ProjectionUnionVariantSelector";
1096
+ SyntaxKind[SyntaxKind["ProjectionInterfaceSelector"] = 66] = "ProjectionInterfaceSelector";
1097
+ SyntaxKind[SyntaxKind["ProjectionEnumSelector"] = 67] = "ProjectionEnumSelector";
1098
+ SyntaxKind[SyntaxKind["ProjectionEnumMemberSelector"] = 68] = "ProjectionEnumMemberSelector";
1099
+ SyntaxKind[SyntaxKind["ProjectionExpressionStatement"] = 69] = "ProjectionExpressionStatement";
1100
+ SyntaxKind[SyntaxKind["ProjectionIfExpression"] = 70] = "ProjectionIfExpression";
1101
+ SyntaxKind[SyntaxKind["ProjectionBlockExpression"] = 71] = "ProjectionBlockExpression";
1102
+ SyntaxKind[SyntaxKind["ProjectionMemberExpression"] = 72] = "ProjectionMemberExpression";
1103
+ SyntaxKind[SyntaxKind["ProjectionLogicalExpression"] = 73] = "ProjectionLogicalExpression";
1104
+ SyntaxKind[SyntaxKind["ProjectionEqualityExpression"] = 74] = "ProjectionEqualityExpression";
1105
+ SyntaxKind[SyntaxKind["ProjectionUnaryExpression"] = 75] = "ProjectionUnaryExpression";
1106
+ SyntaxKind[SyntaxKind["ProjectionRelationalExpression"] = 76] = "ProjectionRelationalExpression";
1107
+ SyntaxKind[SyntaxKind["ProjectionArithmeticExpression"] = 77] = "ProjectionArithmeticExpression";
1108
+ SyntaxKind[SyntaxKind["ProjectionCallExpression"] = 78] = "ProjectionCallExpression";
1109
+ SyntaxKind[SyntaxKind["ProjectionLambdaExpression"] = 79] = "ProjectionLambdaExpression";
1110
+ SyntaxKind[SyntaxKind["ProjectionLambdaParameterDeclaration"] = 80] = "ProjectionLambdaParameterDeclaration";
1111
+ SyntaxKind[SyntaxKind["ProjectionModelExpression"] = 81] = "ProjectionModelExpression";
1112
+ SyntaxKind[SyntaxKind["ProjectionModelProperty"] = 82] = "ProjectionModelProperty";
1113
+ SyntaxKind[SyntaxKind["ProjectionModelSpreadProperty"] = 83] = "ProjectionModelSpreadProperty";
1114
+ SyntaxKind[SyntaxKind["ProjectionSpreadProperty"] = 84] = "ProjectionSpreadProperty";
1115
+ SyntaxKind[SyntaxKind["ProjectionTupleExpression"] = 85] = "ProjectionTupleExpression";
1116
+ SyntaxKind[SyntaxKind["ProjectionStatement"] = 86] = "ProjectionStatement";
1117
+ SyntaxKind[SyntaxKind["ProjectionDecoratorReferenceExpression"] = 87] = "ProjectionDecoratorReferenceExpression";
1118
+ SyntaxKind[SyntaxKind["Return"] = 88] = "Return";
1119
+ SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 89] = "JsNamespaceDeclaration";
1120
+ SyntaxKind[SyntaxKind["TemplateArgument"] = 90] = "TemplateArgument";
1121
+ })(SyntaxKind || (SyntaxKind = {}));
1122
+ var IdentifierKind;
1123
+ (function (IdentifierKind) {
1124
+ IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
1125
+ IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
1126
+ IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
1127
+ IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
1128
+ IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
1129
+ IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
1130
+ IdentifierKind[IdentifierKind["Other"] = 6] = "Other";
1131
+ })(IdentifierKind || (IdentifierKind = {}));
1132
+ /** Used to explicitly specify that a diagnostic has no target. */
1133
+ const NoTarget = Symbol.for("NoTarget");
1134
+ var ListenerFlow;
1135
+ (function (ListenerFlow) {
1136
+ /**
1137
+ * Do not navigate any containing or referenced type.
1139
1138
  */
1140
- "add-response": {
1141
- severity: "error",
1142
- messages: {
1143
- default: "Cannot add a response to anything except an operation statement.",
1144
- },
1145
- },
1146
- "add-parameter": {
1147
- severity: "error",
1148
- messages: {
1149
- default: "Cannot add a parameter to anything except an operation statement.",
1150
- },
1151
- },
1152
- "add-model-property": {
1153
- severity: "error",
1154
- messages: {
1155
- default: "Cannot add a model property to anything except a model statement.",
1156
- },
1157
- },
1158
- "add-model-property-fail": {
1159
- severity: "error",
1160
- messages: {
1161
- default: paramMessage `Could not add property/parameter "${"propertyName"}" of type "${"propertyTypeName"}"`,
1162
- },
1163
- },
1164
- "add-response-type": {
1165
- severity: "error",
1166
- messages: {
1167
- default: paramMessage `Could not add response type "${"responseTypeName"}" to operation ${"operationName"}"`,
1168
- },
1169
- },
1170
- "circular-base-type": {
1171
- severity: "error",
1172
- messages: {
1173
- default: paramMessage `Type '${"typeName"}' recursively references itself as a base type.`,
1174
- },
1175
- },
1176
- "circular-op-signature": {
1177
- severity: "error",
1178
- messages: {
1179
- default: paramMessage `Operation '${"typeName"}' recursively references itself.`,
1180
- },
1181
- },
1182
- "circular-alias-type": {
1183
- severity: "error",
1184
- messages: {
1185
- default: paramMessage `Alias type '${"typeName"}' recursively references itself.`,
1186
- },
1187
- },
1188
- "circular-prop": {
1189
- severity: "error",
1190
- messages: {
1191
- default: paramMessage `Property '${"propName"}' recursively references itself.`,
1192
- },
1193
- },
1194
- "conflict-marker": {
1195
- severity: "error",
1196
- messages: {
1197
- default: "Conflict marker encountered.",
1198
- },
1199
- },
1200
- // #region CLI
1201
- "no-compatible-vs-installed": {
1202
- severity: "error",
1203
- messages: {
1204
- default: "No compatible version of Visual Studio found.",
1205
- },
1206
- },
1207
- "vs-extension-windows-only": {
1208
- severity: "error",
1209
- messages: {
1210
- default: "Visual Studio extension is not supported on non-Windows.",
1211
- },
1212
- },
1213
- "vscode-in-path": {
1214
- severity: "error",
1215
- messages: {
1216
- default: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.",
1217
- osx: "Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.\nSee instruction for Mac OS here https://code.visualstudio.com/docs/setup/mac",
1218
- },
1219
- },
1220
- // #endregion CLI
1221
- };
1222
- const { createDiagnostic, reportDiagnostic } = createDiagnosticCreator(diagnostics);
1139
+ ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
1140
+ })(ListenerFlow || (ListenerFlow = {}));
1141
+
1142
+ function getSourceLocation(target, options = {}) {
1143
+ if (target === NoTarget || target === undefined) {
1144
+ return undefined;
1145
+ }
1146
+ if ("file" in target) {
1147
+ return target;
1148
+ }
1149
+ if (!("kind" in target)) {
1150
+ // symbol
1151
+ if (target.flags & 524288 /* SymbolFlags.Using */) {
1152
+ target = target.symbolSource;
1153
+ }
1154
+ if (!target.declarations[0]) {
1155
+ return createSyntheticSourceLocation();
1156
+ }
1157
+ return getSourceLocationOfNode(target.declarations[0], options);
1158
+ }
1159
+ else if (typeof target.kind === "number") {
1160
+ // node
1161
+ return getSourceLocationOfNode(target, options);
1162
+ }
1163
+ else {
1164
+ // type
1165
+ const targetNode = target.node;
1166
+ if (targetNode) {
1167
+ return getSourceLocationOfNode(targetNode, options);
1168
+ }
1169
+ return createSyntheticSourceLocation();
1170
+ }
1171
+ }
1172
+ function createSyntheticSourceLocation(loc = "<unknown location>") {
1173
+ return {
1174
+ file: createSourceFile("", loc),
1175
+ pos: 0,
1176
+ end: 0,
1177
+ isSynthetic: true,
1178
+ };
1179
+ }
1180
+ function getSourceLocationOfNode(node, options) {
1181
+ let root = node;
1182
+ while (root.parent !== undefined) {
1183
+ root = root.parent;
1184
+ }
1185
+ if (root.kind !== SyntaxKind.TypeSpecScript && root.kind !== SyntaxKind.JsSourceFile) {
1186
+ return createSyntheticSourceLocation(node.flags & 8 /* NodeFlags.Synthetic */
1187
+ ? undefined
1188
+ : "<unknown location - cannot obtain source location of unbound node - file bug at https://github.com/microsoft/typespec>");
1189
+ }
1190
+ if (options.locateId && "id" in node && node.id !== undefined) {
1191
+ node = node.id;
1192
+ }
1193
+ return {
1194
+ file: root.file,
1195
+ pos: node.pos,
1196
+ end: node.end,
1197
+ };
1198
+ }
1199
+ /**
1200
+ * Use this to report bugs in the compiler, and not errors in the source code
1201
+ * being compiled.
1202
+ *
1203
+ * @param condition Throw if this is not true.
1204
+ *
1205
+ * @param message Error message.
1206
+ *
1207
+ * @param target Optional location in source code that might give a clue about
1208
+ * what got the compiler off track.
1209
+ */
1210
+ function compilerAssert(condition, message, target) {
1211
+ if (condition) {
1212
+ return;
1213
+ }
1214
+ if (target) {
1215
+ let location;
1216
+ try {
1217
+ location = getSourceLocation(target);
1218
+ }
1219
+ catch (err) { }
1220
+ if (location) {
1221
+ const pos = location.file.getLineAndCharacterOfPosition(location.pos);
1222
+ const file = location.file.path;
1223
+ const line = pos.line + 1;
1224
+ const col = pos.character + 1;
1225
+ message += `\nOccurred while compiling code in ${file} near line ${line}, column ${col}`;
1226
+ }
1227
+ }
1228
+ throw new Error(message);
1229
+ }
1223
1230
 
1224
1231
  (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1225
1232
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -4563,8 +4570,7 @@ function needsParens(path, options) {
4563
4570
  if (!parent) {
4564
4571
  return false;
4565
4572
  }
4566
- // eslint-disable-next-line deprecation/deprecation
4567
- const node = path.getValue();
4573
+ const node = path.node;
4568
4574
  switch (node.kind) {
4569
4575
  case SyntaxKind.ValueOfExpression:
4570
4576
  return (parent.kind === SyntaxKind.UnionExpression ||
@@ -4604,7 +4610,7 @@ const typespecPrinter = {
4604
4610
  function printTypeSpec(
4605
4611
  // Path to the AST node to print
4606
4612
  path, options, print) {
4607
- const node = path.getValue();
4613
+ const node = path.node;
4608
4614
  const docs = printDocComments(path, options, print);
4609
4615
  const directives = shouldPrintDirective(node) ? printDirectives(path, options, print) : "";
4610
4616
  const printedNode = printNode(path, options, print);
@@ -4625,7 +4631,7 @@ function shouldPrintDirective(node) {
4625
4631
  function printNode(
4626
4632
  // Path to the AST node to print
4627
4633
  path, options, print) {
4628
- const node = path.getValue();
4634
+ const node = path.node;
4629
4635
  switch (node.kind) {
4630
4636
  // Root
4631
4637
  case SyntaxKind.TypeSpecScript:
@@ -4797,7 +4803,7 @@ path, options, print) {
4797
4803
  }
4798
4804
  }
4799
4805
  function printTypeSpecScript(path, options, print) {
4800
- const node = path.getValue();
4806
+ const node = path.node;
4801
4807
  const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
4802
4808
  const body = [];
4803
4809
  if (nodeHasComments) {
@@ -4812,7 +4818,7 @@ function printAliasStatement(path, options, print) {
4812
4818
  return ["alias ", id, template, " = ", path.call(print, "value"), ";"];
4813
4819
  }
4814
4820
  function printTemplateParameters(path, options, print, propertyName) {
4815
- const node = path.getValue();
4821
+ const node = path.node;
4816
4822
  const args = node[propertyName];
4817
4823
  if (args.length === 0) {
4818
4824
  return "";
@@ -4840,7 +4846,7 @@ function canAttachComment(node) {
4840
4846
  !(node.flags & 8 /* NodeFlags.Synthetic */));
4841
4847
  }
4842
4848
  function printComment(commentPath, options) {
4843
- const comment = commentPath.getValue();
4849
+ const comment = commentPath.node;
4844
4850
  comment.printed = true;
4845
4851
  switch (comment.kind) {
4846
4852
  case SyntaxKind.BlockComment:
@@ -4852,7 +4858,7 @@ function printComment(commentPath, options) {
4852
4858
  }
4853
4859
  }
4854
4860
  function printBlockComment(commentPath, options) {
4855
- const comment = commentPath.getValue();
4861
+ const comment = commentPath.node;
4856
4862
  const rawComment = options.originalText.slice(comment.pos + 2, comment.end - 2);
4857
4863
  const printed = isIndentableBlockComment(rawComment)
4858
4864
  ? printIndentableBlockCommentContent(rawComment)
@@ -4877,7 +4883,7 @@ function printIndentableBlockCommentContent(rawComment) {
4877
4883
  }
4878
4884
  /** Print a doc comment. */
4879
4885
  function printDoc(path, options, print) {
4880
- const node = path.getValue();
4886
+ const node = path.node;
4881
4887
  const rawComment = options.originalText.slice(node.pos + 3, node.end - 2);
4882
4888
  const printed = isIndentableBlockComment(rawComment)
4883
4889
  ? printIndentableBlockCommentContent(rawComment)
@@ -4887,7 +4893,7 @@ function printDoc(path, options, print) {
4887
4893
  return ["/**", printed, "*/"];
4888
4894
  }
4889
4895
  function printDecorators(path, options, print, { tryInline }) {
4890
- const node = path.getValue();
4896
+ const node = path.node;
4891
4897
  if (node.decorators.length === 0) {
4892
4898
  return { decorators: "", multiline: false };
4893
4899
  }
@@ -4900,7 +4906,7 @@ function printDecorators(path, options, print, { tryInline }) {
4900
4906
  }
4901
4907
  /** Check if the decorators of the given node should be broken in sparate line */
4902
4908
  function shouldDecoratorBreakLine(path, options, { tryInline }) {
4903
- const node = path.getValue();
4909
+ const node = path.node;
4904
4910
  return (!tryInline || node.decorators.length >= 3 || hasNewlineBetweenOrAfterDecorators(node, options));
4905
4911
  }
4906
4912
  /**
@@ -4931,7 +4937,7 @@ function printAugmentDecoratorArgs(path, options, print) {
4931
4937
  ];
4932
4938
  }
4933
4939
  function printDocComments(path, options, print) {
4934
- const node = path.getValue();
4940
+ const node = path.node;
4935
4941
  if (node.docs === undefined || node.docs.length === 0) {
4936
4942
  return "";
4937
4943
  }
@@ -4939,7 +4945,7 @@ function printDocComments(path, options, print) {
4939
4945
  return group([...docs, breakParent]);
4940
4946
  }
4941
4947
  function printDirectives(path, options, print) {
4942
- const node = path.getValue();
4948
+ const node = path.node;
4943
4949
  if (node.directives === undefined || node.directives.length === 0) {
4944
4950
  return "";
4945
4951
  }
@@ -4951,7 +4957,7 @@ function printDirective(path, options, print) {
4951
4957
  return ["#", path.call(print, "target"), " ", args];
4952
4958
  }
4953
4959
  function printDecoratorArgs(path, options, print) {
4954
- const node = path.getValue();
4960
+ const node = path.node;
4955
4961
  if (node.arguments.length === 0) {
4956
4962
  return "";
4957
4963
  }
@@ -4979,7 +4985,7 @@ function printDecoratorArgs(path, options, print) {
4979
4985
  ];
4980
4986
  }
4981
4987
  function printDirectiveArgs(path, options, print) {
4982
- const node = path.getValue();
4988
+ const node = path.node;
4983
4989
  if (node.arguments.length === 0) {
4984
4990
  return "";
4985
4991
  }
@@ -4991,7 +4997,7 @@ function printEnumStatement(path, options, print) {
4991
4997
  return [decorators, "enum ", id, " ", printEnumBlock(path, options, print)];
4992
4998
  }
4993
4999
  function printEnumBlock(path, options, print) {
4994
- const node = path.getValue();
5000
+ const node = path.node;
4995
5001
  if (node.members.length === 0) {
4996
5002
  return "{}";
4997
5003
  }
@@ -4999,7 +5005,7 @@ function printEnumBlock(path, options, print) {
4999
5005
  return group(["{", indent(body), hardline, "}"]);
5000
5006
  }
5001
5007
  function printEnumMember(path, options, print) {
5002
- const node = path.getValue();
5008
+ const node = path.node;
5003
5009
  const id = path.call(print, "id");
5004
5010
  const value = node.value ? [": ", path.call(print, "value")] : "";
5005
5011
  const { decorators } = printDecorators(path, options, print, {
@@ -5017,7 +5023,7 @@ function printUnionStatement(path, options, print) {
5017
5023
  return [decorators, "union ", id, generic, " ", printUnionVariantsBlock(path, options, print)];
5018
5024
  }
5019
5025
  function printUnionVariantsBlock(path, options, print) {
5020
- const node = path.getValue();
5026
+ const node = path.node;
5021
5027
  if (node.options.length === 0) {
5022
5028
  return "{}";
5023
5029
  }
@@ -5047,7 +5053,7 @@ function printInterfaceStatement(path, options, print) {
5047
5053
  ];
5048
5054
  }
5049
5055
  function printInterfaceExtends(path, options, print) {
5050
- const node = path.getValue();
5056
+ const node = path.node;
5051
5057
  if (node.extends.length === 0) {
5052
5058
  return "";
5053
5059
  }
@@ -5055,7 +5061,7 @@ function printInterfaceExtends(path, options, print) {
5055
5061
  return [group(indent([line, keyword, indent(join([",", line], path.map(print, "extends")))]))];
5056
5062
  }
5057
5063
  function printInterfaceMembers(path, options, print) {
5058
- const node = path.getValue();
5064
+ const node = path.node;
5059
5065
  const hasOperations = node.operations.length > 0;
5060
5066
  const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
5061
5067
  if (!hasOperations && !nodeHasComments) {
@@ -5064,7 +5070,7 @@ function printInterfaceMembers(path, options, print) {
5064
5070
  const lastOperation = node.operations[node.operations.length - 1];
5065
5071
  const parts = [];
5066
5072
  path.each((operationPath) => {
5067
- const node = operationPath.getValue();
5073
+ const node = operationPath.node;
5068
5074
  const printed = print(operationPath);
5069
5075
  parts.push(printed);
5070
5076
  if (node !== lastOperation) {
@@ -5081,13 +5087,13 @@ function printInterfaceMembers(path, options, print) {
5081
5087
  return group(["{", indent(body), hardline, "}"]);
5082
5088
  }
5083
5089
  function printDanglingComments(path, options, { sameIndent }) {
5084
- const node = path.getValue();
5090
+ const node = path.node;
5085
5091
  const parts = [];
5086
5092
  if (!node || !node.comments) {
5087
5093
  return "";
5088
5094
  }
5089
5095
  path.each((commentPath) => {
5090
- const comment = commentPath.getValue();
5096
+ const comment = commentPath.node;
5091
5097
  if (!comment.leading && !comment.trailing) {
5092
5098
  parts.push(printComment(path, options));
5093
5099
  }
@@ -5110,7 +5116,7 @@ function printDanglingComments(path, options, { sameIndent }) {
5110
5116
  * @returns Prettier document.
5111
5117
  */
5112
5118
  function printIntersection(path, options, print) {
5113
- const node = path.getValue();
5119
+ const node = path.node;
5114
5120
  const types = path.map(print, "options");
5115
5121
  const result = [];
5116
5122
  let wasIndented = false;
@@ -5151,12 +5157,12 @@ function printTuple(path, options, print) {
5151
5157
  ]);
5152
5158
  }
5153
5159
  function printMemberExpression(path, options, print) {
5154
- const node = path.getValue();
5160
+ const node = path.node;
5155
5161
  return [node.base ? [path.call(print, "base"), node.selector] : "", path.call(print, "id")];
5156
5162
  }
5157
5163
  function printModelExpression(path, options, print) {
5158
5164
  const inBlock = isModelExpressionInBlock(path);
5159
- const node = path.getValue();
5165
+ const node = path.node;
5160
5166
  if (inBlock) {
5161
5167
  return group(printModelPropertiesBlock(path, options, print));
5162
5168
  }
@@ -5168,7 +5174,7 @@ function printModelExpression(path, options, print) {
5168
5174
  }
5169
5175
  }
5170
5176
  function printModelStatement(path, options, print) {
5171
- const node = path.getValue();
5177
+ const node = path.node;
5172
5178
  const id = path.call(print, "id");
5173
5179
  const heritage = node.extends
5174
5180
  ? [ifBreak(line, " "), "extends ", path.call(print, "extends")]
@@ -5189,7 +5195,7 @@ function printModelStatement(path, options, print) {
5189
5195
  }
5190
5196
  function printModelPropertiesBlock(path, options, print) {
5191
5197
  var _a;
5192
- const node = path.getValue();
5198
+ const node = path.node;
5193
5199
  const hasProperties = node.properties && node.properties.length > 0;
5194
5200
  const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
5195
5201
  if (!hasProperties && !nodeHasComments) {
@@ -5215,7 +5221,7 @@ function printModelPropertiesBlock(path, options, print) {
5215
5221
  */
5216
5222
  function joinMembersInBlock(path, member, options, print, separator, regularLine = hardline) {
5217
5223
  const doc = [regularLine];
5218
- const propertyContainerNode = path.getValue();
5224
+ const propertyContainerNode = path.node;
5219
5225
  let newLineBeforeNextProp = false;
5220
5226
  path.each((item, propertyIndex) => {
5221
5227
  const isFirst = propertyIndex === 0;
@@ -5247,7 +5253,7 @@ function joinMembersInBlock(path, member, options, print, separator, regularLine
5247
5253
  */
5248
5254
  function shouldWrapMemberInNewLines(path, options) {
5249
5255
  var _a;
5250
- const node = path.getValue();
5256
+ const node = path.node;
5251
5257
  return ((node.kind !== SyntaxKind.ModelSpreadProperty &&
5252
5258
  node.kind !== SyntaxKind.ProjectionModelSpreadProperty &&
5253
5259
  node.kind !== SyntaxKind.EnumSpreadMember &&
@@ -5263,7 +5269,7 @@ function shouldWrapMemberInNewLines(path, options) {
5263
5269
  */
5264
5270
  function isModelAValue(path) {
5265
5271
  let count = 0;
5266
- let node = path.getValue();
5272
+ let node = path.node;
5267
5273
  do {
5268
5274
  switch (node.kind) {
5269
5275
  case SyntaxKind.ModelStatement:
@@ -5277,7 +5283,7 @@ function isModelAValue(path) {
5277
5283
  return true;
5278
5284
  }
5279
5285
  function printModelProperty(path, options, print) {
5280
- const node = path.getValue();
5286
+ const node = path.node;
5281
5287
  const { decorators } = printDecorators(path, options, print, {
5282
5288
  tryInline: DecoratorsTryInline.modelProperty,
5283
5289
  });
@@ -5335,7 +5341,7 @@ function isModelExpressionInBlock(path) {
5335
5341
  }
5336
5342
  }
5337
5343
  function printScalarStatement(path, options, print) {
5338
- const node = path.getValue();
5344
+ const node = path.node;
5339
5345
  const id = path.call(print, "id");
5340
5346
  const template = printTemplateParameters(path, options, print, "templateParameters");
5341
5347
  const heritage = node.extends
@@ -5387,11 +5393,11 @@ function printOperationStatement(path, options, print) {
5387
5393
  ];
5388
5394
  }
5389
5395
  function printStatementSequence(path, options, print, property) {
5390
- const node = path.getValue();
5396
+ const node = path.node;
5391
5397
  const parts = [];
5392
5398
  const lastStatement = getLastStatement(node[property]);
5393
5399
  path.each((statementPath) => {
5394
- const node = path.getValue();
5400
+ const node = path.node;
5395
5401
  if (node.kind === SyntaxKind.EmptyStatement) {
5396
5402
  return;
5397
5403
  }
@@ -5416,7 +5422,7 @@ function getLastStatement(statements) {
5416
5422
  return undefined;
5417
5423
  }
5418
5424
  function printUnion(path, options, print) {
5419
- const node = path.getValue();
5425
+ const node = path.node;
5420
5426
  const shouldHug = shouldHugType(node);
5421
5427
  const types = path.map((typePath) => {
5422
5428
  let printedType = print(typePath);
@@ -5443,7 +5449,7 @@ function printTypeReference(path, options, print) {
5443
5449
  return [type, template];
5444
5450
  }
5445
5451
  function printTemplateArgument(path, _options, print) {
5446
- if (path.getValue().name !== undefined) {
5452
+ if (path.node.name !== undefined) {
5447
5453
  const name = path.call(print, "name");
5448
5454
  const argument = path.call(print, "argument");
5449
5455
  return group([name, " = ", argument]);
@@ -5457,7 +5463,7 @@ function printValueOfExpression(path, options, print) {
5457
5463
  return ["valueof ", type];
5458
5464
  }
5459
5465
  function printTemplateParameterDeclaration(path, options, print) {
5460
- const node = path.getValue();
5466
+ const node = path.node;
5461
5467
  return [
5462
5468
  path.call(print, "id"),
5463
5469
  node.constraint ? [" extends ", path.call(print, "constraint")] : "",
@@ -5481,7 +5487,7 @@ function printDecoratorDeclarationStatement(path, options, print) {
5481
5487
  return [printModifiers(path, options, print), "dec ", id, "(", parameters, ")", ";"];
5482
5488
  }
5483
5489
  function printFunctionDeclarationStatement(path, options, print) {
5484
- const node = path.getValue();
5490
+ const node = path.node;
5485
5491
  const id = path.call(print, "id");
5486
5492
  const parameters = [
5487
5493
  group([
@@ -5493,7 +5499,7 @@ function printFunctionDeclarationStatement(path, options, print) {
5493
5499
  return [printModifiers(path, options, print), "fn ", id, "(", parameters, ")", returnType, ";"];
5494
5500
  }
5495
5501
  function printFunctionParameterDeclaration(path, options, print) {
5496
- const node = path.getValue();
5502
+ const node = path.node;
5497
5503
  const id = path.call(print, "id");
5498
5504
  const type = node.type ? [": ", path.call(print, "type")] : "";
5499
5505
  return [
@@ -5505,22 +5511,22 @@ function printFunctionParameterDeclaration(path, options, print) {
5505
5511
  ];
5506
5512
  }
5507
5513
  function printModifiers(path, options, print) {
5508
- const node = path.getValue();
5514
+ const node = path.node;
5509
5515
  if (node.modifiers.length === 0) {
5510
5516
  return "";
5511
5517
  }
5512
5518
  return path.map((x) => [print(x), " "], "modifiers");
5513
5519
  }
5514
5520
  function printStringLiteral(path, options) {
5515
- const node = path.getValue();
5521
+ const node = path.node;
5516
5522
  return getRawText(node, options);
5517
5523
  }
5518
5524
  function printNumberLiteral(path, options) {
5519
- const node = path.getValue();
5525
+ const node = path.node;
5520
5526
  return getRawText(node, options);
5521
5527
  }
5522
5528
  function printBooleanLiteral(path, options) {
5523
- const node = path.getValue();
5529
+ const node = path.node;
5524
5530
  return node.value ? "true" : "false";
5525
5531
  }
5526
5532
  function printProjectionStatement(path, options, print) {
@@ -5539,7 +5545,7 @@ function printProjectionStatement(path, options, print) {
5539
5545
  ];
5540
5546
  }
5541
5547
  function printProjection(path, options, print) {
5542
- const node = path.getValue();
5548
+ const node = path.node;
5543
5549
  const params = printProjectionParameters(path, options, print);
5544
5550
  const body = printProjectionExpressionStatements(path, options, print, "body");
5545
5551
  return [
@@ -5553,7 +5559,7 @@ function printProjection(path, options, print) {
5553
5559
  ];
5554
5560
  }
5555
5561
  function printProjectionParameters(path, options, print) {
5556
- const node = path.getValue();
5562
+ const node = path.node;
5557
5563
  const params = node.parameters;
5558
5564
  if (params.length === 0) {
5559
5565
  return "";
@@ -5569,9 +5575,9 @@ function printProjectionParameters(path, options, print) {
5569
5575
  }
5570
5576
  function printProjectionExpressionStatements(path, options, print, key) {
5571
5577
  const parts = [hardline];
5572
- const lastIndex = path.getValue()[key].length - 1;
5578
+ const lastIndex = path.node[key].length - 1;
5573
5579
  path.each((statementPath, index) => {
5574
- const node = path.getValue();
5580
+ const node = path.node;
5575
5581
  if (node.kind === SyntaxKind.EmptyStatement) {
5576
5582
  return;
5577
5583
  }
@@ -5594,14 +5600,14 @@ function printProjectionExpressionStatement(path, options, print) {
5594
5600
  return path.call(print, "expr");
5595
5601
  }
5596
5602
  function printProjectionIfExpressionNode(path, options, print) {
5597
- const node = path.getValue();
5603
+ const node = path.node;
5598
5604
  const test = path.call(print, "test");
5599
5605
  const consequent = path.call(print, "consequent");
5600
5606
  const alternate = node.alternate ? [" else ", path.call(print, "alternate")] : "";
5601
5607
  return ["if ", test, " ", consequent, alternate];
5602
5608
  }
5603
5609
  function printProjectionBlockExpressionNode(path, options, print) {
5604
- const node = path.getValue();
5610
+ const node = path.node;
5605
5611
  if (node.statements.length === 0) {
5606
5612
  return "{}";
5607
5613
  }
@@ -5613,18 +5619,18 @@ function printProjectionBlockExpressionNode(path, options, print) {
5613
5619
  ];
5614
5620
  }
5615
5621
  function printProjectionMemberExpression(path, options, print) {
5616
- const node = path.getValue();
5622
+ const node = path.node;
5617
5623
  return [path.call(print, "base"), node.selector, path.call(print, "id")];
5618
5624
  }
5619
5625
  function printProjectionLeftRightExpression(path, options, print) {
5620
- const node = path.getValue();
5626
+ const node = path.node;
5621
5627
  return [path.call(print, "left"), " ", node.op, " ", path.call(print, "right")];
5622
5628
  }
5623
5629
  function printProjectionUnaryExpression(path, options, print) {
5624
5630
  return ["!", path.call(print, "target")];
5625
5631
  }
5626
5632
  function printProjectionCallExpression(path, options, print) {
5627
- const node = path.getValue();
5633
+ const node = path.node;
5628
5634
  const target = path.call(print, "target");
5629
5635
  const params = printItemList(path, options, print, "arguments");
5630
5636
  if (node.callKind === "method") {