I'm trying to create a type definition for es6-promisify, a JS package not in the DefinitelyTyped annotations repository. Looking at examples in DefinitelyTyped and following TS Deep Dive / Declaration Files, I created a crude annotation that I saved in my project in a vendor.d.ts:
declare function promisify(original: (...args: any[]) => any, settings: any): Promise<any>
export = promisify
// export interface promisify { } // or should I do an interface?
Now, considering I import with import promisify = require('es6-promisify'), how do I tell TypeScript that the promisify import is annotated in vendor.d.ts? Currently, tsc keeps returning Could not find a declaration file for module 'es6-promisify'. 'promisify.js' implicitly has an 'any' type. I'm trying to digest TS Docs / Module Resolution but am failing at it so far.
Phrased differently: what's the mechanism used by TypeScript to resolve a declaration file from an import? XY problem warning: maybe I'm doing things wrong and shouldn't do a vendor.d.ts? Maybe there's a good reason es6-promisify is not in DT? Feel free to contradict with better ways to reach my goal of making tsc with "noImplicitAny": true happy. Thanks :)
vendor.d.tstoes6-promisify.d.ts, and adding the directory containing the type definition it tocompilerOptions.typeRootsin yourtsconfig? If you are changingcompilerOptions.typeRoots, don't forget to add./node_modules/@typesto it. refer: typescriptlang.org/docs/handbook/tsconfig-json.htmlimportline. Note: an additional thing I just tried: following DT's structure (example of such a simple typing that works: mkdirp) with anes6-promisifyfolder andindex.d.ts+tsconfig.jsonfiles inside. Still failing :-/