angular-cli: AOT build error Cannot read property 'kind' of undefined
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0 Node: 8.5.0 OS: darwin x64 Angular: 5.0.1 … animations, common, compiler, compiler-cli, core, forms … http, language-service, platform-browser … platform-browser-dynamic, router
@angular/cdk: 5.0.0-rc0 @angular/cli: 1.5.0 @angular/flex-layout: 2.0.0-beta.10-4905443 @angular/material: 5.0.0-rc0 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.2 typescript: 2.4.2 webpack-bundle-analyzer: 2.9.1 webpack: 3.8.1
Repro steps.
rm -rf node_modules/ yarn add @angular/cli@latest -D ng build --aot
The log given by the failure.
ERROR in Error: TypeError: Cannot read property 'kind' of undefined at nodeCanBeDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7805:35) at nodeIsDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7825:16) at Object.nodeOrChildIsDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7829:16) at isDecoratedClassElement (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51668:23) at isInstanceDecoratedClassElement (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51659:20) at Object.filter (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:1652:25) at getDecoratedClassElements (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51641:23) at generateClassElementDecorationExpressions (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51815:27) at addClassElementDecorationStatements (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51804:44) at visitClassDeclaration (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51131:13) at visitTypeScript (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50972:28) at visitorWorker (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50785:24) at sourceElementVisitorWorker (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50817:28) at saveStateAndInvoke (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50738:27) at sourceElementVisitor (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50799:20) at visitNodes (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:49280:48)
Desired functionality.
AOT build should be successful
Mention any other details that might be useful.
The project built fine with AOT enabled with CLI v1.4.9
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 40
- Comments: 63 (13 by maintainers)
Links to this issue
Commits related to this issue
- Starting to use MazeTV API Now using real API to get TV show data. Moved selectors into its own service Removed commented out code. Starting to use MazeTV API Now using real API to get TV show da... — committed to mujtabahasni/cheapertv-app by deleted user 7 years ago
- Starting to use MazeTV API Now using real API to get TV show data. Moved selectors into its own service Removed commented out code. Starting to use MazeTV API Now using real API to get TV show da... — committed to mujtabahasni/cheapertv-app by deleted user 7 years ago
- Added Tv show detail view component and configured routing to assign paths to the views TV show detail view will now query the detail info from tvdb API by id. Added id to models. Added unit tests ... — committed to mujtabahasni/cheapertv-app by deleted user 7 years ago
- fix(@ngtools/webpack): allow typescript dev versions #8434 — committed to kevinbuhmann/angular-cli by kevinbuhmann 7 years ago
- fix(@ngtools/webpack): add missing parent to modified decorator nodes during aot transform Fix #8434 — committed to brentwilton/angular-cli by brentwilton 6 years ago
- [WIP] fix for AOT bug https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
- [WIP] fix for AOT bug https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
- add temporal fix for AOT build bug - read details for bug description https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
- fix: add temporal fix for AOT build - read details for bug description https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
- fix: add temporal fix for AOT build - read details for bug description https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
- Temporal fix for AOT build bug - read details for bug description https://github.com/angular/angular-cli/issues/8434 — committed to dkocich/osm-pt-ngx-leaflet by dkocich 6 years ago
@Axure it builds successfully for me with
ng build --prod --aot=false
I’m having the same problem and found it’s because of arrow functions in decorators, like:
@Type(() => Message)
When I change the above to:
It compiles with AOT again =)
Im having the same error since I use the md-bootstrap project.
I seem to have found out the problem. The problematic code there is:
It seems to fail to find the parent of the node when the node is a property declaration. I suddenly realized that it was the @select decorator from angular-redux, and I’m pretty sure the decorator is valid. So I tried adding the following line to bypass the check.
if (!node.parent) return true;
And it turns out to be working.@Brocco @clydin I still get the issue in the 1.6.5 cli version, I undid a class-transformer workaround (show at the end of this comment) and I still get the same kind error:
Typescript: 2.6.2 Angular: 5.2.1
Workaround used:
Install the latest CLI release 1.6.3 and install typescript@next.
In my case, the error was caused by arrow functions used as parameters of decorators. IE :
@someAnnotation(t=>!!t) someField;
for example To find them, use a Regexp search or add a console.log in the typescript.js file before re-compiling :Then it was easy to replace those with named function
The underlying cause is a defect in TypeScript which is fixed in newer versions of TypeScript. The CLI in more recent versions uses more capability of the TypeScript transformation subsystem. This in turn exposed the TypeScript defect to CLI users. As newer versions of TypeScript are not yet officially supported by Angular, the CLI will need to add a workaround for the underlying Typescript defect. The CLI already has a workaround in place for a different decorator related defect and this should be able to be augmented to support handling the defect here as well.
same error and my version is
"typescript": "~2.4.2"
@morganster this issue is about --aot compilation
I had the same issue with: Angular CLI 1.6.1 Typescript 2.4.2 Angular 5.0.2
Found a solution by changing typescript.js for now. Replace all the function
function nodeCanBeDecorated(node)
with the following codeWhich comes from here, if you compile typescript: https://github.com/shlomiassaf/TypeScript/commit/7017fa2a0a8137279230f04b59a6ec89f6928331
These steps worked for me: 1)Clear package.json with the importat packages for example I have delete my package and insert one by one here is my
I had the same issue. I could resolve it with installing dev version of angular/cli and typescript:
npm install @angular/cli@next npm install typescript@next
@filipesilva sorry to pressure, but is there any progress to report? For our teams, the CLI is currently frozen on v1.5.0.
Can verify that it’s angular-cli issue. Rollback to v1.6.0-beta.0 proved that.
@filipesilva can you please get a look here? actually blocking build process (aot)
Getting same error.
@angular/angular-cli 1.5.3 @angular/core 5.0.2 typescript 2.6.1
Running:
ng build --prod --aot
Produces:
Edit: I’ve also narrowed it down to a specific decorator I’m using throughout my app. Removing the instances of the
@Throttle()
decorator (fromlodash-decorators
) from my app “fixes” my issue.I had same problem today.
TypeError: Cannot read property 'kind' of undefined (...)
…and I fix it just upgrading my Typescript for 2.6.2.
Same issue with
"@angular/cli": "^1.6.8"
After installing the angular/cli dev version, I get the following problems: Stackoverflow - Angular CLI - After refreshing in browser the browser try to load files from a wrong location
Downgrading angular-cli seems to be the only solution at the moment.
https://github.com/typestack/class-transformer/issues/108
@rmrevin
Facing this issue with Angular Cli 1.5.2 Works fine with 1.5.0
Angular Version: 1.5.2
issue with md-bootstrap is fixed with typescript 2.7.1
Have a similar issue AOT build wont work, have to use --prod with --aot=fallse ERROR in : TypeError: Cannot read property ‘kind’ of undefined at nodeCanBeDecorated (node_modules\typescript\lib\typescript.js:7811:36)
Error fixed in typescript version 2.7.0-dev.20171201 https://github.com/Microsoft/TypeScript/pull/20314
In my case it turned out to be the fact that we were using 2 decorators on a function Our code was like this, which should work and is valid
Changing to below got rid of the error
@MohammedYaseen I’m not sure, but probably using a custom github repo as registry for the dependency
typescript
inpackage.json
would work. See this for example.Same error with cli 1.5.2. Downgraded to 1.5.0 and it worked.
@angular/cli: 1.5.2 @angular/xxxx: 5.0.2 typescript: 2.4.2