TypeScript/tests/baselines/reference/inOperator.errors.txt
Andrew Branch b0f5e35777
'in' should not operate on primitive types (#41928 + @andrewbranch) (#42288)
* 'in' should not operate on primitive types

* accept baselines of failing tests

* review

* update error message

* check if constraint of right type is assignable to a non primitive or instantiable non primitive

* do not throw errors where narrowing is impossible

* accept baselines

* fix test case failures

* Add more accurate comment discussion and document failing edge case in test

* Update baselines

Co-authored-by: Jonas Hübotter <jonas.huebotter@gmail.com>
2021-01-11 16:46:08 -08:00

18 lines
460 B
Plaintext

tests/cases/compiler/inOperator.ts(7,15): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
==== tests/cases/compiler/inOperator.ts (1 errors) ====
var a=[];
for (var x in a) {}
if (3 in a) {}
var b = '' in 0;
~
!!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
var c: any;
var y: number;
if (y in c) { }