Skip to content

Commit cc58ddc

Browse files
committed
[FEATURE] generate type registry entry in service blueprint
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.
1 parent 7d24b03 commit cc58ddc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
import Service from '@ember/service';
22

33
export default class <%= classifiedModuleName %>Service extends Service {}
4+
5+
// Don't remove this declaration: this is what enables TypeScript to resolve
6+
// this service using `Owner.lookup('service:<%= dasherizedModuleName %>')`, as well
7+
// as to check when you pass the service name as an argument to the decorator,
8+
// like `@service('<%= dasherizedModuleName %>') declare altName: <%= classifiedModuleName %>Service;`.
9+
declare module '@ember/service' {
10+
interface Registry {
11+
'<%= dasherizedModuleName %>': <%= classifiedModuleName %>Service;
12+
}
13+
}

0 commit comments

Comments
 (0)