Try enforcing contextual type of array literal elements #19541
Open
Description
opened on Oct 27, 2017
Part of #19236
Code
const s1: string[] = ["x", 3, null as any];
const s2: string[] = ["x", 3];
Expected behavior:
s1
should be an errors2
should have an error span on3
Actual behavior:
s1
is not an errors2
has an error span ons2
, which makes it impossible to figure out which element is wrong
Hypothesis: When checking a contextually-typed array literal, if an element type isn't assignable to the contextual type, issue an error on that element and return unknownType
Activity