Merge pull request #1630 from balena-io/strict-by-default

Enable strict options by default and only disable specific ones
This commit is contained in:
bulldozer-balena[bot] 2021-03-22 18:37:28 +00:00 committed by GitHub
commit bf5b5b9082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { EventEmitter } from 'events';
import { Transaction } from 'knex';
import type { Transaction } from 'knex';
import * as _ from 'lodash';
import StrictEventEmitter from 'strict-event-emitter-types';
import { inspect } from 'util';
@ -54,7 +54,7 @@ export async function get<T extends SchemaTypeKey>(
key: T,
trx?: Transaction,
): Promise<SchemaReturn<T>> {
const $db = trx || db.models.bind(db);
const $db = trx || db.models;
if (Schema.schema.hasOwnProperty(key)) {
const schemaKey = key as Schema.SchemaKey;
@ -183,7 +183,7 @@ export async function set<T extends SchemaTypeKey>(
if (trx != null) {
await setValuesInTransaction(trx);
} else {
await db.transaction((tx: Transaction) => setValuesInTransaction(tx));
await db.transaction((tx) => setValuesInTransaction(tx));
}
events.emit('change', keyValues as ConfigMap<SchemaTypeKey>);
}
@ -235,7 +235,7 @@ export function valueIsValid<T extends SchemaTypeKey>(
async function getSchema<T extends Schema.SchemaKey>(
key: T,
$db: Transaction,
$db: typeof db.models,
): Promise<unknown> {
let value: unknown;
switch (Schema.schema[key].source) {

View File

@ -2,10 +2,11 @@
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"preserveConstEnums": true,
"inlineSourceMap": true,
"strictNullChecks": true,
"outDir": "./build/",
"skipLibCheck": true,
"lib": ["es6"],