title: How are you supposed to create Winston logger stream for Morgan in TypeScript
body: <p>What is the correct way to create a winston logger in TypeScript that will log the express Morgan middleware logging?  I found a number of JavaScript samples but have had trouble converting them over to TypeScript, because I get an error <code>Type '{ write: (message: string, encoding: any) =&gt; {}; logger: any; }' is not assignable to type '(options?: any) =&gt; ReadableStream'. Object literal may only specify known properties, and 'write' does not exist in type '(options?: any) =&gt; ReadableStream'.</code></p>
  
  <p>Here is my code:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Logger, transports } from 'winston';
  
  // http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
  // https://www.loggly.com/ultimate-guide/node-logging-basics/
  
  const logger = new Logger({
      transports: [
          new (transports.Console)({
              level: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
              handleExceptions: true,
              json: false,
              colorize: true
          }),
          new (transports.File)({
              filename: 'debug.log', level: 'info',
              handleExceptions: true,
              json: true,
              colorize: false
          })
      ],
      exitOnError: false,
  });
  
  
  
  if (process.env.NODE_ENV !== 'production') {
      logger.debug('Logging initialized at debug level');
  }
  
  
  
  // [ts]
  // Type '{ write: (message: string, encoding: any) =&gt; {}; logger: any; }' is not assignable to type '(options?: any) =&gt; ReadableStream'.
  //   Object literal may only specify known properties, and 'write' does not exist in type '(options?: any) =&gt; ReadableStream'.
  logger.stream = {
      write: function (message: string, encoding: any) {
          logger.info(message);
      };
  }
  
  
  export default logger;
  </code></pre>
  
  <p>I have been able to work around this by adjusting my code to use <code>const winston = require('winston');</code> but would like to know how you are supposed to do this maintaining types?</p>