I have a module

```
import pino, { Logger } from 'pino';

let logger: Logger;

if (process.env.NODE_ENV === 'production') {
    const dest = pino.extreme();
    logger = pino(dest);
}

if (process.env.NODE_ENV === 'development') {
    // @ts-ignore
    logger = pino({ prettyPrint: { colorize: true } });
}

...

export default logger;
// ^^^ [ts] Variable 'logger' is used before being assigned. [2454]

```

Here is no any situation when logger is undefined, but even if it will be undefined it is suted for me

How to resolve the TypeScript error at the end:

> 
> Variable 'logger' is used before being assigned. [2454]
> 
> 
> 

I've rewritten my code but the error still here

```
import pino, { Logger } from 'pino';

let logger: Logger;

if (process.env.NODE_ENV === 'production') {
    const dest = pino.extreme();
    logger = pino(dest);
} else 

if (process.env.NODE_ENV === 'development') {
    // @ts-ignore
    logger = pino({ prettyPrint: { colorize: true } });
} else

if (process.env.NODE_ENV === undefined) {
    throw new Error('Logger must be initialized! Set up process.env.NODE_ENV');
}

if (logger) { // <-- Variable 'logger' is used before being assigned. [2454]
   // configuring process
}

export default logger;

```

Even in another way

```
import pino, { Logger } from 'pino';

let logger: Logger;

function configureProcess(theLogger: Logger) {
  // setup process with theLogger
}

if (process.env.NODE_ENV === 'production') {
    const dest = pino.extreme();
    logger = pino(dest);
    configureProcess(logger); // <-- code duplication
} else if (process.env.NODE_ENV === 'development') {
    // @ts-ignore
    logger = pino({ prettyPrint: { colorize: true } });
    configureProcess(logger); // <-- code duplication
}

if (process.env.NODE_ENV === undefined) {
    throw new Error('Logger must be initialized! Set up process.env.NODE_ENV');
}

export default logger;
// ^^^ [ts] Variable 'logger' is used before being assigned. [2454]

```

I feel like a fighter against TypeScrit instead of developer - so many dances to solve a problem which is not a problem in reality (