question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for `useDefineForClassFields`

See original GitHub issue

Angular Material should support useDefineForClassFields as that is prospectively the default for classes. See: https://www.typescriptlang.org/v2/en/tsconfig#useDefineForClassFields

This flag is used as part of migrating to the upcoming standard version of class fields. […] This flag switches to the upcoming ECMA runtime behavior.

Currently, components might not be compatible. As seen below with MatColumnDef:

Reproduction

$ ng new --defaults=true test
$ cd test
$ ng add --defaults=true @angular/material 
$ ng generate @angular/material:table table
$ echo '<app-table></app-table>' > src/app/app.component.html
$ git add -A && git commit -m 'before'
$ cat tsconfig.json | jq '. * {compilerOptions: {useDefineForClassFields:true}}' > tsconfig.json2 && mv tsconfig.json2 tsconfig.json
$ ng build

ERROR in node_modules/@angular/material/table/cell.d.ts:42:5 - error TS2610: 'name' is defined as an accessor in class 'CdkColumnDef', but is overridden here in 'MatColumnDef' as an instance property.

42     name: string;
$ git diff
diff --git i/tsconfig.json w/tsconfig.json
index 8c4ef3b..f640ca7 100644
--- i/tsconfig.json
+++ w/tsconfig.json
@@ -14,7 +14,8 @@
     "lib": [
       "es2018",
       "dom"
-    ]
+    ],
+    "useDefineForClassFields": true
   },
   "angularCompilerOptions": {
     "fullTemplateTypeCheck": true,

Expected Behavior

no error

Actual Behavior

ERROR in node_modules/@angular/material/table/cell.d.ts:42:5 - error TS2610: 'name' is defined as an accessor in class 'CdkColumnDef', but is overridden here in 'MatColumnDef' as an instance property.

42     name: string;

Environment

NPM: 6.14.4 Angular CLI: 9.1.4 Node: 12.16.2 OS: darwin x64

$ npm ls --depth=0
test@0.0.0 /Users/dev/tmp/test
β”œβ”€β”€ @angular-devkit/build-angular@0.901.4
β”œβ”€β”€ @angular/animations@9.1.4
β”œβ”€β”€ @angular/cdk@9.2.2
β”œβ”€β”€ @angular/cli@9.1.4
β”œβ”€β”€ @angular/common@9.1.4
β”œβ”€β”€ @angular/compiler@9.1.4
β”œβ”€β”€ @angular/compiler-cli@9.1.4
β”œβ”€β”€ @angular/core@9.1.4
β”œβ”€β”€ @angular/forms@9.1.4
β”œβ”€β”€ @angular/language-service@9.1.4
β”œβ”€β”€ @angular/material@9.2.2
β”œβ”€β”€ @angular/platform-browser@9.1.4
β”œβ”€β”€ @angular/platform-browser-dynamic@9.1.4
β”œβ”€β”€ @angular/router@9.1.4
β”œβ”€β”€ @types/jasmine@3.5.10
β”œβ”€β”€ @types/jasminewd2@2.0.8
β”œβ”€β”€ @types/node@12.12.37
β”œβ”€β”€ codelyzer@5.2.2
β”œβ”€β”€ jasmine-core@3.5.0
β”œβ”€β”€ jasmine-spec-reporter@4.2.1
β”œβ”€β”€ karma@4.4.1
β”œβ”€β”€ karma-chrome-launcher@3.1.0
β”œβ”€β”€ karma-coverage-istanbul-reporter@2.1.1
β”œβ”€β”€ karma-jasmine@3.0.3
β”œβ”€β”€ karma-jasmine-html-reporter@1.5.3
β”œβ”€β”€ protractor@5.4.4
β”œβ”€β”€ rxjs@6.5.5
β”œβ”€β”€ ts-node@8.3.0
β”œβ”€β”€ tslib@1.11.1
β”œβ”€β”€ tslint@6.1.2
β”œβ”€β”€ typescript@3.8.3
└── zone.js@0.10.3

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
angular-robot[bot]commented, Feb 22, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular’s feature request process in our documentation.

0reactions
angular-robot[bot]commented, Mar 14, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn’t collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular’s scope, we’d encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useDefineForClassFields - TypeScript: TSConfig Option
TSConfig. useDefineForClassFields ... Get Help Β· Blog Β· GitHub Repo Β· Community Chat Β· @TypeScript Β· Stack Overflow Β· Web Repo.
Read more >
Add support for useDefineForClassFields typescript option
When I try to compile my application with next swc compiler I have this error : Error: [MobX] Cannot apply 'observable' to 'User@2.elo':...
Read more >
TypeScript: useDefineForClassFields – How to avoid future ...
The JavaScript programming language (or more correctly, the ECMAScript standard) did not fully support class properties at that time, since theΒ ...
Read more >
One or more browsers which are configured in the project's ...
In the file .browsersllist.rc you specify the version of the browser you want to support. Since Chrome 60 does not fully support ES6...
Read more >
TypeScript
... Better Support for never -Returning Functions; (More) Recursive Type Aliases; --declaration and --allowJs; The useDefineForClassFields Flag and TheΒ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found