Ng2 does not compile with Typescript --strictNullChecks · Issue #8720 · angular/angular · GitHub
Skip to content

Ng2 does not compile with Typescript --strictNullChecks #8720

Closed

Description

@opensrcken

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.

Activity

  1. changed the title [-]Ng2 does not compile with Typescript Strict Null Checks[/-] [+]Ng2 does not compile with Typescript --strictNullChecks[/+] on May 19, 2016
  2. opensrcken commented on May 19, 2016

    @opensrcken
    ContributorAuthor

    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.

    export interface QueryMetadataFactory {
        (selector: Type | string, whatever?: {
            descendants?: boolean;
            read?: any;
        }): ParameterDecorator;
        new (selector: Type | string, whatever?: {
            descendants?: boolean;
            read?: any;
        }): QueryMetadata;
    }
    
  3. opensrcken commented on May 29, 2016

    @opensrcken
    ContributorAuthor

    After the fix to microsoft/TypeScript#8681, the only outstanding compiler error with strict null checks is

    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[]'.
    

    This seems like a simple fix.

  4. opensrcken commented on Jun 5, 2016

    @opensrcken
    ContributorAuthor

    Fixed.

  5. hlobil commented on Jun 20, 2016

    @hlobil

    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[]'.

  6. sam-s4s commented on Aug 4, 2016

    @sam-s4s

    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'.

  7. d-ph commented on Aug 14, 2016

    @d-ph

    Adding a unit test for checking, whether the whole angular2 project builds with typescript 2.0+ with strictNullChecks enabled, would be helpful.

  8. seanesss commented on Aug 18, 2016

    @seanesss

    I have this problem too.

  9. abierbaum commented on Sep 22, 2016

    @abierbaum

    I opened a new bug for this now that Angular 2.0.0 and Typescript 2 are both released.

    #11844

  10. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    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.

  11. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions