@typespec/prettier-plugin-typespec 0.51.0-dev.1 → 0.51.0

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
@@ -42,56 +42,61 @@ var SyntaxKind;
42
42
  SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
43
43
  SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
44
44
  SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
45
- SyntaxKind[SyntaxKind["ExternKeyword"] = 35] = "ExternKeyword";
46
- SyntaxKind[SyntaxKind["VoidKeyword"] = 36] = "VoidKeyword";
47
- SyntaxKind[SyntaxKind["NeverKeyword"] = 37] = "NeverKeyword";
48
- SyntaxKind[SyntaxKind["UnknownKeyword"] = 38] = "UnknownKeyword";
49
- SyntaxKind[SyntaxKind["ValueOfExpression"] = 39] = "ValueOfExpression";
50
- SyntaxKind[SyntaxKind["TypeReference"] = 40] = "TypeReference";
51
- SyntaxKind[SyntaxKind["ProjectionReference"] = 41] = "ProjectionReference";
52
- SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 42] = "TemplateParameterDeclaration";
53
- SyntaxKind[SyntaxKind["EmptyStatement"] = 43] = "EmptyStatement";
54
- SyntaxKind[SyntaxKind["InvalidStatement"] = 44] = "InvalidStatement";
55
- SyntaxKind[SyntaxKind["LineComment"] = 45] = "LineComment";
56
- SyntaxKind[SyntaxKind["BlockComment"] = 46] = "BlockComment";
57
- SyntaxKind[SyntaxKind["Doc"] = 47] = "Doc";
58
- SyntaxKind[SyntaxKind["DocText"] = 48] = "DocText";
59
- SyntaxKind[SyntaxKind["DocParamTag"] = 49] = "DocParamTag";
60
- SyntaxKind[SyntaxKind["DocReturnsTag"] = 50] = "DocReturnsTag";
61
- SyntaxKind[SyntaxKind["DocErrorsTag"] = 51] = "DocErrorsTag";
62
- SyntaxKind[SyntaxKind["DocTemplateTag"] = 52] = "DocTemplateTag";
63
- SyntaxKind[SyntaxKind["DocUnknownTag"] = 53] = "DocUnknownTag";
64
- SyntaxKind[SyntaxKind["Projection"] = 54] = "Projection";
65
- SyntaxKind[SyntaxKind["ProjectionParameterDeclaration"] = 55] = "ProjectionParameterDeclaration";
66
- SyntaxKind[SyntaxKind["ProjectionModelSelector"] = 56] = "ProjectionModelSelector";
67
- SyntaxKind[SyntaxKind["ProjectionModelPropertySelector"] = 57] = "ProjectionModelPropertySelector";
68
- SyntaxKind[SyntaxKind["ProjectionOperationSelector"] = 58] = "ProjectionOperationSelector";
69
- SyntaxKind[SyntaxKind["ProjectionUnionSelector"] = 59] = "ProjectionUnionSelector";
70
- SyntaxKind[SyntaxKind["ProjectionUnionVariantSelector"] = 60] = "ProjectionUnionVariantSelector";
71
- SyntaxKind[SyntaxKind["ProjectionInterfaceSelector"] = 61] = "ProjectionInterfaceSelector";
72
- SyntaxKind[SyntaxKind["ProjectionEnumSelector"] = 62] = "ProjectionEnumSelector";
73
- SyntaxKind[SyntaxKind["ProjectionEnumMemberSelector"] = 63] = "ProjectionEnumMemberSelector";
74
- SyntaxKind[SyntaxKind["ProjectionExpressionStatement"] = 64] = "ProjectionExpressionStatement";
75
- SyntaxKind[SyntaxKind["ProjectionIfExpression"] = 65] = "ProjectionIfExpression";
76
- SyntaxKind[SyntaxKind["ProjectionBlockExpression"] = 66] = "ProjectionBlockExpression";
77
- SyntaxKind[SyntaxKind["ProjectionMemberExpression"] = 67] = "ProjectionMemberExpression";
78
- SyntaxKind[SyntaxKind["ProjectionLogicalExpression"] = 68] = "ProjectionLogicalExpression";
79
- SyntaxKind[SyntaxKind["ProjectionEqualityExpression"] = 69] = "ProjectionEqualityExpression";
80
- SyntaxKind[SyntaxKind["ProjectionUnaryExpression"] = 70] = "ProjectionUnaryExpression";
81
- SyntaxKind[SyntaxKind["ProjectionRelationalExpression"] = 71] = "ProjectionRelationalExpression";
82
- SyntaxKind[SyntaxKind["ProjectionArithmeticExpression"] = 72] = "ProjectionArithmeticExpression";
83
- SyntaxKind[SyntaxKind["ProjectionCallExpression"] = 73] = "ProjectionCallExpression";
84
- SyntaxKind[SyntaxKind["ProjectionLambdaExpression"] = 74] = "ProjectionLambdaExpression";
85
- SyntaxKind[SyntaxKind["ProjectionLambdaParameterDeclaration"] = 75] = "ProjectionLambdaParameterDeclaration";
86
- SyntaxKind[SyntaxKind["ProjectionModelExpression"] = 76] = "ProjectionModelExpression";
87
- SyntaxKind[SyntaxKind["ProjectionModelProperty"] = 77] = "ProjectionModelProperty";
88
- SyntaxKind[SyntaxKind["ProjectionModelSpreadProperty"] = 78] = "ProjectionModelSpreadProperty";
89
- SyntaxKind[SyntaxKind["ProjectionSpreadProperty"] = 79] = "ProjectionSpreadProperty";
90
- SyntaxKind[SyntaxKind["ProjectionTupleExpression"] = 80] = "ProjectionTupleExpression";
91
- SyntaxKind[SyntaxKind["ProjectionStatement"] = 81] = "ProjectionStatement";
92
- SyntaxKind[SyntaxKind["ProjectionDecoratorReferenceExpression"] = 82] = "ProjectionDecoratorReferenceExpression";
93
- SyntaxKind[SyntaxKind["Return"] = 83] = "Return";
94
- SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 84] = "JsNamespaceDeclaration";
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";
95
100
  })(SyntaxKind || (SyntaxKind = {}));
96
101
  var IdentifierKind;
97
102
  (function (IdentifierKind) {
@@ -911,6 +916,12 @@ const diagnostics = {
911
916
  default: "Projections are experimental - your code will need to change as this feature evolves.",
912
917
  },
913
918
  },
919
+ "non-literal-string-template": {
920
+ severity: "error",
921
+ messages: {
922
+ default: "Value interpolated in this string template cannot be converted to a string. Only literal types can be automatically interpolated.",
923
+ },
924
+ },
914
925
  /**
915
926
  * Binder
916
927
  */
@@ -3288,107 +3299,110 @@ var Token;
3288
3299
  Token[Token["Identifier"] = 3] = "Identifier";
3289
3300
  Token[Token["NumericLiteral"] = 4] = "NumericLiteral";
3290
3301
  Token[Token["StringLiteral"] = 5] = "StringLiteral";
3302
+ Token[Token["StringTemplateHead"] = 6] = "StringTemplateHead";
3303
+ Token[Token["StringTemplateMiddle"] = 7] = "StringTemplateMiddle";
3304
+ Token[Token["StringTemplateTail"] = 8] = "StringTemplateTail";
3291
3305
  // Add new tokens above if they don't fit any of the categories below
3292
3306
  ///////////////////////////////////////////////////////////////
3293
3307
  // Trivia
3294
- /**@internal */ Token[Token["__StartTrivia"] = 6] = "__StartTrivia";
3295
- Token[Token["SingleLineComment"] = 6] = "SingleLineComment";
3296
- Token[Token["MultiLineComment"] = 7] = "MultiLineComment";
3297
- Token[Token["NewLine"] = 8] = "NewLine";
3298
- Token[Token["Whitespace"] = 9] = "Whitespace";
3299
- Token[Token["ConflictMarker"] = 10] = "ConflictMarker";
3308
+ /**@internal */ Token[Token["__StartTrivia"] = 9] = "__StartTrivia";
3309
+ Token[Token["SingleLineComment"] = 9] = "SingleLineComment";
3310
+ Token[Token["MultiLineComment"] = 10] = "MultiLineComment";
3311
+ Token[Token["NewLine"] = 11] = "NewLine";
3312
+ Token[Token["Whitespace"] = 12] = "Whitespace";
3313
+ Token[Token["ConflictMarker"] = 13] = "ConflictMarker";
3300
3314
  // Add new trivia above
3301
- /** @internal */ Token[Token["__EndTrivia"] = 11] = "__EndTrivia";
3315
+ /** @internal */ Token[Token["__EndTrivia"] = 14] = "__EndTrivia";
3302
3316
  ///////////////////////////////////////////////////////////////
3303
3317
  ///////////////////////////////////////////////////////////////
3304
3318
  // Doc comment content
3305
- /** @internal */ Token[Token["__StartDocComment"] = 11] = "__StartDocComment";
3306
- Token[Token["DocText"] = 11] = "DocText";
3307
- Token[Token["DocCodeSpan"] = 12] = "DocCodeSpan";
3308
- Token[Token["DocCodeFenceDelimiter"] = 13] = "DocCodeFenceDelimiter";
3309
- /** @internal */ Token[Token["__EndDocComment"] = 14] = "__EndDocComment";
3319
+ /** @internal */ Token[Token["__StartDocComment"] = 14] = "__StartDocComment";
3320
+ Token[Token["DocText"] = 14] = "DocText";
3321
+ Token[Token["DocCodeSpan"] = 15] = "DocCodeSpan";
3322
+ Token[Token["DocCodeFenceDelimiter"] = 16] = "DocCodeFenceDelimiter";
3323
+ /** @internal */ Token[Token["__EndDocComment"] = 17] = "__EndDocComment";
3310
3324
  ///////////////////////////////////////////////////////////////
3311
3325
  ///////////////////////////////////////////////////////////////
3312
3326
  // Punctuation
3313
- /** @internal */ Token[Token["__StartPunctuation"] = 14] = "__StartPunctuation";
3314
- Token[Token["OpenBrace"] = 14] = "OpenBrace";
3315
- Token[Token["CloseBrace"] = 15] = "CloseBrace";
3316
- Token[Token["OpenParen"] = 16] = "OpenParen";
3317
- Token[Token["CloseParen"] = 17] = "CloseParen";
3318
- Token[Token["OpenBracket"] = 18] = "OpenBracket";
3319
- Token[Token["CloseBracket"] = 19] = "CloseBracket";
3320
- Token[Token["Dot"] = 20] = "Dot";
3321
- Token[Token["Ellipsis"] = 21] = "Ellipsis";
3322
- Token[Token["Semicolon"] = 22] = "Semicolon";
3323
- Token[Token["Comma"] = 23] = "Comma";
3324
- Token[Token["LessThan"] = 24] = "LessThan";
3325
- Token[Token["GreaterThan"] = 25] = "GreaterThan";
3326
- Token[Token["Equals"] = 26] = "Equals";
3327
- Token[Token["Ampersand"] = 27] = "Ampersand";
3328
- Token[Token["Bar"] = 28] = "Bar";
3329
- Token[Token["Question"] = 29] = "Question";
3330
- Token[Token["Colon"] = 30] = "Colon";
3331
- Token[Token["ColonColon"] = 31] = "ColonColon";
3332
- Token[Token["At"] = 32] = "At";
3333
- Token[Token["AtAt"] = 33] = "AtAt";
3334
- Token[Token["Hash"] = 34] = "Hash";
3335
- Token[Token["Star"] = 35] = "Star";
3336
- Token[Token["ForwardSlash"] = 36] = "ForwardSlash";
3337
- Token[Token["Plus"] = 37] = "Plus";
3338
- Token[Token["Hyphen"] = 38] = "Hyphen";
3339
- Token[Token["Exclamation"] = 39] = "Exclamation";
3340
- Token[Token["LessThanEquals"] = 40] = "LessThanEquals";
3341
- Token[Token["GreaterThanEquals"] = 41] = "GreaterThanEquals";
3342
- Token[Token["AmpsersandAmpersand"] = 42] = "AmpsersandAmpersand";
3343
- Token[Token["BarBar"] = 43] = "BarBar";
3344
- Token[Token["EqualsEquals"] = 44] = "EqualsEquals";
3345
- Token[Token["ExclamationEquals"] = 45] = "ExclamationEquals";
3346
- Token[Token["EqualsGreaterThan"] = 46] = "EqualsGreaterThan";
3327
+ /** @internal */ Token[Token["__StartPunctuation"] = 17] = "__StartPunctuation";
3328
+ Token[Token["OpenBrace"] = 17] = "OpenBrace";
3329
+ Token[Token["CloseBrace"] = 18] = "CloseBrace";
3330
+ Token[Token["OpenParen"] = 19] = "OpenParen";
3331
+ Token[Token["CloseParen"] = 20] = "CloseParen";
3332
+ Token[Token["OpenBracket"] = 21] = "OpenBracket";
3333
+ Token[Token["CloseBracket"] = 22] = "CloseBracket";
3334
+ Token[Token["Dot"] = 23] = "Dot";
3335
+ Token[Token["Ellipsis"] = 24] = "Ellipsis";
3336
+ Token[Token["Semicolon"] = 25] = "Semicolon";
3337
+ Token[Token["Comma"] = 26] = "Comma";
3338
+ Token[Token["LessThan"] = 27] = "LessThan";
3339
+ Token[Token["GreaterThan"] = 28] = "GreaterThan";
3340
+ Token[Token["Equals"] = 29] = "Equals";
3341
+ Token[Token["Ampersand"] = 30] = "Ampersand";
3342
+ Token[Token["Bar"] = 31] = "Bar";
3343
+ Token[Token["Question"] = 32] = "Question";
3344
+ Token[Token["Colon"] = 33] = "Colon";
3345
+ Token[Token["ColonColon"] = 34] = "ColonColon";
3346
+ Token[Token["At"] = 35] = "At";
3347
+ Token[Token["AtAt"] = 36] = "AtAt";
3348
+ Token[Token["Hash"] = 37] = "Hash";
3349
+ Token[Token["Star"] = 38] = "Star";
3350
+ Token[Token["ForwardSlash"] = 39] = "ForwardSlash";
3351
+ Token[Token["Plus"] = 40] = "Plus";
3352
+ Token[Token["Hyphen"] = 41] = "Hyphen";
3353
+ Token[Token["Exclamation"] = 42] = "Exclamation";
3354
+ Token[Token["LessThanEquals"] = 43] = "LessThanEquals";
3355
+ Token[Token["GreaterThanEquals"] = 44] = "GreaterThanEquals";
3356
+ Token[Token["AmpsersandAmpersand"] = 45] = "AmpsersandAmpersand";
3357
+ Token[Token["BarBar"] = 46] = "BarBar";
3358
+ Token[Token["EqualsEquals"] = 47] = "EqualsEquals";
3359
+ Token[Token["ExclamationEquals"] = 48] = "ExclamationEquals";
3360
+ Token[Token["EqualsGreaterThan"] = 49] = "EqualsGreaterThan";
3347
3361
  // Add new punctuation above
3348
- /** @internal */ Token[Token["__EndPunctuation"] = 47] = "__EndPunctuation";
3362
+ /** @internal */ Token[Token["__EndPunctuation"] = 50] = "__EndPunctuation";
3349
3363
  ///////////////////////////////////////////////////////////////
3350
3364
  ///////////////////////////////////////////////////////////////
3351
3365
  // Statement keywords
3352
- /** @internal */ Token[Token["__StartKeyword"] = 47] = "__StartKeyword";
3353
- /** @internal */ Token[Token["__StartStatementKeyword"] = 47] = "__StartStatementKeyword";
3354
- Token[Token["ImportKeyword"] = 47] = "ImportKeyword";
3355
- Token[Token["ModelKeyword"] = 48] = "ModelKeyword";
3356
- Token[Token["ScalarKeyword"] = 49] = "ScalarKeyword";
3357
- Token[Token["NamespaceKeyword"] = 50] = "NamespaceKeyword";
3358
- Token[Token["UsingKeyword"] = 51] = "UsingKeyword";
3359
- Token[Token["OpKeyword"] = 52] = "OpKeyword";
3360
- Token[Token["EnumKeyword"] = 53] = "EnumKeyword";
3361
- Token[Token["AliasKeyword"] = 54] = "AliasKeyword";
3362
- Token[Token["IsKeyword"] = 55] = "IsKeyword";
3363
- Token[Token["InterfaceKeyword"] = 56] = "InterfaceKeyword";
3364
- Token[Token["UnionKeyword"] = 57] = "UnionKeyword";
3365
- Token[Token["ProjectionKeyword"] = 58] = "ProjectionKeyword";
3366
- Token[Token["ElseKeyword"] = 59] = "ElseKeyword";
3367
- Token[Token["IfKeyword"] = 60] = "IfKeyword";
3368
- Token[Token["DecKeyword"] = 61] = "DecKeyword";
3369
- Token[Token["FnKeyword"] = 62] = "FnKeyword";
3370
- Token[Token["ValueOfKeyword"] = 63] = "ValueOfKeyword";
3366
+ /** @internal */ Token[Token["__StartKeyword"] = 50] = "__StartKeyword";
3367
+ /** @internal */ Token[Token["__StartStatementKeyword"] = 50] = "__StartStatementKeyword";
3368
+ Token[Token["ImportKeyword"] = 50] = "ImportKeyword";
3369
+ Token[Token["ModelKeyword"] = 51] = "ModelKeyword";
3370
+ Token[Token["ScalarKeyword"] = 52] = "ScalarKeyword";
3371
+ Token[Token["NamespaceKeyword"] = 53] = "NamespaceKeyword";
3372
+ Token[Token["UsingKeyword"] = 54] = "UsingKeyword";
3373
+ Token[Token["OpKeyword"] = 55] = "OpKeyword";
3374
+ Token[Token["EnumKeyword"] = 56] = "EnumKeyword";
3375
+ Token[Token["AliasKeyword"] = 57] = "AliasKeyword";
3376
+ Token[Token["IsKeyword"] = 58] = "IsKeyword";
3377
+ Token[Token["InterfaceKeyword"] = 59] = "InterfaceKeyword";
3378
+ Token[Token["UnionKeyword"] = 60] = "UnionKeyword";
3379
+ Token[Token["ProjectionKeyword"] = 61] = "ProjectionKeyword";
3380
+ Token[Token["ElseKeyword"] = 62] = "ElseKeyword";
3381
+ Token[Token["IfKeyword"] = 63] = "IfKeyword";
3382
+ Token[Token["DecKeyword"] = 64] = "DecKeyword";
3383
+ Token[Token["FnKeyword"] = 65] = "FnKeyword";
3384
+ Token[Token["ValueOfKeyword"] = 66] = "ValueOfKeyword";
3371
3385
  // Add new statement keyword above
3372
- /** @internal */ Token[Token["__EndStatementKeyword"] = 64] = "__EndStatementKeyword";
3386
+ /** @internal */ Token[Token["__EndStatementKeyword"] = 67] = "__EndStatementKeyword";
3373
3387
  ///////////////////////////////////////////////////////////////
3374
3388
  ///////////////////////////////////////////////////////////////
3375
- /** @internal */ Token[Token["__StartModifierKeyword"] = 64] = "__StartModifierKeyword";
3376
- Token[Token["ExternKeyword"] = 64] = "ExternKeyword";
3377
- /** @internal */ Token[Token["__EndModifierKeyword"] = 65] = "__EndModifierKeyword";
3389
+ /** @internal */ Token[Token["__StartModifierKeyword"] = 67] = "__StartModifierKeyword";
3390
+ Token[Token["ExternKeyword"] = 67] = "ExternKeyword";
3391
+ /** @internal */ Token[Token["__EndModifierKeyword"] = 68] = "__EndModifierKeyword";
3378
3392
  ///////////////////////////////////////////////////////////////
3379
3393
  ///////////////////////////////////////////////////////////////
3380
3394
  // Other keywords
3381
- Token[Token["ExtendsKeyword"] = 65] = "ExtendsKeyword";
3382
- Token[Token["TrueKeyword"] = 66] = "TrueKeyword";
3383
- Token[Token["FalseKeyword"] = 67] = "FalseKeyword";
3384
- Token[Token["ReturnKeyword"] = 68] = "ReturnKeyword";
3385
- Token[Token["VoidKeyword"] = 69] = "VoidKeyword";
3386
- Token[Token["NeverKeyword"] = 70] = "NeverKeyword";
3387
- Token[Token["UnknownKeyword"] = 71] = "UnknownKeyword";
3395
+ Token[Token["ExtendsKeyword"] = 68] = "ExtendsKeyword";
3396
+ Token[Token["TrueKeyword"] = 69] = "TrueKeyword";
3397
+ Token[Token["FalseKeyword"] = 70] = "FalseKeyword";
3398
+ Token[Token["ReturnKeyword"] = 71] = "ReturnKeyword";
3399
+ Token[Token["VoidKeyword"] = 72] = "VoidKeyword";
3400
+ Token[Token["NeverKeyword"] = 73] = "NeverKeyword";
3401
+ Token[Token["UnknownKeyword"] = 74] = "UnknownKeyword";
3388
3402
  // Add new non-statement keyword above
3389
- /** @internal */ Token[Token["__EndKeyword"] = 72] = "__EndKeyword";
3403
+ /** @internal */ Token[Token["__EndKeyword"] = 75] = "__EndKeyword";
3390
3404
  ///////////////////////////////////////////////////////////////
3391
- /** @internal */ Token[Token["__Count"] = 72] = "__Count";
3405
+ /** @internal */ Token[Token["__Count"] = 75] = "__Count";
3392
3406
  })(Token || (Token = {}));
3393
3407
  /** @internal */
3394
3408
  const TokenDisplay = getTokenDisplayTable([
@@ -3400,6 +3414,9 @@ const TokenDisplay = getTokenDisplayTable([
3400
3414
  [Token.ConflictMarker, "conflict marker"],
3401
3415
  [Token.NumericLiteral, "numeric literal"],
3402
3416
  [Token.StringLiteral, "string literal"],
3417
+ [Token.StringTemplateHead, "string template head"],
3418
+ [Token.StringTemplateMiddle, "string template middle"],
3419
+ [Token.StringTemplateTail, "string template tail"],
3403
3420
  [Token.NewLine, "newline"],
3404
3421
  [Token.Whitespace, "whitespace"],
3405
3422
  [Token.DocCodeFenceDelimiter, "doc code fence delimiter"],
@@ -3547,6 +3564,9 @@ function createScanner(source, diagnosticHandler) {
3547
3564
  scan,
3548
3565
  scanRange,
3549
3566
  scanDoc,
3567
+ reScanStringTemplate,
3568
+ findTripleQuotedStringIndent,
3569
+ unindentAndUnescapeTripleQuotedString,
3550
3570
  eof,
3551
3571
  getTokenText,
3552
3572
  getTokenValue,
@@ -3560,7 +3580,10 @@ function createScanner(source, diagnosticHandler) {
3560
3580
  function getTokenValue() {
3561
3581
  switch (token) {
3562
3582
  case Token.StringLiteral:
3563
- return getStringTokenValue();
3583
+ case Token.StringTemplateHead:
3584
+ case Token.StringTemplateMiddle:
3585
+ case Token.StringTemplateTail:
3586
+ return getStringTokenValue(token, tokenFlags);
3564
3587
  case Token.Identifier:
3565
3588
  return getIdentifierTokenValue();
3566
3589
  default:
@@ -3684,8 +3707,8 @@ function createScanner(source, diagnosticHandler) {
3684
3707
  return lookAhead(1) === 124 /* CharCode.Bar */ ? next(Token.BarBar, 2) : next(Token.Bar);
3685
3708
  case 34 /* CharCode.DoubleQuote */:
3686
3709
  return lookAhead(1) === 34 /* CharCode.DoubleQuote */ && lookAhead(2) === 34 /* CharCode.DoubleQuote */
3687
- ? scanTripleQuotedString()
3688
- : scanString();
3710
+ ? scanString(TokenFlags.TripleQuoted)
3711
+ : scanString(TokenFlags.None);
3689
3712
  case 33 /* CharCode.Exclamation */:
3690
3713
  return lookAhead(1) === 61 /* CharCode.Equals */
3691
3714
  ? next(Token.ExclamationEquals, 2)
@@ -3759,6 +3782,11 @@ function createScanner(source, diagnosticHandler) {
3759
3782
  }
3760
3783
  return (token = Token.EndOfFile);
3761
3784
  }
3785
+ function reScanStringTemplate(lastTokenFlags) {
3786
+ position = tokenPosition;
3787
+ tokenFlags = TokenFlags.None;
3788
+ return scanStringTemplateSpan(lastTokenFlags);
3789
+ }
3762
3790
  function scanRange(range, callback) {
3763
3791
  const savedPosition = position;
3764
3792
  const savedEndPosition = endPosition;
@@ -3808,10 +3836,10 @@ function createScanner(source, diagnosticHandler) {
3808
3836
  const codePoint = input.codePointAt(position);
3809
3837
  return (token = next(t, utf16CodeUnits(codePoint)));
3810
3838
  }
3811
- function error(report) {
3839
+ function error(report, pos, end) {
3812
3840
  const diagnostic = createDiagnostic({
3813
3841
  ...report,
3814
- target: { file, pos: tokenPosition, end: position },
3842
+ target: { file, pos: pos !== null && pos !== void 0 ? pos : tokenPosition, end: end !== null && end !== void 0 ? end : position },
3815
3843
  });
3816
3844
  diagnosticHandler(diagnostic);
3817
3845
  }
@@ -3903,8 +3931,22 @@ function createScanner(source, diagnosticHandler) {
3903
3931
  }
3904
3932
  return unterminated(Token.DocCodeSpan);
3905
3933
  }
3906
- function scanString() {
3907
- position++; // consume '"'
3934
+ function scanString(tokenFlags) {
3935
+ if (tokenFlags & TokenFlags.TripleQuoted) {
3936
+ position += 3; // consume '"""'
3937
+ }
3938
+ else {
3939
+ position++; // consume '"'
3940
+ }
3941
+ return scanStringLiteralLike(tokenFlags, Token.StringTemplateHead, Token.StringLiteral);
3942
+ }
3943
+ function scanStringTemplateSpan(tokenFlags) {
3944
+ position++; // consume '{'
3945
+ return scanStringLiteralLike(tokenFlags, Token.StringTemplateMiddle, Token.StringTemplateTail);
3946
+ }
3947
+ function scanStringLiteralLike(requestedTokenFlags, template, tail) {
3948
+ const multiLine = requestedTokenFlags & TokenFlags.TripleQuoted;
3949
+ tokenFlags = requestedTokenFlags;
3908
3950
  loop: for (; !eof(); position++) {
3909
3951
  const ch = input.charCodeAt(position);
3910
3952
  switch (ch) {
@@ -3916,35 +3958,69 @@ function createScanner(source, diagnosticHandler) {
3916
3958
  }
3917
3959
  continue;
3918
3960
  case 34 /* CharCode.DoubleQuote */:
3919
- position++;
3920
- return (token = Token.StringLiteral);
3961
+ if (multiLine) {
3962
+ if (lookAhead(1) === 34 /* CharCode.DoubleQuote */ && lookAhead(2) === 34 /* CharCode.DoubleQuote */) {
3963
+ position += 3;
3964
+ token = tail;
3965
+ return tail;
3966
+ }
3967
+ else {
3968
+ continue;
3969
+ }
3970
+ }
3971
+ else {
3972
+ position++;
3973
+ token = tail;
3974
+ return tail;
3975
+ }
3976
+ case 36 /* CharCode.$ */:
3977
+ if (lookAhead(1) === 123 /* CharCode.OpenBrace */) {
3978
+ position += 2;
3979
+ token = template;
3980
+ return template;
3981
+ }
3982
+ continue;
3921
3983
  case 13 /* CharCode.CarriageReturn */:
3922
3984
  case 10 /* CharCode.LineFeed */:
3923
- break loop;
3985
+ if (multiLine) {
3986
+ continue;
3987
+ }
3988
+ else {
3989
+ break loop;
3990
+ }
3924
3991
  }
3925
3992
  }
3926
- return unterminated(Token.StringLiteral);
3927
- }
3928
- function scanTripleQuotedString() {
3929
- tokenFlags |= TokenFlags.TripleQuoted;
3930
- position += 3; // consume '"""'
3931
- for (; !eof(); position++) {
3932
- if (input.charCodeAt(position) === 34 /* CharCode.DoubleQuote */ &&
3933
- lookAhead(1) === 34 /* CharCode.DoubleQuote */ &&
3934
- lookAhead(2) === 34 /* CharCode.DoubleQuote */) {
3935
- position += 3;
3936
- return (token = Token.StringLiteral);
3937
- }
3993
+ return unterminated(tail);
3994
+ }
3995
+ function getStringLiteralOffsetStart(token, tokenFlags) {
3996
+ switch (token) {
3997
+ case Token.StringLiteral:
3998
+ case Token.StringTemplateHead:
3999
+ return tokenFlags & TokenFlags.TripleQuoted ? 3 : 1; // """ or "
4000
+ default:
4001
+ return 1; // {
3938
4002
  }
3939
- return unterminated(Token.StringLiteral);
3940
4003
  }
3941
- function getStringTokenValue() {
3942
- const quoteLength = tokenFlags & TokenFlags.TripleQuoted ? 3 : 1;
3943
- const start = tokenPosition + quoteLength;
3944
- const end = tokenFlags & TokenFlags.Unterminated ? position : position - quoteLength;
3945
- if (tokenFlags & TokenFlags.TripleQuoted) {
3946
- return unindentAndUnescapeTripleQuotedString(start, end);
4004
+ function getStringLiteralOffsetEnd(token, tokenFlags) {
4005
+ switch (token) {
4006
+ case Token.StringLiteral:
4007
+ case Token.StringTemplateTail:
4008
+ return tokenFlags & TokenFlags.TripleQuoted ? 3 : 1; // """ or "
4009
+ default:
4010
+ return 2; // ${
3947
4011
  }
4012
+ }
4013
+ function getStringTokenValue(token, tokenFlags) {
4014
+ if (tokenFlags & TokenFlags.TripleQuoted) {
4015
+ const start = tokenPosition;
4016
+ const end = position;
4017
+ const [indentationStart, indentationEnd] = findTripleQuotedStringIndent(start, end);
4018
+ return unindentAndUnescapeTripleQuotedString(start, end, indentationStart, indentationEnd, token, tokenFlags);
4019
+ }
4020
+ const startOffset = getStringLiteralOffsetStart(token, tokenFlags);
4021
+ const endOffset = getStringLiteralOffsetEnd(token, tokenFlags);
4022
+ const start = tokenPosition + startOffset;
4023
+ const end = tokenFlags & TokenFlags.Unterminated ? position : position - endOffset;
3948
4024
  if (tokenFlags & TokenFlags.Escaped) {
3949
4025
  return unescapeString(start, end);
3950
4026
  }
@@ -3961,21 +4037,8 @@ function createScanner(source, diagnosticHandler) {
3961
4037
  }
3962
4038
  return text;
3963
4039
  }
3964
- function unindentAndUnescapeTripleQuotedString(start, end) {
3965
- // ignore leading whitespace before required initial line break
3966
- while (start < end && isWhiteSpaceSingleLine(input.charCodeAt(start))) {
3967
- start++;
3968
- }
3969
- // remove required initial line break
3970
- if (isLineBreak(input.charCodeAt(start))) {
3971
- if (isCrlf(start, start, end)) {
3972
- start++;
3973
- }
3974
- start++;
3975
- }
3976
- else {
3977
- error({ code: "no-new-line-start-triple-quote" });
3978
- }
4040
+ function findTripleQuotedStringIndent(start, end) {
4041
+ end = end - 3; // Remove the """
3979
4042
  // remove whitespace before closing delimiter and record it as required
3980
4043
  // indentation for all lines
3981
4044
  const indentationEnd = end;
@@ -3985,7 +4048,7 @@ function createScanner(source, diagnosticHandler) {
3985
4048
  const indentationStart = end;
3986
4049
  // remove required final line break
3987
4050
  if (isLineBreak(input.charCodeAt(end - 1))) {
3988
- if (isCrlf(end - 2, start, end)) {
4051
+ if (isCrlf(end - 2, 0, end)) {
3989
4052
  end--;
3990
4053
  }
3991
4054
  end--;
@@ -3993,13 +4056,61 @@ function createScanner(source, diagnosticHandler) {
3993
4056
  else {
3994
4057
  error({ code: "no-new-line-end-triple-quote" });
3995
4058
  }
4059
+ return [indentationStart, indentationEnd];
4060
+ }
4061
+ function unindentAndUnescapeTripleQuotedString(start, end, indentationStart, indentationEnd, token, tokenFlags) {
4062
+ const startOffset = getStringLiteralOffsetStart(token, tokenFlags);
4063
+ const endOffset = getStringLiteralOffsetEnd(token, tokenFlags);
4064
+ start = start + startOffset;
4065
+ end = tokenFlags & TokenFlags.Unterminated ? end : end - endOffset;
4066
+ if (token === Token.StringLiteral || token === Token.StringTemplateHead) {
4067
+ // ignore leading whitespace before required initial line break
4068
+ while (start < end && isWhiteSpaceSingleLine(input.charCodeAt(start))) {
4069
+ start++;
4070
+ }
4071
+ // remove required initial line break
4072
+ if (isLineBreak(input.charCodeAt(start))) {
4073
+ if (isCrlf(start, start, end)) {
4074
+ start++;
4075
+ }
4076
+ start++;
4077
+ }
4078
+ else {
4079
+ error({ code: "no-new-line-start-triple-quote" });
4080
+ }
4081
+ }
4082
+ if (token === Token.StringLiteral || token === Token.StringTemplateTail) {
4083
+ while (end > start && isWhiteSpaceSingleLine(input.charCodeAt(end - 1))) {
4084
+ end--;
4085
+ }
4086
+ // remove required final line break
4087
+ if (isLineBreak(input.charCodeAt(end - 1))) {
4088
+ if (isCrlf(end - 2, start, end)) {
4089
+ end--;
4090
+ }
4091
+ end--;
4092
+ }
4093
+ else {
4094
+ error({ code: "no-new-line-end-triple-quote" });
4095
+ }
4096
+ }
4097
+ let skipUnindentOnce = false;
4098
+ // We are resuming from the middle of a line so we want to keep text as it is from there.
4099
+ if (token === Token.StringTemplateMiddle || token === Token.StringTemplateTail) {
4100
+ skipUnindentOnce = true;
4101
+ }
3996
4102
  // remove required matching indentation from each line and unescape in the
3997
4103
  // process of doing so
3998
4104
  let result = "";
3999
4105
  let pos = start;
4000
4106
  while (pos < end) {
4001
- // skip indentation at start of line
4002
- start = skipMatchingIndentation(pos, end, indentationStart, indentationEnd);
4107
+ if (skipUnindentOnce) {
4108
+ skipUnindentOnce = false;
4109
+ }
4110
+ else {
4111
+ // skip indentation at start of line
4112
+ start = skipMatchingIndentation(pos, end, indentationStart, indentationEnd);
4113
+ }
4003
4114
  let ch;
4004
4115
  while (pos < end && !isLineBreak((ch = input.charCodeAt(pos)))) {
4005
4116
  if (ch !== 92 /* CharCode.Backslash */) {
@@ -4008,7 +4119,7 @@ function createScanner(source, diagnosticHandler) {
4008
4119
  }
4009
4120
  result += input.substring(start, pos);
4010
4121
  if (pos === end - 1) {
4011
- error({ code: "invalid-escape-sequence" });
4122
+ error({ code: "invalid-escape-sequence" }, pos, pos);
4012
4123
  pos++;
4013
4124
  }
4014
4125
  else {
@@ -4069,7 +4180,7 @@ function createScanner(source, diagnosticHandler) {
4069
4180
  continue;
4070
4181
  }
4071
4182
  if (pos === end - 1) {
4072
- error({ code: "invalid-escape-sequence" });
4183
+ error({ code: "invalid-escape-sequence" }, pos, pos);
4073
4184
  break;
4074
4185
  }
4075
4186
  result += input.substring(start, pos);
@@ -4093,10 +4204,12 @@ function createScanner(source, diagnosticHandler) {
4093
4204
  return '"';
4094
4205
  case 92 /* CharCode.Backslash */:
4095
4206
  return "\\";
4207
+ case 36 /* CharCode.$ */:
4208
+ return "$";
4096
4209
  case 96 /* CharCode.Backtick */:
4097
4210
  return "`";
4098
4211
  default:
4099
- error({ code: "invalid-escape-sequence" });
4212
+ error({ code: "invalid-escape-sequence" }, pos, pos + 2);
4100
4213
  return String.fromCharCode(ch);
4101
4214
  }
4102
4215
  }
@@ -4423,6 +4536,10 @@ function needsParens(path, options) {
4423
4536
  // eslint-disable-next-line deprecation/deprecation
4424
4537
  const node = path.getValue();
4425
4538
  switch (node.kind) {
4539
+ case SyntaxKind.ValueOfExpression:
4540
+ return (parent.kind === SyntaxKind.UnionExpression ||
4541
+ parent.kind === SyntaxKind.ArrayExpression ||
4542
+ parent.kind === SyntaxKind.IntersectionExpression);
4426
4543
  case SyntaxKind.IntersectionExpression:
4427
4544
  return (parent.kind === SyntaxKind.UnionExpression || parent.kind === SyntaxKind.ArrayExpression);
4428
4545
  case SyntaxKind.UnionExpression:
@@ -4633,6 +4750,12 @@ path, options, print) {
4633
4750
  return "";
4634
4751
  case SyntaxKind.EmptyStatement:
4635
4752
  return "";
4753
+ case SyntaxKind.StringTemplateExpression:
4754
+ return printStringTemplateExpression(path, options, print);
4755
+ case SyntaxKind.StringTemplateSpan:
4756
+ case SyntaxKind.StringTemplateHead:
4757
+ case SyntaxKind.StringTemplateMiddle:
4758
+ case SyntaxKind.StringTemplateTail:
4636
4759
  case SyntaxKind.JsSourceFile:
4637
4760
  case SyntaxKind.JsNamespaceDeclaration:
4638
4761
  case SyntaxKind.InvalidStatement:
@@ -5484,6 +5607,17 @@ function printProjectionLambdaParameterDeclaration(path, options, print) {
5484
5607
  function printReturnExpression(path, options, print) {
5485
5608
  return ["return ", path.call(print, "value")];
5486
5609
  }
5610
+ function printStringTemplateExpression(path, options, print) {
5611
+ const node = path.node;
5612
+ const content = [
5613
+ getRawText(node.head, options),
5614
+ path.map((span) => {
5615
+ const expression = span.call(print, "expression");
5616
+ return [expression, getRawText(span.node.literal, options)];
5617
+ }, "spans"),
5618
+ ];
5619
+ return content;
5620
+ }
5487
5621
  function printItemList(path, options, print, key) {
5488
5622
  return join(", ", path.map(print, key));
5489
5623
  }
@@ -6539,6 +6673,8 @@ function createParser(code, options = {}) {
6539
6673
  return parseReferenceExpression();
6540
6674
  case Token.StringLiteral:
6541
6675
  return parseStringLiteral();
6676
+ case Token.StringTemplateHead:
6677
+ return parseStringTemplateExpression();
6542
6678
  case Token.TrueKeyword:
6543
6679
  case Token.FalseKeyword:
6544
6680
  return parseBooleanLiteral();
@@ -6636,6 +6772,90 @@ function createParser(code, options = {}) {
6636
6772
  ...finishNode(pos),
6637
6773
  };
6638
6774
  }
6775
+ function parseStringTemplateExpression() {
6776
+ const pos = tokenPos();
6777
+ const head = parseStringTemplateHead();
6778
+ const spans = parseStringTemplateSpans(head.tokenFlags);
6779
+ const last = spans[spans.length - 1];
6780
+ if (head.tokenFlags & TokenFlags.TripleQuoted) {
6781
+ const [indentationsStart, indentationEnd] = scanner.findTripleQuotedStringIndent(last.literal.pos, last.literal.end);
6782
+ mutate(head).value = scanner.unindentAndUnescapeTripleQuotedString(head.pos, head.end, indentationsStart, indentationEnd, Token.StringTemplateHead, head.tokenFlags);
6783
+ for (const span of spans) {
6784
+ mutate(span.literal).value = scanner.unindentAndUnescapeTripleQuotedString(span.literal.pos, span.literal.end, indentationsStart, indentationEnd, span === last ? Token.StringTemplateTail : Token.StringTemplateMiddle, head.tokenFlags);
6785
+ }
6786
+ }
6787
+ return {
6788
+ kind: SyntaxKind.StringTemplateExpression,
6789
+ head,
6790
+ spans,
6791
+ ...finishNode(pos),
6792
+ };
6793
+ }
6794
+ function parseStringTemplateHead() {
6795
+ const pos = tokenPos();
6796
+ const flags = tokenFlags();
6797
+ const text = flags & TokenFlags.TripleQuoted ? "" : tokenValue();
6798
+ parseExpected(Token.StringTemplateHead);
6799
+ return {
6800
+ kind: SyntaxKind.StringTemplateHead,
6801
+ value: text,
6802
+ tokenFlags: flags,
6803
+ ...finishNode(pos),
6804
+ };
6805
+ }
6806
+ function parseStringTemplateSpans(tokenFlags) {
6807
+ const list = [];
6808
+ let node;
6809
+ do {
6810
+ node = parseTemplateTypeSpan(tokenFlags);
6811
+ list.push(node);
6812
+ } while (node.literal.kind === SyntaxKind.StringTemplateMiddle);
6813
+ return list;
6814
+ }
6815
+ function parseTemplateTypeSpan(tokenFlags) {
6816
+ const pos = tokenPos();
6817
+ const expression = parseExpression();
6818
+ const literal = parseLiteralOfTemplateSpan(tokenFlags);
6819
+ return {
6820
+ kind: SyntaxKind.StringTemplateSpan,
6821
+ literal,
6822
+ expression,
6823
+ ...finishNode(pos),
6824
+ };
6825
+ }
6826
+ function parseLiteralOfTemplateSpan(headTokenFlags) {
6827
+ const pos = tokenPos();
6828
+ const flags = tokenFlags();
6829
+ const text = flags & TokenFlags.TripleQuoted ? "" : tokenValue();
6830
+ if (token() === Token.CloseBrace) {
6831
+ nextStringTemplateToken(headTokenFlags);
6832
+ return parseTemplateMiddleOrTemplateTail();
6833
+ }
6834
+ else {
6835
+ parseExpected(Token.StringTemplateTail);
6836
+ return {
6837
+ kind: SyntaxKind.StringTemplateTail,
6838
+ value: text,
6839
+ tokenFlags: flags,
6840
+ ...finishNode(pos),
6841
+ };
6842
+ }
6843
+ }
6844
+ function parseTemplateMiddleOrTemplateTail() {
6845
+ const pos = tokenPos();
6846
+ const flags = tokenFlags();
6847
+ const text = flags & TokenFlags.TripleQuoted ? "" : tokenValue();
6848
+ const kind = token() === Token.StringTemplateMiddle
6849
+ ? SyntaxKind.StringTemplateMiddle
6850
+ : SyntaxKind.StringTemplateTail;
6851
+ nextToken();
6852
+ return {
6853
+ kind,
6854
+ value: text,
6855
+ tokenFlags: flags,
6856
+ ...finishNode(pos),
6857
+ };
6858
+ }
6639
6859
  function parseNumericLiteral() {
6640
6860
  const pos = tokenPos();
6641
6861
  const valueAsString = tokenValue();
@@ -7467,7 +7687,7 @@ function createParser(code, options = {}) {
7467
7687
  /**
7468
7688
  * Parses a documentation tag.
7469
7689
  *
7470
- * @see <a href="https://microsoft.github.io/typespec/language-basics/documentation#tsdoc-doc-comments">TypeSpec documentation docs</a>
7690
+ * @see <a href="https://microsoft.github.io/typespec/language-basics/documentation#doc-comments">TypeSpec documentation docs</a>
7471
7691
  */
7472
7692
  function parseDocTag() {
7473
7693
  const pos = tokenPos();
@@ -7612,6 +7832,9 @@ function createParser(code, options = {}) {
7612
7832
  // NOTE: trivia tokens are always significant in doc comments.
7613
7833
  scanner.scanDoc();
7614
7834
  }
7835
+ function nextStringTemplateToken(tokenFlags) {
7836
+ scanner.reScanStringTemplate(tokenFlags);
7837
+ }
7615
7838
  function createMissingIdentifier() {
7616
7839
  const pos = tokenPos();
7617
7840
  previousTokenEnd = pos;
@@ -8089,7 +8312,14 @@ function visitChildren(node, cb) {
8089
8312
  case SyntaxKind.DocErrorsTag:
8090
8313
  case SyntaxKind.DocUnknownTag:
8091
8314
  return visitNode(cb, node.tagName) || visitEach(cb, node.content);
8315
+ case SyntaxKind.StringTemplateExpression:
8316
+ return visitNode(cb, node.head) || visitEach(cb, node.spans);
8317
+ case SyntaxKind.StringTemplateSpan:
8318
+ return visitNode(cb, node.expression) || visitNode(cb, node.literal);
8092
8319
  // no children for the rest of these.
8320
+ case SyntaxKind.StringTemplateHead:
8321
+ case SyntaxKind.StringTemplateMiddle:
8322
+ case SyntaxKind.StringTemplateTail:
8093
8323
  case SyntaxKind.StringLiteral:
8094
8324
  case SyntaxKind.NumericLiteral:
8095
8325
  case SyntaxKind.BooleanLiteral: