@@ -596,6 +596,7 @@ export const tokenizeLine = (line, lineState) => {
596596 lineState . isFunctionTypeAlias ||
597597 RE_FUNCTION_TYPE_ALIAS . test ( line ) ||
598598 isAmbientFunctionTypeDeclaration
599+ let isReadonlyTupleType = lineState . isReadonlyTupleType || false
599600 const arrowFunctionTypeOffsets = getArrowFunctionTypeOffsets ( line )
600601 const genericTypeArgumentOffsets = getGenericTypeArgumentOffsets ( line )
601602 const functionParameterTypeOffsets = getFunctionParameterTypeOffsets ( line )
@@ -1277,11 +1278,33 @@ export const tokenizeLine = (line, lineState) => {
12771278 case State . InsideTypeExpression :
12781279 if ( ( next = part . match ( RE_ROUND_CLOSE ) ) ) {
12791280 token = TokenType . Punctuation
1281+ if (
1282+ isReadonlyTupleType &&
1283+ stack . at ( - 1 ) === State . AfterTypeExpression
1284+ ) {
1285+ stack . pop ( )
1286+ }
12801287 state = State . AfterTypeExpression
12811288 } else if ( ( next = part . match ( RE_ANGLE_OPEN ) ) ) {
12821289 stack . push ( State . InsideTypeExpression )
12831290 token = TokenType . Punctuation
12841291 state = State . InsideGeneric
1292+ } else if ( ( next = part . match ( RE_KEYWORD_READONLY ) ) ) {
1293+ token = TokenType . KeywordModifier
1294+ isReadonlyTupleType = / ^ \s * \[ / . test ( part . slice ( next [ 0 ] . length ) )
1295+ state = State . InsideTypeExpression
1296+ } else if (
1297+ isReadonlyTupleType &&
1298+ ( next = part . match ( RE_TYPE_PRIMITIVE ) )
1299+ ) {
1300+ token = TokenType . TypePrimitive
1301+ state = State . InsideTypeExpression
1302+ } else if (
1303+ isReadonlyTupleType &&
1304+ ( next = part . match ( RE_VARIABLE_NAME ) )
1305+ ) {
1306+ token = TokenType . Type
1307+ state = State . InsideTypeExpression
12851308 } else if ( ( next = part . match ( RE_VARIABLE_NAME ) ) ) {
12861309 token = TokenType . VariableName
12871310 state = State . AfterVariableName
@@ -1406,6 +1429,19 @@ export const tokenizeLine = (line, lineState) => {
14061429 if ( ( next = part . match ( RE_SEMICOLON ) ) ) {
14071430 token = TokenType . Punctuation
14081431 state = State . TopLevelContent
1432+ } else if ( isReadonlyTupleType && ( next = part . match ( RE_SQUARE_OPEN ) ) ) {
1433+ token = TokenType . Punctuation
1434+ state = State . AfterTypeExpression
1435+ } else if (
1436+ isReadonlyTupleType &&
1437+ ( next = part . match ( RE_SQUARE_CLOSE ) )
1438+ ) {
1439+ token = TokenType . Punctuation
1440+ state = State . AfterTypeExpression
1441+ } else if ( isReadonlyTupleType && ( next = part . match ( RE_COMMA ) ) ) {
1442+ token = TokenType . Punctuation
1443+ state = stack . pop ( ) || State . TopLevelContent
1444+ isReadonlyTupleType = false
14091445 } else if ( ( next = part . match ( RE_ARROW ) ) ) {
14101446 token = TokenType . Punctuation
14111447 if ( ! isAmbientFunctionTypeDeclaration ) {
@@ -3561,6 +3597,7 @@ export const tokenizeLine = (line, lineState) => {
35613597 isArrowFunctionParameterObjectType,
35623598 isGenericArrowFunctionParameters,
35633599 isFunctionTypeAlias,
3600+ isReadonlyTupleType,
35643601 isTypeAssertion,
35653602 objectDepth,
35663603 parenthesisDepth,
0 commit comments