From cc9dd21a4aea6cb26cc9e2abf33c63e24069af96 Mon Sep 17 00:00:00 2001 From: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> Date: Sun, 5 Nov 2023 22:33:54 +0000 Subject: [PATCH] refactor: use `@ts-expect-error` over `@ts-ignore` --- addon/initializers/embedded.ts | 2 +- addon/instance-initializers/embedded.ts | 3 +-- addon/services/embedded.ts | 4 ++-- tests/unit/initializers/embedded-test.ts | 2 +- .../export-application-global-test.ts | 16 +++++++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/addon/initializers/embedded.ts b/addon/initializers/embedded.ts index 5b396ed9..0b732320 100644 --- a/addon/initializers/embedded.ts +++ b/addon/initializers/embedded.ts @@ -74,7 +74,7 @@ export function initialize(application: Application): void { const embeddedConfig: ObjectConfig = normalizeConfig(env.embedded) if (embeddedConfig.delegateStart) { - // @ts-ignore: until correct public types are available + // @ts-expect-error: Until correct public types are available application.reopen({ start: function emberCliEmbeddedStart(this: Application, config = {}) { const _embeddedConfig = Object.assign({}, embeddedConfig.config, config) diff --git a/addon/instance-initializers/embedded.ts b/addon/instance-initializers/embedded.ts index b3e8615b..2290bfb9 100644 --- a/addon/instance-initializers/embedded.ts +++ b/addon/instance-initializers/embedded.ts @@ -1,8 +1,7 @@ import ApplicationInstance from '@ember/application/instance' export function initialize(appInstance: ApplicationInstance): void { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: https://github.com/typed-ember/ember-cli-typescript/issues/1471 + // @ts-expect-error: https://github.com/typed-ember/ember-cli-typescript/issues/1471 const appConf = appInstance.resolveRegistration('config:environment').APP const embedConf = appInstance.resolveRegistration('config:embedded') diff --git a/addon/services/embedded.ts b/addon/services/embedded.ts index cf4ee1eb..8087fab2 100644 --- a/addon/services/embedded.ts +++ b/addon/services/embedded.ts @@ -11,8 +11,8 @@ export default class EmbeddedService< super(...arguments) // eslint-disable-line prefer-rest-params const factoryName = 'config:embedded' - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: https://github.com/typed-ember/ember-cli-typescript/issues/1471 + + // @ts-expect-error: https://github.com/typed-ember/ember-cli-typescript/issues/1471 const factory: { class: EmbeddedOptions } | undefined = getOwner(this).factoryFor(factoryName) assert(`The factory "${factoryName}" could not be found.`, typeof factory === 'object') diff --git a/tests/unit/initializers/embedded-test.ts b/tests/unit/initializers/embedded-test.ts index 3ec0b6ab..62c50a84 100644 --- a/tests/unit/initializers/embedded-test.ts +++ b/tests/unit/initializers/embedded-test.ts @@ -33,7 +33,7 @@ module('Unit | Initializer | embedded', function (hooks) { initialize, }) - // @ts-ignore: temporarily required as public types are incomplete + // @ts-expect-error: Temporarily required as public types are incomplete this.application = this.TestApplication.create({ autoboot: false, Resolver, diff --git a/tests/unit/initializers/export-application-global-test.ts b/tests/unit/initializers/export-application-global-test.ts index 9aa479d2..fad65548 100644 --- a/tests/unit/initializers/export-application-global-test.ts +++ b/tests/unit/initializers/export-application-global-test.ts @@ -33,7 +33,7 @@ module('Unit | Initializer | export-application-global', function (hooks) { initialize, }) - // @ts-ignore: temporarily required as public types are incomplete + // @ts-expect-error: Temporarily required as public types are incomplete this.application = this.TestApplication.create({ autoboot: false, Resolver, @@ -46,8 +46,10 @@ module('Unit | Initializer | export-application-global', function (hooks) { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO replace `any` const config: any = this.application.resolveRegistration('config:environment') const exportedApplicationGlobal: string = classify(config.modulePrefix) - // @ts-ignore: because TS doesn't like window[dynamicPropertyName] + + // @ts-expect-error: No index signature for Window delete window[exportedApplicationGlobal] + run(this.application, 'destroy') }) @@ -78,7 +80,7 @@ module('Unit | Initializer | export-application-global', function (hooks) { ) assert.deepEqual( - // @ts-ignore: because TS doesn't like window[dynamicPropertyName] + // @ts-expect-error: No index signature for Window window[exportedApplicationGlobal], this.application, 'it creates expected application global on window', @@ -93,7 +95,7 @@ module('Unit | Initializer | export-application-global', function (hooks) { await this.application.boot() - // @ts-ignore: because TS doesn't like window[dynamicPropertyName] + // @ts-expect-error: No index signature for Window assert.notOk(window.SomethingRandom) }) @@ -108,7 +110,7 @@ module('Unit | Initializer | export-application-global', function (hooks) { await this.application.boot() - // @ts-ignore: because TS doesn't like window[dynamicPropertyName] + // @ts-expect-error: No index signature for Window assert.notOk(window.SomethingRandom) }) @@ -124,14 +126,14 @@ module('Unit | Initializer | export-application-global', function (hooks) { await this.application.boot() assert.deepEqual( - // @ts-ignore: because TS doesn't like window.PropertyName ? + // @ts-expect-error: No index signature for Window window.SomethingElse, this.application, 'name set in config is used for exported application global, instead of original module prefix', ) assert.notOk( - // @ts-ignore: because TS doesn't like window.PropertyName ? + // @ts-expect-error: No index signature for Window window.SomethingRandom, 'original module prefix is not used in exported application global', )