mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 14:59:37 +08:00
Merge branch 'master' into fix_mapbox_point
This commit is contained in:
46
types/draggabilly/draggabilly-tests.ts
Normal file
46
types/draggabilly/draggabilly-tests.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import Draggabilly from 'draggabilly';
|
||||
|
||||
const elem = document.querySelector('.draggable') as Element;
|
||||
|
||||
const draggieA = new Draggabilly('.test');
|
||||
const draggieB = new Draggabilly(elem);
|
||||
|
||||
const draggie = new Draggabilly(elem, {
|
||||
axis: 'x',
|
||||
containment: true,
|
||||
grid: [20, 20],
|
||||
handle: '.handle'
|
||||
});
|
||||
|
||||
const draggiePosX: number = draggie.position.x;
|
||||
const draggiePosY: number = draggie.position.y;
|
||||
|
||||
draggie.on( 'dragMove', (event, pointer, moveVector) => {
|
||||
const pointerPageX: number = pointer.pageX;
|
||||
const pointePageY: number = pointer.pageY;
|
||||
|
||||
const moveVectorX: number = moveVector.x;
|
||||
const moveVectorY: number = moveVector.y;
|
||||
});
|
||||
|
||||
draggie.on( 'dragStart', (event, pointer) => {});
|
||||
|
||||
draggie.on( 'dragEnd', (event, pointer) => {});
|
||||
|
||||
draggie.on( 'pointerDown', (event, pointer) => {});
|
||||
|
||||
draggie.on( 'pointerMove', (event, pointer, moveVector) => {});
|
||||
|
||||
draggie.on( 'pointerUp', (event, pointer) => {});
|
||||
|
||||
draggie.on( 'staticClick', (event, pointer) => {});
|
||||
|
||||
draggie.off('dragMove', (event, pointer, moveVector) => {});
|
||||
|
||||
draggie.once('dragMove', (event, pointer, moveVector) => {});
|
||||
|
||||
draggie.enable();
|
||||
|
||||
draggie.disable();
|
||||
|
||||
draggie.destroy();
|
||||
45
types/draggabilly/index.d.ts
vendored
Normal file
45
types/draggabilly/index.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Type definitions for draggabilly 2.1
|
||||
// Project: http://draggabilly.desandro.com/
|
||||
// Definitions by: Jason Wu <https://github.com/jaydubu/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export interface Position {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface DraggabillyOptions {
|
||||
axis?: 'x' | 'y';
|
||||
containment?: Element | string | boolean;
|
||||
grid?: [number, number];
|
||||
handle?: string;
|
||||
}
|
||||
|
||||
export type DraggabillyClickEventName = 'dragStart' | 'dragEnd' | 'pointerDown' | 'pointerUp' | 'staticClick';
|
||||
|
||||
export type DraggabillyMoveEventName = 'dragMove' | 'pointerMove';
|
||||
|
||||
export default class Draggabilly {
|
||||
position: Position;
|
||||
|
||||
constructor(element: Element | string, options?: DraggabillyOptions);
|
||||
|
||||
on(eventName: DraggabillyClickEventName, listener: (event: Event, pointer: MouseEvent | Touch) => void): Draggabilly;
|
||||
|
||||
on(eventName: DraggabillyMoveEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): Draggabilly;
|
||||
|
||||
off(eventName: DraggabillyClickEventName, listener: (event: Event, pointer: MouseEvent | Touch) => void): Draggabilly;
|
||||
|
||||
off(eventName: DraggabillyMoveEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): Draggabilly;
|
||||
|
||||
once(eventName: DraggabillyClickEventName, listener: (event: Event, pointer: MouseEvent | Touch) => void): Draggabilly;
|
||||
|
||||
once(eventName: DraggabillyMoveEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): Draggabilly;
|
||||
|
||||
enable(): void;
|
||||
|
||||
disable(): void;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
23
types/draggabilly/tsconfig.json
Normal file
23
types/draggabilly/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"draggabilly-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/is-alphanumerical/tslint.json
Normal file
1
types/is-alphanumerical/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
19
types/jsonp/index.d.ts
vendored
Normal file
19
types/jsonp/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for jsonp 0.2
|
||||
// Project: https://github.com/LearnBoost/jsonp
|
||||
// Definitions by: Savva Surenkov <https://github.com/surenkov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = jsonp;
|
||||
|
||||
declare function jsonp(url: string, options?: Options, cb?: RequestCallback): CancelFn;
|
||||
declare function jsonp(url: string, callback?: RequestCallback): CancelFn;
|
||||
|
||||
type CancelFn = () => void;
|
||||
type RequestCallback = (error: Error | null, data: any) => void;
|
||||
|
||||
interface Options {
|
||||
param?: string;
|
||||
prefix?: string;
|
||||
name?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
28
types/jsonp/jsonp-tests.ts
Normal file
28
types/jsonp/jsonp-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import jsonp = require('jsonp');
|
||||
|
||||
/**
|
||||
* Dummy response callback.
|
||||
*/
|
||||
const print = (err: Error | null, data: any) =>
|
||||
console.log(err !== null ? err.message : data);
|
||||
|
||||
/**
|
||||
* Tests jsonp request with default parameters.
|
||||
*/
|
||||
const cancel1 = jsonp('https://jsonplaceholder.typicode.com/posts/1', print);
|
||||
cancel1();
|
||||
|
||||
/**
|
||||
* Tests parametrized jsonp request.
|
||||
*/
|
||||
const cancel2 = jsonp(
|
||||
'https://jsonplaceholder.typicode.com/posts/1',
|
||||
{
|
||||
param: 'cb',
|
||||
timeout: 40000,
|
||||
prefix: '_jsonp',
|
||||
name: 'func',
|
||||
},
|
||||
print,
|
||||
);
|
||||
cancel2();
|
||||
21
types/jsonp/tsconfig.json
Normal file
21
types/jsonp/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jsonp-tests.ts"
|
||||
]
|
||||
}
|
||||
6
types/jsonp/tslint.json
Normal file
6
types/jsonp/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
6
types/mapbox-gl/index.d.ts
vendored
6
types/mapbox-gl/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Mapbox GL JS v0.39.0
|
||||
// Type definitions for Mapbox GL JS v0.39.1
|
||||
// Project: https://github.com/mapbox/mapbox-gl-js
|
||||
// Definitions by: Dominik Bruderer <https://github.com/dobrud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -709,7 +709,7 @@ declare namespace mapboxgl {
|
||||
angleWidth(p: Point): number;
|
||||
|
||||
angleWithSep(x: number, y: number): number;
|
||||
|
||||
|
||||
static convert(a: Array<number> | Point): Point;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1048,7 @@ declare namespace mapboxgl {
|
||||
export interface CirclePaint {
|
||||
"circle-radius"?: number | StyleFunction;
|
||||
"circle-radius-transition"?: Transition;
|
||||
"circle-color"?: string;
|
||||
"circle-color"?: string | StyleFunction;
|
||||
"circle-blur"?: number | StyleFunction;
|
||||
"circle-opacity"?: number | StyleFunction;
|
||||
"circle-translate"?: number[];
|
||||
|
||||
2
types/node/index.d.ts
vendored
2
types/node/index.d.ts
vendored
@@ -1731,7 +1731,7 @@ declare module "readline" {
|
||||
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine;
|
||||
export function createInterface(options: ReadLineOptions): ReadLine;
|
||||
|
||||
export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
|
||||
export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number): void;
|
||||
export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
|
||||
export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
|
||||
export function clearScreenDown(stream: NodeJS.WritableStream): void;
|
||||
|
||||
@@ -1410,6 +1410,7 @@ namespace readline_tests {
|
||||
let x: number;
|
||||
let y: number;
|
||||
|
||||
readline.cursorTo(stream, x);
|
||||
readline.cursorTo(stream, x, y);
|
||||
}
|
||||
|
||||
|
||||
136
types/pixi.js/index.d.ts
vendored
136
types/pixi.js/index.d.ts
vendored
@@ -199,25 +199,6 @@ declare namespace PIXI {
|
||||
|
||||
// display
|
||||
|
||||
interface ApplicationOptions extends RendererOptions {
|
||||
view?: HTMLCanvasElement;
|
||||
transparent?: boolean;
|
||||
autoResize?: boolean;
|
||||
antialias?: boolean;
|
||||
resolution?: number;
|
||||
clearBeforeRender?: boolean;
|
||||
backgroundColor?: number;
|
||||
roundPixels?: boolean;
|
||||
context?: WebGLRenderingContext;
|
||||
preserveDrawingBuffer?: boolean;
|
||||
legacy?: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
forceCanvas?: boolean;
|
||||
sharedTicker?: boolean;
|
||||
sharedLoader?: boolean;
|
||||
}
|
||||
|
||||
class Application {
|
||||
constructor(options?: ApplicationOptions)
|
||||
constructor(width?: number, height?: number, options?: ApplicationOptions, noWebGL?: boolean, sharedTicker?: boolean, sharedLoader?: boolean);
|
||||
@@ -725,18 +706,91 @@ declare namespace PIXI {
|
||||
}
|
||||
// renderers
|
||||
interface RendererOptions {
|
||||
view?: HTMLCanvasElement;
|
||||
transparent?: boolean;
|
||||
autoResize?: boolean;
|
||||
antialias?: boolean;
|
||||
resolution?: number;
|
||||
clearBeforeRender?: boolean;
|
||||
backgroundColor?: number;
|
||||
roundPixels?: boolean;
|
||||
context?: WebGLRenderingContext;
|
||||
/**
|
||||
* the width of the renderers view [default=800]
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* the height of the renderers view [default=600]
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
/**
|
||||
* the canvas to use as a view, optional
|
||||
*/
|
||||
view?: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* If the render view is transparent, [default=false]
|
||||
*/
|
||||
transparent?: boolean;
|
||||
|
||||
/**
|
||||
* sets antialias (only applicable in chrome at the moment) [default=false]
|
||||
*/
|
||||
antialias?: boolean;
|
||||
|
||||
/**
|
||||
* enables drawing buffer preservation, enable this if you need to call toDataUrl on the webgl context [default=false]
|
||||
*/
|
||||
preserveDrawingBuffer?: boolean;
|
||||
|
||||
/**
|
||||
* The resolution / device pixel ratio of the renderer, retina would be 2 [default=1]
|
||||
*/
|
||||
resolution?: number;
|
||||
|
||||
/**
|
||||
* prevents selection of WebGL renderer, even if such is present [default=false]
|
||||
*/
|
||||
forceCanvas?: boolean;
|
||||
|
||||
/**
|
||||
* The background color of the rendered area (shown if not transparent) [default=0x000000]
|
||||
*/
|
||||
backgroundColor?: number;
|
||||
|
||||
/**
|
||||
* This sets if the renderer will clear the canvas or not before the new render pass. [default=true]
|
||||
*/
|
||||
clearBeforeRender?: boolean;
|
||||
|
||||
/**
|
||||
* If true Pixi will Math.floor() x/ y values when rendering, stopping pixel interpolation. [default=false]
|
||||
*/
|
||||
roundPixels?: boolean;
|
||||
|
||||
/**
|
||||
* forces FXAA antialiasing to be used over native FXAA is faster, but may not always look as great ** webgl only** [default=false]
|
||||
*/
|
||||
forceFXAA?: boolean;
|
||||
|
||||
/**
|
||||
* `true` to ensure compatibility with older / less advanced devices. If you experience unexplained flickering try setting this to true. **webgl only** [default=false]
|
||||
*/
|
||||
legacy?: boolean;
|
||||
|
||||
/**
|
||||
* Depricated
|
||||
*/
|
||||
context?: WebGLRenderingContext;
|
||||
|
||||
/**
|
||||
* Depricated
|
||||
*/
|
||||
autoResize?: boolean;
|
||||
}
|
||||
interface ApplicationOptions extends RendererOptions {
|
||||
/**
|
||||
* `true` to use PIXI.ticker.shared, `false` to create new ticker. [default=false]
|
||||
*/
|
||||
sharedTicker?: boolean;
|
||||
|
||||
/**
|
||||
* `true` to use PIXI.loaders.shared, `false` to create new Loader.
|
||||
*/
|
||||
sharedLoader?: boolean;
|
||||
}
|
||||
class SystemRenderer extends utils.EventEmitter {
|
||||
constructor(system: string, options?: RendererOptions);
|
||||
@@ -825,20 +879,7 @@ declare namespace PIXI {
|
||||
resize(width: number, height: number): void;
|
||||
destroy(): void;
|
||||
}
|
||||
interface WebGLRendererOptions {
|
||||
view?: HTMLCanvasElement;
|
||||
transparent?: boolean;
|
||||
autoResize?: boolean;
|
||||
antialias?: boolean;
|
||||
forceFXAA?: boolean;
|
||||
resolution?: number;
|
||||
clearBeforeRender?: boolean;
|
||||
backgroundColor?: number;
|
||||
preserveDrawingBuffer?: boolean;
|
||||
roundPixels?: boolean;
|
||||
legacy?: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
interface WebGLRendererOptions extends RendererOptions {
|
||||
}
|
||||
class WebGLRenderer extends SystemRenderer {
|
||||
// plugintarget mixin start
|
||||
@@ -2512,12 +2553,18 @@ declare namespace PIXI {
|
||||
|
||||
protected maxItemsPerFrame: number;
|
||||
protected itemsLeft: number;
|
||||
|
||||
beginFrame(): void;
|
||||
allowedToUpload(): boolean;
|
||||
}
|
||||
class TimeLimiter {
|
||||
constructor(maxMilliseconds: number);
|
||||
|
||||
protected maxMilliseconds: number;
|
||||
protected frameStart: number;
|
||||
|
||||
beginFrame(): void;
|
||||
allowedToUpload(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2713,6 +2760,11 @@ declare namespace PIXI {
|
||||
function isWebGLSupported(): boolean;
|
||||
function sign(n: number): number;
|
||||
function removeItems<T>(arr: T[], startIdx: number, removeCount: number): void;
|
||||
function correctBlendMode(blendMode: number, premultiplied: boolean): number;
|
||||
function premultiplyTint(tint: number, alpha: number): number;
|
||||
function premultiplyRgba(rgb: Float32Array | number[], alpha: number, out?: Float32Array, premultiply?: boolean): Float32Array;
|
||||
function premultiplyTintToRgba(tint: number, alpha: number, out?: Float32Array, premultiply?: boolean): Float32Array;
|
||||
const premultiplyBlendMode: number[][];
|
||||
const TextureCache: any;
|
||||
const BaseTextureCache: any;
|
||||
|
||||
|
||||
4
types/redux-form/lib/Field.d.ts
vendored
4
types/redux-form/lib/Field.d.ts
vendored
@@ -278,7 +278,7 @@ interface WrappedFieldMetaProps<S> {
|
||||
* The error for this field if its value is not passing validation. Both
|
||||
* synchronous, asynchronous, and submit validation errors will be reported here.
|
||||
*/
|
||||
error?: string;
|
||||
error?: any;
|
||||
|
||||
/**
|
||||
* The name of the form. Could be useful if you want to manually dispatch actions.
|
||||
@@ -329,5 +329,5 @@ interface WrappedFieldMetaProps<S> {
|
||||
/**
|
||||
* The warning for this field if its value is not passing warning validation.
|
||||
*/
|
||||
warning?: string;
|
||||
warning?: any;
|
||||
}
|
||||
|
||||
101
types/sequelize/index.d.ts
vendored
101
types/sequelize/index.d.ts
vendored
@@ -259,7 +259,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* An optional where clause to limit the associated models.
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Apply a scope on the related model, or remove its default scope by passing false.
|
||||
@@ -346,7 +346,7 @@ declare namespace sequelize {
|
||||
*/
|
||||
(
|
||||
newAssociations?: Array<TInstance | TInstancePrimaryKey>,
|
||||
options?: HasManySetAssociationsMixinOptions | FindOptions | InstanceUpdateOptions
|
||||
options?: HasManySetAssociationsMixinOptions | AnyFindOptions | InstanceUpdateOptions
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* An optional where clause to limit the associated models.
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Apply a scope on the related model, or remove its default scope by passing false.
|
||||
@@ -722,7 +722,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* An optional where clause to limit the associated models.
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Apply a scope on the related model, or remove its default scope by passing false.
|
||||
@@ -809,7 +809,7 @@ declare namespace sequelize {
|
||||
*/
|
||||
(
|
||||
newAssociations?: Array<TInstance | TInstancePrimaryKey>,
|
||||
options?: BelongsToManySetAssociationsMixinOptions | FindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
options?: BelongsToManySetAssociationsMixinOptions | AnyFindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ declare namespace sequelize {
|
||||
*/
|
||||
(
|
||||
newAssociations?: Array<TInstance | TInstancePrimaryKey>,
|
||||
options?: BelongsToManyAddAssociationsMixinOptions | FindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
options?: BelongsToManyAddAssociationsMixinOptions | AnyFindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ declare namespace sequelize {
|
||||
*/
|
||||
(
|
||||
newAssociation?: TInstance | TInstancePrimaryKey,
|
||||
options?: BelongsToManyAddAssociationMixinOptions | FindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
options?: BelongsToManyAddAssociationMixinOptions | AnyFindOptions | BulkCreateOptions | InstanceUpdateOptions | InstanceDestroyOptions | { through: TJoinTableAttributes }
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1135,7 +1135,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* An optional where clause to limit the associated models.
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Apply a scope on the related model, or remove its default scope by passing false.
|
||||
@@ -2618,7 +2618,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* A hash of attributes to describe your search. See above for examples.
|
||||
*/
|
||||
where?: WhereOptions | Array<col | and | or | string>;
|
||||
where?: AnyWhereOptions | Array<col | and | or | string>;
|
||||
|
||||
}
|
||||
|
||||
@@ -2668,7 +2668,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* A hash of attributes to describe your search. See above for examples.
|
||||
*/
|
||||
where?: WhereOptions | Array<col | and | or | string>;
|
||||
where?: AnyWhereOptions | Array<col | and | or | string>;
|
||||
|
||||
}
|
||||
|
||||
@@ -2829,7 +2829,7 @@ declare namespace sequelize {
|
||||
* return a new instance. With this method, all references to the Instance are updated with the new data
|
||||
* and no new objects are created.
|
||||
*/
|
||||
reload(options?: FindOptions): Promise<this>;
|
||||
reload(options?: AnyFindOptions): Promise<this>;
|
||||
|
||||
/**
|
||||
* Validate the attribute of this instance according to validation rules set in the model definition.
|
||||
@@ -3036,8 +3036,8 @@ declare namespace sequelize {
|
||||
* Where Complex nested query
|
||||
*/
|
||||
interface WhereNested {
|
||||
$and: Array<WhereOptions | WhereLogic>;
|
||||
$or: Array<WhereOptions | WhereLogic>;
|
||||
$and: Array<AnyWhereOptions | WhereLogic>;
|
||||
$or: Array<AnyWhereOptions | WhereLogic>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3059,10 +3059,10 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Logic of where statement
|
||||
*/
|
||||
interface WhereLogic {
|
||||
type WhereLogic = Partial<{
|
||||
$ne: string | number | WhereLogic;
|
||||
$in: Array<string | number> | literal;
|
||||
$not: boolean | string | number | WhereOptions;
|
||||
$not: boolean | string | number | AnyWhereOptions;
|
||||
$notIn: Array<string | number> | literal;
|
||||
$gte: number | string | Date;
|
||||
$gt: number | string | Date;
|
||||
@@ -3083,7 +3083,7 @@ declare namespace sequelize {
|
||||
"@>": any;
|
||||
$contained: any;
|
||||
"<@": any;
|
||||
}
|
||||
}>;
|
||||
|
||||
/**
|
||||
* A hash of attributes to describe your search. See above for examples.
|
||||
@@ -3091,8 +3091,15 @@ declare namespace sequelize {
|
||||
* We did put Object in the end, because there where query might be a JSON Blob. It cripples a bit the
|
||||
* typesafety, but there is no way to pass the tests if we just remove it.
|
||||
*/
|
||||
interface WhereOptions {
|
||||
[field: string]: string | number | WhereLogic | WhereOptions | col | and | or | WhereGeometryOptions | Array<string | number> | Object | null;
|
||||
type WhereOptions<T> = {
|
||||
[P in keyof T]?: string | number | WhereLogic | WhereOptions<T[P]> | col | and | or | WhereGeometryOptions | Array<string | number> | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* A hash of attributes to describe your search, accepting any field names. See `WhereOptions` for details.
|
||||
*/
|
||||
interface AnyWhereOptions {
|
||||
[field: string]: WhereOptions<any>[] | Object;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3103,7 +3110,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Filter on the join model for belongsToMany relations
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* A list of attributes to select from the join model for belongsToMany relations
|
||||
@@ -3146,7 +3153,7 @@ declare namespace sequelize {
|
||||
* Where clauses to apply to the child models. Note that this converts the eager load to an inner join,
|
||||
* unless you explicitly set `required: false`
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* A list of attributes to select from the child model
|
||||
@@ -3188,12 +3195,12 @@ declare namespace sequelize {
|
||||
*
|
||||
* A hash of options to describe the scope of the search
|
||||
*/
|
||||
interface FindOptions extends LoggingOptions, SearchPathOptions {
|
||||
interface FindOptions<T> extends LoggingOptions, SearchPathOptions {
|
||||
|
||||
/**
|
||||
* A hash of attributes to describe your search. See above for examples.
|
||||
*/
|
||||
where?: WhereOptions | fn | Array<col | and | or | string>;
|
||||
where?: WhereOptions<T> | fn | Array<col | and | or | string>;
|
||||
|
||||
/**
|
||||
* A list of the attributes that you want to select. To rename an attribute, you can pass an array, with
|
||||
@@ -3250,7 +3257,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* having ?!?
|
||||
*/
|
||||
having?: WhereOptions;
|
||||
having?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Group by. It is not mentioned in sequelize's JSDoc, but mentioned in docs.
|
||||
@@ -3270,6 +3277,8 @@ declare namespace sequelize {
|
||||
subQuery?: boolean;
|
||||
}
|
||||
|
||||
type AnyFindOptions = FindOptions<any>;
|
||||
|
||||
/**
|
||||
* Options for Model.count method
|
||||
*/
|
||||
@@ -3278,7 +3287,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* A hash of search attributes.
|
||||
*/
|
||||
where?: WhereOptions | string[];
|
||||
where?: AnyWhereOptions | string[];
|
||||
|
||||
/**
|
||||
* Include options. See `find` for details
|
||||
@@ -3340,7 +3349,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Options for Model.findOrInitialize method
|
||||
*/
|
||||
interface FindOrInitializeOptions<TAttributes> extends FindOptions {
|
||||
interface FindOrInitializeOptions<TAttributes> extends AnyFindOptions {
|
||||
|
||||
/**
|
||||
* Default values to use if building a new instance
|
||||
@@ -3352,7 +3361,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Options for Model.findOrInitialize method
|
||||
*/
|
||||
interface FindCreateFindOptions<TAttributes> extends FindOptions {
|
||||
interface FindCreateFindOptions<TAttributes> extends FindOptions<TAttributes> {
|
||||
|
||||
/**
|
||||
* Default values to use if building a new instance
|
||||
@@ -3428,7 +3437,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Filter the destroy
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Run before / after bulk destroy hooks?
|
||||
@@ -3467,7 +3476,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Filter the restore
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Run before / after bulk restore hooks?
|
||||
@@ -3500,7 +3509,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Options to describe the scope of the search.
|
||||
*/
|
||||
where: WhereOptions;
|
||||
where: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* Run before / after bulk update hooks?
|
||||
@@ -3548,7 +3557,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* A hash of search attributes.
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
/**
|
||||
* The type of the result. If `field` is a field in this Model, the default will be the type of that field,
|
||||
@@ -3639,7 +3648,7 @@ declare namespace sequelize {
|
||||
* @param {Object} [options]
|
||||
* @param {Boolean} [options.override=false]
|
||||
*/
|
||||
addScope(name: string, scope: FindOptions | Function, options?: AddScopeOptions): void;
|
||||
addScope(name: string, scope: AnyFindOptions | Function, options?: AddScopeOptions): void;
|
||||
|
||||
/**
|
||||
* Add a new scope to the model. This is especially useful for adding scopes with includes, when the model you want to include is not available at the time this model is defined.
|
||||
@@ -3651,7 +3660,7 @@ declare namespace sequelize {
|
||||
* @param {Object} [options]
|
||||
* @param {Boolean} [options.override=false]
|
||||
*/
|
||||
addScope(name: string, scope: FindOptions | Function, options?: AddScopeOptions): void;
|
||||
addScope(name: string, scope: AnyFindOptions | Function, options?: AddScopeOptions): void;
|
||||
|
||||
/**
|
||||
* Apply a scope created in `define` to the model. First let's look at how to create scopes:
|
||||
@@ -3700,7 +3709,7 @@ declare namespace sequelize {
|
||||
* @return Model A reference to the model, with the scope(s) applied. Calling scope again on the returned
|
||||
* model will clear the previous scope.
|
||||
*/
|
||||
scope(options?: string | ScopeOptions | WhereOptions | Array<string | ScopeOptions | WhereOptions>): this;
|
||||
scope(options?: string | ScopeOptions | AnyWhereOptions | Array<string | ScopeOptions | AnyWhereOptions>): this;
|
||||
|
||||
/**
|
||||
* Search for multiple instances.
|
||||
@@ -3764,22 +3773,22 @@ declare namespace sequelize {
|
||||
*
|
||||
* @see {Sequelize#query}
|
||||
*/
|
||||
findAll(options?: FindOptions): Promise<TInstance[]>;
|
||||
all(optionz?: FindOptions): Promise<TInstance[]>;
|
||||
findAll<TCustomAttributes>(options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance[]>;
|
||||
all<TCustomAttributes>(optionz?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance[]>;
|
||||
|
||||
/**
|
||||
* Search for a single instance by its primary key. This applies LIMIT 1, so the listener will
|
||||
* always be called with a single instance.
|
||||
*/
|
||||
findById(identifier?: number | string, options?: FindOptions): Promise<TInstance | null>;
|
||||
findByPrimary(identifier?: number | string, options?: FindOptions): Promise<TInstance | null>;
|
||||
findById<TCustomAttributes>(identifier?: number | string, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
findByPrimary<TCustomAttributes>(identifier?: number | string, options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
|
||||
/**
|
||||
* Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single
|
||||
* instance.
|
||||
*/
|
||||
findOne(options?: FindOptions): Promise<TInstance | null>;
|
||||
find(options?: FindOptions): Promise<TInstance | null>;
|
||||
findOne<TCustomAttributes>(options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
find<TCustomAttributes>(options?: FindOptions<TAttributes & TCustomAttributes>): Promise<TInstance | null>;
|
||||
|
||||
/**
|
||||
* Run an aggregation method on the specified field
|
||||
@@ -3834,8 +3843,8 @@ declare namespace sequelize {
|
||||
* without
|
||||
* profiles will be counted
|
||||
*/
|
||||
findAndCount(options?: FindOptions): Promise<{ rows: TInstance[], count: number }>;
|
||||
findAndCountAll(options?: FindOptions): Promise<{ rows: TInstance[], count: number }>;
|
||||
findAndCount<TCustomAttributes>(options?: FindOptions<TAttributes & TCustomAttributes>): Promise<{ rows: TInstance[], count: number }>;
|
||||
findAndCountAll<TCustomAttributes>(options?: FindOptions<TAttributes & TCustomAttributes>): Promise<{ rows: TInstance[], count: number }>;
|
||||
|
||||
/**
|
||||
* Find the maximum value of field
|
||||
@@ -3891,7 +3900,7 @@ declare namespace sequelize {
|
||||
* A more performant findOrCreate that will not work under a transaction (at least not in postgres)
|
||||
* Will execute a find call, if empty then attempt to create, if unique constraint then attempt to find again
|
||||
*/
|
||||
findCreateFind(options: FindCreateFindOptions<TAttributes>): Promise<TInstance>;
|
||||
findCreateFind<TCustomAttributes>(options: FindCreateFindOptions<TAttributes & TCustomAttributes>): Promise<TInstance>;
|
||||
|
||||
/**
|
||||
* Insert or update a single row. An update will be executed if a row which matches the supplied values on
|
||||
@@ -3999,7 +4008,7 @@ declare namespace sequelize {
|
||||
interface AddCheckConstraintOptions {
|
||||
type: 'check';
|
||||
name?: string;
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
}
|
||||
|
||||
interface AddPrimaryKeyConstraintOptions {
|
||||
@@ -4855,7 +4864,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Condition for partioal index
|
||||
*/
|
||||
where?: WhereOptions;
|
||||
where?: AnyWhereOptions;
|
||||
|
||||
}
|
||||
|
||||
@@ -4906,7 +4915,7 @@ declare namespace sequelize {
|
||||
/**
|
||||
* Name of the scope and it's query
|
||||
*/
|
||||
[scopeName: string]: FindOptions | Function;
|
||||
[scopeName: string]: AnyFindOptions | Function;
|
||||
|
||||
}
|
||||
|
||||
@@ -4921,7 +4930,7 @@ declare namespace sequelize {
|
||||
* Define the default search scope to use for this model. Scopes have the same form as the options passed to
|
||||
* find / findAll.
|
||||
*/
|
||||
defaultScope?: FindOptions;
|
||||
defaultScope?: AnyFindOptions;
|
||||
|
||||
/**
|
||||
* More scopes, defined in the same way as defaultScope above. See `Model.scope` for more information about
|
||||
|
||||
@@ -1318,7 +1318,7 @@ s.define( 'ProductWithSettersAndGetters1', {
|
||||
get : function() {
|
||||
return 'answer = ' + this.getDataValue( 'price' );
|
||||
},
|
||||
set : function( v ) {
|
||||
set : function( v: number ) {
|
||||
return this.setDataValue( 'price', v + 42 );
|
||||
}
|
||||
}
|
||||
@@ -1437,6 +1437,37 @@ s.define( 'ScopeMe', {
|
||||
}
|
||||
} );
|
||||
|
||||
// Generic find options
|
||||
interface ChairAttributes {
|
||||
id: number;
|
||||
color: string;
|
||||
legs: number;
|
||||
}
|
||||
interface ChairInstance extends Sequelize.Instance<ChairAttributes> {}
|
||||
|
||||
const Chair = s.define<ChairInstance, ChairAttributes>('chair', {});
|
||||
|
||||
Chair.findAll({
|
||||
where: {
|
||||
color: 'blue',
|
||||
legs: { $in: [3, 4] },
|
||||
},
|
||||
});
|
||||
|
||||
// If you want to use a property that isn't explicitly on the model's Attributes
|
||||
// use the find-function's generic type parameter.
|
||||
Chair.findAll<{ customProperty: number }>({
|
||||
where: {
|
||||
customProperty: 123,
|
||||
}
|
||||
});
|
||||
Chair.findAll<any>({
|
||||
where: {
|
||||
customProperty1: 123,
|
||||
customProperty2: 456,
|
||||
}
|
||||
});
|
||||
|
||||
s.define( 'ScopeMe', {
|
||||
username : Sequelize.STRING,
|
||||
email : Sequelize.STRING,
|
||||
|
||||
Reference in New Issue
Block a user