Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript type definitions #565

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions addon/declarations/modifiers/sortable-group.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module 'ember-sortable/modifiers/sortable-group' {
import Modifier from 'ember-modifier';

export default class SortableGroup<T> extends Modifier<{
Args: {
Named: {
groupName?: string;
onChange: (value: T[]) => void;
};
};
Element: HTMLElement;
}> {}
}
7 changes: 7 additions & 0 deletions addon/declarations/modifiers/sortable-handle.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module 'ember-sortable/modifiers/sortable-handle' {
import Modifier from 'ember-modifier';

export default class SortableHandle extends Modifier<{
Element: HTMLElement;
}> {}
}
13 changes: 13 additions & 0 deletions addon/declarations/modifiers/sortable-item.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}> {}
}
8 changes: 8 additions & 0 deletions addon/declarations/test-support.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>,
): unknown;
}
7 changes: 7 additions & 0 deletions test-app/app/type-tests.ts
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"start": "concurrently 'ember serve' 'pnpm _syncPnpm --watch' --names 'tests serve,tests sync deps'",
"test:ember": "pnpm _syncPnpm && ember test",
"test:all": "ember try:each"
Expand All @@ -36,6 +37,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",
Expand Down Expand Up @@ -66,6 +71,7 @@
"prettier": "^2.5.1",
"qunit": "^2.18.0",
"qunit-dom": "^2.0.0",
"typescript": "^5.5.3",
"webpack": "^5.69.1"
},
"ember": {
Expand Down
17 changes: 17 additions & 0 deletions test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
},
}
Loading