我已经看到数千个类似问题的答案,但没有一个对我有用。我试图通过创建我自己的.d.ts文件来使用没有打字稿类型定义的npm模块。我总是收到以下错误:Could not find a declaration file for module 'aws-elasticsearch-connector'.
文件结构
tsconfig.json
{
"include": [
"src"
],
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
}
}
aws-elasticsearch-connector.d.ts
declare module 'aws-elasticsearch-connector';
index.ts
import * as AWS from 'aws-sdk'
import { Client } from '@elastic/elasticsearch'
import { createAwsElasticsearchConnector } from 'aws-elasticsearch-connector'
答案 0 :(得分:0)
您能否尝试像这样在tsconfig.json中设置include选项:
"include": ["src/**/*"]