Closed sharpchen closed 9 months ago
infer
is very similar to var
pattern in csharp, both work for inline declaration, however applied on type. That's why I make it #A78CFA
.
Span<int> span = stackalloc int[1024];
if (span is [var first, .. var _])
{
Console.WriteLine(first);
}
if (span.ToArray() is { Length: var length })
{
Console.WriteLine(length);
}
type First<T extends any[]> = T extends [infer TFirst, ...infer _] ? TFirst : never;
type Length<T extends any[]> = T extends { length: infer TLength } ? TLength : never;
The colors provided for the is
and infer
are correct.
The object properties inside the green box have the wanted color, while the properties inside the red box are the result of the inability of VSCode to differentiate the scope values.
@sharpchen Happy New Year! Best wishes to you! : D
@fisheva 🤗Happy New Year By the way, what about the type param, it seems you didn't merge it.
Adding entity.name.type.ts
will overwrite the rule meta.type.parameters entity.name.type
, but the T and U in angle brackets are intentionally set to the color of parameters #F0AA0B
because they are generic parameters.
The desired implementation is for the T and U inside the red box to also be displayed with #F0AA0B
, similar to function parameters. It may achieve this in the future relying on semantic token color customizations.
Scopes
infer
keyword.operator.expression.infer.ts
is
keyword.operator.expression.is.ts
entity.name.type.ts
string.quoted.single.ts,punctuation.definition.string.end.ts,punctuation.definition.string.begin.ts
Code sample
Screenshots