Skip to content

Commit

Permalink
[BUGFIX] generate type registry entry in service blueprint
Browse files Browse the repository at this point in the history
We have support for this capability in the types, so the blueprints
should make sure that there is a registry entry for each service. We
originally left this out because we were unsure of the future of the
service registry, but we made `Owner.lookup()` smart enough to resolve
it, and the `@service` decorator continues to expect it.
  • Loading branch information
chriskrycho committed Jan 19, 2023
1 parent 7d24b03 commit 5d9391d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blueprints/service/files/__root__/__path__/__name__.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import Service from '@ember/service';

export default class <%= classifiedModuleName %>Service extends Service {}

// Don't remove this declaration: this is what enables TypeScript to resolve
// this service using `Owner.lookup('service:<%= dasherizedModuleName %>')`, as well
// as to check when you pass the service name as an argument to the decorator,
// like `@service('<%= dasherizedModuleName %>') declare altName: <%= classifiedModuleName %>Service;`.
declare module '@ember/service' {
interface Registry {
'<%= dasherizedModuleName %>': <%= classifiedModuleName %>Service;
}
}

0 comments on commit 5d9391d

Please sign in to comment.