Closed
Description
TypeScript Version: 3.9.2 and 4.0.0 beta (works fine on 3.8.2 and below)
Search Terms: generic extend any unknown
Expected behavior:
This code should compile just fine
Actual behavior:
I get an error saying Property 'error' does not exist on type 'T'.
Because currentBaz: T extends unknown
instead extends `any.
Related Issues:
Code
class Foo {
public bar<T extends any>(baz: T[]): void {
baz.forEach(currentBaz => {
if (currentBaz.error) {
console.log(currentBaz.error);
}
})
}
}
Output
"use strict";
class Foo {
bar(baz) {
baz.forEach(currentBaz => {
if (currentBaz.error) {
console.log(currentBaz.error);
}
});
}
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}
Playground Link: Provided