TypeScript: TypeError: Cannot read property 'flags' of undefined
TypeScript Version: 3.7.2
How to reproduce
- (Step 1) Create file
test.js
(function () {
var obj = {};
/**
* test test
* @constructor
* @remind remind
* @param { Object } options param
* @example
* ```javascript
* var editor = new UE.Editor();
* editor.execCommand('blod');
* ```
* @see TEST.Config
*/
var a = obj.a = function (options) {
console.log(this)
};
})();
- (Step 2) Create file
tsconfig.json
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"newLine": "lf",
"target": "es5"
},
"files": [
"test.js"
]
}
- (Step 3) Open git bash, run command
tsc
Expected behavior: no errors
Actual behavior:
$ tsc
C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:78566
throw e;
^
TypeError: Cannot read property 'flags' of undefined
at getFlowTypeOfReference (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:42017:80)
at tryGetThisTypeAt (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:43171:28)
at checkThisExpression (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:43135:24)
at checkExpressionWorker (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:48624:28)
at checkExpression (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:48578:38)
at checkExpressionWithContextualType (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:48319:24)
at getSignatureApplicabilityError (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:45667:35)
at chooseOverload (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:46035:25)
at resolveCall (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:45938:26)
at resolveCallExpression (C:\Users\talen\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:46256:20)
Playground Link:
Related Issues:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 22
- Comments: 31 (2 by maintainers)
solution :
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4
npm install
ng serve
Hi, I’m getting the error
**ERROR in TypeError: Cannot read property 'flags' of undefined**
When i updated to latest angular-cli packages previous versioncurrent updated to latest which is
Can somebody help me please.
Same here. Created a new app just a few hours ago and got the same error set as others before in this thread.
Angular: 9.1.5 … animations, common, compiler, compiler-cli, core, forms … language-service, platform-browser, platform-browser-dynamic … router, service-worker Ivy Workspace: Yes
Package Version
@angular-devkit/architect 0.901.4 @angular-devkit/build-angular 0.901.4 @angular-devkit/build-optimizer 0.901.4 @angular-devkit/build-webpack 0.901.4 @angular-devkit/core 9.1.4 @angular-devkit/schematics 9.1.4 @angular/cli 9.1.4 @ngtools/webpack 9.1.4 @schematics/angular 9.1.4 @schematics/update 0.901.4 rxjs 6.5.5 typescript 3.8.3 webpack 4.42.0
still an issue. facing the same with angular 10
“@angular/animations”: “^10.1.0”, “@angular/common”: “^10.1.0”, “@angular/compiler”: “^10.1.0”, “@angular/core”: “^10.1.0”, “@angular/forms”: “^10.1.0”, “@angular/platform-browser”: “^10.1.0”, “@angular/platform-browser-dynamic”: “^10.1.0”, “@angular/router”: “^10.1.0”, “@angular-devkit/build-angular”: “~0.1001.3”, “@angular/cli”: “~10.1.3”, “@angular/compiler-cli”: “^10.1.0”, “@angular/language-service”: “^10.1.0”,
Edit: this is really giving me headaches. i found this:
it’s worked. thanks
Are you using Yarn? I am getting this error when using yarn
Something is broken in Angular 9.1.5 - if you run the following it should work:
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4
ng build Just spent about 4-5 hours trying to fix it myself…
The issue seems to stem from using Angular CLI 9.1.4 with Angular 9.1.5 (most likely the compiler
You’ll see the issue when you do
ng --version if you get:
Angular CLI: 9.1.4 Node: 12.16.3 OS: win32 x64
Angular: 9.1.5 … animations, cli, common, compiler, compiler-cli, core, forms … language-service, platform-browser, platform-browser-dynamic … router Ivy Workspace: Yes Then you will need to follow the npm installs i listed above
Same error angular 10. Tried downgrading to 9.1.4, no difference, nothing works
“dependencies”: { “@angular/animations”: “^10.0.3”, “@angular/common”: “^10.0.3”, “@angular/compiler”: “^10.0.3”, “@angular/core”: “^10.0.3”, “@angular/forms”: “^10.0.3”, “@angular/language-service”: “^10.0.3”, “@angular/platform-browser”: “^10.0.3”, “@angular/platform-browser-dynamic”: “^10.0.3”, “@angular/router”: “^10.0.3”, “rxjs”: “~6.6.0”, “tslib”: “^2.0.0”, “zone.js”: “~0.10.3” }, “devDependencies”: { “@angular-builders/custom-webpack”: “^9.2.0”, “@angular-devkit/build-angular”: “^0.1000.2”, “@angular/cli”: “^10.0.2”, “@angular/compiler-cli”: “^10.0.3”, “@types/jasmine”: “~3.5.11”, “@types/jasminewd2”: “~2.0.8”, “@types/node”: “^14.0.23”, “buffer”: “^5.6.0”, “child_process”: “^1.0.2”, “codelyzer”: “^6.0.0”, “eslint”: “^7.4.0”, “fs”: “0.0.1-security”, “jasmine-core”: “~3.5.0”, “jasmine-spec-reporter”: “~5.0.2”, “karma”: “~5.1.0”, “karma-chrome-launcher”: “~3.1.0”, “karma-coverage-istanbul-reporter”: “~3.0.3”, “karma-jasmine”: “~3.3.1”, “karma-jasmine-html-reporter”: “^1.5.4”, “net”: “^1.0.2”, “process”: “^0.11.10”, “protractor”: “~7.0.0”, “tls”: “0.0.1”, “ts-node”: “~8.10.2”, “tslint”: “~6.1.2”, “typescript”: “^3.9.6” }
its worked for me! Thanks
Hello everyone , My problem is solved by downgrade which is probably not a fix at all but it works ! @shikhasreekumar99 : thank you 👍
Step 1 : 👍
Permanently delete your node modules.
Step 2 : 👍
RUN THIS COMMAND ON YOUR CONSOLE
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4
Step 3 : 💯
CONGRATULATIONS YOU SUCCESSFULLY DOWNGRADED THE DEPENDENCIES AND THE TYPEERROR IS RESOLVED SUCCESSFULLY Now you may try these !
ng serve --open ng build .............etc
SCREEN SHOT OF SUCCESFULL NG SERVE
this is only downgrade, not fix