Last active
November 22, 2021 09:15
-
-
Save micmro/24f0a7d61a7f4de597b0512aff656c73 to your computer and use it in GitHub Desktop.
Add a custom type definition file for an existing (non-typed) npm module, while automatically pick up the typing (for both Typescript or Javascript in case of VS Code). Typings are contained in the `typings/` directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//real file is in: `typings/swagger-express-mw/index.d.ts` (relative to tsconfig.json) | |
import {Config, ConnectMiddleware} from "../swagger-node-runner" | |
/** | |
* Create a new instance of Connect specific SwaggerNodeRunner | |
*/ | |
export function create(config: Config, cb: {(err: Error | undefined, runner: ConnectMiddleware): void}): void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"baseUrl": ".", // needed for custom mapping of typing | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"target": "es6", | |
// custom mapping of typing | |
"paths": { | |
"*" : [ "typings/*"] //generic version | |
// "swagger-express-mw": ["typings/swagger-express-mw"] //specific module version | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment