Generating types definitions for tediousjs

At work, we use the tedious library to connect to MS-SQL/T-SQL servers from TypeScript applications.

Unfortunately, the current @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), we can use TypeScript to infer a definitions file we can use in our projects. The process is as follows:


    {
      "extends": "./tsconfig",
      "exclude": [
        "test/**/*.js"
      ],
      "compilerOptions": {
        "declaration": true,
        "noEmit": false,
        "emitDeclarationOnly": true,
        "isolatedModules": false
      }
    }

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 $