Skip to content

Commit 7aa8785

Browse files
committed
Finish
1 parent 5ff3c66 commit 7aa8785

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import EmberApplication from '@ember/application';
22
import { StrictResolver } from './strict-resolver.ts';
33

4+
type ExportableType =
5+
| undefined
6+
| null
7+
| object
8+
| number
9+
| string
10+
| boolean
11+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
12+
| Function;
13+
414
export default class EmberApp extends EmberApplication {
515
Resolver = {
616
create: ({
@@ -24,7 +34,11 @@ export default class EmberApp extends EmberApplication {
2434
@property modules
2535
@public
2636
*/
27-
declare modules?: Record<string, Record<string, unknown>>;
37+
declare modules?: {
38+
[modulePath: string]:
39+
| ExportableType
40+
| { [exportName: string]: ExportableType };
41+
};
2842

2943
// TODO: I don't think I really want to add this, but I also don't want to
3044
// keep legacy pluralization baked in.

src/strict-resolver.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ export class StrictResolver implements Resolver {
55
#plurals = new Map<string, string>();
66
original: any;
77

8-
static create(...args: any[]) {
9-
new StrictResolver(...args);
10-
}
11-
128
constructor(
139
modules: Record<string, Record<string, unknown>>,
1410
plurals: Record<string, string> | undefined = undefined,

tests/registry-test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ module('Registry', function (hooks) {
1818
assert.ok(manual.weDidIt);
1919
});
2020

21+
test('has a manually registered (shorthand) service', function (assert) {
22+
const manual = this.owner.lookup('service:manual-shorthand') as {
23+
weDidIt: boolean;
24+
};
25+
26+
assert.ok(manual);
27+
assert.ok(manual.weDidIt);
28+
});
29+
2130
test('has a service from import.meta.glob', function (assert) {
2231
const metaGlob = this.owner.lookup('service:from-meta-glob') as {
2332
weDidIt: boolean;

tests/test-helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestApp extends EmberApp {
2020
modules = {
2121
'./router': { default: Router },
2222
'./services/manual': { default: Manual },
23+
'./services/manual-shorthand': Manual,
2324
...import.meta.glob('./services/*', { eager: true }),
2425
};
2526
}

0 commit comments

Comments
 (0)