"@parcel/transformer-typescript-types: Got unexpected undefined" on parcel@2.0.0-nightly.554
See original GitHub issueI saw this issue reported here: https://github.com/parcel-bundler/parcel/issues/4035
But I think this case is different.
This is the full error message:
yarn workspace v1.22.10
yarn run v1.22.10
$ parcel build ./src/index.ts
🚨 Build failed.
@parcel/transformer-typescript-types: Got unexpected undefined
Error: Got unexpected undefined
at nullthrows (/path-to-project/node_modules/nullthrows/nullthrows.js:7:15)
at Object.transform (/path-to-project/node_modules/@parcel/transformer-typescript-types/lib/TSTypesTransformer.js:204:42)
at async runTransformer (/path-to-project/node_modules/@parcel/core/lib/Transformation.js:651:3)
at async Transformation.runPipeline (/path-to-project/node_modules/@parcel/core/lib/Transformation.js:422:36)
at async Transformation.runPipelines (/path-to-project/node_modules/@parcel/core/lib/Transformation.js:363:40)
at async Transformation.run (/path-to-project/node_modules/@parcel/core/lib/Transformation.js:277:19)
at async Child.handleRequest (/path-to-project/node_modules/@parcel/workers/lib/child.js:255:9)
when I run yarn build.
Here is the relevant part of my package.json
"type": "module",
"main": "dist/main/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "parcel build ./src/index.ts",
"dev": "parcel watch ./src/index.ts"
}
I will add that this was all working 100% less than 24 hours ago. I have the dependency of "parcel": "^2.0.0-beta.1", which is pulling parcel@2.0.0-nightly.554. I cannot confirm whether it was pulling that same version earlier this morning or yesterday, but it looks like that has been the latest release for about three days now, so I am pretty sure that hasn’t changed.
EDIT:
One thing that works is if I turn off types and reference a manually written types declaration:
"types": "index.d.ts",
"targets": {
"types": false
},
But, it definitely worked without having to do this just this morning and yesterday, so I am not sure how this might be related.
Parcel seems like an awesome project and I really want to use it, so I would appreciate any help with this.
🤔 Expected Behavior
The project builds every time, even without types: false
😯 Current Behavior
The project does not build. This behavior started some time within the last 16 hours or so.
💻 Code Sample
I can try to put together a small project that reproduces the error if need be, although I would first like to see if this issue seems familiar to anyone here and if there are some things that I can try.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | parcel@2.0.0-nightly.554 |
| Node | v12.20.1 |
| npm/Yarn | yarn 1.22.10 |
| Operating System | MacOS 10.15.7 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)

Top Related StackOverflow Question
This issue is still present for me.
I get the same exact error(
@parcel/transformer-typescript-types: Got unexpected undefined) with a500nightly build on Parcel.But on a
600-700nightly build, i get those errors insteadEven though running
tscreturnsFound 0 errors.So… in the process of making this into a smaller project that reproduces the error, I found several things that needed to be cleaned.
Everything is now working, but I cannot say for sure what exactly “fixed” it, especially since even while having this issue, it seemed to sometimes build even without “fixing” anything.
I even tried reintroducing the things that were “wrong” in the original project (like a
.d.tsfile that was importing a nonexistent module), but my test project still builds, even after deleting.parcel-cache.I would still consider this to be a bug, as the problem is ultimately that this error message did not contain any helpful information:
Still, the fact that I cannot seem to pinpoint what the problem is means that it would be impossible to look into any further.
I think this can be closed, and if this comes up again in some easily repeatable way, I will create a new issue for it.