microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.82k stars 12.46k forks source link

Error: Debug Failure. False expression: Unexpected node. #11933

Closed ghost closed 7 years ago

ghost commented 7 years ago

TypeScript Version: nightly (2.1.0-dev.20161028)

I'm not sure what code is causing this issue, as I have a few dozen code files and no particular file seems to be called out in the error.

Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node 136 was unexpected.
    at Object.assert (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:1711:23)
    at Object.Debug.failBadSyntaxKind (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:35627:55)
    at serializeTypeNode (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36745:30)
    at serializeTypeNode (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36721:56)
    at serializeTypeOfNode (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36616:28)
    at addOldTypeMetadata (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36566:120)
    at addTypeMetadata (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36560:17)
    at transformAllDecoratorsOfDeclaration (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36479:13)
    at generateClassElementDecorationExpression (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36504:40)
    at generateClassElementDecorationExpressions (C:\Users\error\Documents\src\working\r3-repro\node_modules\typescript\lib\tsc.js:36490:34)                      

Here is the tsconfig:

{
    "compilerOptions": {
        "target": "es2015",
        "outDir": "js",
        "module": "system",
        "moduleResolution": "node",
        "lib": [ "dom", "es2017" ],
        "rootDirs": [ "ts", "../ts" ],
        "types": [ "systemjs", "mathjs" ],
        "allowSyntheticDefaultImports": false,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "strictNullChecks": false
    },
    "include": [
        "ts/**/*",
        "../ts/**/*"
    ]
}
ghost commented 7 years ago

I am going to attempt to isolate the issue by removing code until the issue goes away.

ghost commented 7 years ago

Actually, the issue seems to be resolved in (2.1.0-dev.20161029)

ghost commented 7 years ago

Issue seems to be related to Node 7. Not resolved.

ghost commented 7 years ago

Issue seems to be with

import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { ModalDirective } from 'ng2-bootstrap';

@Component( {
    selector: 'modal-choose',
    templateUrl: 'templates/modal/choose.html'
} )
export class ModalChooseComponent {
    @ViewChild('chooseModal')
    protected chooseModal: ModalDirective;

    @Output()
    public onChoose = new EventEmitter<string>();

    @Input()
    public title = '';

    @Input()
    public prompt = '';

    @Input()
    public buttons = [] as string[];

    @Input( 'default-button' )

public defaultButton: string|undefined;

    protected dismiss() {
        const { defaultButton } = this;
        if( defaultButton ) {
            this.choose( defaultButton );
        } else {
            this.hide();
        }
    }

    protected choose( button: string ) {
        this.onChoose.next( button );
        this.hide();
    }

    public show() {
        const { chooseModal } = this;
        chooseModal.show();
    }

    public hide() {
        const { chooseModal } = this;
        chooseModal.hide();
    }
}
mhegazy commented 7 years ago

I can ont get the error to reproduce locally. can you share more context?

ghost commented 7 years ago
git clone https://github.com/errorx666/r3 --branch repro-11933
cd r3
npm install
node node_modules/typescript/bin/tsc -p client/tsconfig.json
mhegazy commented 7 years ago

this is what i am seeing following these steps:

c:\test\11933\r3>node node_modules/typescript/bin/tsc -p client/tsconfig.json
client/ts/components/board.ts(3,28): error TS2307: Cannot find module 'rxjs/Rx'.
client/ts/components/board.ts(5,79): error TS2307: Cannot find module '@angular/core'.
client/ts/components/chat.ts(1,28): error TS2307: Cannot find module 'rxjs/Rx'.
client/ts/components/chat.ts(2,56): error TS2307: Cannot find module '@angular/core'.
client/ts/components/game.ts(6,45): error TS2307: Cannot find module 'rxjs/Rx'.
client/ts/components/game.ts(8,34): error TS2307: Cannot find module '@angular/core'.
client/ts/components/lobby.ts(1,38): error TS2307: Cannot find module '@angular/core'.
client/ts/components/modal/choose.ts(1,67): error TS2307: Cannot find module '@angular/core'.
client/ts/components/modal/choose.ts(2,32): error TS2307: Cannot find module 'ng2-bootstrap'.
client/ts/components/modal/create-room.ts(1,38): error TS2307: Cannot find module '@angular/core'.
client/ts/components/modal/create-room.ts(3,32): error TS2307: Cannot find module 'ng2-bootstrap'.
client/ts/components/r3.ts(1,45): error TS2307: Cannot find module '@angular/core'.
client/ts/components/room.ts(1,27): error TS2307: Cannot find module '@angular/core'.
client/ts/default.ts(3,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
client/ts/modules/app.ts(1,26): error TS2307: Cannot find module '@angular/core'.
client/ts/modules/app.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
client/ts/modules/app.ts(3,30): error TS2307: Cannot find module '@angular/common'.
client/ts/modules/app.ts(4,29): error TS2307: Cannot find module '@angular/forms'.
client/ts/modules/app.ts(5,28): error TS2307: Cannot find module '@angular/http'.
client/ts/modules/modal.ts(1,26): error TS2307: Cannot find module '@angular/core'.
client/ts/modules/modal.ts(2,30): error TS2307: Cannot find module '@angular/common'.
client/ts/modules/modal.ts(3,29): error TS2307: Cannot find module '@angular/forms'.
client/ts/modules/modal.ts(5,47): error TS2307: Cannot find module 'ng2-bootstrap'.
client/ts/services/game.ts(1,36): error TS2307: Cannot find module '@angular/core'.
client/ts/services/room.ts(1,60): error TS2307: Cannot find module 'rxjs/Rx'.
client/ts/services/room.ts(2,36): error TS2307: Cannot find module '@angular/core'.
client/ts/services/session.ts(1,43): error TS2307: Cannot find module 'rxjs/Rx'.
client/ts/services/session.ts(2,28): error TS2307: Cannot find module '@angular/core'.
ts/fsm.ts(1,28): error TS2307: Cannot find module 'rxjs/Observable'.
ts/fsm.ts(2,33): error TS2307: Cannot find module 'rxjs/BehaviorSubject'.
ts/fsm.ts(3,33): error TS2307: Cannot find module 'rxjs/observable/ArrayObservable'.
ghost commented 7 years ago

@mhegazy Sounds like you need to npm install both dev and production dependencies. My mistake.

mhegazy commented 7 years ago

no luck still:

c:\test\11933\r3>node node_modules/typescript/bin/tsc -p client/tsconfig.json

c:\test\11933\r3>echo %ERRORLEVEL%
0
ghost commented 7 years ago

I've repro'd this on 4 different machines now. 2 are Windows 10 x64, 1 is Windows 7 x64, one is Linux x64. Node v6.9.1 and Node v7.

image

Strate commented 7 years ago

Almost same issue with typescript@2.2.0-dev.20161130 and typescript@2.1.1 (rc):

Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node 94 (NullKeyword) was unexpected.
    at Object.assert (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:3164:23)
    at Object.Debug.failBadSyntaxKind (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:44736:55)
    at serializeTypeNode (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46685:30)
    at serializeTypeNode (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46653:56)
    at serializeTypeOfNode (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46514:28)
    at addOldTypeMetadata (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46438:92)
    at addTypeMetadata (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46432:17)
    at transformAllDecoratorsOfDeclaration (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46271:13)
    at generateClassElementDecorationExpression (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46318:40)
    at generateClassElementDecorationExpressions (/devel/src/hotfix/megaplan/front/node_modules/typescript/lib/typescript.js:46298:34)

But happens only with ts-loader or awesome-typescript-loader.

UPD.

happens if emitDecoratorMetadata & experimentalDecorators and property has a decorator like

class BLabla {
  @inject private member: Member | null = null;
}

then:

  1. metadata emitted as Object, not as Member (this might be a breaking change!)
  2. Exception described above is raised.
mhegazy commented 7 years ago

metadata emitted as Object, not as Member (this might be a breaking change!)

Object is what i expect. union types in general are represented as Object.

Exception described above is raised.

Can you share more context. i can not get this to repro locally:

c:\test>type a.ts
class Member { }

class BLabla {
  @inject private member: Member | null = null;
}

c:\test>tsc --v
Version 2.2.0-dev.20161130

c:\test>tsc a.ts --emitDecoratorMetadata --experimentalDecorators
a.ts(4,4): error TS2304: Cannot find name 'inject'.
zhouweiming commented 7 years ago

@mhegazy @Strate Hi, i get almost same errors in my project and more detail here:

http://stackoverflow.com/questions/40990736/error-debug-failure-false-expression-unexpected-node-when-typescript-upgrade

I think the issue should be caused by typescript@2.1 or awesome-typescript-loader, but I haven't solved it yet.

I get the same errors with typescript@2.2.0-dev.20161206.

ghost commented 7 years ago

I never pinpointed the issue, but I was not using awesome-typescript-loader (or webpack), so I do not think that is related.

mhegazy commented 7 years ago

A repro project would be appreciated.

sheetalkamat commented 7 years ago

@errorx666 I tried repro steps in https://github.com/Microsoft/TypeScript/issues/11933#issuecomment-257362883 and just like @mhegazy I haven't been able to repro this. Need a repro to be able to look into this. Thanks.

aluanhaddad commented 7 years ago

For the related issue, #12684 I was able to repro immediately using the instructions in https://github.com/Microsoft/TypeScript/issues/12684#issuecomment-265345827

sheetalkamat commented 7 years ago

I am not sure what kind of interactions with the plugins going there in the repro. But if I did below steps I don't repro the issue:

>node tsc --v
Version 2.2.0

>node tsc -p c:\repro\tsissuedemo\src

>echo %ERRORLEVEL%
0
ASHISH060792 commented 6 years ago

Any solution

ERROR in ./node_modules/crypto-js/core.js Module build failed: Error: Debug Failure. False expression. at getJSDocTags (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:13173:22) at getFirstJSDocTag (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:13181:24) at Object.getJSDocTypeTag (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:13130:19) at checkParenthesizedExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45552:56) at checkExpressionWorker (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45600:28) at checkExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45533:42) at checkBinaryLikeExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45082:29) at checkBinaryExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45074:20) at checkExpressionWorker (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45626:28) at checkExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45533:42) at checkExpressionCached (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45384:38) at getTypeOfExpression (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45504:28) at checkDeclarationInitializer (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:45396:24) at getTypeForVariableLikeDeclaration (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:30667:28) at getWidenedTypeForVariableLikeDeclaration (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:30890:24) at getTypeOfVariableOrParameterOrProperty (G:\Projects\Angular_Projects\Live_Projects\Git\dataguruWebApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:30991:28)

mhegazy commented 6 years ago

@ASHISH060792 this is almost 2 years old issue with some 8 releases in between.

Please file a new issue, and give us some repro steps, or sample project to be able to help you out.

jindalrohit commented 6 years ago

@ASHISH060792 Did you get any solution for this? I am also facing the same issue.