React native 和 MobX:对装饰器的实验性支持是一个主题 [...]。但是“tsconfig”或“jsconfig”不存在

Posted

技术标签:

【中文标题】React native 和 MobX:对装饰器的实验性支持是一个主题 [...]。但是“tsconfig”或“jsconfig”不存在【英文标题】:React native & MobX: Experimental support for decorators is a feature that is subject [...]. But 'tsconfig' or 'jsconfig' doesn't exist 【发布时间】:2021-06-14 08:39:22 【问题描述】:

所以当我尝试将 mobx 观察者实现为 react native 时,我的 vscode 一直给我这个错误。

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.

我相信我已遵循以下网站中的每一条说明。

https://jamesmargrove.medium.com/setting-up-a-typescript-react-native-project-with-decorators-93eb8a8ffa9

此外,我在我的项目中的任何地方都找不到tsconfigjsconfig。请帮忙

【问题讨论】:

【参考方案1】:

尝试在项目根目录下添加jsconfig.json文件,内容如下:


  "compilerOptions": 
    "experimentalDecorators": true
  

【讨论】:

哦,所以我必须自己创建它 没错,它也只会删除VS Code中的警告。您链接的教程中提到的 babel 插件添加了编译装饰器的功能。

以上是关于React native 和 MobX:对装饰器的实验性支持是一个主题 [...]。但是“tsconfig”或“jsconfig”不存在的主要内容,如果未能解决你的问题,请参考以下文章

React项目中使用Mobx状态管理

react项目的中使用mobx状态管理安装ES7装饰器(Decorator)语法教程

如何让 MobX 装饰器与 Create-React-App v2 一起工作?

无法从 mobx 导入装饰

react-native+MobX

react+mobx 编写 withStoreHistory 装饰器