小编use*_*949的帖子

类型“keyof T”不满足约束

尽管验证有效,但我还是收到此错误。我所需要的只是一个函数,该函数使用对象来生成另一个函数来过滤固定类型的参数

Type 'keyof T' does not satisfy the constraint '"a" | "b" | "c"'.
  Type 'string' is not assignable to type '"a" | "b" | "c"'.
    Type 'keyof T' is not assignable to type '"c"'.
      Type 'string' is not assignable to type '"c"'
Run Code Online (Sandbox Code Playgroud)

type GM = {
    a: number;
    b: string;
    c: string
}

type VMeth<T, C > = (old: T, n: C) => any;

const getVF = <T extends { [key in keyof Partial<GM>]: 1 }>(part: T):  VMeth<GM, Pick<GM, …
Run Code Online (Sandbox Code Playgroud)

typescript typescript-generics

7
推荐指数
1
解决办法
3万
查看次数

如何更改 Enter 键是运行代码还是接受 Chrome Devtools 控制台中的自动完成建议?

当我在控制台中输入内容并出现建议列表时,如果我按下,Enter则会选择第一个选项。我希望按 按Enter原样运行代码,并且仅当我按 时才插入建议Tab。这可能吗?

google-chrome-devtools

5
推荐指数
1
解决办法
1635
查看次数