【发布时间】:2021-04-15 15:22:04
【问题描述】:
在 monaco-editor 中,如果您尝试使用联合类型作为函数的参数,它不会为您提供任何建议。在 vscode 中执行相同操作会为您提供建议。我需要在摩纳哥启用什么功能才能获得相同的功能吗?
它确实提供了正确的检查和错误,但是似乎缺少建议。
有人有什么建议吗?还是 monaco-editor 不支持这个?
以下示例:
type Test = {
choice1: "A" | "B" | "C";
choice2: "X" | "Y" | "Z";
}
function test<T extends keyof Test>(t: T, s: Test[T]) {
}
test("choice1", "")
vscode:
摩纳哥编辑:
我也尝试过使用简单的联合类型,并且相同 Simple in Monaco
type Test2 = "something" | "somethingelse"
function test2(t: Test2) {
}
test2("")
【问题讨论】: