reactjs - 即使代码已修复,Typescript 也会出现错误
问题描述
我有一个错字并调用了green[4500]
, 不存在(在 Material UI 中,但这并不重要)而不是green[500]
, 存在。
所以我得到了一个打字稿错误,因为Property '4500' does not exist on type
......无论是什么类型的green
. 是。
然后我修复它并保存它,我仍然得到错误。即使错误具有固定代码,但错误仍然存在。
Property '4500' does not exist on type '{ 50: "#e8f5e9"; 100: "#c8e6c9"; 200: "#a5d6a7"; 300: "#81c784"; 400: "#66bb6a"; 500: "#4caf50"; 600: "#43a047"; 700: "#388e3c"; 800: "#2e7d32"; 900: "#1b5e20"; A100: "#b9f6ca"; A200: "#69f0ae"; A400: "#00e676"; A700: "#00c853"; }'. Did you mean '400'? TS2551
6 |
7 | const StartButton = styled(Button)({
> 8 | background: green[500],
| ^
9 | color: 'white'
10 | })
11 | const StopButton = styled(Button)({
重新启动服务器可以修复它,这并不奇怪。如果这有什么不同,我正在使用 WebStorm 并从运行菜单(而不是直接从终端)运行服务器。
为什么 Typescript 落后了?
解决方案
推荐阅读
- autodesk-forge - 不支持文件扩展名:null 错误代码:13。加载多个模型时
- laravel-5.7 - Laravel 5.7 控制器检查已单击哪个按钮
- jquery - 使用动态值检测 URL 变化
- angular - 如何从 Angular 2+ 的缩小中排除一些文件?
- asp.net - 使用 Restful - JSON 发送图像和元数据
- javascript - 如何对数组中的每个文件发出 POST 请求
- c# - Visual Studio 找不到安装项目的依赖项
- f# - 列表:将每个第一个、第二个、第三个元素组合到一个子列表列表中
- javascript - 我无法在引导工具提示中单击 html 锚标记中的链接
- java - 如何在适配器类中传递意图