Skip to content

Crash when trying to merge global augmentation #25410

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
timocov opened this issue Jul 3, 2018 · 3 comments
Closed

Crash when trying to merge global augmentation #25410

timocov opened this issue Jul 3, 2018 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@timocov
Copy link
Contributor

timocov commented Jul 3, 2018

TypeScript Version: 3.0.0-dev.20180703

Search Terms: Global augmentation

Code

  1. mkdir src && echo "import * as React from 'react';console.log(React);" > src/index.ts
  2. mkdir tests && echo "import * as React from 'react';console.log(React);" > tests/index.ts
  3. npm init -y && npm install --save-dev typescript@next @types/react
  4. cd tests && npm init -y && npm install --save-dev @types/react && cd ../
  5. ./node_modules/.bin/tsc --init
  6. ./node_modules/.bin/tsc --noEmit

Expected behavior:

Compiled without errors

Actual behavior:

Error: Debug Failure. False expression.
    at mergeSymbol (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:24252:26)
    at E:\git\ts-bug\node_modules\typescript\lib\tsc.js:24344:49
    at Map.forEach (<anonymous>)
    at mergeSymbolTable (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:24343:20)
    at mergeModuleAugmentation (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:24354:17)
    at initializeTypeChecker (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:45114:25)
    at Object.createTypeChecker (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:24102:9)
    at getDiagnosticsProducingTypeChecker (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:66941:93)
    at Object.getGlobalDiagnostics (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:67286:53)
    at Object.emitFilesAndReportErrors (E:\git\ts-bug\node_modules\typescript\lib\tsc.js:69563:46)
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 3, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.0 milestone Jul 3, 2018
@RyanCavanaugh
Copy link
Member

@sandersn probably a better repro for #25339

@timocov
Copy link
Contributor Author

timocov commented Jul 3, 2018

Probably it can be useful. I guess that the reason of this is in initializeTypeChecker function - it walks through all source files and pushes augmentation to an array (via (augmentations || (augmentations = [])).push(file.moduleAugmentations);), but here we can have source file with redirectInfo, and it is possible that we should skip it in the loop (but I am not sure).

@sandersn
Copy link
Member

sandersn commented Jul 5, 2018

Thanks @timocov for the excellent repro -- all I had to do was make it work in our test harness. Your fix was exactly right too.

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

No branches or pull requests

3 participants