Skip to content

Commit

Permalink
fix: type imports for optional packages
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Mar 25, 2020
1 parent b427e03 commit 0a75913
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
10 changes: 5 additions & 5 deletions lib/health-indicator/database/typeorm.health.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, Scope } from '@nestjs/common';
import type { Connection } from 'typeorm';
import { ModuleRef } from '@nestjs/core';
import { HealthCheckError } from '../../health-check/health-check.error';

import * as TypeOrm from 'typeorm';
import * as NestJSTypeOrm from '@nestjs/typeorm';

import {
Expand All @@ -22,7 +22,7 @@ export interface TypeOrmPingCheckSettings {
* The connection which the ping check should get executed
*/
// `any` type in case of typeorm version mismatch
connection?: Connection | any;
connection?: TypeOrm.Connection | any;
/**
* The amount of time the check should require in ms
*/
Expand Down Expand Up @@ -58,7 +58,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
/**
* Returns the connection of the current DI context
*/
private getContextConnection(): Connection | null {
private getContextConnection(): TypeOrm.Connection | null {
const {
getConnectionToken,
} = require('@nestjs/typeorm/dist/common/typeorm.utils') as typeof NestJSTypeOrm;
Expand Down Expand Up @@ -94,7 +94,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
* @param timeout The timeout how long the ping should maximum take
*
*/
private async pingDb(connection: Connection, timeout: number) {
private async pingDb(connection: TypeOrm.Connection, timeout: number) {
let check: Promise<any>;
switch (connection.options.type) {
case 'mongodb':
Expand Down Expand Up @@ -126,7 +126,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
let isHealthy = false;
this.checkDependantPackages();

const connection: Connection | null =
const connection: TypeOrm.Connection | null =
options.connection || this.getContextConnection();
const timeout = options.timeout || 1000;

Expand Down
3 changes: 1 addition & 2 deletions lib/health-indicator/microservice/grpc.health.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HealthCheckError } from '../../health-check/health-check.error';
import { Injectable, Scope } from '@nestjs/common';
import type * as NestJSMicroservices from '@nestjs/microservices';
import type { GrpcOptions } from '@nestjs/microservices';
import { join } from 'path';
import { Observable } from 'rxjs';
import {
Expand Down Expand Up @@ -54,7 +53,7 @@ interface GRPCHealthService {
/**
* @internal
*/
type GrpcOptionsOptions = PropType<GrpcOptions, 'options'>;
type GrpcOptionsOptions = PropType<NestJSMicroservices.GrpcOptions, 'options'>;

/**
* The function to check whether the service is up or down
Expand Down
20 changes: 6 additions & 14 deletions lib/health-indicator/microservice/microservice.health.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { HealthCheckError } from '../../health-check/health-check.error';
import { Injectable, Scope } from '@nestjs/common';
import * as NestJSMicroservices from '@nestjs/microservices';
import {
GrpcOptions,
MqttOptions,
NatsOptions,
RedisOptions,
RmqOptions,
TcpOptions,
} from '@nestjs/microservices';
import { TimeoutError } from '../../errors';
import {
checkPackages,
Expand All @@ -18,12 +10,12 @@ import {
import { HealthIndicator, HealthIndicatorResult } from '../';

type ClientOptions =
| RedisOptions
| NatsOptions
| MqttOptions
| GrpcOptions
| TcpOptions
| RmqOptions;
| NestJSMicroservices.RedisOptions
| NestJSMicroservices.NatsOptions
| NestJSMicroservices.MqttOptions
| NestJSMicroservices.GrpcOptions
| NestJSMicroservices.TcpOptions
| NestJSMicroservices.RmqOptions;

/**
* The options for the `MicroserviceHealthInidcator`
Expand Down
2 changes: 1 addition & 1 deletion lib/terminus-lib.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { checkPackages } from './utils';
*
* @internal
*/
export const TerminusLibProvider: Provider = {
export const TerminusLibProvider = {
provide: TERMINUS_LIB,
useFactory: () => {
const [terminus] = checkPackages(
Expand Down

0 comments on commit 0a75913

Please sign in to comment.