嗨,我正在把我的js react redux项目转换成typescript。我想从我的redux reducers文件开始。
Project/ ... reducers/ index.ts actions/ index.js types/ actions/ index.d.ts ... tsconfig.js
文件内容-
减速器/索引.ts
import { Actions } from "../actions";
[ts] Could not find a declaration file for module '../actions'
在我的心里 类型/ 索引d.ts 我有-
declare module "actions";
{ "compilerOptions": { "target": "esnext", "module": "commonjs", "jsx": "react", "strict": true, "typeRoots": ["./types", "./node_modules/@types"], "allowSyntheticDefaultImports": true, "esModuleInterop": true }, "exclude": ["node_modules", "typings"] }
所以我不知道该怎么解决-
您可以跳过模块定义技巧(.d.ts)。 尝试在重构时使用--allowJs编译器标志,typescript在理解.js代码方面做得很好。
Ts config options
{ "compilerOptions": { "target": "esnext", "module": "commonjs", "jsx": "react", "strict": true, "allowJs": true, //Allows you to import and compile .js files "typeRoots": [ "./types", "./node_modules/@types" ], "allowSyntheticDefaultImports": true, "esModuleInterop": true }, "exclude": [ "node_modules", "typings" ] }