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

Add Glint template registry for local-class helper #301

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@ export default Ember.Controller.extend({
});
```

### Glint usage

Helper `{{local-class}}` has proper [Glint](https://github.com/typed-ember/glint) types,
which allow you when using TypeScript to get strict type checking in your templates.

Unless you are using [strict mode](http://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html) templates
(via [first class component templates](http://emberjs.github.io/rfcs/0779-first-class-component-templates.html)),
you need to import the addon's Glint template registry and extend your app's registry declaration
as described in the [Using Addons](https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons#using-glint-enabled-addons) documentation:

```ts
import '@glint/environment-ember-loose';
import type EmberCssModulesRegistry from 'ember-css-modules/template-registry';

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry extends EmberCssModulesRegistry, /* other addon registries */ {
// local entries
}
}
```

## Usage in Addons

You can also use ember-css-modules in addons that expose components to their consuming application. To do this you'll need to move `ember-css-modules` out of `devDependencies` and into `dependencies` in your addon's `package.json` ([see issue #8](https://github.com/salsify/ember-css-modules/issues/8)).
Expand Down
15 changes: 15 additions & 0 deletions packages/ember-css-modules/template-registry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { HelperLike } from '@glint/template';

interface Signature {
Args: {
Positional: [string];
Named: {
from?: string | undefined;
};
};
Return: string;
}

export default interface EmberCssModulesRegistry {
'local-class': HelperLike<Signature>;
}
Loading