Strict function variance fixes round 1, stage 1

This commit is contained in:
Nathan Shively-Sanders
2017-09-28 09:14:42 -07:00
parent 50320784e8
commit ed0a73fbb2
11 changed files with 27 additions and 22 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ declare namespace Backbone {
/**
* Specify a model attribute name (string) or function that will be used to sort the collection.
*/
comparator: string | ((element: TModel) => number | string) | ((compare: TModel, to?: TModel) => number);
comparator: string | { bivarianceHack(element: TModel): number | string }["bivarianceHack"] | { bivarianceHack(compare: TModel, to?: TModel): number }["bivarianceHack"];
add(model: {}|TModel, options?: AddOptions): TModel;
add(models: ({}|TModel)[], options?: AddOptions): TModel[];
+7 -7
View File
@@ -7,9 +7,9 @@
/// <reference types="jquery" />
/** Bootbox options shared by all modal types */
interface BootboxBaseOptions {
interface BootboxBaseOptions<T = any> {
title?: string | Element;
callback?: (result: boolean | string) => any;
callback?: (result: T) => any;
onEscape?: (() => any) | boolean;
show?: boolean;
backdrop?: boolean;
@@ -22,24 +22,24 @@ interface BootboxBaseOptions {
}
/** Bootbox options available for custom modals */
interface BootboxDialogOptions extends BootboxBaseOptions {
interface BootboxDialogOptions<T = any> extends BootboxBaseOptions<T> {
message: string | Element;
}
/** Bootbox options available for alert modals */
interface BootboxAlertOptions extends BootboxDialogOptions {
interface BootboxAlertOptions extends BootboxDialogOptions<void> {
callback?: () => any;
buttons?: BootboxAlertButtonMap;
}
/** Bootbox options available for confirm modals */
interface BootboxConfirmOptions extends BootboxDialogOptions {
interface BootboxConfirmOptions extends BootboxDialogOptions<boolean> {
callback: (result: boolean) => any;
buttons?: BootboxConfirmPromptButtonMap;
}
/** Bootbox options available for prompt modals */
interface BootboxPromptOptions extends BootboxBaseOptions {
interface BootboxPromptOptions extends BootboxBaseOptions<string> {
title: string;
value?: string;
inputType?: "text" | "textarea" | "email" | "select" | "checkbox" | "date" | "time" | "number" | "password";
@@ -93,7 +93,7 @@ interface BootboxStatic {
prompt(message: string, callback: (result: string) => void): JQuery;
prompt(options: BootboxPromptOptions): JQuery;
dialog(message: string, callback?: (result: string) => void): JQuery;
dialog(options: BootboxDialogOptions): JQuery;
dialog(options: BootboxDialogOptions<string>): JQuery;
setDefaults(options: BootboxDefaultOptions): void;
hideAll(): void;
+2 -1
View File
@@ -8,6 +8,7 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +21,4 @@
"index.d.ts",
"bootbox-tests.ts"
]
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ interface Window {
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
onloadstart(type: InAppBrowserEvent): void;
onloadstart(type: Event): void;
onloadstop(type: InAppBrowserEvent): void;
onloaderror(type: InAppBrowserEvent): void;
onexit(type: InAppBrowserEvent): void;
@@ -8,6 +8,7 @@
"noImplicitAny": false,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +21,4 @@
"index.d.ts",
"cordova-plugin-inappbrowser-tests.ts"
]
}
}
+2 -2
View File
@@ -61,8 +61,8 @@ declare namespace WL {
getHeader(name: any): string;
}
interface Options {
onSuccess?: (response: IResponse) => void;
onFailure?: (response: IResponse) => void;
onSuccess?(response: IResponse): void;
onFailure?(response: IResponse): void;
invocationContext?: any;
}
interface ResponseHandler<T> {
+2 -1
View File
@@ -8,6 +8,7 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +21,4 @@
"index.d.ts",
"ibm-mobilefirst-tests.ts"
]
}
}
+5 -5
View File
@@ -144,13 +144,13 @@ const nodeStyle = (input: string, cb: (error: any, success: any) => void) => {
cb(null, input);
};
Q.nfapply(nodeStyle, ["foo"]).done((result: string) => {
Q.nfapply<string>(nodeStyle, ["foo"]).done((result: string) => {
});
Q.nfcall(nodeStyle, "foo").done((result: string) => {
Q.nfcall<string>(nodeStyle, "foo").done((result: string) => {
});
Q.denodeify(nodeStyle)('foo').done((result: string) => {
Q.denodeify<string>(nodeStyle)('foo').done((result: string) => {
});
Q.nfbind(nodeStyle)('foo').done((result: string) => {
Q.nfbind<string>(nodeStyle)('foo').done((result: string) => {
});
class Repo {
@@ -171,7 +171,7 @@ class Repo {
}
const kitty = new Repo();
Q.nbind(kitty.find, kitty)({cute: true}).done((kitties: any[]) => {
Q.nbind<any[]>(kitty.find, kitty)({cute: true}).done((kitties: any[]) => {
});
/**
+1
View File
@@ -8,6 +8,7 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
+3 -3
View File
@@ -72,7 +72,7 @@ declare namespace React {
type ComponentType<P = {}> = ComponentClass<P> | StatelessComponent<P>;
type Key = string | number;
type Ref<T> = string | ((instance: T | null) => any);
type Ref<T> = string | { bivarianceHack(instance: T | null): any }["bivarianceHack"];
// tslint:disable-next-line:interface-over-type-literal
type ComponentState = {};
@@ -555,7 +555,7 @@ declare namespace React {
// Event Handler Types
// ----------------------------------------------------------------------
type EventHandler<E extends SyntheticEvent<any>> = (event: E) => void;
type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];
type ReactEventHandler<T> = EventHandler<SyntheticEvent<T>>;
@@ -3369,7 +3369,7 @@ declare namespace React {
// React.PropTypes
// ----------------------------------------------------------------------
type Validator<T> = (object: T, key: string, componentName: string, ...rest: any[]) => Error | null;
type Validator<T> = { bivarianceHack(object: T, key: string, componentName: string, ...rest: any[]): Error | null }["bivarianceHack"];
interface Requireable<T> extends Validator<T> {
isRequired: Validator<T>;
+1
View File
@@ -14,6 +14,7 @@
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"