-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
native type should be same with web type #1339
Comments
but if do this
|
just as @bccsafe said |
this code runs on web
but will find button/index.tsd which is for react-native, causing error type for web. In conclusion, web and react-native types should be same, although may need some docs like: https://github.com/react-component/m-picker/blob/master/src/PickerTypes.tsx#L13 @silentcloud 可以自己试下 |
I only tested like this...
try
webpack can set the order of module resolution, but ts maybe cannot |
@bccsafe #1280 this issue is in conflict with your PR, can you resolve this if you have any time ? thanks |
As a result, native type should be same with web type? if it is, I will resolve it But I am still confused with it. The problem is the ts module resolution order, not the type. Could you give me a explanation about it.
|
|
主要问题还是因为 typescript 读取类型文件的时候不识别 https://unpkg.com/[email protected]/es/button/ PropsType.d.ts
PropsType.js
index.d.ts
index.js
index.web.d.ts
index.web.js
style
由于 webpack resolve 的配置,源码会优先读取 index.web.js, |
这段代码我测试过,在 现在有问题的是
如果用这个不推荐的方式去使用,就应该自己加上 @paranoidjk 正解 👍 ,我简单的说过这个问题的根源,可能没表达清楚
|
我发现的确有问题,不过是在native下
这里Button的type用了web的... 有什么好办法解决吗,没有的话我先revert我的代码 或者2.0里可以解决这个问题吗?type还是分开的好 |
@bccsafe 研究一下为什么第一种没问题?被转换过后是 |
@paranoidjk ts这个和babel-plugin-import没有关系 可以用
可以看到
所以 这也是导致了rn去找类型定义时,拿到了web的type而不是native的 所以如果要把type分开,首先就要解决type入口的问题,现在是写死在
|
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html 目前来说
是否可以考虑这样的方案呢 可能会影响到按需加载的那套方案,包括最后的publish,我不太了解,需要你们评估下 |
把 native 和 web 的 ts 定义放到各自的组件里去,能不能解决这个问题了? |
@silentcloud 目前 |
RN 直接 |
@afc163 可行的 |
还是 babel-plugin-import 造成的副作用。 |
这个是已经 ok 了么 @bccsafe |
嗯对的 @silentcloud |
https://github.com/ant-design/ant-design-mobile/blob/master/components/button/PropsType.tsx#L12
ts:
error:
The text was updated successfully, but these errors were encountered: