Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@parcel/transformer-typescript-types: Debug Failure. Unhandled SyntaxKind: ImportClause. #8419

Closed
TechQuery opened this issue Aug 26, 2022 · 18 comments · Fixed by #8661
Closed

Comments

@TechQuery
Copy link

@parcel-bundler

🎛 Configuration

package.json

{
    "source": "source/index.ts",
    "types": "dist/index.d.ts",
    "module": "dist/index.esm.js",
    "main": "dist/index.js",
    "dependencies": {
        "@swc/helpers": "^0.4.11",
        "class-validator": "^0.13.2",
        "koajax": "^0.8.1",
        "reflect-metadata": "^0.1.13",
        "regenerator-runtime": "^0.13.9",
        "web-utility": "^3.9.2"
    },
    "peerDependencies": {
        "mobx": ">=4 <6"
    },
    "devDependencies": {
        "@parcel/packager-ts": "^2.7.0",
        "@parcel/transformer-typescript-types": "^2.7.0",
        "@types/node": "^14.18.26",
        "dotenv": "^16.0.1",
        "mobx": "^5.15.7",
        "parcel": "^2.7.0",
        "typescript": "~4.8.2"
    },
    "browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
    "targets": {
        "main": {
            "optimize": true
        }
    },
    "scripts": {
        "build": "rm -rf dist/ docs/  &&  parcel build"
    }
}

tsconfig.json

{
    "compilerOptions": {
        "target": "ES5",
        "module": "ES6",
        "moduleResolution": "Node",
        "esModuleInterop": true,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "skipLibCheck": true,
        "lib": ["ES2022", "DOM", "DOM.Iterable"]
    },
    "include": ["source/*"]
}

🤔 Expected Behavior

Build TS libraries with typescript@^4.8.0 successfully.

😯 Current Behavior

Throw an error with typescript@4.8.2:

@parcel/transformer-typescript-types: Debug Failure. Unhandled SyntaxKind: ImportClause.

but succeed with typescript@^4.7.0.

💁 Possible Solution

Support ImportClause Syntax Kind.

💻 Code Sample

idea2app/MobX-RESTful#6

🌍 Your Environment

Software Version(s)
Parcel 2.7.0
Node 14.19.1
PNPM 7.9.5
Operating System Windows 10 Pro 21H2
@levino
Copy link

levino commented Aug 29, 2022

Is this a problem caused by typescript or by @parcel/transformer-typescript-types? Is there an issue / bug ticket at typescript to follow?

@TechQuery
Copy link
Author

TechQuery commented Aug 29, 2022

@levino I think there're Interface Breaking Changes between TS 4.7 and 4.8, which needs Parcel to adapt.

@levino
Copy link

levino commented Aug 29, 2022

Breaking Changes between TS 4.7 and 4.8

That is an oxymoron. A breaking change would have meant that typescript@5 should have been released. Maybe they do not want to clutter the versions too much but then there must be a clear list of "breaking changes" from 4.7 to 4.8. Are we sure that we are not using undocumented features / internal functions from typescript instead?

@levino
Copy link

levino commented Aug 29, 2022

@mischnic
Copy link
Member

That is an oxymoron. A breaking change would have meant that typescript@5 should have been released. Maybe they do not want to clutter the versions too much but then there must be a clear list of "breaking changes" from 4.7 to 4.8.

No, Typescript doesn't follow the usual semver rules, every "minor" version can also contain breaking changes, see e.g. microsoft/TypeScript#14116

@levino
Copy link

levino commented Aug 29, 2022


This should then rather be ~4.7. I suggest to change it.

@TechQuery
Copy link
Author

@levino Unfortunately, TypeScript never follows the Semantic Version specification, almost every Iteration version have breaking changes. This is not the first time I met in TypeScript ecosystem...

@mischnic
Copy link
Member

This should then rather be ~4.7. I suggest to change it.

Well ... #6263 and #5978

@antonio-goncalves
Copy link

Having the same issue when trying to setup a fresh typescript react project, curiously I don't have this problem with an older react typescript project since it uses an "older" packages-lock.json

@levino
Copy link

levino commented Sep 5, 2022

Using the package-lock.json or yarn.lock to pin a dependency version is abusive and dangerous. An acceptable workaround is to use yarns "resolutions" field. For example in your (root when using workspaces) package.json file:

"resolutions": {
   "typescript": "~4.7"
}

@wkrueger
Copy link

wkrueger commented Nov 11, 2022

extra note:

Downgrading to TS 4.7 works. But sometimes due to package manager details, the lib still gets TS 4.8 (if it exists on another package in scope).

Also, I've noticed that the "auto-installer" was adding the extra packages to the workspace root.
Try manually adding the dependencies to the child package (and removing them from the root package). Pay attention if the root package.json has been modified by parcel.

Also, Yarn seems to prefer linking 4.8 versions from other packages even if the child package has 4.7.

  "devDependencies": {
    "@parcel/packager-ts": "2.8.0",
    "@parcel/transformer-sass": "2.8.0",
    "@parcel/transformer-typescript-tsc": "^2.8.0",
    "@parcel/transformer-typescript-types": "2.8.0",
    "typescript": "4.7",

@shubham-kaushal
Copy link

shubham-kaushal commented Nov 11, 2022

Hi @devongovett , could you plz. suggest the solution to this issue. I am using pnpm workspace and TS 4.8.4, also tried the above suggestion and downgraded the TS to 4.7 still got the same issue.

@levino
Copy link

levino commented Nov 14, 2022

You need to pin typescript to version 4.7.x using the "resolutions" field in the root package.json as described above. @wkrueger s attempt does not work as they say themselves. If you really cannot get it to work with the "resolutions" solution, please share a demo repo where we can reproduce your issue and then I will have a look.

@wkrueger
Copy link

wkrueger commented Nov 17, 2022

If I recall I have tried resolutions but ts 4.8 still got in through from another project in the monorepo.

When yarn list showed TS 4.8 in the root project and 4.7 in the leaf project, Parcel still got 4.8. Gotta fight the module resolution a bit.

@levino
Copy link

levino commented Nov 17, 2022

Without a repo to replicate, you can only help yourself.

@shubham-kaushal
Copy link

shubham-kaushal commented Nov 17, 2022

You need to pin typescript to version 4.7.x using the "resolutions" field in the root package.json as described above. @wkrueger s attempt does not work as they say themselves. If you really cannot get it to work with the "resolutions" solution, please share a demo repo where we can reproduce your issue and then I will have a look.

Hi, @levino Sorry for the late response, I was unwell. Today, I am back. Thank you for the response! I was trying to migrate our tastycss repo from tsup to parcel and followed the above-suggested method still got the same error. You'll find the repo here https://github.com/OutpostHQ/tasty

I will look forward to your response.

@levino
Copy link

levino commented Nov 17, 2022

Lets continue this conversation in your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants