导入路径不能以“.ts”扩展名结尾。考虑导入 'src/theme.js'
An import path cannot end with a '.ts' extension. Consider importing 'src/theme.js'
所以这个错误对我来说有点神秘,我不知道如何解决它。
我有一个 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
文件中,当我尝试导入它时 与导入其他所有内容的方式相同...我在故事书中收到以下错误:
好吧,所以我想我需要写 theme.ts
,但这有两个作用。第一,它会产生如下所示的错误;第二,它会破坏 VsCode TS.
附带的智能感知
我怎样才能修复我的 Button.stories.tsx
文件,这样导入路径错误就消失了,我可以只导入为 src/theme
?
将您的 *.tsx
文件包含在您的 tsconfig.json
中:
{
"compilerOptions": {
// ....
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
所以这个错误对我来说有点神秘,我不知道如何解决它。
我有一个 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
文件中,当我尝试导入它时 与导入其他所有内容的方式相同...我在故事书中收到以下错误:
好吧,所以我想我需要写 theme.ts
,但这有两个作用。第一,它会产生如下所示的错误;第二,它会破坏 VsCode TS.
我怎样才能修复我的 Button.stories.tsx
文件,这样导入路径错误就消失了,我可以只导入为 src/theme
?
将您的 *.tsx
文件包含在您的 tsconfig.json
中:
{
"compilerOptions": {
// ....
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}