1

I am facing an error that caused by lower version of TypeScript, root cause is I update prettier version, related post: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60310

So dependency issue was:

React -> TypeScript@4.7.4

Other-library -> Webpack-dev-server -> TypeScript@3.8.2

Prettier -> TypeScriptv4+

Since Prettier require TS version 4+ and the Webpack-dev-server has a version of 3.8.2, that will cause the program to throw error.

I can not change the version of Other-library, but I still need the version of TypeScript to be v4+

I am looking at this post:How do I override nested NPM dependency versions?

This seems does exactly what I needed to do.

But after I use the overrides property in package.json, I do see React is pickup the TypeScript version 4.7.4,

howerver I get the following error: Child process failed to process the request: Error: Debug Failure. Palse expression. at resolveNamesWithLocalCache, at typescipt/lib

Thanks

My package json looks like:

{
   "devDependencies": {
      "typescript": "^4.7.4"
   },
   "overrides": {
      "webpack-dev-server": {
         "typescript": "$typescript"
      }
   }
}
`
Xinrui Ma
  • 2,065
  • 5
  • 30
  • 52
  • Info provided at its current state is insufficient to pin point your problem. Try at least answer these: 1. when you "run the app" what exactly happens? what program runs? 2. where does the console output comes from? Clearly multiple versions of TS are installed. It's easier for us to help if you can create a minimal reproducible example. – hackape Jul 29 '22 at 03:29

1 Answers1

0

So I checked, typescript is only "devDependencies" to webpack-dev-server. It's NOT supposed to be installed at all. How did you even end up in this situation

It must be something about the way you install those packages. I don't know what happened, just try remove node_modules folder entirely, and also package-lock.json, then npm install again. You don't need that "overrides" field.

Additionally, it sounds to me this whole mayhem starts because of @types/prettier. HOWEVER, unless you have a very specific use case (which I seriously doubt) that requires integrating with prettier's programmatic API, through hand written TS code, you don't even need @types/prettier in the first place. Just get rid of that troublemaker. All @types/* packages are optional.

hackape
  • 18,643
  • 2
  • 29
  • 57