From 7fc648e70a1b872d0057940fdd17038cba45bbf8 Mon Sep 17 00:00:00 2001 From: Charles Fries Date: Wed, 3 Jul 2024 11:25:32 -0700 Subject: [PATCH 1/2] Add type defs --- addon/declarations/modifiers/sortable-group.d.ts | 13 +++++++++++++ addon/declarations/modifiers/sortable-handle.d.ts | 7 +++++++ addon/declarations/modifiers/sortable-item.d.ts | 13 +++++++++++++ addon/declarations/test-support.d.ts | 8 ++++++++ 4 files changed, 41 insertions(+) create mode 100644 addon/declarations/modifiers/sortable-group.d.ts create mode 100644 addon/declarations/modifiers/sortable-handle.d.ts create mode 100644 addon/declarations/modifiers/sortable-item.d.ts create mode 100644 addon/declarations/test-support.d.ts diff --git a/addon/declarations/modifiers/sortable-group.d.ts b/addon/declarations/modifiers/sortable-group.d.ts new file mode 100644 index 00000000..ce4b58d2 --- /dev/null +++ b/addon/declarations/modifiers/sortable-group.d.ts @@ -0,0 +1,13 @@ +declare module 'ember-sortable/modifiers/sortable-group' { + import Modifier from 'ember-modifier'; + + export default class SortableGroup extends Modifier<{ + Args: { + Named: { + groupName?: string; + onChange: (value: T[]) => void; + }; + }; + Element: HTMLElement; + }> {} +} diff --git a/addon/declarations/modifiers/sortable-handle.d.ts b/addon/declarations/modifiers/sortable-handle.d.ts new file mode 100644 index 00000000..18e0078f --- /dev/null +++ b/addon/declarations/modifiers/sortable-handle.d.ts @@ -0,0 +1,7 @@ +declare module 'ember-sortable/modifiers/sortable-handle' { + import Modifier from 'ember-modifier'; + + export default class SortableHandle extends Modifier<{ + Element: HTMLElement; + }> {} +} diff --git a/addon/declarations/modifiers/sortable-item.d.ts b/addon/declarations/modifiers/sortable-item.d.ts new file mode 100644 index 00000000..f594b768 --- /dev/null +++ b/addon/declarations/modifiers/sortable-item.d.ts @@ -0,0 +1,13 @@ +declare module 'ember-sortable/modifiers/sortable-item' { + import Modifier from 'ember-modifier'; + + export default class SortableItem extends Modifier<{ + Args: { + Named: { + groupName?: string; + model: unknown; + }; + }; + Element: HTMLElement; + }> {} +} diff --git a/addon/declarations/test-support.d.ts b/addon/declarations/test-support.d.ts new file mode 100644 index 00000000..b0d1455f --- /dev/null +++ b/addon/declarations/test-support.d.ts @@ -0,0 +1,8 @@ +declare module 'ember-sortable/test-support' { + export function drag( + mode: 'mouse' | 'touch', + itemSelector: string, + offsetFn: () => { dx?: number; dy?: number }, + callbacks?: Record, + ): unknown; +} From 43453b8ed7538af5ef21a0720daf24e5039e0b1c Mon Sep 17 00:00:00 2001 From: Charles Fries Date: Tue, 16 Jul 2024 09:38:42 -0700 Subject: [PATCH 2/2] Install Glint (WIP) --- test-app/app/type-tests.ts | 7 +++++++ test-app/package.json | 6 ++++++ test-app/tsconfig.json | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 test-app/app/type-tests.ts create mode 100644 test-app/tsconfig.json diff --git a/test-app/app/type-tests.ts b/test-app/app/type-tests.ts new file mode 100644 index 00000000..eb1bd60b --- /dev/null +++ b/test-app/app/type-tests.ts @@ -0,0 +1,7 @@ +import sortableGroup from 'ember-sortable/modifiers/sortable-group'; +import sortableHandle from 'ember-sortable/modifiers/sortable-handle'; +import sortableItem from 'ember-sortable/modifiers/sortable-item'; + +sortableGroup; +sortableHandle; +sortableItem; diff --git a/test-app/package.json b/test-app/package.json index 5b0e3bcc..7f811a41 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -12,6 +12,7 @@ "lint:hbs:fix": "ember-template-lint . --fix", "lint:js": "eslint . --cache", "lint:js:fix": "eslint . --fix", + "lint:types": "glint", "start": "ember serve", "test:ember": "ember test", "test:all": "ember try:each" @@ -35,6 +36,10 @@ "@embroider/test-setup": "^2.1.1", "@glimmer/component": "^1.0.4", "@glimmer/tracking": "^1.0.4", + "@glint/core": "^1.4.0", + "@glint/environment-ember-loose": "^1.4.0", + "@glint/template": "^1.4.0", + "@tsconfig/ember": "^3.0.8", "babel-eslint": "^10.0.3", "broccoli-asset-rev": "^3.0.0", "ember-auto-import": "^2.4.0", @@ -64,6 +69,7 @@ "prettier": "^2.5.1", "qunit": "^2.18.0", "qunit-dom": "^2.0.0", + "typescript": "^5.5.3", "webpack": "^5.69.1" }, "ember": { diff --git a/test-app/tsconfig.json b/test-app/tsconfig.json new file mode 100644 index 00000000..9db399d8 --- /dev/null +++ b/test-app/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "@tsconfig/ember/tsconfig.json", + "compilerOptions": { + // The combination of `baseUrl` with `paths` allows Ember's classic package + // layout, which is not resolvable with the Node resolution algorithm, to + // work with TypeScript. + "baseUrl": ".", + "paths": { + "test-app/tests/*": ["tests/*"], + "test-app/*": ["app/*"], + "*": ["types/*"] + } + }, + "glint": { + "environment": "ember-loose" + }, +}