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

Update to new Glint addon best practices #246

Merged
merged 3 commits into from
Sep 4, 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
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;
}
8 changes: 0 additions & 8 deletions packages/ember-svg-jar/types/glint.d.ts

This file was deleted.

Loading