-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 2.5.2
Code
let array = [];
array.push(1); // tsc error: 1 is not never;
console.log(array);Compiler Options
{
"target": "es2017",
"module": "commonjs",
"strict": true,
"noImplicitAny": false,
"noImplicitThis": false,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}Expected behavior
» tsc⏎
# a pause of nothingnessActual behavior
» tsc
2 array.push(1); // tsc error: {} is not never;
~
example.ts(2,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'never'.
Potential causes
After some testing, I did pinpoint the culprit behind this problem in my compiler options:
"noImplicitAny": falseIt seems that setting noImplicitAny to true does not suffer from this issue but for some reason false seems to result in the opposite effect of what is expected.
So in my opinion, somewhere in related to parsing this particular compiler option there might be some assumption related to the various possible values for the tri-states of noImplicitAny.
Sample Project:
typescript-empty-array-issue.zip
» yarn && yarn buildThanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug