Support for `useDefineForClassFields`
See original GitHub issueAngular 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:
- Created 3 years ago
- Reactions:4
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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.