feat: add noImplicitAny config

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-06-20 18:25:12 +08:00
parent 6c61f14907
commit e67fe154de
3 changed files with 7 additions and 6 deletions

View File

@ -7,17 +7,17 @@ export class MongoDBConnection {
private static isConnected: boolean = false; private static isConnected: boolean = false;
private static db: Db; private static db: Db;
public static getConnection(result: (connection) => void) { public static getConnection(result: (connection: Db) => void) {
if (this.isConnected) { if (this.isConnected) {
return result(this.db); return result(this.db);
} else { } else {
this.connect((error, db: Db) => { this.connect((error: Error, db: Db) => {
return result(this.db); return result(this.db);
}); });
} }
} }
private static connect(result: (error, db: Db) => void) { private static connect(result: (error: Error, db: Db) => void) {
MongoClient.connect(connStr, { useNewUrlParser: true }, (err, client) => { MongoClient.connect(connStr, { useNewUrlParser: true }, (err, client) => {
this.db = client.db(dbName); this.db = client.db(dbName);
this.isConnected = true; this.isConnected = true;

View File

@ -1,5 +1,5 @@
import "reflect-metadata"; import "reflect-metadata";
import { Container, inject } from 'inversify'; import { Container, inject, interfaces } from 'inversify';
import { autoProvide, provide, fluentProvide, buildProviderModule } from 'inversify-binding-decorators'; import { autoProvide, provide, fluentProvide, buildProviderModule } from 'inversify-binding-decorators';
let container = new Container(); let container = new Container();
@ -7,13 +7,13 @@ let container = new Container();
// a module to be loaded by the container // a module to be loaded by the container
// container.load(buildProviderModule()); // container.load(buildProviderModule());
const provideNamed = (identifier, name) => { const provideNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier) return fluentProvide(identifier)
.whenTargetNamed(name) .whenTargetNamed(name)
.done(); .done();
}; };
const provideSingleton = (identifier: any) => { const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
return fluentProvide(identifier) return fluentProvide(identifier)
.inSingletonScope() .inSingletonScope()
.done(); .done();

View File

@ -6,6 +6,7 @@
"module": "commonjs", "module": "commonjs",
"sourceMap": true, "sourceMap": true,
"declaration": true, "declaration": true,
"noImplicitAny": true,
"allowUnreachableCode": true, "allowUnreachableCode": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true "emitDecoratorMetadata": true