NPM is throwing Type expected while build react/nextjs project after adding use-places-autocomplete

huangapple go评论67阅读模式
英文:

NPM is throwing Type expected while build react/nextjs project after adding use-places-autocomplete

问题

我在构建我的React/Next.js项目时遇到了这个错误。
我尝试以管理员身份打开VS Code,但仍然面临此问题。

./node_modules/use-places-autocomplete/dist/index.d.ts:21:24
类型错误:期望类型。

19 |   export type Suggestion = google.maps.places.AutocompletePrediction;
20 | 
> 21 |   export type Status = `${google.maps.places.PlacesServiceStatus}` | "";
     |                        ^

Windows 10机器    
Node版本14.17.5
Package.json
react 17.0.2
typescript ^3.7.2

ts升级到4.1.0会导致此错误 ->  `E/launcher - Error: TSError: ⨯ Unable to compile TypeScript`
英文:

I am getting this error upon building my react/nextjs project.
I have tried to open vs code as an administrator but still facing this issue.

./node_modules/use-places-autocomplete/dist/index.d.ts:21:24
Type error: Type expected.

  19 |   export type Suggestion = google.maps.places.AutocompletePrediction;
  20 | 
> 21 |   export type Status = `${google.maps.places.PlacesServiceStatus}` | "";
     |                        ^

Windows 10 machine
Node version 14.17.5
Package.json
react 17.0.2
typescript ^3.7.2

Upgarding ts to 4.1.0 gives this error -> E/launcher - Error: TSError: ⨯ Unable to compile TypeScript

答案1

得分: 0

问题出在TS版本上。我升级到4.3.2版本,问题得以解决!

英文:

Issue was with TS version. I upgraded to 4.3.2 and it worked!

huangapple
  • 本文由 发表于 2023年6月22日 17:43:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530570.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定