{{ message }}
Repository navigation
Ng2 does not compile with Typescript --strictNullChecks #8720
Copy link
Copy link
Closed
Description
IMPORTANT: This repository's issues are reserved for feature requests and bug reports. Do not submit support requests here, see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question.
Steps to reproduce and a minimal demo of the problem
# set up ng2 quick start -- https://angular.io/docs/ts/latest/quickstart.html
> npm install typescript@next -g
# set `strictNullChecks: true` in `tsconfig.json`.
> npm start
> tsc && concurrently "npm run tsc:w" "npm run lite"
node_modules/@angular/core/src/metadata.d.ts(356,32): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(356,45): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(360,36): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(360,49): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(369,32): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(369,45): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(373,36): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(373,49): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(382,32): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(385,36): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(393,32): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(396,36): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(404,32): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata.d.ts(407,36): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(147,44): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(147,57): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'first' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(147,64): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(193,44): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(193,57): error TS2459: Type '{ descendants?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(220,44): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(261,44): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'descendants' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(261,57): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'first' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(261,64): error TS2459: Type '{ descendants?: boolean | undefined; first?: boolean | undefined; read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(351,44): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/di.d.ts(427,44): error TS2459: Type '{ read?: any; } | undefined' has no property 'read' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,18): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'selector' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,28): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'inputs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,36): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'outputs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,45): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'properties' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,57): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'events' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,65): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'host' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,71): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'bindings' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,81): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'providers' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,92): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'exportAs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(721,102): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'queries' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,18): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'selector' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,28): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'inputs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,36): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'outputs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,45): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'properties' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,57): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'events' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,65): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'host' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,71): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'exportAs' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,81): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'moduleId' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,91): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'bindings' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,101): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'providers' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,112): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'viewBindings' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,126): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'viewProviders' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,141): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'changeDetection' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,158): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'queries' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,167): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'templateUrl' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,180): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'template' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,190): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'styleUrls' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,201): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'styles' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,209): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'directives' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,221): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'pipes' and no string index signature.
node_modules/@angular/core/src/metadata/directives.d.ts(844,228): error TS2459: Type '{ selector?: string | undefined; inputs?: string[] | undefined; outputs?: string[] | undefined; p...' has no property 'encapsulation' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,18): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'templateUrl' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,31): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'template' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,41): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'directives' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,53): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'pipes' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,60): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'encapsulation' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,75): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'styles' and no string index signature.
node_modules/@angular/core/src/metadata/view.d.ts(114,83): error TS2459: Type '{ templateUrl?: string | undefined; template?: string | undefined; directives?: (Type | any[])[] ...' has no property 'styleUrls' and no string index signature.
node_modules/@angular/core/src/util/decorators.d.ts(9,5): error TS2411: Property 'extends' of type 'Type | undefined' is not assignable to string index type 'Type | Function | any[]'.
Current behavior
Compilation fails.
Expected/desired behavior
Compilation succeeds.
Other information
Strict null checking is a highly anticipated feature that will come to Typescript 1.9. I think lots of Typescript developers would appreciate support for it in ng2.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Issue actions
You can’t perform that action at this time.

Activity
[-]Ng2 does not compile with Typescript Strict Null Checks[/-][+]Ng2 does not compile with Typescript --strictNullChecks[/+]opensrcken commentedon May 19, 2016
Many of those errors might be caused by an issue with the compiler. I've opened an issue here to be sure: microsoft/TypeScript#8681 to get the TS team's take.
If this issue is not addressed in the Typescript compiler, a current working solution seems to be replacing the destructuring in the interface with a standard variable name. The implementers of the interface are still allowed to destructure in their function signatures. e.g.
opensrcken commentedon May 29, 2016
After the fix to microsoft/TypeScript#8681, the only outstanding compiler error with strict null checks is
This seems like a simple fix.
Allow angular2 to compile with TS --strictNullChecks
fix(d.ts): enable angular2 compilation with TS flag --strictNullChecks
fix(d.ts): enable angular2 compilation with TS flag --strictNullChecks
fix(d.ts): enable angular2 compilation with TS flag --strictNullChecks
fix(d.ts): enable angular2 compilation with TS flag --strictNullChecks (
opensrcken commentedon Jun 5, 2016
Fixed.
hlobil commentedon Jun 20, 2016
I have rc2 and 1.9.0-dev.20160620-1.0.
I am still getting error when enabling strict null check.
9 extends?: Type;
~~~~~~~~~~~~~~~
node_modules/@angular/core/src/util/decorators.d.ts(9,5): error TS2411: Property 'extends' of type 'Type | undefined' is not assignable to string index type 'Type | Function | any[]'.
sam-s4s commentedon Aug 4, 2016
Any word on this?
I just tried strictNullChecks on rc4 (and typescript 2.1.0-dev.20160803) and I get the same error as above...
ERROR in [default] C:\test\node_modules@angular\core\src\util\decorators.d.ts:18:4
Property 'extends' of type 'Type | undefined' is not assignable to string index type 'Function | any[] | Type'.
d-ph commentedon Aug 14, 2016
Adding a unit test for checking, whether the whole angular2 project builds with typescript 2.0+ with strictNullChecks enabled, would be helpful.
seanesss commentedon Aug 18, 2016
I have this problem too.
abierbaum commentedon Sep 22, 2016
I opened a new bug for this now that Angular 2.0.0 and Typescript 2 are both released.
#11844
angular-automatic-lock-bot commentedon Sep 9, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.