question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

native type should be same with web type

See original GitHub issue

https://github.com/ant-design/ant-design-mobile/blob/master/components/button/PropsType.tsx#L12

ts:

import Button from 'antd-mobile/es/button'

<Button inline />

error:

Property 'inline' does not exist on type 

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
himStonecommented, May 23, 2017

@paranoidjk ts这个和babel-plugin-import没有关系

可以用tsc --traceResolution来查看ts查找模块的顺序

antd-mobile的type

======== Resolving module 'antd-mobile' from '/Users/BccSafe/Downloads/test0523/src/components/TsExample.tsx'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module 'antd-mobile' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/Users/BccSafe/Downloads/test0523/src/components/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/BccSafe/Downloads/test0523/src/node_modules' does not exist, skipping all lookups in it.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile.ts' does not exist.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile.tsx' does not exist.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile.d.ts' does not exist.
Found 'package.json' at '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/package.json'.
'package.json' has 'typings' field 'lib/index.web.d.ts' that references '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts'.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts' exist - use it as a name resolution result.
Resolving real path for '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts', result '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts'.
======== Module name 'antd-mobile' was successfully resolved to '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts'. ========

Button的type

======== Resolving module './button/index.web' from '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/index.web.d.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module as file / folder, candidate module location '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/button/index.web', target file type 'TypeScript'.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/button/index.web.ts' does not exist.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/button/index.web.tsx' does not exist.
File '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/button/index.web.d.ts' exist - use it as a name resolution result.
======== Module name './button/index.web' was successfully resolved to '/Users/BccSafe/Downloads/test0523/node_modules/antd-mobile/lib/button/index.web.d.ts'. ========

可以看到antd-mobile的类型定义是在lib/index.web.d.ts下的,所有组件的type全部用了web的,Button也不例外

export { default as Button } from './button/index.web';

所以import { Button } from 'antd-mobile',ts是直接拿到了web的type

这也是导致了rn去找类型定义时,拿到了web的type而不是native的


所以如果要把type分开,首先就要解决type入口的问题,现在是写死在package.json里的

"typings": "lib/index.web.d.ts"
1reaction
afc163commented, May 23, 2017

还是 babel-plugin-import 造成的副作用。

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exporting types · Issue #1684 · necolas/react-native-web
Does this library need to export Flow and TypeScript types? ... I think if react-native-web can maintain an exact same type info match...
Read more >
How to Choose the Right Type of Mobile App: Native, Web or ...
Native apps are “native” to one platform—you'll need to create different apps for iOS, Android, etc. Hybrid ones work on any device regardless ......
Read more >
Native Apps, Web Apps or Hybrid Apps? What's the Difference?
Which type of app should you build? Unfortunately there is no single, definitive answer. The debate between Native Apps vs Hybrid Apps vs...
Read more >
The HTML5 input types - Learn web development | MDN
Objective: To understand the newer input type values available to create native form controls, and how to implement them using HTML.
Read more >
Native Types and Semantic Categories
The native types included in the type system are all possible data types in the data source for which the connector is built....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found