ember-page-title icon indicating copy to clipboard operation
ember-page-title copied to clipboard

Convert to TS or supply ambient definitions

Open chriskrycho opened this issue 3 years ago • 4 comments

As part of Ember.js RFC #0800, this package needs to supply type definitions. Preferably, this would happen by converting to TS and generating from the source; as an alternative, it can publish ambient types (presumably starting with the ones on DefinitelyTyped).

All the members of the Typed Ember team are happy to advise on how to do this; feel free to reach out in #dev-typescript on Discord if you have questions!

chriskrycho avatar Aug 23 '22 00:08 chriskrycho

If converting to TS, is there a setup that people are using in embroider addons? Would love an example. cc @NullVoxPopuli

knownasilya avatar Aug 25 '22 15:08 knownasilya

My* TS v2 addons:

  • https://github.com/NullVoxPopuli/ember-statechart-component/tree/main/ember-statechart-component
  • https://github.com/NullVoxPopuli/ember-resources/tree/main/ember-resources
  • https://github.com/NullVoxPopuli/ember-popperjs/tree/main/ember-popperjs
  • https://github.com/NullVoxPopuli/ember-deep-tracked/tree/main/ember-deep-tracked
  • https://github.com/emberjs/ember-string/pull/345
  • https://github.com/CrowdStrike/ember-browser-services/tree/main/ember-browser-services
  • https://github.com/CrowdStrike/ember-toucan-styles/tree/main/ember-toucan-styles
  • https://github.com/CrowdStrike/ember-aria/tree/main/ember-aria-utilities

probably others, I've lost track

NullVoxPopuli avatar Aug 25 '22 15:08 NullVoxPopuli

Is there a consistent TS setup among them?

knownasilya avatar Aug 25 '22 15:08 knownasilya

mostly, ya

NullVoxPopuli avatar Aug 25 '22 16:08 NullVoxPopuli

I ran into the lack of page-title types when trying to use the new ember 5.1 ember-source types:

app/templates/application.hbs:1:3 - error TS7053: Unknown name 'page-title'. If this isn't a typo, you may be missing a registry entry for this value; see the Template Registry page in the Glint documentation for more details.
  Element implicitly has an 'any' type because expression of type '"page-title"' can't be used to index type 'Globals'.
    Property 'page-title' does not exist on type 'Globals'.

To fix, I added types to types/ember-page-title/index.d.ts:

import { HelperLike } from '@glint/template';

export type PageTitle = abstract new <T>() => InstanceType<
  HelperLike<{
    Args: {
      Positional: [value: T];
    };
    Return: '';
  }>
>;

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry {
    'page-title': PageTitle;
  }
}

leepfrog avatar Jul 20 '23 23:07 leepfrog

@leepfrog any help in getting https://github.com/ember-cli/ember-page-title/pull/246 across the finish line is appreciated 👍🏼

knownasilya avatar Jul 21 '23 12:07 knownasilya

@knownasilya opened up #256 that might help?

leepfrog avatar Jul 21 '23 21:07 leepfrog

@NullVoxPopuli This should be fixed by https://github.com/ember-cli/ember-page-title/pull/275 ?

HeroicEric avatar Jan 11 '24 21:01 HeroicEric

yup! thanks!

NullVoxPopuli avatar Jan 11 '24 22:01 NullVoxPopuli