Skip to content

Commit c792fb8

Browse files
More TS fixes
1 parent cdd1869 commit c792fb8

5 files changed

Lines changed: 37 additions & 18 deletions

File tree

app/controllers/palettes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ export default class PalettesController extends Controller {
168168
};
169169
const colorsList = targetList.map((c) => c.$identity);
170170

171-
const existingColor = targetList.findBy('hex', sourceColor.hex);
171+
const existingColor = targetList.find((c) => c.hex === sourceColor.hex);
172172

173173
if (existingColor) {
174-
const colorToRemove = colorsList.findBy('id', existingColor.id);
174+
const colorToRemove = colorsList.find((c) => c.id === existingColor.id);
175175

176176
if (colorToRemove) {
177177
colorsList.removeObject(colorToRemove);

app/data-sources/backup.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export default {
4444
const newColors: InitializedRecord[] = [];
4545

4646
for (const color of oldColors) {
47-
if (color.relationships?.palettes) {
48-
const paletteIdentities = color.relationships.palettes
47+
if (color.relationships?.['palettes']) {
48+
const paletteIdentities = color.relationships['palettes']
4949
.data as RecordIdentity[];
5050

51-
delete color.relationships.palettes;
51+
delete color.relationships['palettes'];
5252

5353
if (paletteIdentities?.length) {
5454
color.relationships.palette = { data: paletteIdentities[0] };
@@ -74,18 +74,18 @@ export default {
7474
: { type: 'color', id: colorCopy.id };
7575
};
7676

77-
if (palette.relationships?.colors.data) {
77+
if (palette.relationships?.['colors']?.data) {
7878
// Replace color in palette with color copy
79-
palette.relationships.colors.data =
80-
palette.relationships.colors.data.map(
79+
palette.relationships['colors'].data =
80+
palette.relationships['colors'].data.map(
8181
replaceColorIdWithCopy,
8282
);
8383
}
8484

85-
if (palette.attributes?.colorOrder) {
85+
if (palette.attributes?.['colorOrder']) {
8686
// Replace color id in colorOrder
87-
palette.attributes.colorOrder =
88-
palette.attributes.colorOrder.map(replaceColorIdWithCopy);
87+
palette.attributes['colorOrder'] =
88+
palette.attributes['colorOrder'].map(replaceColorIdWithCopy);
8989
}
9090
}
9191
}

tests/acceptance/settings/cloud-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module('Acceptance | settings/cloud', function (hooks) {
2828
assert.ok(true, 'signUp has been called');
2929

3030
return MockUser.create({
31+
// @ts-expect-error TODO: maybe fix this?
3132
username: 'testuser@gmail.com',
3233
attributes: {
3334
sub: 'aaaabbbb-cccc-dddd-eeee-ffffgggghhhh',

tests/helpers.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ import { getContext, settled } from '@ember/test-helpers';
22
import { animationsSettled } from 'ember-animated/test-support';
33
import { waitForSource } from 'ember-orbit/test-support';
44

5+
import type Owner from '@ember/owner';
6+
7+
import type Coordinator from '@orbit/coordinator';
8+
import type { IndexedDBSource } from '@orbit/indexeddb';
9+
import type BucketClass from '@orbit/indexeddb-bucket';
10+
11+
// @ts-expect-error TODO: not yet typed
512
import seedOrbit from './orbit/seed';
613

714
export async function waitForAll() {
8-
const { owner } = getContext();
15+
const { owner } = getContext() as { owner: Owner };
16+
// @ts-expect-error Not sure why it says this does not exist
917
const { services } = owner.resolveRegistration('ember-orbit:config');
10-
const coordinator = owner.lookup(`service:${services.coordinator}`);
18+
const coordinator = owner.lookup(
19+
`service:${services.coordinator}`,
20+
) as unknown as Coordinator;
1121

1222
for (let source of coordinator.sources) {
1323
await waitForSource(source);
@@ -17,7 +27,10 @@ export async function waitForAll() {
1727
await animationsSettled();
1828
}
1929

20-
export function resetStorage(hooks, options = {}) {
30+
export function resetStorage(
31+
hooks: NestedHooks,
32+
options: { seed?: { source?: string; scenario?: string } } = {},
33+
) {
2134
hooks.beforeEach(async function () {
2235
if (options.seed) {
2336
const sourceName = options.seed.source ?? 'backup';
@@ -28,11 +41,15 @@ export function resetStorage(hooks, options = {}) {
2841
});
2942

3043
hooks.afterEach(async function () {
31-
const backup = this.owner.lookup('data-source:backup');
44+
const backup = this.owner.lookup(
45+
'data-source:backup',
46+
) as unknown as IndexedDBSource;
3247

3348
await backup.cache.deleteDB();
3449

35-
const bucket = this.owner.lookup('data-bucket:main');
50+
const bucket = this.owner.lookup('data-bucket:main') as unknown as
51+
| BucketClass
52+
| undefined;
3653

3754
await bucket?.clear();
3855

tests/unit/services/data-test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type IndexedDBSource from '@orbit/indexeddb';
99
import type Palette from 'swach/data-models/palette';
1010
import type DataService from 'swach/services/data';
1111
import { resetStorage } from 'swach/tests/helpers';
12+
// @ts-expect-error TODO: not yet typed
1213
import seedOrbit from 'swach/tests/orbit/seed';
1314

1415
module('Unit | Service | data', function (hooks) {
@@ -61,9 +62,9 @@ module('Unit | Service | data', function (hooks) {
6162

6263
try {
6364
await dataService.synchronize();
64-
} catch (e) {
65+
} catch (e: unknown) {
6566
assert.strictEqual(
66-
e.message,
67+
(e as Error).message,
6768
'Data service: synchronize cannot be called prior to activate',
6869
);
6970
}

0 commit comments

Comments
 (0)