Skip to content
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

Ng2 does not compile with Typescript --strictNullChecks #8720

Closed
opensrcken opened this issue May 19, 2016 · 9 comments
Closed

Ng2 does not compile with Typescript --strictNullChecks #8720

opensrcken opened this issue May 19, 2016 · 9 comments

Comments

@opensrcken
Copy link
Contributor

opensrcken commented May 19, 2016

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.

@opensrcken opensrcken changed the title Ng2 does not compile with Typescript Strict Null Checks Ng2 does not compile with Typescript --strictNullChecks May 19, 2016
@opensrcken
Copy link
Contributor Author

opensrcken commented 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.

export interface QueryMetadataFactory {
    (selector: Type | string, whatever?: {
        descendants?: boolean;
        read?: any;
    }): ParameterDecorator;
    new (selector: Type | string, whatever?: {
        descendants?: boolean;
        read?: any;
    }): QueryMetadata;
}

@opensrcken
Copy link
Contributor Author

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.

opensrcken added a commit to opensrcken/angular that referenced this issue May 29, 2016
opensrcken added a commit to opensrcken/angular that referenced this issue May 29, 2016
Currently, compiling an ng2 project with TS 1.9 strict null checking causes the following compilation error:
```
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[]'.
```
The change to the d.ts file in this pull request eliminates this compilation error.

Reference: angular#8720
opensrcken added a commit to opensrcken/angular that referenced this issue May 29, 2016
Currently, compiling an ng2 project with TS 1.9 strict null checking causes the following compilation error:

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

The change to the d.ts file in this pull request eliminates this compilation error.

Fixes: angular#8720
opensrcken added a commit to opensrcken/angular that referenced this issue May 29, 2016
Eliminate the following compiler error when using TS 1.9+ with strict null checking enabled:

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

angular#8720
mhevery pushed a commit that referenced this issue Jun 1, 2016
#8902)

Eliminate the following compiler error when using TS 1.9+ with strict null checking enabled:

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

#8720
@opensrcken
Copy link
Contributor Author

Fixed.

@hlobil
Copy link

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

KiaraGrouwstra pushed a commit to KiaraGrouwstra/angular that referenced this issue Jun 21, 2016
angular#8902)

Eliminate the following compiler error when using TS 1.9+ with strict null checking enabled:

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

angular#8720
@sam-s4s
Copy link

sam-s4s commented 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
Copy link

d-ph commented 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.

@sseefried
Copy link

I have this problem too.

@abierbaum
Copy link

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

#11844

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants