gpt4 book ai didi

reactjs - 导入路径不能以 '.ts' 扩展名结尾。考虑导入 'src/theme.js'

转载 作者:行者123 更新时间:2023-12-05 03:40:00 25 4
gpt4 key购买 nike

所以这个错误对我来说有点神秘,我不知道如何解决它。

我有一个 theme.ts 文件,大致如下所示:

import { AgnosticStyles, ThemeParameters } from 'styled-components';
import { createTheme } from '@material-ui/core/styles';

const agnosticStyles: AgnosticStyles = {
font: {
weight: {
light: '300',
normal: '400',
bold: '600',
},
},
};
...
// more themes

const defaultTheme = {
lightTheme,
darkTheme,
};

export default defaultTheme;

在我的 Button.stories.txs 文件中,当我尝试导入它时以与导入其他所有内容相同的方式...我在故事书中收到以下错误:

enter image description here

好的,所以我想我需要编写 theme.ts,但这有两件事。第一,它会产生如下所示的错误;第二,它会破坏 VsCode TS 附带的智能感知。

enter image description here


如何修复我的 Button.stories.tsx 文件,这样导入路径错误就消失了,我可以只导入为 src/theme

最佳答案

tsconfig.json 中包含您的 *.tsx 文件:

{
"compilerOptions": {
// ....
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

关于reactjs - 导入路径不能以 '.ts' 扩展名结尾。考虑导入 'src/theme.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68330985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com