mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Strict function variance fixes round 1, stage 3
This commit is contained in:
Vendored
+2
-2
@@ -85,7 +85,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
* @since 1.3
|
||||
*/
|
||||
off: boolean;
|
||||
step: JQuery.PlainObject<JQuery.AnimationHook<TElement>>;
|
||||
step: JQuery.PlainObject<JQuery.AnimationHook<Node>>;
|
||||
};
|
||||
/**
|
||||
* A Promise-like object (or "thenable") that resolves when the document is ready.
|
||||
@@ -4754,7 +4754,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
|
||||
* @see {@link https://api.jquery.com/queue/}
|
||||
* @since 1.2
|
||||
*/
|
||||
queue(queueName?: string): JQuery.Queue<TElement>;
|
||||
queue(queueName?: string): JQuery.Queue<Node>;
|
||||
/**
|
||||
* Specify a function to execute when the DOM is fully loaded.
|
||||
*
|
||||
|
||||
@@ -3061,7 +3061,7 @@ function examples() {
|
||||
type: 'dog',
|
||||
|
||||
// Note that event comes *after* one and two
|
||||
test: function(one: typeof you, two: typeof they, event: JQuery.Event<HTMLButtonElement>) {
|
||||
test: function(one: typeof you, two: typeof they, event: JQuery.Event<HTMLElement>) {
|
||||
$('#log')
|
||||
|
||||
// `one` maps to `you`, the 1st additional
|
||||
@@ -3081,7 +3081,7 @@ function examples() {
|
||||
|
||||
// The clicked element is `event.target`,
|
||||
// and its type is "button"
|
||||
.append('the ' + event.target.type + '.');
|
||||
.append('the ' + (event.target as HTMLButtonElement).type + '.');
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1332,7 +1332,7 @@ function longdesc() {
|
||||
|
||||
function jquery_css_hooks_6() {
|
||||
$.fx.step.someCSSProp = function(fx) {
|
||||
$.cssHooks.someCSSProp.set(fx.elem, fx.now + fx.unit);
|
||||
$.cssHooks.someCSSProp.set(fx.elem as HTMLElement, fx.now + fx.unit);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -225,9 +225,9 @@ declare namespace R {
|
||||
/**
|
||||
* Returns a new list containing the contents of the given list, followed by the given element.
|
||||
*/
|
||||
append<U>(el: U): <T>(list: T[]) => Array<(T & U)>;
|
||||
append<T, U>(el: U, list: T[]): Array<(T & U)>;
|
||||
append<U>(el: U): <T>(list: T[]) => Array<(T & U)>;
|
||||
append<U>(el: U): <T>(list: T[]) => Array<(T & U)>;
|
||||
append<T>(el: T, list: string): Array<T & string>;
|
||||
|
||||
/**
|
||||
* Applies function fn to the argument list args. This is useful for creating a fixed-arity function from
|
||||
|
||||
+11
-16
@@ -151,9 +151,9 @@ class F2 {
|
||||
};
|
||||
|
||||
() => {
|
||||
const truncate = R.when(
|
||||
const truncate = R.when(
|
||||
R.propSatisfies(R.flip(R.gt)(10), "length"),
|
||||
R.pipe(R.take(10), R.append("…"), R.join(""))
|
||||
R.pipe<string,string,string[],string>(R.take(10), R.append("…") as (wrong: any) => string[], R.join(""))
|
||||
);
|
||||
const a: string = truncate("12345"); // => '12345'
|
||||
const b: string = truncate("0123456789ABC"); // => '0123456789…'
|
||||
@@ -317,8 +317,7 @@ R.times(i, 5);
|
||||
|
||||
(() => {
|
||||
const numbers = [1, 2, 3];
|
||||
const add = (a: number, b: number) => a + b;
|
||||
R.reduce(add, 10, numbers); // => 16;
|
||||
R.reduce((a,b) => a + b, 10, numbers); // => 16;
|
||||
})();
|
||||
|
||||
(() => {
|
||||
@@ -326,7 +325,7 @@ R.times(i, 5);
|
||||
})();
|
||||
|
||||
(() => {
|
||||
const pairs = [["a", 1], ["b", 2], ["c", 3]];
|
||||
const pairs = [["a", 1], ["b", 2], ["c", 3]] as [string, number][];
|
||||
|
||||
function flattenPairs(pair: [string, number], acc: Array<string|number>): Array<string|number> {
|
||||
return acc.concat(pair);
|
||||
@@ -854,13 +853,9 @@ interface Obj {
|
||||
() => {
|
||||
const numbers = [1, 2, 3];
|
||||
|
||||
function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
R.reduce(add, 10, numbers); // => 16
|
||||
R.reduce((a,b) => a + b, 10, numbers); // => 16
|
||||
R.reduce(add)(10, numbers); // => 16
|
||||
R.reduce(add, 10)(numbers); // => 16
|
||||
R.reduce<number,number>((a,b) => a + b, 10)(numbers); // => 16
|
||||
};
|
||||
|
||||
interface Student {
|
||||
@@ -1086,7 +1081,7 @@ type Pair = KeyValuePair<string, number>;
|
||||
R.transduce(transducer, fn, [], numbers); // => [2, 3]
|
||||
R.transduce(transducer, fn, [])(numbers); // => [2, 3]
|
||||
R.transduce(transducer, fn)([], numbers); // => [2, 3]
|
||||
R.transduce(transducer)(fn, [], numbers); // => [2, 3]
|
||||
R.transduce<number, number>(transducer)(fn, [], numbers); // => [2, 3]
|
||||
};
|
||||
|
||||
() => {
|
||||
@@ -1101,7 +1096,7 @@ type Pair = KeyValuePair<string, number>;
|
||||
const list = [1, 2, 3];
|
||||
R.traverse(of, fn, list);
|
||||
R.traverse(of, fn)(list);
|
||||
R.traverse(of)(fn, list);
|
||||
R.traverse<number, number[], {}>(of)(fn, list);
|
||||
};
|
||||
|
||||
() => {
|
||||
@@ -1691,7 +1686,7 @@ class Rectangle {
|
||||
|
||||
const format = R.converge(
|
||||
R.call, [
|
||||
R.pipe(R.prop("indent"), indentN),
|
||||
R.pipe<{}, number, (s: string) => string>(R.prop("indent"), indentN),
|
||||
R.prop("value")
|
||||
]
|
||||
);
|
||||
@@ -1841,7 +1836,7 @@ class Rectangle {
|
||||
};
|
||||
|
||||
() => {
|
||||
const sortByAgeDescending = R.sortBy(R.compose(R.negate, R.prop("age")));
|
||||
const sortByAgeDescending = R.sortBy(R.compose<{}, number, number>(R.negate, R.prop("age")));
|
||||
const alice = {
|
||||
name: "ALICE",
|
||||
age : 101
|
||||
@@ -1859,7 +1854,7 @@ class Rectangle {
|
||||
};
|
||||
|
||||
() => {
|
||||
const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop("name")));
|
||||
const sortByNameCaseInsensitive = R.sortBy(R.compose<string,string,string>(R.toLower, R.prop("name")));
|
||||
const alice = {
|
||||
name: "ALICE",
|
||||
age : 101
|
||||
|
||||
@@ -297,7 +297,7 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi
|
||||
|
||||
return <ScrollView {...props} style={[scrollViewStyle1.scrollView, scrollViewStyle2]}/>
|
||||
}}
|
||||
renderRow={({ type, data }, _, row: number) => {
|
||||
renderRow={({ type, data }, _, row) => {
|
||||
return <Text>Filler</Text>
|
||||
}
|
||||
} />
|
||||
|
||||
@@ -381,6 +381,7 @@ interface DispatchProps {
|
||||
declare var actionCreators: () => {
|
||||
action: Function;
|
||||
}
|
||||
declare var dispatchActionCreators: () => DispatchProps;
|
||||
declare var addTodo: () => { type: string; };
|
||||
declare var todoActionCreators: { [type: string]: (...args: any[]) => any; };
|
||||
declare var counterActionCreators: { [type: string]: (...args: any[]) => any; };
|
||||
@@ -521,7 +522,7 @@ function mergeProps(stateProps: TodoState, dispatchProps: DispatchProps, ownProp
|
||||
});
|
||||
}
|
||||
|
||||
connect(mapStateToProps2, actionCreators, mergeProps)(MyRootComponent);
|
||||
connect(mapStateToProps2, dispatchActionCreators, mergeProps)(MyRootComponent);
|
||||
|
||||
|
||||
//https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14622#issuecomment-279820358
|
||||
|
||||
@@ -530,7 +530,8 @@ namespace CSR {
|
||||
.onPreRender(hookFormContext)
|
||||
.onPostRender(fixCsrCustomLayout);
|
||||
|
||||
function hookFormContext(ctx: FormRenderContexWithHook) {
|
||||
function hookFormContext(preRenderContext: SPClientTemplates.RenderContext /* FormRenderContexWithHook */) {
|
||||
let ctx = preRenderContext as FormRenderContexWithHook;
|
||||
if (ctx.ControlMode === SPClientTemplates.ClientControlMode.EditForm
|
||||
|| ctx.ControlMode === SPClientTemplates.ClientControlMode.NewForm) {
|
||||
for (const fieldSchemaInForm of ctx.ListSchema.Field) {
|
||||
@@ -561,7 +562,8 @@ namespace CSR {
|
||||
}
|
||||
}
|
||||
|
||||
function fixCsrCustomLayout(ctx: SPClientTemplates.RenderContext_Form) {
|
||||
function fixCsrCustomLayout(postRenderContext: SPClientTemplates.RenderContext /* SPClientTemplates.RenderContext_Form */) {
|
||||
let ctx = postRenderContext as SPClientTemplates.RenderContext_Form;
|
||||
if (ctx.ControlMode === SPClientTemplates.ClientControlMode.Invalid
|
||||
|| ctx.ControlMode === SPClientTemplates.ClientControlMode.View) {
|
||||
return;
|
||||
@@ -817,7 +819,8 @@ namespace CSR {
|
||||
}
|
||||
}
|
||||
})
|
||||
.onPostRenderField(fieldName, (schema: SPClientTemplates.FieldSchema_InForm_User, ctx) => {
|
||||
.onPostRenderField(fieldName, (postRenderSchema, ctx) => {
|
||||
let schema = postRenderSchema as SPClientTemplates.FieldSchema_InForm_User;
|
||||
if (ctx.ControlMode === SPClientTemplates.ClientControlMode.EditForm
|
||||
|| ctx.ControlMode === SPClientTemplates.ClientControlMode.NewForm) {
|
||||
if (schema.Type === 'User' || schema.Type === 'UserMulti') {
|
||||
@@ -1148,7 +1151,9 @@ namespace CSR {
|
||||
computedValue(targetField: string, transform: (...values: string[]) => string, ...sourceField: string[]): CSR {
|
||||
const dependentValues: { [field: string]: string } = {};
|
||||
|
||||
return this.onPostRenderField(targetField, (schema: SPClientTemplates.FieldSchema_InForm, ctx: SPClientTemplates.RenderContext_FieldInForm) => {
|
||||
return this.onPostRenderField(targetField, (postRenderSchema, postRenderContext) => {
|
||||
let schema = postRenderSchema as SPClientTemplates.FieldSchema_InForm;
|
||||
let ctx = postRenderContext as SPClientTemplates.RenderContext_FieldInForm;
|
||||
if (ctx.ControlMode === SPClientTemplates.ClientControlMode.EditForm
|
||||
|| ctx.ControlMode === SPClientTemplates.ClientControlMode.NewForm) {
|
||||
const targetControl = CSR.getControl(schema as SPClientTemplates.FieldSchema_InForm);
|
||||
@@ -1165,8 +1170,8 @@ namespace CSR {
|
||||
|
||||
setInitialValue(fieldName: string, value: any, ignoreNull?: boolean): CSR {
|
||||
if (value || !ignoreNull) {
|
||||
return this.onPreRenderField(fieldName, (schema, ctx: SPClientTemplates.RenderContext_FieldInForm) => {
|
||||
ctx.ListData.Items[0][fieldName] = value;
|
||||
return this.onPreRenderField(fieldName, (schema, ctx) => {
|
||||
(ctx as SPClientTemplates.RenderContext_FieldInForm).ListData.Items[0][fieldName] = value;
|
||||
});
|
||||
} else {
|
||||
return this;
|
||||
@@ -1335,8 +1340,9 @@ namespace CSR {
|
||||
}
|
||||
|
||||
lookupAddNew(fieldName: string, prompt: string, showDialog?: boolean, contentTypeId?: string): CSR {
|
||||
return this.onPostRenderField(fieldName,
|
||||
(schema: SPClientTemplates.FieldSchema_InForm_Lookup, ctx: SPClientTemplates.RenderContext_FieldInForm) => {
|
||||
return this.onPostRenderField(fieldName, (postRenderSchema, postRenderContext) => {
|
||||
let schema = postRenderSchema as SPClientTemplates.FieldSchema_InForm_Lookup;
|
||||
let ctx = postRenderContext as SPClientTemplates.RenderContext_FieldInForm;
|
||||
let control: HTMLInputElement;
|
||||
if (ctx.ControlMode === SPClientTemplates.ClientControlMode.EditForm
|
||||
|| ctx.ControlMode === SPClientTemplates.ClientControlMode.NewForm)
|
||||
@@ -2271,7 +2277,8 @@ namespace SampleReputation {
|
||||
SP.SOD.registerSod('typescripttemplates.ts', '/SPTypeScript/Extensions/typescripttemplates.js');
|
||||
SP.SOD.executeFunc('typescripttemplates.ts', 'CSR', () => {
|
||||
CSR.override(10004, 1)
|
||||
.onPreRender((ctx: MyList) => {
|
||||
.onPreRender(preRenderContext => {
|
||||
let ctx = preRenderContext as MyList;
|
||||
ctx.listId = ctx.listName.substring(1, 37);
|
||||
})
|
||||
.header('<ul>')
|
||||
@@ -2287,7 +2294,8 @@ namespace SampleReputation {
|
||||
SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs('likes.js');
|
||||
}
|
||||
|
||||
function renderTemplate(ctx: MyList) {
|
||||
function renderTemplate(renderContext: SPClientTemplates.RenderContext) {
|
||||
let ctx = renderContext as MyList;
|
||||
const rows = ctx.ListData.Row;
|
||||
let result = '';
|
||||
for (const row of rows) {
|
||||
|
||||
@@ -622,7 +622,7 @@ configuration = {
|
||||
performance,
|
||||
};
|
||||
|
||||
function loader(this: webpack.loader.LoaderContext, source: string, sourcemap: string): void {
|
||||
function loader(this: webpack.loader.LoaderContext, source: string | Buffer, sourcemap: string | Buffer): void {
|
||||
this.cacheable();
|
||||
|
||||
this.async();
|
||||
|
||||
Reference in New Issue
Block a user