Code Monkey home page Code Monkey logo

Comments (9)

geekact avatar geekact commented on June 8, 2024

看看文件后缀是否为.tsx或者.jsx,如果是.ts则需要改成.tsx

from foca.

softmaxs avatar softmaxs commented on June 8, 2024

是tsx文件,使用你的taro demo没报红,但删除yarn.lock,再install也会报红

from foca.

geekact avatar geekact commented on June 8, 2024

请提供一个最小仓库以供测试,不然没法知道发生了什么事。

from foca.

geekact avatar geekact commented on June 8, 2024

是tsx文件,使用你的taro demo没报红,但删除yarn.lock,再install也会报红

我试一下

from foca.

softmaxs avatar softmaxs commented on June 8, 2024

demo 直接install不会报红,删除yarn.lock,再install,会报红。

from foca.

geekact avatar geekact commented on June 8, 2024

知道原因了。react-redux的依赖中包含了 @types/react的版本为*通配符,这直接导致安装了@types/react@18版本,lock文件展示如下:

"@types/react@*":
  version "18.0.9"
  resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.9.tgz#d6712a38bd6cd83469603e7359511126f122e878"
  integrity sha512-9bjbg1hJHUm4De19L1cHiW0Jvx3geel6Qczhjd0qY5VKVE2X5+x77YxAepuCwVh4vrgZJdgEJw48zrhRIeF4Nw==
  dependencies:
    "@types/prop-types" "*"
    "@types/scheduler" "*"
    csstype "^3.0.2"

"@types/react@^17.0.2":
  version "17.0.45"
  resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.45.tgz#9b3d5b661fd26365fefef0e766a1c6c30ccf7b3f"
  integrity sha512-YfhQ22Lah2e3CHPsb93tRwIGNiSwkuz1/blk4e6QrWS0jQzCSNbGLtOEYhPg02W0yGTTmpajp7dCTbBAMN3qsg==
  dependencies:
    "@types/prop-types" "*"
    "@types/scheduler" "*"
    csstype "^3.0.2"

目前Taro是还没有兼容到18的,所以我们需要把18的类型移除

-"@types/react@*":
-  version "18.0.9"
-  resolved "https://registry.yarnpkg.com/@types/react/-/react--18.0.9.tgz#d6712a38bd6cd83469603e7359511126f122e878"
-  integrity sha512--9bjbg1hJHUm4De19L1cHiW0Jvx3geel6Qczhjd0qY5VKVE2X5+x77YxAepuCwVh4vrgZJdgEJw48zrhRIeF4Nw==
-  dependencies:
-    "@types/prop-types" "*"
-    "@types/scheduler" "*"
-    csstype "^3.0.2"

-"@types/react@^17.0.2":
+"@types/react@*", "@types/react@^17.0.2":
  version "17.0.45"
  resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.45.tgz#9b3d5b661fd26365fefef0e766a1c6c30ccf7b3f"
  integrity sha512-YfhQ22Lah2e3CHPsb93tRwIGNiSwkuz1/blk4e6QrWS0jQzCSNbGLtOEYhPg02W0yGTTmpajp7dCTbBAMN3qsg==
  dependencies:
    "@types/prop-types" "*"
    "@types/scheduler" "*"
    csstype "^3.0.2"

这个版本我控制不了,目前只能这样做,我这边也看看有没有更好的解决方案

from foca.

softmaxs avatar softmaxs commented on June 8, 2024

好的

from foca.

geekact avatar geekact commented on June 8, 2024

方案二,在package.json中加入如下配置即可:

{
  "resolutions": {
    "foca/react-redux/@types/hoist-non-react-statics/@types/react": "^17"
  }
}

from foca.

softmaxs avatar softmaxs commented on June 8, 2024

谢谢,已经解决。

from foca.

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.