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

typescript 的 Optional chaining(?.) 运算符支持 #5183

Closed
waiwaic opened this issue Dec 24, 2019 · 12 comments
Closed

typescript 的 Optional chaining(?.) 运算符支持 #5183

waiwaic opened this issue Dec 24, 2019 · 12 comments

Comments

@waiwaic
Copy link

waiwaic commented Dec 24, 2019

问题描述

是否应该支持typescript的?.运算符

复现步骤

const [state,setState]=Taro.useState([])
<View>{state?.map(value=>{})}</View>

期望行为

报错信息

Unexpected token

系统信息

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

@taro-bot
Copy link

taro-bot bot commented Dec 24, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@waiwaic waiwaic changed the title typescript的Optional Chaining功能支持 typescript的.?运算符支持 Dec 24, 2019
@jsLyLeeHi
Copy link

希望多支持一些新的JS语法

@js-newbee
Copy link
Contributor

@Yeeing 标题写反了,是 ?. 操作符...

现在 taro 用的是 babel6,还不支持 optional chaining,但新版的 typescript 已经提供支持了,然而编译 ts 代码并不是用的 ts-loader,所以升级 typescript 版本也没用... 这块有计划支持么,?. 特性还行相当有用的,也已经到了 Stage 4 了

@Garfield550
Copy link
Collaborator

@js-newbee Taro 2 小程序也是用 Webpack 编译了,所以理论上可以添加 babel 插件搞定,当然更希望 TS 的代码是用 ts-loader 编译。

cc @luckyadam

@Garfield550 Garfield550 changed the title typescript的.?运算符支持 typescript 的 Optional chaining(?.) 运算符支持 Dec 25, 2019
@Garfield550
Copy link
Collaborator

问了一下老李,Taro 2 也还是基于 Babel 6 的,不过 Taro 3 是基于 Bable 7,Taro 3 就可以支持了。
Taro 3 会在 Taro 2 正式版发布不久之后发布测试版。

@luckyadam
Copy link
Member

先 close 咯

@melochale
Copy link

这个特性巨大提升生产力啊,建议优先考虑

@lake2
Copy link

lake2 commented Mar 28, 2020

same issue +1

@dont-see-big-shark
Copy link

why close it? not fragrant?

@GongLLei
Copy link

GongLLei commented Feb 1, 2021

taro2 也是可以支持的,目前wx-transformer中ts.transpile的target配置为ESNEXT,配置为<=ES2019即可开启

@Sevenonclick
Copy link

taro2 也是可以支持的,目前wx-transformer中ts.transpile的target配置为ESNEXT,配置为<=ES2019即可开启

这个wx-transformer具体在什么地方配置呢

@Elliott-Hu
Copy link

taro2 也是可以支持的,目前wx-transformer中ts.transpile的target配置为ESNEXT,配置为<=ES2019即可开启

这个wx-transformer具体在什么地方配置呢

看了一下,没有开放配置,要深入到源码改
/node_modules/@tarojs/transformer-wx/lib/src/index.js
166行左右

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests