Type alias TypePropertyNames<T, KT>

TypePropertyNames<T, KT>: { [ K in keyof T]: T[K] extends KT ? K : never }[keyof T]

选取T类型中值为KT类型的所有键

    class A
{
a = 1;
f(){}
}

var a: TypePropertyNames<A, number>; //var a: "a"
var a1: TypePropertyNames<A, Function>; //var a1: "f"

Type Parameters

  • T

  • KT

Generated using TypeDoc