question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"@parcel/transformer-typescript-types: Got unexpected undefined" on parcel@2.0.0-nightly.554

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
Banou26commented, Jul 8, 2021

This issue is still present for me.

I get the same exact error(@parcel/transformer-typescript-types: Got unexpected undefined) with a 500 nightly build on Parcel.

But on a 600-700 nightly build, i get those errors instead

@parcel/transformer-typescript-types: Cannot find global value 'Promise'.      

@parcel/transformer-typescript-types: Cannot find module '@mfkn/oz-web/src/api/api' or its corresponding type declarations.

@parcel/transformer-typescript-types: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.

  C:/dev/oz/lib/src/index.ts:27:38
    26 | if (window.parent !== window) {
  > 27 |   window.addEventListener('message', async ev => {
  >    |                                      ^^^^^^^^^^^^^^ An async function 
or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a 
declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
    28 |     const { data: messageData, origin }: { data: ApiMessageData } & Om    29 |

Even though running tsc returns Found 0 errors.

2reactions
jeffpeck10xcommented, Feb 1, 2021

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.ts file 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:

@parcel/transformer-typescript-types: Got unexpected undefined

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found