Generating types definitions for tediousjs ========================================== At work, we use the [tedious](https://tediousjs.github.io/) library to connect to MS-SQL/T-SQL servers from TypeScript applications. Unfortunately, the current [@types/tedious](https://www.npmjs.com/package/@types/tedious) is unmaintained, and only contains types for tedious v4.0.0 (current latest version is v8.3.0). So, what can we do about this? Since tedious uses TypeScript anyway (but [doesn't currently publish it's definitions](https://github.com/tediousjs/tedious/issues/1072)), we can use TypeScript to infer a definitions file we can use in our projects. The process is as follows: * Clone the upstream tedious repo. * Create a new tsconfig file, called `declarations.tsconfig.json` or whatever takes your fancy, add the following:

    {
      "extends": "./tsconfig",
      "exclude": [
        "test/**/*.js"
      ],
      "compilerOptions": {
        "declaration": true,
        "noEmit": false,
        "emitDeclarationOnly": true,
        "isolatedModules": false
      }
    }
* Run `tsc -p declarations.tsconfig.json --out tedious.types.d.ts` to generate your definitions file. If you set the `compilerOptions.isolatedModules` to `true` and omit the `out` flag, you'll generate individual definitions for each file in `src/`. Hopefully tedious v9 will include types by default, however I'm glad this wasn't a hard fix. -- $ dylan@debian $ 2020-05-31 $