Skip to content

Commit 587532d

Browse files
committed
intersect duh
1 parent b0f0fc5 commit 587532d

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19173,7 +19173,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1917319173

1917419174
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) {
1917519175
if (indexType.flags & TypeFlags.Substitution) {
19176-
indexType = (indexType as SubstitutionType).baseType;
19176+
indexType = getSubstitutionIntersection(indexType as SubstitutionType);
1917719177
}
1917819178
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined;
1917919179
const propName = accessNode && isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);

tests/baselines/reference/nonGenericIndexedAccessInConditionalTrueBranch1.symbols

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ type E = "k" extends keyof C ? C["k" | "other"] : never;
3737
>C : Symbol(C, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 6, 46))
3838
>C : Symbol(C, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 6, 46))
3939

40+
type F = keyof C extends "k" ? C[keyof C] : never;
41+
>F : Symbol(F, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 14, 56))
42+
>C : Symbol(C, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 6, 46))
43+
>C : Symbol(C, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 6, 46))
44+
>C : Symbol(C, Decl(nonGenericIndexedAccessInConditionalTrueBranch1.ts, 6, 46))
45+

tests/baselines/reference/nonGenericIndexedAccessInConditionalTrueBranch1.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ type E = "k" extends keyof C ? C["k" | "other"] : never;
3939
>E : boolean | symbol
4040
> : ^^^^^^^^^^^^^^^^
4141

42+
type F = keyof C extends "k" ? C[keyof C] : never;
43+
>F : never
44+
> : ^^^^^
45+

tests/cases/compiler/nonGenericIndexedAccessInConditionalTrueBranch1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ type C = {
1616

1717
type D = "k" extends keyof C ? C["k"] : never;
1818
type E = "k" extends keyof C ? C["k" | "other"] : never;
19+
type F = keyof C extends "k" ? C[keyof C] : never;

0 commit comments

Comments
 (0)