Skip to content

Should not widen in type argument inference #1436

Description

Compile the following using noImplicitAny:

functionfoo<T>(x: T): T{returnx}interfaceI{x: string;}vari: I=foo({x: null});// Errorvars: string=f(null);// No error

Neither of these should be errors. According to the spec, both of these should widen, but in #531Daniel Rosenwasser (@DanielRosenwasser) and I explain why these should not widen.

The noImplicitAny error resulting from widening is a breaking change from 1.0, and it broke a customer.

Metadata

Metadata

Labels

Breaking ChangeWould introduce errors in existing codeSpecIssues related to the TypeScript language specification

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions