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

Verbose Debug Information: Node 94 (NullKeyword) was unexpected on typescript 2.1.1 #12684

Closed
zhouweiming opened this issue Dec 6, 2016 · 16 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@zhouweiming
Copy link

zhouweiming commented Dec 6, 2016

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.20161206)

When I compile my angular2 project with webpack and awesome-typescript-loader, get errors:

[at-loader] Using typescript@2.2.0-dev.20161206 from typescript and "tsconfig.json" from /Users/zhouweiming/data/project/iermu_opssite/src/tsconfig.json

/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:62645
                throw e;
                ^

Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node 94 (NullKeyword) was unexpected.
    at Object.assert (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:3177:23)
    at Object.Debug.failBadSyntaxKind (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:44765:55)
    at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46715:30)
    at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46683:56)
    at serializeTypeOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46544:28)
    at serializeParameterTypesOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46596:42)
    at addOldTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46471:98)
    at addTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46462:17)
    at transformAllDecoratorsOfDeclaration (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46301:13)
    at generateConstructorDecorationExpression (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46411:40)

get same error on typescript@2.1.1 and typescript@2.0.10 and typescript@2.2.0-dev.20161206.

other env:

  • mac os: 10.12.1
  • node: 7.2.0
  • webpack: 1.13.3
  • angular: 2.2.4
  • awesome-typescript-loader: 3.0.0-beta.9

When I remove @Injectable() from all my codes, my project can compile success, but in browser I get errors: can't resolve all params in a class who depend another @Injectable() class.

@aluanhaddad
Copy link
Contributor

Does it work with tsloader?

@zhouweiming
Copy link
Author

@aluanhaddad same error with tsloader@1.3.0.

ts-loader: Using typescript@2.2.0-dev.20161206 and /Users/zhouweiming/data/project/iermu_opssite/src/tsconfig.json
Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node 94 (NullKeyword) was unexpected.
    at Object.assert (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:3177:23)
    at Object.Debug.failBadSyntaxKind (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:44765:55)
    at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46715:30)
    at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46683:56)
    at serializeTypeOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46544:28)
    at serializeParameterTypesOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46596:42)
    at addOldTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46471:98)
    at addTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46462:17)
    at transformAllDecoratorsOfDeclaration (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46301:13)
    at generateConstructorDecorationExpression (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46411:40)
    at addConstructorDecorationStatement (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:46399:30)
    at visitClassDeclaration (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45681:13)
    at visitTypeScript (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45536:28)
    at visitorWorker (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45351:24)
    at sourceElementVisitorWorker (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45383:28)
    at saveStateAndInvoke (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45304:27)
    at sourceElementVisitor (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45365:20)
    at visitNodes (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:44366:48)
    at Object.visitLexicalEnvironment (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:44404:22)
    at visitSourceFile (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45622:53)
    at saveStateAndInvoke (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45304:27)
    at transformSourceFile (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.2.0-dev.20161206/lib/typescript.js:45288:27)

@aluanhaddad
Copy link
Contributor

That's very strange. I haven't seen that error in my Angular project and I've been using 2.1.1 (rc) for weeks now. I've been using the latest available tsloader, the same version of webpack and the previous patch release 2.2.3.

@zhouweiming
Copy link
Author

zhouweiming commented Dec 6, 2016

@aluanhaddad

That's really strange, I am preparing a simple demo to test again.

that is my tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "lib": ["dom", "es2015"],
    "rootDirs": ["./"],
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noUnusedParameters": false,
    "noUnusedLocals": false,
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "compileOnSave": true,
  "exclude": [
    "node_modules/*",
    "config/helpers.js",
    "config/webpack.common.js",
    "config/webpack.dev.js",
    "config/webpack.prod.js",
    "webpack.config.js",
    "gulpfile.js"
  ]
}

@aluanhaddad
Copy link
Contributor

Host your demo on GitHub and I'll take a look later.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Dec 6, 2016
@zhouweiming
Copy link
Author

zhouweiming commented Dec 7, 2016

thanks at first, @aluanhaddad @mhegazy

simple demo is here:
https://github.com/zhouweiming/tsissuedemo

  • clone it
  • cd tsissuedemo/src
  • npm install
  • npm run dev

you will see the error.

tried any of the following three ways, can be resolved this error, but I do not know why:

  • remove @Injectable() from src/services/base.service.ts
  • change private model_name: string | null to private model_name: string in src/services/passport.service.ts
  • remove private model_name: string | null from src/services/base.service.ts and change super("") to super() in src/services/passport.service.ts

But before and include the version 2.0.3, these codes can compile success.

@aluanhaddad
Copy link
Contributor

Still investigating, so far this looks related to #11391

@aluanhaddad
Copy link
Contributor

Looks like this has to do with how Angular 2 statically captures decorators into ngfactories...

@aluanhaddad
Copy link
Contributor

aluanhaddad commented Dec 7, 2016

OK, I believe I have found the root cause and this issue is external, and only incidentally worked in previous versions of TypeScript.

Angular 2 does not support inherited decorators.
As of this commit angular/angular@f5c8e09, which is in angular@2.3.0-rc.0, Angular 2 has added support for inheriting decorators.

Prior to typescript@2.1.*, inherited decorators would have been ignored, by both Angular 2 and TypeScript but I suspect the change to use the return value of super as this may be the reason for this breakage.

@zhouweiming Upgrading your project's @angular dependencies to 2.3.0-rc.0 resolved the issue.

@mhegazy This may also be related to how Angular 2 treats decorators. It considers them to be pseudo-design time constructs and they get transformed into class properties of the factories that the angular compiler generates, the consumption of decorators by Angular is a bit odd since they lose much of their capabilities but this is not obvious to users and is poorly documented in Angular.

@aluanhaddad
Copy link
Contributor

ugh now it stopped working again 😭

@zhouweiming
Copy link
Author

Yes, I also tried it at angular@2.3.0-rc.0, same error again

@aluanhaddad
Copy link
Contributor

Sign my error was I ran tsc to test something and forgot to clean the output. Webpack was loading the transpiled sources which do work...

@zhouweiming
Copy link
Author

@aluanhaddad I found another issue.

in project: https://github.com/zhouweiming/tsissuedemo

  • cd src
  • add import "jquery" in src/public/common.ts
  • change typescript@2.2.0-dev.20161206 to typescript@2.1.1
  • rm -rf node_modules
  • npm install
  • npm run dev

show errors:

[at-loader] Checking started in a separate process...

[at-loader] Checking finished with 2 errors
[at-loader] node_modules/.@types/jquery@2.0.34/index.d.ts:3246:5 
    Duplicate identifier 'export='. 

[at-loader] node_modules/@types/jquery/index.d.ts:3246:5 
    Duplicate identifier 'export='. 

webpack built af2844b1d7c2435617f5 in 5851ms

but compile success at typescript@2.2.0-dev.20161206

@andfaulkner
Copy link
Contributor

andfaulkner commented Dec 19, 2016

This isn't an Angular-specific problem: I'm getting exactly the same error with a React project I'm using Typescript 2.1.4 with. Note that I'm also using MobX and mobx-react, with the decorator syntax (@observer etc.). I can post more information if it will help.

@mhegazy mhegazy added this to the TypeScript 2.2 milestone Dec 19, 2016
@mhegazy mhegazy added the Bug A bug in TypeScript label Dec 19, 2016
@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Needs More Info The issue still hasn't been fully clarified labels Dec 20, 2016
@tdsmithATabc
Copy link

tdsmithATabc commented Feb 14, 2017

(For historical information:)

I was experiencing this on TS 2.0.3 when I was using a decorator on a constructor argument whose type was declared to be null:

export class RootComponent {
  public constructor (@Inject(LAUNCH_DEPENDENCIES) ld : null) {}
}

In this case the injected value is actually null because it is a special injector token we use to instantiate a number of services eagerly. (We wanted it to be apparent that the value had no utility itself.)

Since we aren't able to upgrade TS at the moment, we got around it simply by changing the typing to any.

@kt215
Copy link

kt215 commented Jun 15, 2017

This issue was resolved after I upgraded to TypeScript 2.3.4.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

7 participants