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? #531

Closed
ImJoeHs opened this issue Nov 15, 2016 · 7 comments
Closed

当前如何使用typescript? #531

ImJoeHs opened this issue Nov 15, 2016 · 7 comments

Comments

@ImJoeHs
Copy link

ImJoeHs commented Nov 15, 2016

本地环境

dva+typescript

  • antd-mobile 版本: 0.9.8

你做了什么?

tsx中引入antd-mobile

你期待的结果是:

正常使用

实际上的结果:

ERROR in ./src/routes/IndexPage.tsx
Module not found: Error: Cannot resolve module 'antd-mobile' in D:\cs\src\routes
@ ./src/routes/IndexPage.tsx 5:20-42

使用antd没有任何问题,去掉ts也能正常使用,antd-mobile+ts则出错

@silentcloud
Copy link
Contributor

@ImJoeHs
Copy link
Author

ImJoeHs commented Nov 15, 2016

我确认都看过了。去掉typescript是没问题的,应该说明该有的的都有了吧?只有使用typescript才有这种情况。
我做的事情有:
1.dva-cli new
2.install antd-mobile
3.配置typescript环境,js(x) => ts(x)

3开始才报错,尝试将 antd-mobile 换成 antd 也跑得通的。

@warmhug
Copy link
Contributor

warmhug commented Nov 29, 2016

更新到 antd-mobile 0.9 的最新版,另外麻烦给出更详细的错误日志

@warmhug warmhug closed this as completed Nov 29, 2016
@warmhug warmhug reopened this Nov 29, 2016
@warmhug
Copy link
Contributor

warmhug commented Nov 29, 2016

关联 #523

@warmhug
Copy link
Contributor

warmhug commented Dec 6, 2016

dva 生成的项目带有 typescript 配置,https://github.com/ant-tool/atool-build/blob/master/src/getWebpackCommonConfig.js#L63 这里有支持。参考这个能正常跑的示例 https://github.com/warmhug/__/blob/master/_react/dva-ts/package.json

@ImJoeHs
Copy link
Author

ImJoeHs commented Dec 8, 2016

抱歉没有及时回复,我的问题出在自己配置了tsconfig,其中module选项应为es2015;
我沿用了之前使用antd时的配置,也难怪antd能跑而mobile不行==。
建议在文档中提醒一下~ 十分感谢回复!

@lock
Copy link

lock bot commented May 28, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants