Giter VIP home page Giter VIP logo

Comments (9)

mortalYoung avatar mortalYoung commented on May 27, 2024

是用 molecule 的脚手架初始化的仓库么?看一下 @types/react 的版本是不是不是 18.x 的

from molecule.

resetsix avatar resetsix commented on May 27, 2024

是用 molecule 的脚手架初始化的仓库么?看一下 @types/react 的版本是不是不是 18.x 的

是18.x。使用的yarn create @dtinsight/命令

图片

from molecule.

mortalYoung avatar mortalYoung commented on May 27, 2024

删除 node_modules 和 .lock 文件,重装一下依赖试试

from molecule.

resetsix avatar resetsix commented on May 27, 2024

删除 node_modules 和 .lock 文件,重装一下依赖试试

重新安装依赖了也不行,项目我也重装过很多遍。我觉得可能是TS的问题,把App.tsx修改成App.jsx在启动的时候不经过编译就能启动成功。不知道是TS版本过高原因还是什么?我全局安装TS版本是最新的5.2.2;但项目中自带的是4.4。我不知道启动的时候编译的版本会选择哪个?我问gpt说是会选择项目中的版本。

图片

from molecule.

mortalYoung avatar mortalYoung commented on May 27, 2024

image
我本地试了一下没有复现,但是我是用 pnpm 装的依赖

from molecule.

mortalYoung avatar mortalYoung commented on May 27, 2024

我不知道启动的时候编译的版本会选择哪个

VSCode 做 typescript 的类型检查的时候,会用 VSCode 的版本,这个可以打开一个 .tsx 文件,然后看右下角 TypeScript JSX 边上的 {},会显示当前版本。
image

然后启动项目的时候,编译用的是项目里的版本。我看这个报错应该是类型不兼容导致的

from molecule.

HaydenOrz avatar HaydenOrz commented on May 27, 2024

可以在 package.json 中通过resolutions 字段,强制指定 react 相关类型包的版本试试,比如

"resolutions": {
  "@types/react": "xxx",
  "@types/react-dom": "xxx",
},

from molecule.

resetsix avatar resetsix commented on May 27, 2024

image 我本地试了一下没有复现,但是我是用 pnpm 装的依赖

难受,我使用pnpm也不得行。

图片

这是我的本地代码:https://github.com/resetsix/ide

from molecule.

resetsix avatar resetsix commented on May 27, 2024

可以在 package.json 中通过resolutions 字段,强制指定 react 相关类型包的版本试试,比如

"resolutions": {
  "@types/react": "xxx",
  "@types/react-dom": "xxx",
},

好嘞 我试试。麻烦了大佬 感谢感谢

from molecule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.