Description
TypeScript Version: 2.7.0-dev.201xxxxx
Context
I am trying to create a local type declaration file for winston-papertrail that adds a new property to winston.transports.Papertrail. There is a @types/winston but no @types/winston-papertrail. Requiring "winston-papertrail" should augment winston.transports to also contain this additional Papertrail property. My assumption was that types inside of 'typeRoots' do not take effect until after the corresponding import statement has been made.
I am able to make it work by doing the following:
Code
The main file is index.ts:
import * as winston from 'winston'
// import 'winston-papertrail'
winston.transports.
tsconfig.json:
{
"compilerOptions": {
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"strict": true, /* Enable all strict type-checking options. */
"typeRoots": [ "node_modules/@types", "types" ] /* List of folders to include type definitions from. */
},
"include": [ "index.ts" ]
}
types/winston-papertrail/index.d.ts:
import * as winston from 'winston'
declare module "winston" {
interface Transports {
Papertrail: any
}
}
export { }
Expected behavior:
The expected behavior is that the Papertrail
property is NOT showing up in the autocompletion suggestions for properties on the winston.transports
value since I haven't imported "winston-papertrail" yet.
Actual behavior:
The Papertrail
property is showing up in the autocompletion suggestions.