vscode React Native StyleSheet 没有代码提示解决

  1. run npm i --save-dev @types/react-native in your project's root
  2. open <project>/node_modules/@types/react-native/index.d.ts
  3. add the following snippet
interface Styles {
    [style: string]: Style
}

export function create(styles: Styles): any;

right after the line with export namespace StyleSheet { (it's line 4469 in my case).

You might also need to restart VSCode after applying the changes, but in my case they were applied immediately.

参考链接: https://github.com/Microsoft/vscode-react-native/issues/379

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。