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.

Updating to Angular 5 and the latest ng-packagr gives library build errors Cannot read property 'type' of undefined

See original GitHub issue

Type of Issue

[*] Bug Report
[ ] Feature Request

Description

I have updated angular to 5.0 (cli - 1.5.0). Angular suggests to update typescript to version ‘>=2.4.2 & <2.5.0’

but when i Build my library with “build”: “ng-packagr -p ng-package.json”, it gives me an error

BUILD ERROR Cannot read property ‘type’ of undefined TypeError: Cannot read property ‘type’ of undefined - this is with the node_modules typescript.js file.

I can get rid of this error by updating typescript to latest i.e, 2.6.1, but then angular gives an build warning

build warning -> angular/compiler-cli@5.0.0 requires typescript@‘>=2.4.2 <2.5.0’ but 2.6.1 was found instead. Using this version can result in undefined behaviour and difficult to debug problems.

How To Reproduce

update ng-packagr to latest version update angular to 5.0

Then build your package with “build”: “ng-packagr -p ng-package.json”

Expected Behaviour

Should be working fine typescript@‘>=2.4.2 <2.5.0’

Version Information

ng-packagr: "^1.5.0"
node: v7.7.2
@angular: v5.0.0
 rxjs: ^5.4.2,
 zone.js: 0.8.14

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
minuzcommented, Nov 14, 2017

I found what was wrong on our package. We had one import { Observable } from 'rxjs'; replaced that with

import { Observable } from "rxjs/Observable";
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/mergeMap';

My version info:

        "versions": {
            "angular": "5.0.1",
            "angularCli": "1.5.0",
            "ngPackagr": "1.6.0-rc.0",
            "coreJs": "2.5.1",
            "zoneJs": "0.8.18",
            "rxJs": "5.5.2",
            "typescript": "2.4.2"
        }

And this is working fine.

2reactions
Anirudh-Konduricommented, Nov 10, 2017

Hi @dherges

Thanks for your response.

I have tried with both the versions. I have typescript v2.4.2

with v1.5.1 i get the same error, BUILD ERROR Cannot read property 'type' of undefined TypeError: Cannot read property 'type' of undefined

with v1.6.0-rc.0, i get a different error now, BUILD ERROR ENOENT: no such file or directory, open '/Library/WebServer/istweb/Documents/supporting-apps/istweb-core/src/istweb-core/.ng_pkg_build/@ccs-istweb-core/ts/istweb-core.js' Error: ENOENT: no such file or directory, open '/Library/WebServer/istweb/Documents/supporting-apps/istweb-core/src/istweb-core/.ng_pkg_build/@ccs-istweb-core/ts/istweb-core.js'

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'type' of null - Stack Overflow
The solution was to make sure to export any components / modules via typescript that I exported in the NgModule . Example problem...
Read more >
Component testing scenarios - Angular
Error : This test module uses the component BannerComponent which is using a "templateUrl" or "styleUrls", but they were never compiled. Please call...
Read more >
FormControlName - Angular
Syncs a FormControl in an existing FormGroup to a form control element by name. ... The top-level directive for this group if present,...
Read more >
NgForm - Angular
Property, Description. submitted: boolean, Read-Only. Returns whether the form submission has been triggered. form: FormGroup.
Read more >
AbstractControl - Angular
An object containing any errors generated by failing validation, or null if there are no errors. pristine: boolean, Read-Only. A control is pristine...
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