Skip to content

Commit

Permalink
refactor: use @ts-expect-error over @ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
MrChocolatine committed Nov 5, 2023
1 parent bc0a1c9 commit cc9dd21
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion addon/initializers/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions addon/instance-initializers/embedded.ts
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
4 changes: 2 additions & 2 deletions addon/services/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/initializers/embedded-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 9 additions & 7 deletions tests/unit/initializers/export-application-global-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')
})

Expand Down Expand Up @@ -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',
Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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',
)
Expand Down

0 comments on commit cc9dd21

Please sign in to comment.