Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix incompatibility with ember-source/types #787

Closed
wants to merge 1 commit into from

Conversation

HeroicEric
Copy link

@HeroicEric HeroicEric commented Jan 24, 2024

Fixes #784

Currently LinkManagerService#currentTransitionStack() has an implicit return type:

export default class LinkManagerService extends Service {
  @tracked private internalCurrentTransitionStack?: Transition[];

  get currentTransitionStack() {
    return this.internalCurrentTransitionStack;
  }
}

Which results in the following type declaration:

declare class LinkManagerService extends Service {
  private internalCurrentTransitionStack?;

  get currentTransitionStack(): Transition<unknown>[] | undefined;
}

Which causes errors when using the types from ember-source/types because Transition is not generic.

Adding an explicit return type to currentTransitionStack seems to prevent TypeScript from expanding Transition[] to Transition<unknown>[].

Here is the resulting type after the change:

declare class LinkManagerService extends Service {
  private internalCurrentTransitionStack?;

  get currentTransitionStack(): Transition[] | undefined;
}

I'm guessing there is a better way to deal with this but I'm not sure what it is.

Currently `LinkManagerService#currentTransitionStack()` has an implicit
return type:

```ts
export default class LinkManagerService extends Service {
  @Tracked private internalCurrentTransitionStack?: Transition[];

  get currentTransitionStack() {
    return this.internalCurrentTransitionStack;
  }
}
```

Which results in the following type declaration:

```ts
declare class LinkManagerService extends Service {
  private internalCurrentTransitionStack?;

  get currentTransitionStack(): Transition<unknown>[] | undefined;
}
```

Which causes errors when using the types from `ember-source/types`
because `Transition` is not generic.

Adding an explicit return type to `currentTransitionStack` seems to
prevent TypeScript from expanding `Transition[]` to
`Transition<unknown>[]`.

Here is the resulting type after the change:

```
declare class LinkManagerService extends Service {
  private internalCurrentTransitionStack?;

  get currentTransitionStack(): Transition[] | undefined;
}
```

I'm guessing there is a better way to deal with this but I'm not sure
what it is.
@HeroicEric
Copy link
Author

@NullVoxPopuli I think you mentioned you may have figured out a way to test against DefinitelyTyped & ember-source/types?

@HeroicEric
Copy link
Author

Closing this in favor of #786

@HeroicEric HeroicEric closed this Jan 24, 2024
@HeroicEric HeroicEric deleted the fix-transition-types branch January 24, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible with stable ember-source/types
1 participant