我不明白为什么找不到它。typescript:找不到模块'react'
$ cat tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"target": "es6",
"jsx": "react",
"types": [
"lodash",
"react",
"react-dom"
]
}
}
$ tree node_modules/@types
node_modules/@types/
├── lodash
│ ├── README.md
│ ├── index.d.ts
│ ├── package.json
│ └── types-metadata.json
├── react
│ ├── README.md
│ ├── index.d.ts
│ ├── package.json
│ └── types-metadata.json
└── react-dom
├── README.md
├── index.d.ts
├── package.json
├── server.d.ts
└── types-metadata.json
导入组件文件。
// src/components/component.tsx
import * as React from "react";
什么给?
你是如何导入反应的? –
您是否尝试过'导入React = require(“react”);'而不是? –
使用'--traceResolution'运行的输出会有帮助 –