You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeIsString<X>=[X]extends[string] ? true : falsefunctionisString<Xextendsstring,Y>(x: X,y: Y){if(typeofx==="string"){// 因为 typeof x === 'string' 并没有为 X 增加额外的信息 (X 本来就 extends string)x;// X extends string,consta: IsString<typeofx>=true;// error: conditional type is deferred}if(typeofy==="string"){// 1. Y 原来并没有任何约束, (no extends)// 2. typeof y === 'string' -> typeof y <: string, // 3. 同时 y: Y, // 4. 所以 typeof y <: Y & stringy;// Y & string,constb: IsString<typeofy>=true;}}
microsoft/TypeScript#29939 (comment)
The text was updated successfully, but these errors were encountered: