'TS7016: Could not find a declaration file. And I can't add it
I need to work with ssl-validator ssl-validator in my nodeJs(typescript) project - to validate ssl certificate uploaded by user. The library doesn't have index.d.ts file and I have to add it if I understood this principle correct. My file structure:
├── package-lock.json
├── package.json
├── index.ts
├── tsconfig.json
└── typings
└── sslValidator.d.ts
index.ts:
import * as sslValidator from 'ssl-validator';
const { validateSSLCert, isValidSSL } = sslValidator;
const main = async () => {
const result = await isValidSSL(
"-----BEGIN CERTIFICATE-----\n" +
<CERTIFICATE>
"-----END CERTIFICATE-----"
);
return result;
}
main();
sslValidator.d.ts:
declare module 'ssl-validator' {
function isValidSSL (certificate: string): Promise<boolean>;
function validateSSLCert (certificate: string): Promise<any>;
}
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2017",
"noImplicitAny": true,
"strictNullChecks": false,
"lib": ["es2017", "dom", "esnext.asynciterable"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
"baseUrl": ".",
"sourceMap": true,
"typeRoots": ["typings"],
"traceResolution": false
},
"include": ["*/*.ts"],
}
Static code analysis doesn't underline anything, but after running I get:
index_t.ts:1:31 - error TS7016: Could not find a declaration file for module 'ssl-validator'. '/Users/nikita/Desktop/code/aws_sandbox/node_modules/ssl-validator/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ssl-validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'ssl-validator';`
1 import * as sslValidator from 'ssl-validator';
~~~~~~~~~~~~~~~
What do I do wrongly?
p.s. Is there any alternative of ssl-validator with typing in library?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
