Custom .d.ts file for NPM library not found by TSC

1k Views Asked by At
import audioConcat from 'audioconcat';
Could not find a declaration file for module 'audioconcat'. '/home/owner/projectDir/node_modules/audioconcat/index.js' implicitly has an 'any' type.
  Try `npm install @types/audioconcat` if it exists or add a new declaration (.d.ts) file containing `declare module 'audioconcat';`ts(7016)

This NPM library doesn't have its own typings, or community package on DefinitelyTyped: https://www.npmjs.com/package/audioconcat

// src/types/audioconcat/index.d.ts

declare module "audioconcat" {
    export default class AudioConcat {
     constructor(audios: Array<string>);

     VERSION: string;

     ffmpeg: Function;

     concat(images: string[], options: any): this;

     on(event: 'start', callback: (command: any) => void): this;
     on(event: 'error', callback: (err: any, stdout: any, stderr: any) => void):  this;
     on(event: 'end', callback: (output: any) => void): this; 
  } 
}

And my tsconfig.json:

{
   "compilerOptions": {
       "target" : "ES5",
       "module": "commonjs",
       "noImplicitAny": true,
       "removeComments": true,
       "sourceMap": true
       , "outDir": "compiled/"
       , "esModuleInterop": true
       , "strict": true
       , "typeRoots": ["./src/types", "node_modules/@types"]
   },
   "include": ["src/**/*"]
   , "exclude": ["node_modules", "compiled", "__tests__", "types"]
}

// On line 1: Cannot find type definition file for 'audioconcat'.ts

What detail am I missing for Typescript not to detect this declaration file after rerunning tsc?

0

There are 0 best solutions below