1
0
Fork 0

feat: add noImplicitAny config

Signed-off-by: MiaoWoo <admin@yumc.pw>
master
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 db: Db;
public static getConnection(result: (connection) => void) {
public static getConnection(result: (connection: Db) => void) {
if (this.isConnected) {
return result(this.db);
} else {
this.connect((error, db: Db) => {
this.connect((error: Error, db: 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) => {
this.db = client.db(dbName);
this.isConnected = true;

View File

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

View File

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