Pab*_*blo 4 typescript eslint typescript-typings typescript-eslint
我有一个用打字稿编写的无服务器项目。当我运行 ESLint 时,出现以下错误:
1:85 error Unable to resolve path to module 'aws-lambda' import/no-unresolved
Run Code Online (Sandbox Code Playgroud)
对于以下代码行:(我的 devDependency 中import { APIGatewayProxyEvent, APIGatewayProxyHandler, APIGatewayProxyResult } from 'aws-lambda';有"@types/aws-lambda": "^8.10.64")。
我不明白可能是什么错误,因为类型已安装,如果我尝试从“@types/aws-lambda”导入,VS Code 会告诉我直接从“aws-lambda”导入。
我在这里做错了什么?
hendrixchord 的 anwser 帮助我解决了这个问题,但以下是真正对我有用的必要步骤的精简版本:
# It's a must, otherwise the below `settings` won't work:
$ npm install --save-dev eslint-import-resolver-typescript
# Not `--save-dev`.
$ npm install @types/aws-lambda
Run Code Online (Sandbox Code Playgroud)
在文件中.eslintrc(请注意,我正在使用该.js版本):
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11636 次 |
| 最近记录: |