Open jakubmazanec opened 2 years ago
With the debugger, it looks like here is the node remains undefined.
I also ran into this issue recently although slightly different
@parcel/transformer-typescript-types: Cannot read properties of undefined (reading 'unshift')
TypeError: Cannot read properties of undefined (reading 'unshift')
the modifiers on the node in my case was undefined and I have found that this is only introduced when you have a typescript version >= 4.6.0.
@jakubmazanec I notice you have "typescript": "^4.5.5"
can you take a look in your yarn.lock/package-lock.json and see what version is actually in your project? I suspect if you explicitly set a version like "typescript": "4.5.5"
your problem might go away like mine did.
This does however not explain the problem since that is a minor version bump of TS and I would have expected a library depending on that to not be affected. If it is, then I think this lib needs a strict version associated to prevent this issue until the code causing the error is updated with the newer version of TS.
@rathpc I reported this 2 months ago, when TypeScript 4.6 wasn't released yet. But I'll try anyway.
I installed and run the repo with TypeScript 4.6.3 and also with TypeScript 4.5.5, same error.
Best if somebody took a look at that PR...
I installed and run the repo with TypeScript 4.6.3 and also with TypeScript 4.5.5, same error.
Best if somebody took a look at that PR...
Ah ok, thanks for testing my theory at least!
I got the same error. Don't know is it the same bug or not, but I figured out the following:
Let's import some type from some npm package:
// index.ts
import { FC } from "react";
Use this type and export:
// index.ts
export type MyComponent = FC<{}>;
Create a file with the same name of the module in the first step:
// react.ts
export default "";
Try to import something from the file that created in the third step:
// index.ts
import { FC } from "react";
// @parcel/transformer-typescript-types: Got unexpected undefined import {} from "./react";
export type MyComponent = FC<{}>;
It also works with other modules. React is just an example.
Versions:
- `parcel`: 2.5.0
- `@parcel/transformer-typescript-types`: 2.5.0
- `@parcel/packager-ts`: 2.5.0
- `typescript`: 4.6.3
- `node`: 17.8.0
Repo with reproduction: https://github.com/alexgraddev/parcel2-typescript-types-bug
Would also appreciate a fix for this!
I ran into this problem and figured out what the error means. So at least I can fix it in user-land code, but a more helpful message would be nice.
It happens when you get a squiggly line on a type import.
Also looks like there's something with index re-exports
this doesn't work:
// src/index.ts
import { customTheme } from './themes'
// src/themes/index.ts
export * from './customTheme'
// src/themes/customTheme.ts
export const customTheme = ...
this works:
// src/index.ts
import { customTheme } from './themes/customTheme'
// src/themes/index.ts
export * from './customTheme'
// src/themes/customTheme.ts
export const customTheme = ...
I had the same problem that was mentioned here https://github.com/parcel-bundler/parcel/issues/7669#issuecomment-1106567699, and found another issue when renaming it.
Name | Works |
---|---|
react | ❌ |
_react | ❌ |
react_ | ✅ |
It seems like leading _
is not welcome 🤔
I'm having the same problem. Here is a reproducible repo. Would love if this could get resolved, or if anyone has any solutions. Thanks!
I'm still seeing this every now and then, don't think it has been resolved
I updated all dependencies in the repo with the bug reproduction; the bug still exists.
I updated Parcel and TypeScript in the repo with the bug reproduction; the bug still exists.
I encountered "Got unexpected undefined" error. I don't know what exactly causes it, but I created repo with minimal reproduction.
🎛 Configuration
package.json
tsconfig.json
Source code:
🤔 Expected Behavior
Parcel builds with no error? I think this minimal reproduction shouldn't actually build (because of e.g. missing React), but the errors should be more descriptive and useful.
😯 Current Behavior
Parcel errors:
💻 Code Sample
Repo with reproduction. Clone and run
npm install
andnpm run build
.🌍 Your Environment