Skip to content

"Debug Failure. Unexpected node." with --allowjs over transpiled enums #36098

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

Closed
filipesilva opened this issue Jan 9, 2020 · 3 comments · Fixed by #36136
Closed

"Debug Failure. Unexpected node." with --allowjs over transpiled enums #36098

filipesilva opened this issue Jan 9, 2020 · 3 comments · Fixed by #36136
Assignees
Labels
Bug A bug in TypeScript

Comments

@filipesilva
Copy link
Contributor

filipesilva commented Jan 9, 2020

TypeScript Version: 3.7.4

Search Terms:
allowjs
Debug Failure. Unexpected node.
Code

Note: in case it's relevant this js code is transpiled from TS. Having the comment and the import seem to be an integral part of the repro. I assume this is related to the allowJs changes in 3.7.

// repro.js
import { share } from 'rxjs/operators';
/** @enum {number} */
const ChangeDetectionStrategy = {
  OnPush: 0,
  Default: 1,
};
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = 'OnPush';
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = 'Default';
kamik@RED-X1C6 MINGW64 /d/sandbox/ts-issue-XYZ-allow-js-debug-failure (master)
$ yarn tsc --allowJs --outFile out.js repro.js
yarn run v1.21.1
$ D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\.bin\tsc --allowJs --outFile out.js repro.js
D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:78593
                throw e;
                ^

Error: Debug Failure. Unexpected node.
Node 75 was unexpected.
    at getDeclarationSpaces (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:49632:41)
    at checkExportsOnMergedDeclarations (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:49566:
41)
    at checkVariableLikeDeclaration (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:50567:17) 
    at checkVariableDeclaration (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:50604:20)     
    at checkSourceElementWorker (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:52654:28)     
    at checkSourceElement (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:52511:17)
    at Object.forEach (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:116:30)
    at checkVariableStatement (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:50613:16)       
    at checkSourceElementWorker (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:52623:28)     
    at checkSourceElement (D:\sandbox\ts-issue-XYZ-allow-js-debug-failure\node_modules\typescript\lib\tsc.js:52511:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior:
No Debug Failure. Unexpected node. error.
Actual behavior:
Errored out in a weird way.

Playground Link:

Related Issues:

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 9, 2020
Workaround for microsoft/TypeScript#36098.

Should go back to 3.7 once it is fixed.
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 9, 2020
Workaround for microsoft/TypeScript#36098.

Should go back to 3.7 once it is fixed.
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 9, 2020
Workaround for microsoft/TypeScript#36098.

Should go back to 3.7 once it is fixed.
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jan 9, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.8.1 milestone Jan 9, 2020
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 9, 2020
Workaround for microsoft/TypeScript#36098.

Should go back to 3.7 once it is fixed.
mgechev pushed a commit to angular/angular-cli that referenced this issue Jan 9, 2020
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jan 10, 2020
Workaround for microsoft/TypeScript#36098.

Should go back to 3.7 once it is fixed.
mgechev pushed a commit to angular/angular-cli that referenced this issue Jan 10, 2020
@filipesilva
Copy link
Contributor Author

Awesome, thanks!

@cenkce
Copy link

cenkce commented Jan 23, 2020

I have been taking same error when require inside of a function while generate d.ts files from existing js files.
For example :
function a(){
var c = require('foo.');
}

Any suggestion ?

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jan 23, 2020

Check if the nightly fixes it (npm install typescript@next), otherwise if you think it's a bug please file a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants