Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

No type inference from callback in mapped type #21273

Copy link
Copy link
@ghost

Description

TypeScript Version: 2.7.0-dev.20180118

Code

declare function conforms<T>(source: { [K in keyof T]: (val: T[K]) => boolean }): (value: T) => boolean;
conforms({ foo: (v: string) => false })({ foo: "foo" });

Expected behavior:

No error. T is inferred as { foo: string }.

Actual behavior:

T is inferred as { foo: {} }.

src/a.ts(2,10): error TS2345: Argument of type '{ foo: (v: string) => boolean; }' is not assignable to parameter of type '{ foo: (val: {}) => boolean; }'.
  Types of property 'foo' are incompatible.
    Type '(v: string) => boolean' is not assignable to type '(val: {}) => boolean'.
      Types of parameters 'v' and 'val' are incompatible.
        Type '{}' is not assignable to type 'string'.

Worked in 2.7.0-dev.20180116.

Detected in lodash on DefinitelyTyped.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.