网站搜索

Visual Studio Code - 在 VSCode TypeScript 语法高亮中,类型的 token 名称是什么?


我想更改我的 VSCode 语法高亮样式,以便我可以区分类型和类。

class Thing; // should be one color
type ThingT; // should be another color

我需要指定的代币名称是什么?我需要 TODO 高亮吗?

答案#1

class 的前景色使用了作用域 entity.name.type.class.ts。type 使用了 entity.name.type.alias.ts。

更新: 如果在 settings.json 中覆盖,请使用:

"editor.semanticTokenColorCustomizations": {
    "enabled": true,
    "rules": {
        "type": {
            "foreground": "#ff0000" // color here
        }
    }
}

仅供参考,你可以通过 Developer: Inspect Editor Tokens and Scopes 命令查看作用域。例如,我在我的 TypeScript 类中得到如下结果:

语言TypeScript
标准令牌类型其他
前景#FFCB6B
背景#0F0F0F
对比度12.78
------
TextMate 范围entity.name.type.class.ts meta.class.ts source.ts
前景entity.name.type.class { "foreground": "#FFCB6B" }

你还可以使用 开发者:从当前设置生成颜色主题 命令: