Change some types to string unions, make m.redraw.strategy a BasicProperty<T>

In the latter case, the type already structurally satisfied that type.
Changing m.redraw.strategy simplifies the definition file, and aligns with
the docs.
This commit is contained in:
impinball 2016-03-22 10:39:30 -04:00
parent 490a5c7b73
commit 26af09a017

43
mithril.d.ts vendored
View file

@ -206,9 +206,8 @@ declare namespace Mithril {
*/ */
(force?: boolean): void; (force?: boolean): void;
strategy: {
/** /**
* Gets the current redraw strategy, which returns one of the * Gets/sets the current redraw strategy, which returns one of the
* following: * following:
* *
* "all" - recreates the DOM tree from scratch * "all" - recreates the DOM tree from scratch
@ -220,30 +219,7 @@ declare namespace Mithril {
* *
* @return The current strategy * @return The current strategy
*/ */
(): string; strategy: BasicProperty<"all" | "diff" | "none">;
/**
* Sets the current redraw strategy. The parameter must be one of
* the following values:
*
* "all" - recreates the DOM tree from scratch
* "diff" - recreates the DOM tree from scratch
* "none" - leaves the DOM tree intact
*
* This is useful for event handlers, which may want to cancel
* the next redraw if the event doesn't update the UI.
*
* @param value The value to set
* @return The new strategy
*/
(value: string): string;
/**
* @private
* Implementation detail - it's a BasicProperty instance
*/
toJSON(): string;
}
} }
route: { route: {
@ -324,7 +300,7 @@ declare namespace Mithril {
* page refreshes on IE8 and lower. Note that this requires that the * page refreshes on IE8 and lower. Note that this requires that the
* application to be run from the root of the URL. * application to be run from the root of the URL.
*/ */
mode: string; mode: "search" | "hash" | "pathname";
/** /**
* Serialize an object into a query string. * Serialize an object into a query string.
@ -782,16 +758,9 @@ declare namespace Mithril {
*/ */
interface XHROptions<T> { interface XHROptions<T> {
/** /**
* This represents the HTTP method used, one of the following: * This represents the HTTP method used, defaulting to "GET".
*
* - "GET" (default)
* - "POST"
* - "PUT"
* - "DELETE"
* - "HEAD"
* - "OPTIONS"
*/ */
method?: string; method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
/** /**
* The URL to send the request to. * The URL to send the request to.
@ -899,7 +868,7 @@ declare namespace Mithril {
* For JSONP requests, this must be the string "jsonp". Otherwise, it's * For JSONP requests, this must be the string "jsonp". Otherwise, it's
* ignored. * ignored.
*/ */
dataType?: string; dataType?: "jsonp";
/** /**
* For JSONP requests, this is the query string key for the JSONP * For JSONP requests, this is the query string key for the JSONP