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

[BUGFIX release] Add some missing types to preview types #20274

Merged
merged 2 commits into from
Nov 22, 2022

Conversation

wagenet
Copy link
Member

@wagenet wagenet commented Nov 21, 2022

  • Adds some new type tests for preview types
  • Removes some non-public API from the preview types
  • Adds some missing APIs to preview types

@wagenet wagenet marked this pull request as ready for review November 21, 2022 20:55
Comment on lines +5 to +8
// Good enough for testing
let factory = {} as TemplateFactory;

expectTypeOf(setComponentTemplate(factory, {})).toEqualTypeOf<object>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two alternative approaches that work well for spots like this:

  1. Use declare:

    Suggested change
    // Good enough for testing
    let factory = {} as TemplateFactory;
    expectTypeOf(setComponentTemplate(factory, {})).toEqualTypeOf<object>();
    declare let factory: TemplateFactory
    expectTypeOf(setComponentTemplate(factory, {})).toEqualTypeOf<object>();
  2. Test the parameters and return type explicitly instead:

    Suggested change
    // Good enough for testing
    let factory = {} as TemplateFactory;
    expectTypeOf(setComponentTemplate(factory, {})).toEqualTypeOf<object>();
    expectTypeOf(setComponentTemplate).parameters.toEqualTypeOf<[TemplateFactory, object]>();
    expectTypeOf(setComponentTemplate).returns.toEqualTypeOf<object>();

Both of these avoid needing the cast, which is not a particularly big deal here but is nice in the "modeling what we want to see" sense.

@chriskrycho chriskrycho added the TypeScript Work on Ember’s types label Nov 22, 2022
@chriskrycho chriskrycho merged commit 3f89e15 into emberjs:master Nov 22, 2022
@chriskrycho chriskrycho changed the title More Type Tweaks [BUGFIX release] Add some missing types to preview types Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TypeScript Work on Ember’s types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants