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

Taro的TARO_ENV_TYPE改成了枚举后,ENV_TYPE在使用时报【类型“TARO_ENV_TYPE”上不存在属性“WEAPP”】 #10652

Closed
bobsam opened this issue Nov 13, 2021 · 3 comments · Fixed by #10657
Assignees
Labels
A-typings Area - TypeScript Typings 相关 F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@bobsam
Copy link

bobsam commented Nov 13, 2021

相关平台

微信小程序

小程序基础库: 2.20
使用框架: React

复现步骤

PS:这是3.3.14版本!!!
直接ts使用 Taro.getEnv() === Taro.ENV_TYPE.WEAPP 时报错

期望结果

不报错

实际结果

实际是报错了

环境信息

 Taro CLI 3.3.14 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 14.17.5 - /usr/local/bin/node
      Yarn: 1.22.4 - ~/.yarn/bin/yarn
      npm: 7.21.1 - /usr/local/bin/npm
    npmGlobalPackages:
      typescript: 3.8.3
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Nov 13, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 13, 2021

看来类型改得有问题,我们看看的

@Chen-jj Chen-jj added the A-typings Area - TypeScript Typings 相关 label Nov 13, 2021
@ZakaryCode
Copy link
Contributor

和枚举没有关系,改版后的 Taro 类型并不会挂载任何实体类,所以 enum 类型无法直接引用。针对该问题,将在下一个版本修复,可参考以下写法:

if (Taro.getEnv() === TaroGeneral.ENV_TYPE.WEAPP) {
  // TODO
}

@wuhaohuang
Copy link

TaroGeneral

TaroGeneral 在哪导入?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typings Area - TypeScript Typings 相关 F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants