我意识到有几个与此错误相关的问题,但据我所知,这是一种独特的情况,与不正确的import陈述无关。
我正在React用TypeScript和构建一个组件库webpack。
我的目录结构:
- src
- index.ts
- components
- Button
- Button.tsx
- index.ts
- Button.css
- Button.d.css (generated by webpack plugin)
- package.json
- tsconfig.json
- webpack.config.js
- postcss.config.js
Run Code Online (Sandbox Code Playgroud)
我的tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "es2015",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"outDir": "dist",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"declaration": true
},
"include": [
"src/**/*" …Run Code Online (Sandbox Code Playgroud)