diff --git a/benchmark/src/benchmark.ts b/benchmark/src/benchmark.ts index efebf07fe0ed..cd1ea48df420 100644 --- a/benchmark/src/benchmark.ts +++ b/benchmark/src/benchmark.ts @@ -5,7 +5,7 @@ import * as byline from 'byline'; import {ChildProcess, spawn} from 'child_process'; -import pEvent from 'p-event'; +import pEvent, {Emitter} from 'p-event'; import {Autocannon, EndpointStats} from './autocannon'; import {Client} from './client'; import {scenarios} from './scenarios'; @@ -111,5 +111,10 @@ function startWorker() { async function closeWorker(worker: ChildProcess) { worker.kill(); - await pEvent(worker, 'close'); + await pEvent( + // workaround for a bug in pEvent types which makes them + // incompatible with "strictFunctionTypes" + worker as Emitter<[unknown]>, + 'close', + ); } diff --git a/packages/build/config/tsconfig.common.json b/packages/build/config/tsconfig.common.json index eb58cee2e096..5aa85c2b0b3b 100644 --- a/packages/build/config/tsconfig.common.json +++ b/packages/build/config/tsconfig.common.json @@ -3,11 +3,12 @@ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, - "noImplicitAny": true, - "strictNullChecks": true, "resolveJsonModule": true, - "strictBindCallApply": true, "skipLibCheck": true, + "strict": true, + + // FIXME(bajtos) LB4 is not compatible with this setting yet + "strictPropertyInitialization": false, "lib": ["es2018", "esnext.asynciterable"], "module": "commonjs", diff --git a/packages/context/src/context-view.ts b/packages/context/src/context-view.ts index a354cf44aecc..e563a57701f9 100644 --- a/packages/context/src/context-view.ts +++ b/packages/context/src/context-view.ts @@ -45,6 +45,9 @@ export class ContextView extends EventEmitter public readonly filter: BindingFilter, ) { super(); + + // Workaround to pass TypeScript's "strictFunctionTypes" check + this.filter = filter as BindingFilter; } /** @@ -85,10 +88,11 @@ export class ContextView extends EventEmitter /** * Find matching bindings and refresh the cache */ - protected findBindings() { + protected findBindings(): Readonly>[] { debug('Finding matching bindings'); - this._cachedBindings = this.context.find(this.filter); - return this._cachedBindings; + const found = this.context.find(this.filter); + this._cachedBindings = found; + return found; } /** diff --git a/packages/core/src/lifecycle.ts b/packages/core/src/lifecycle.ts index 606473d4bc89..8b59b8f008b4 100644 --- a/packages/core/src/lifecycle.ts +++ b/packages/core/src/lifecycle.ts @@ -62,7 +62,7 @@ export function asLifeCycleObserver(binding: Binding) { * Find all life cycle observer bindings. By default, a binding tagged with * `CoreTags.LIFE_CYCLE_OBSERVER`. It's used as `BindingFilter`. */ -export function lifeCycleObserverFilter(binding: Binding): boolean { +export function lifeCycleObserverFilter(binding: Readonly): boolean { return binding.tagMap[CoreTags.LIFE_CYCLE_OBSERVER] != null; } diff --git a/packages/repository/src/__tests__/unit/type-resolver.unit.ts b/packages/repository/src/__tests__/unit/type-resolver.unit.ts index ceb469741bd1..a3079a4c7842 100644 --- a/packages/repository/src/__tests__/unit/type-resolver.unit.ts +++ b/packages/repository/src/__tests__/unit/type-resolver.unit.ts @@ -4,7 +4,12 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {isBuiltinType, isTypeResolver, resolveType} from '../../type-resolver'; +import { + isBuiltinType, + isTypeResolver, + resolveType, + TypeResolver, +} from '../../type-resolver'; class SomeModel { constructor(public name: string) {} @@ -60,7 +65,8 @@ describe('isTypeResolver', () => { describe('resolveType', () => { it('resolves the arg when the value is a resolver', () => { - const ctor = resolveType(() => SomeModel); + const resolver: TypeResolver = () => SomeModel; + const ctor = resolveType(resolver); expect(ctor).to.eql(SomeModel); const inst = new ctor('a-name');