Microsoft/TypeScript
Ver no GitHubTypeScript colorizer confused by comments after colon in class member function signature with Generic return type
Open
#58.614 aberto em 22 de mai. de 2024
BugDomain: Something ElseHelp Wanted
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 Search Terms
color comment white Promise async function type declaration
🕗 Version & Regression Information
- I was unable to test this on prior versions because no idea when this started
⏯ Playground Link
💻 Code
import os from 'os';
type Test<T> = T;
export class test {
fine(): Test<void> {
const test = 0;
}
ok(): /**/ Test<void> {
const test = 0;
}
bad(): // any comment with a new line breaks colorizer for a function
Test<void> {
const test = 0;
os.hostname();
true ? false : undefined;
throw new Error('');
return;
}
fixed() // Not broken this way. Compare colorization with the bad function.
: Test<void> {
const test = 0;
os.hostname();
true ? false : undefined;
throw new Error('');
return;
}
alsoBad(): /* can be a /* comment too, but formatters usually remove the new line unless it is really long */
Test<void> { // all but { colors are different
const test = 0; // const is white
os.hostname(); // all alpha is white
true ? false : !!undefined; // true and false are different
throw new Error(''); // throw is different, but not new or Error
return; // return is different
}
}
function ok(): // not broken outside of class
Test<void> {
const test = 0;
}
🙁 Actual behavior
In the class functions that have comments after the : in the signature but before the actual Generic type, I noticed many differences from normal:
- Type coloring is different
constis white- global variables are white
trueandfalseare different in ternarythrowis different, but notneworErrorreturnis different
🙂 Expected behavior
Consistent colorizing, no matter the comments
Additional information about the issue
Does not reproduce on GitHub or playground's colorizer. Reproduces quickly and easily on vscode.dev.
I wasn't sure where to post this issue. It seem like a very TypeSript specific issue, but maybe this should be a VS Code bug...