Skip to content

Commit 5e19b41

Browse files
committed
Fix glint issues
1 parent 3c60d40 commit 5e19b41

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

test-app/app/helpers/clock.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export function Clock() {
88

99
on.cleanup(() => clearInterval(interval));
1010

11-
return time;
11+
// this works at runtime but TS/Glint can't figure it out
12+
// return time;
13+
14+
// The above is a shorthand for this
15+
// (but with a cast to string to appease Glint's restructive ContentValue type
16+
// (Date is a renderable value, but Glint doesn't think so)
17+
return () => time.current.toString();
1218
});
1319
}
1420

test-app/app/helpers/time-format.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ const formatter = new Intl.DateTimeFormat(locale, {
66
hour12: false,
77
});
88

9-
export default function timeFormat(input: string) {
9+
export default function timeFormat(input: Date) {
1010
return formatter.format(input);
1111
}

test-app/tests/loose-mode-test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module('Loose mode', function (hooks) {
88

99
test('it works', async function (assert) {
1010
await render(hbs`
11-
{{! @glint-nocheck }}
1211
<time>{{ clock }}</time>
1312
`);
1413

@@ -24,7 +23,6 @@ module('Loose mode', function (hooks) {
2423

2524
test('can be passed to a helper', async function (assert) {
2625
await render(hbs`
27-
{{! @glint-nocheck }}
2826
<time>{{time-format (clock) }}</time>
2927
`);
3028

test-app/types/glint-registry.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import '@glint/environment-ember-loose';
22
import '@glint/environment-ember-loose/native-integration';
33

44
// import type { ComponentLike, HelperLike, ModifierLike } from "@glint/template";
5+
import type Clock from 'test-app/helpers/clock';
6+
import type TimeFormat from 'test-app/helpers/time-format';
57

68
declare module '@glint/environment-ember-loose/registry' {
79
export default interface Registry {
10+
'clock': typeof Clock & { (): typeof Clock };
11+
'time-format': typeof TimeFormat;
812
// Examples
913
// state: HelperLike<{ Args: {}, Return: State }>;
1014
// attachShadow: ModifierLike<{ Args: { Positional: [State['update']]}}>;

0 commit comments

Comments
 (0)