打字稿是否支持条件类型的某种形式的 AND 运算符?

问题描述 投票:0回答:1

例如,采用以下类型:

type TKeysofFunctionsStartingWithS<T, S extends string> = {
        [K in keyof T]: T[K] extends Function
            ? K extends `${S}${string}`
                ? K
                : never
            : never;
}[keyof T];

打字稿是否支持某种形式的 AND 运算符,允许这样的事情:

type TKeysofFunctionsStartingWithS<T, S extends string> = {
    [K in keyof T]: T[K] extends Function && K extends `${S}${string}`
        ? K
        : never
}[keyof T];
typescript conditional-types and-operator typescript-conditional-types
1个回答
0
投票

根据:https://www.tutorialspoint.com/typescript/typescript_operators.htm

AND 运算符在打字稿中为

&&

© www.soinside.com 2019 - 2024. All rights reserved.