Skip to content

Commit

Permalink
Update to new Glint addon best practices
Browse files Browse the repository at this point in the history
The Glint docs now recommend to export the Registry, see https://typed-ember.gitbook.io/glint/using-glint/ember/authoring-addons
  • Loading branch information
langalex committed Dec 23, 2022
1 parent e4aee21 commit 662e998
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ var app = new EmberApp(defaults, {

[Click here for more configuration options](#configuration)

### TypeScript usage

The `svg-jar` helper 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 EmberSvgJarRegistry from 'ember-svg-jar/template-registry';

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

Should you want to manage the registry by yourself, then omit this import, and instead add the entries in your app by explicitly importing the types of the helper from this addon.

> Note that Glint itself is still under active development, and as such breaking changes might occur. Therefore, Glint support by this addon is also considered experimental, and not covered by our SemVer contract!
### Usage in an addon

Using `ember-svg-jar` in an addon is the same as in an app, except that in the `package.json`
Expand Down
6 changes: 6 additions & 0 deletions packages/ember-svg-jar/addon/template-registry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type SvgJar from './types';

export default interface EmberSvgJarRegistry {
'svg-jar': typeof SvgJar;
svgJar: typeof SvgJar;
}
File renamed without changes.
8 changes: 0 additions & 8 deletions packages/ember-svg-jar/types/glint.d.ts

This file was deleted.

0 comments on commit 662e998

Please sign in to comment.