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

TS: add setup transition argument TS support #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
declare module 'ember-parachute' {
import Transition from '@ember/routing/-private/transition';

interface QueryParamOption<T> {
as?: string;
defaultValue?: T;
Expand Down Expand Up @@ -29,10 +31,12 @@ declare module 'ember-parachute' {

export class QueryParamMixin<T> {
queryParamsState: QueryParamsState<T>;
setup(queryParamsChangedEvent: ParachuteEvent<T>): void;
setup(queryParamsChangedEvent: ParachuteEvent<T>, transition: Transition): void;
queryParamsDidChange(queryParamsChangedEvent: ParachuteEvent<T>): void;
reset(queryParamsChangedEvent: ParachuteEvent<T>, isExiting: boolean): void;
resetQueryParams(params?: string[]): void;

get allQueryParams(): T;
}

export default class QueryParams<T> {
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/routes/route-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import QueryParams from 'ember-parachute';
import ParachuteEvent from 'ember-parachute/-private/parachute-event';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import Transition from '@ember/routing/-private/transition';

const queryParams = new QueryParams({
direction: {
Expand Down Expand Up @@ -41,12 +42,15 @@ module('Unit | Route', function(hooks) {
assert.expect(2);

let controller = QPController.extend({
setup(event) {
setup(event, transition) {
assert.ok(event instanceof ParachuteEvent);
assert.ok(transition instanceof Transition);
debugger
},

onSetup: on('setup', function(event) {
onSetup: on('setup', function(event, transition) {
assert.ok(event instanceof ParachuteEvent);
assert.ok(transition instanceof Transition);
})
}).create();

Expand Down