简体   繁体   English

tslint错误:找不到模块'redux / todo / actions'.ts(2307)

[英]tslint error: Cannot find module 'redux/todo/actions'.ts(2307)

I have read many posts and articles about getting absolute imports working in a TypeScript project but I am not having a problem with that. 我已经阅读了许多关于在TypeScript项目中获取绝对导入的帖子和文章,但我没有遇到任何问题。 My project is successfully working with absolute imports. 我的项目成功地使用绝对导入。

However, in VS Code, all absolute imports have the red squiggly underline with the message such as 但是,在VS Code中,所有绝对导入都有红色波浪线下划线,如下所示

Cannot find module 'redux/todo/actions'.ts(2307)

My assumption is that this is a tslint issue, but I have not been able to find resolution. 我的假设是这是一个tslint问题,但我无法找到解决方案。

tsconfig.json tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src", // must be set to /src for abs imports
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    // "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "importHelpers": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ]
}

I have tried various configurations for "paths" 我试过“路径”的各种配置

"paths": {
  "*": [
    "*",
   "redux/*"
    ]

},

and

"paths": {
  "redux*": ["/redux/*]
}

I also tried 我也试过了

"rootDir": "src"

Also went through the telint documentation but found nothing relevant. 还通过了telint文档,但没有发现任何相关内容。

This is not a TSLint issue. 这不是TSLint问题。 This is a TypeScript issue. 这是一个TypeScript问题。 TSLint adds static analysis ("linting") on top of the TypeScript language & services. TSLint在TypeScript语言和服务之上添加了静态分析(“linting”)。 Your error is from TypeScript saying it can't find a file/module. 您的错误来自TypeScript,说它无法找到文件/模块。

It's hard to help more concretely without code samples, but since you mentioned the error went array, hooray! 没有代码示例,很难更具体地帮助,但是因为你提到错误就是数组,万岁!

For future reference, restarting the VS Code window (Ctrl/Cmd + Shift + P > Reload Window) generally gets rid of these complaints. 为了将来参考,重新启动VS代码窗口(Ctrl / Cmd + Shift + P>重新加载窗口)通常可以摆脱这些抱怨。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误TS2307:找不到模块'反应' - error TS2307: Cannot find module 'react' 找不到模块 'react'.ts(2307) - Cannot find module 'react'.ts(2307) 导入空类时出错,错误TS2307:找不到模块“菜单” - Error importing empty class, error TS2307: Cannot find module 'menu' 找不到模块 '../../images/Logo.png'.ts(2307) 红色错误仍在显示 - Cannot find module '../../images/Logo.png'.ts(2307) Red Error is Still showing Typescript React / NestJS 应用程序失败 @Heroku 构建 - “错误 TS2307:找不到模块” - Typescript React / NestJS app fails @Heroku build - “error TS2307: Cannot find module” 将 PNG/SVG 导入 React - TS2307:找不到模块 - Importing PNGs/SVGs into React - TS2307: Cannot find module 打字稿智能感知和 TS2307 (TS) 的 Visual Studio 设置找不到模块杂项 - visual studio settings for typescript intellisense and TS2307 (TS) Cannot find module Miscellaneous 如何修复/忽略此控制台错误“TS2307:找不到模块‘@components/common/ButtonBlock’或其相应的类型声明。” - How fix/ignore this console error “TS2307: Cannot find module '@components/common/ButtonBlock' or its corresponding type declarations.” 当 js 文件中不存在模块时,为什么 VS Code 不会抛出“找不到模块 'typescript'.ts(2307)”? - Why does VS Code NOT throw "Cannot find module 'typescript'. ts(2307)" when the module is NOT there in js files? TS2307:找不到模块 '_rc-trigger@5.2.0@rc-trigger' 或其对应的类型声明 - TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM