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:
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
}
}
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 $