Skip to content

tsc crashes when trying to use the bcoin library with allowJs=true #33230

Closed
@thomaseizinger

Description

@thomaseizinger

TypeScript Version: 3.7.0-dev.20190903

Search Terms:

allowJs, TypeError, Cannot read property 'exports' of undefined

Code

https://github.com/thomaseizinger/typescript-bcoin-crash

Expected behavior:

Being able to import and use the library bcoin with allowJs enabled.

Actual behavior:

Trying to use bcoin crashes the compiler with:

~/src/github.com/thomaseizinger/typescript-bcoin-crash(master) » yarn tsc
yarn run v1.16.0
$ /home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/.bin/tsc
/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:23296
                        return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
                                                              ^

TypeError: Cannot read property 'exports' of undefined
    at declareModuleMember (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:23296:63)
    at delayedBindJSDocTypedefTag (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:24397:25)
    at bindSourceFile (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:23085:17)
    at Object.bindSourceFile (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:23034:9)
    at initializeTypeChecker (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:51464:20)
    at Object.createTypeChecker (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:26729:9)
    at getDiagnosticsProducingTypeChecker (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:75651:93)
    at Object.getGlobalDiagnostics (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:76008:72)
    at emitFilesAndReportErrors (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:79168:46)
    at Object.emitFilesAndReportErrorsAndGetExitStatus (/home/thomas/src/github.com/thomaseizinger/typescript-bcoin-crash/node_modules/typescript/lib/tsc.js:79195:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------------------------------------------------------------

I was able to locate at least one of the files that cause the problem, it is: node_modules/bcoin/lib/blockchain/common.js. Here is a link to a repository that reproduces the issue:

https://github.com/thomaseizinger/typescript-bcoin-crash

Playground Link:

Not applicable.

Related Issues:

#18224

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: JavaScriptThe issue relates to JavaScript specificallyFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions