[英]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.