Skip to content

Commit

Permalink
Update to new Glint addon best practices (#246)
Browse files Browse the repository at this point in the history
* Update to new Glint addon best practices
The Glint docs now recommend to export the Registry, see https://typed-ember.gitbook.io/glint/using-glint/ember/authoring-addons

* Update README.md

Co-authored-by: Sergey Astapov <[email protected]>

* Update template-registry.d.ts

---------

Co-authored-by: Sergey Astapov <[email protected]>
  • Loading branch information
langalex and SergeAstapov committed Sep 4, 2023
1 parent 9f59c06 commit 43663dd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@ 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.


### 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
5 changes: 5 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,5 @@
import type SvgJar from './types';

export default interface EmberSvgJarRegistry {
'svg-jar': 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 43663dd

Please sign in to comment.