From 6a8e29fab28116d3424e3c8e14279cf7b23f2e89 Mon Sep 17 00:00:00 2001 From: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> Date: Mon, 18 Oct 2021 12:33:29 +0100 Subject: [PATCH] feat: allow to pass type of embedded options --- addon/services/embedded.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addon/services/embedded.ts b/addon/services/embedded.ts index 0f62b33c..f674025e 100644 --- a/addon/services/embedded.ts +++ b/addon/services/embedded.ts @@ -2,21 +2,24 @@ import ObjectProxy from '@ember/object/proxy' import { getOwner } from '@ember/application' import { assert } from '@ember/debug' -export default class EmbeddedService extends ObjectProxy { +type AnyObject = Record + +export default class EmbeddedService< + EmbeddedOptions extends AnyObject = AnyObject +> extends ObjectProxy { constructor() { super(...arguments) // eslint-disable-line prefer-rest-params const factoryName = 'config:embedded' - const factory: Record | undefined = getOwner(this).factoryFor(factoryName) + const factory: { class: EmbeddedOptions } | undefined = getOwner(this).factoryFor(factoryName) assert( `The factory "${factoryName}" could not be found.`, typeof factory === 'object' ) - // eslint-disable-next-line @typescript-eslint/ban-types - this.content = factory.class as object + this.content = factory.class } }