Skip to content

No contextual type from indexed access into intersection type #27224

Closed
@ghost

Description

TypeScript Version: 3.1.0-dev.20180828

Code

type Keys = "a" | "b";

type OptionsForKey = { a: { cb: (p: number) => number } } & { b: {} };

declare function f<K extends Keys>(key: K, options: OptionsForKey[K]): void;

f("a", {
    cb: p => p,
});

Expected behavior:

No error.

Actual behavior:

src/a.ts:8:9 - error TS7006: Parameter 'p' implicitly has an 'any' type.

Broken by #26281

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions