Skip to content

Commit cc1c18d

Browse files
committed
More poking, non of this works
1 parent 49de067 commit cc1c18d

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

addon/services/toaster.ts

+11-15
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ import { A, type NativeArray } from '@ember/array';
55
import type { ComponentLike } from '@glint/template';
66

77
export type ToastData = {
8+
component?: ComponentLike<CustomToastSignature>;
89
title?: string;
910
message?: string;
10-
options: ToastOptions;
11+
options: ToastOptions | Record<string, unknown>;
1112
};
1213

13-
export type CustomToastData = {
14-
component?: ComponentLike<CustomToastSignature>;
15-
options: object;
16-
}
17-
1814
export type ToastOptions = {
1915
icon?: string | ComponentLike<{ Element: Element }>;
2016
closable?: boolean;
@@ -24,7 +20,7 @@ export type ToastOptions = {
2420

2521
export interface CustomToastSignature {
2622
Args: {
27-
options: object;
23+
options: Record<string, unknown>;
2824
close: () => void;
2925
};
3026
}
@@ -35,26 +31,26 @@ export default class ToasterService extends Service {
3531
@tracked toasts: NativeArray<ToastData> = A<ToastData>([]);
3632

3733
displayToast = task(async (toast: ToastData) => {
38-
if (typeof toast.options.timeOut === 'undefined') {
39-
toast.options.timeOut = null;
34+
if (typeof toast.options['timeOut'] === 'undefined') {
35+
toast.options['timeOut'] = null;
4036
}
4137

42-
if (typeof toast.options.closable === 'undefined') {
43-
toast.options.closable = true;
38+
if (typeof toast.options['closable'] === 'undefined') {
39+
toast.options['closable'] = true;
4440
}
4541

4642
this.toasts.pushObject(toast);
4743

48-
if (toast.options.timeOut) {
49-
await timeout(toast.options.timeOut);
44+
if (toast.options['timeOut']) {
45+
await timeout(toast.options['timeOut']);
5046

5147
this.close(toast);
5248
}
5349
});
5450

5551
show(
56-
component: ComponentLike<CustomToastSignature>,
57-
options: object = {},
52+
component: ComponentLike<unknown>,
53+
options: Record<string, unknown> = {},
5854
) {
5955
const toast = {
6056
component,

tests/integration/components/au-toaster-test.gts

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ module('Integration | Component | au-toaster', function (hooks) {
153153

154154
const CustomToast: TOC<{
155155
Args: {
156-
options: {
157-
foo: string
158-
};
159-
// options: ToastOptionsWithFoo; // Doesn't work
156+
// options: {
157+
// foo: string
158+
// };
159+
options: ToastOptionsWithFoo; // Doesn't work
160160
// options: ToastOptions; // Works, but fails on the `@options.foo` usage in the template
161161
// options: ToastOptions & { foo: string }; // Doesn't work
162162
close: CustomToastSignature['Args']['close'];

0 commit comments

Comments
 (0)