We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Property 'error' does not exist on type 'T'.
currentBaz: T extends unknown
Related Issues:
Code
class Foo { public bar<T extends any>(baz: T[]): void { baz.forEach(currentBaz => { if (currentBaz.error) { console.log(currentBaz.error); } }) } }
"use strict"; class Foo { bar(baz) { baz.forEach(currentBaz => { if (currentBaz.error) { console.log(currentBaz.error); } }); } }
{ "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
The text was updated successfully, but these errors were encountered:
This is intended change Type Parameters That Extend any No Longer Act as any
any
Also see discussion in that PR #29571
Sorry, something went wrong.
@IllusionMH thanks
No branches or pull requests
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'.
BecausecurrentBaz: T extends unknown
instead extends `any.Related Issues:
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: