parcel: @parcel/transformer-typescript-types does not work
๐ bug report
๐ Configuration (.babelrc, package.json, cli command)
package.json:
{
"source": "src/index.ts",
"module": "dist/index.js",
"types": "dist/index.d.ts",
}
src/index.ts
export * from './src/components';
CLI: parcel build index.ts
๐ค Expected Behavior
It should build.
๐ฏ Current Behavior
@parcel/transformer-typescript-types: node.exportClause.elements is not iterable
TypeError: node.exportClause.elements is not iterable
at visit (/home/rsa/skyfall/frontend/node_modules/@parcel/transformer-typescript-types/lib/collect.js:66:47)
at visitNodes (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80382:48)
at Object.visitEachChild (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80739:56)
at visit (/home/rsa/skyfall/frontend/node_modules/@parcel/transformer-typescript-types/lib/collect.js:112:15)
at visitNode (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80329:23)
at Object.visitEachChild (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80737:222)
at visit (/home/rsa/skyfall/frontend/node_modules/@parcel/transformer-typescript-types/lib/collect.js:112:15)
at visitNodes (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80382:48)
at visitLexicalEnvironment (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80422:22)
at Object.visitEachChild (/home/rsa/skyfall/frontend/node_modules/typescript/lib/typescript.js:80809:55)
๐ Possible Solution
๐ฆ Context
I just want to build this with types.
๐ป Code Sample
๐ Your Environment
| Software | Version(s) |
|---|---|
| Parcel | parcel@2.0.0-nightly.579 |
| Node | v15.9.0 |
| npm/Yarn | 1.22.10 |
| Operating System | Arch Linux |
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 17
- Comments: 28 (7 by maintainers)
Commits related to this issue
- chore: major api updates to work around parcel bugs We need to allow fine-grained imports, and parcel has several bugs that block doing this in the normal way: https://github.com/parcel-bundler/parce... — committed to starpit/madwizard by starpit 2 years ago
- chore: major api updates to work around parcel bugs We need to allow fine-grained imports, and parcel has several bugs that block doing this in the normal way: https://github.com/parcel-bundler/parce... — committed to guidebooks/madwizard by starpit 2 years ago
- Change import to address known issue with @parcel/transformer-typescript-types https://github.com/parcel-bundler/parcel/issues/5911 — committed to jwhitham-ds/emoji-mart by jwhitham-ds 2 years ago
- Change import to address known issue with @parcel/transformer-typescript-types https://github.com/parcel-bundler/parcel/issues/5911 — committed to jwhitham-ds/emoji-mart by jwhitham-ds 2 years ago
- Change import to address known issue with @parcel/transformer-typescript-types https://github.com/parcel-bundler/parcel/issues/5911 — committed to jwhitham-ds/emoji-mart by jwhitham-ds 2 years ago
Any updates about this issue? Same error with
"@parcel/transformer-typescript-types": "^2.4.1"Still an issue with
"@parcel/transformer-typescript-types": "^2.3.2"unfortunatelya reasonable workaround
Confirmed I ran in to this issue and it goes away if I comment out my usage of
export * asI tested, and #7315 doesnโt address this issue, unfortunately (although it does fix #7306).
I can confirm the repro -
export * as something from "./somewhere"causes the issue above. Its because we assume that ifnode.exportClauseis defined, it will have anelementsproperty.https://github.com/parcel-bundler/parcel/blob/106939872e15014f45671fa971ad96fee27b2d6d/packages/transformers/typescript-types/src/collect.js#L58-L60
But if you look at the relevant typescript API types, โexportsClauseโ could be a
NamespaceExporttype, in which case there will be noelementspropertyExportDeclaration (code)
NamedExportBindings (code)
NamespaceExport (code)
So the issue is that we donโt handle this case, probably because it was released after the initial implementation of
@parcel/transformer-typescript-types- in Typescript 3.8 (Feb 2020)Preliminary results show that changing the line
if (node.exportClause) {toif (node.exportClause && node.exportClause.elements) {seems to work as expected. Itโs correctly exporting allexport * as Module from '...';I can make a PR if anyone doesnโt see anything wrong with that.My
src/components/index.tshad anexport * as Icons from './Icons', andIcons.tsxexported several React components. That alone created issues with thebabeltransformer, a cryptic error message that unfortunately I didnโt save, so I have been using thetypescript-tscwhich goes past that. I donโt have the files in hand now, but maybe thatโs related?Yep.
Ah, I missed that comment, thanks!
So at this point this is still an open issue?
After adding tsconfig.json everything works
You can get it working by doing this:
export { default as StringUtils2 } from './utils/StringUtils'Same error with โ@parcel/transformer-typescript-typesโ: โ^2.5.0โ
Still an issue with โ@parcel/transformer-typescript-typesโ: โ^2.4.0โ
I have exactly the same issue as @ranisalt when trying to export an
Iconsfile on myindex.ts.Iโve tried this:
but it builds fine. Looks like some code in
./src/componentsis triggering that error (or you have a different typescript version)?