Skip to content

Commit

Permalink
Fix types for chainable methods
Browse files Browse the repository at this point in the history
Summary: TypeScript has a `this` type to represent the return value of a chainable method.

Reviewers: skevy

Reviewed By: skevy

Differential Revision: http://codereview.cc/D3449
  • Loading branch information
appsforartists committed Jan 16, 2018
1 parent 6323687 commit bd7b496
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions wobble.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ export class Spring {
* The spring's current velocity.
*/
readonly currentVelocity: number;

/**
* If the spring has reached its `toValue`, or if its velocity is below the
* `restVelocityThreshold`, it is considered at rest. If `stop()` is called
* during a simulation, both `isAnimating` and `isAtRest` will be false.
*/
readonly isAtRest: boolean;

/**
* Whether or not the spring is currently emitting values.
*
* Note: this is distinct from whether or not it is at rest.
*
* Note: this is distinct from whether or not it is at rest.
* See also `isAtRest`.
*/
readonly isAnimating: boolean;
Expand All @@ -53,42 +53,42 @@ export class Spring {
* If `fromValue` differs from `toValue`, or `initialVelocity` is non-zero,
* start the simulation and call the `onStart` listeners.
*/
start(): Spring;
start(): this;

/**
* If a simulation is in progress, stop it and call the `onStop` listeners.
*/
stop(): Spring;
stop(): this;

/**
* Updates the spring config with the given values. Values not explicitly
* supplied will be reused from the existing config.
*/
updateConfig(updatedConfig: PartialSpringConfig): Spring;
updateConfig(updatedConfig: PartialSpringConfig): this;

/**
* The provided callback will be invoked when the simulation begins.
*/
onStart(listener: SpringListener): Spring;
onStart(listener: SpringListener): this;

/**
* The provided callback will be invoked on each frame while the simulation is
* running.
*/
onUpdate(listener: SpringListener): Spring;
onUpdate(listener: SpringListener): this;

/**
* The provided callback will be invoked when the simulation ends.
*/
onStop(listener: SpringListener): Spring;
onStop(listener: SpringListener): this;

/**
* Remove a single listener from this spring.
*/
removeListener(listener: SpringListener): Spring;
removeListener(listener: SpringListener): this;

/**
* Removes all listeners from this spring.
*/
removeAllListeners(): Spring
removeAllListeners(): this;
}

0 comments on commit bd7b496

Please sign in to comment.