Skip to content

Cannot read property 'flags' of undefined #19142

New issue

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

Closed
ghost opened this issue Oct 12, 2017 · 21 comments
Closed

Cannot read property 'flags' of undefined #19142

ghost opened this issue Oct 12, 2017 · 21 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@ghost
Copy link

ghost commented Oct 12, 2017

Been dealing with this for months, please fix.

./src/app/auth/auth.manager.ts
Module build failed: TypeError: Cannot read property 'flags' of undefined
    at resolveAlias (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:28064:36)
    at checkAliasSymbol (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46447:26)
    at checkImportBinding (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46477:13)
    at Object.forEach (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:1506:30)
    at checkImportDeclaration (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46498:32)
    at checkSourceElement (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46789:28)
    at Object.forEach (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:1506:30)
    at checkSourceFileWorker (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46862:20)
    at checkSourceFile (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46842:13)
    at getDiagnosticsWorker (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46906:17)
    at getDiagnostics (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:46892:24)
    at Object.getEmitResolver (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:27162:13)
    at C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:70021:69
    at runWithCancellationToken (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:69779:24)
    at getDeclarationDiagnosticsForFileNoCache (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:70020:20)
    at getAndCacheDiagnostics (C:\Users\brian.cullinan\Documents\portal\node_modules\typescript\lib\typescript.js:70033:26)
 @ ./src/app/core/core.module.ts 19:0-51
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:9090 ./src/main.ts
@mhegazy
Copy link
Contributor

mhegazy commented Oct 13, 2017

what version are you seeing this on? have you tried on typescript@next? what is the source code that is causing this issue to happen?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Oct 13, 2017
@ghost
Copy link
Author

ghost commented Oct 13, 2017 via email

@mhegazy
Copy link
Contributor

mhegazy commented Oct 14, 2017

We would be happy to sign any required NDA to get access to the code. you can also email me directly a sample that reproduces the issue on my github username @microsoft.com.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

You can email me the zip file.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

You can also launch the compiler under node inspector, assuming you have node v7 or later

node --inspect --debug-brk node_modules\typescript\lib\tsc.js --p <path to your tsconfig.json>

in your chrome go to chrome://inspect. let the process run, when it breaks, there should be getSemanticDiagnosticsForFileNoCache on the stack. Look up the value of sourceFile.fileName in your watch window, this should tell you which file is causing the issue. you can also dump the diagnostic object that is the argument of the function.

@ghost
Copy link
Author

ghost commented Oct 16, 2017 via email

@ghost
Copy link
Author

ghost commented Oct 16, 2017

Any ideas @filipesilva ?

@filipesilva
Copy link
Contributor

filipesilva commented Oct 16, 2017

@megamindbrian this looks like a bug with one of the transforms we use in Angular CLI. Impossible to tell what's happening just from the log though. Can you open an issue on https://github.com/angular/angular-cli and include a reproduction of what I can do to see the error myself?

Meanwhile if you want to inspect the error you can use the following command: node --inspect --debug-brk ./node_modules/@angular/cli/bin/ng serve.

@ghost
Copy link
Author

ghost commented Oct 16, 2017

Perfect, thank you! This is gold. I didn't even know this was possible.

@ghost
Copy link
Author

ghost commented Oct 16, 2017

Cool, just got it to fail in the debugger. Looks like if you are editing a file in watch mode, and you create something invalid like <new line> alert with no semi-colon. Save. Edit, and remove the line alert.
Watch never recovers from errors and just displays this flags error.

image

@filipesilva
Copy link
Contributor

Awesome, that's definitely not intended. Please include that reproduction in the CLI issue, together with the other details. Angular and TS versions are especially important because we use different pipeline depending on those.

@ghost
Copy link
Author

ghost commented Oct 16, 2017

I got it to break in the typescript compiler on an Injectable token, but I am not sure what file or anything unusual that is causing it:

image

I'll probably hunt around a bit and then try some different versions. Thank you for the good starting point!

@RyanCavanaugh
Copy link
Member

@megamindbrian running ts.getTextOfNode(node) ts.getTextOfNode(node.parent) at that point in the debugger's console window should tell you the offending node

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Oct 16, 2017

(You can keep adding .parent until the entire node context becomes obvious)

@ghost
Copy link
Author

ghost commented Oct 16, 2017

@RyanCavanaugh Yeah, I dropped down to getDiagnostics(), and it was just the same file that I edited erroneously. Maybe watch doesn't recover on Injectables because there is no configuration options? Injectable() takes 0 arguments? I am trying typescript@next now. I haven't updated Angular 4 in a while (~ a least a month).

@ghost
Copy link
Author

ghost commented Oct 16, 2017

Confirmed this Module build failed: TypeError: Cannot read property 'flags' of undefined
error only occurs (for me) when a mistake is made in an Injectable, and then corrected. Watch mode doesn't recover on that specific file until another correct change is made.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

can you get us a small sample that makes it crash?

@ghost
Copy link
Author

ghost commented Oct 16, 2017 via email

@ghost
Copy link
Author

ghost commented Oct 16, 2017 via email

@mhegazy
Copy link
Contributor

mhegazy commented Oct 30, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Oct 30, 2017
@lddubeau
Copy link

lddubeau commented Nov 2, 2017

As megamindbrian's last comment suggests, switching TypeScript versions may be enough to fix the issue. I had it with TS 2.4. It went away after switching to TS 2.6.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants