From aedacdd3fa7c74dac674e34374b75e4bc6f62e78 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 09:04:22 -0700 Subject: [PATCH 01/68] updates some types in (#28869) --- types/mali/index.d.ts | 108 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/types/mali/index.d.ts b/types/mali/index.d.ts index 1c73b18c75..8e536d5330 100644 --- a/types/mali/index.d.ts +++ b/types/mali/index.d.ts @@ -10,68 +10,68 @@ import { EventEmitter } from 'events'; import { Stream } from 'stream'; declare class Mali extends EventEmitter { - constructor(path: any, name?: string | ReadonlyArray, options?: any); - name: string; - env: string; - ports: ReadonlyArray; // ? not sure which it is - silent: boolean; + constructor(path: any, name?: string | ReadonlyArray, options?: any); + name: string; + env: string; + ports: ReadonlyArray; + silent: boolean; - addService(path: any, name: string | ReadonlyArray, options?: any): void; - use(service?: any, name?: any, fns?: any): void; - start(port?: any, creds?: any, options?: any): any; // gnarly type asserting for these functions so Im just gonna let them handle it. - toJSON(): any; - close(): void; - inspect(): any; + addService(path: any, name: string | ReadonlyArray, options?: any): void; + use(service?: any, name?: any, fns?: any): void; + start(port: number | string, creds?: any, options?: any): any; // gnarly type inferring for these functions so Im just gonna let them handle it. + toJSON(): any; + close(): Promise; + inspect(): any; } declare namespace Mali { - interface Context { - name: string; - fullName: string; - service: string; - package: string; - app: any; // ? app - call: any; - request: Request; - response: Response; - req: any; // ? - res: any; // ? - type: string; - metadata: string; - get(field: string): any; - set(field: any, val?: any): void; // do I need `?:` if its of type `any`? - sendMetadata(md: any): void; - getStatus(field: string): any; - setStatus(field: any, val?: any): void; // ^ - } + interface Context { + name: string; + fullName: string; + service: string; + package: string; + app: any; // ? app + call: any; + request: Request; + response: Response; + req: any; // ? + res: any; // ? + type: string; + metadata: string; + get(field: string): any; + set(field: any, val?: any): void; // do I need `?:` if its of type `any`? + sendMetadata(md: any): void; + getStatus(field: string): any; + setStatus(field: any, val?: any): void; // ^ + } - class Request { - constructor(call: any, type: string); - call: any; - type: string; - metadata: any; - req: any; // ? + class Request { + constructor(call: any, type: string); + call: any; + type: string; + metadata: any; + req: any; // ? - getMetadata(): any; - get(field: string): any; - } + getMetadata(): any; + get(field: string): any; + } - class Response { - constructor(call: any, type: string); - call: any; - type: string; - metadata: any; - status: any; - res: any; // ? - set(field: any, val?: any): void; // is `val?:` necessary when its of type `any`? - get(field: string): any; - getMetadata(): any; - sendMetadata(md?: any): void; - getStatus(field: string): any; - setStatus(field: any, val?: any): void; // ^ same as above - } + class Response { + constructor(call: any, type: string); + call: any; + type: string; + metadata: any; + status: any; + res: any; // ? + set(field: any, val?: any): void; // is `val?:` necessary when its of type `any`? + get(field: string): any; + getMetadata(): any; + sendMetadata(md?: any): void; + getStatus(field: string): any; + setStatus(field: any, val?: any): void; // ^ same as above + } - function exec(ctx: Context, handler: any, cb?: any): void; + function exec(ctx: Context, handler: any, cb?: any): void; } export = Mali; From 1695c608fd0e58902a77a52a2ba48194b9b1a315 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Fri, 14 Sep 2018 18:04:59 +0200 Subject: [PATCH 02/68] smtp-server: callback for `close` doesn't have arguments (#28799) * smtp-server: minor tweaks for jsdoc * smtp-server: callback foe `close` doesn't have arguments * smtp-server: 2nd callback argument for `onAuth` handler is optional * smtp-server: tests for handlers in subclass * smtp-server: more EventEmitter methods --- types/smtp-server/index.d.ts | 52 ++++--- types/smtp-server/smtp-server-tests.ts | 201 +++++++++++++++++-------- 2 files changed, 177 insertions(+), 76 deletions(-) diff --git a/types/smtp-server/index.d.ts b/types/smtp-server/index.d.ts index d7e25dd342..3b5f320613 100644 --- a/types/smtp-server/index.d.ts +++ b/types/smtp-server/index.d.ts @@ -153,8 +153,8 @@ export interface SMTPServerOptions extends tls.TlsOptions { */ banner?: string; /** - * optional maximum allowed message size in bytes, - * see details:https://github.com/andris9/smtp-server#using-size-extension + * optional maximum allowed message size in bytes + * ([see details](https://github.com/andris9/smtp-server#using-size-extension)) */ size?: number; /** @@ -176,7 +176,7 @@ export interface SMTPServerOptions extends tls.TlsOptions { * use ['AUTH'] as this value. * If you want to allow authentication in clear text, set it to ['STARTTLS']. */ - disabledCommands?: string[]; // TODO ('AUTH' | 'STARTTLS' | 'XCLIENT' | 'XFORWARD')[]; + disabledCommands?: string[]; // TODO: ('AUTH' | 'STARTTLS' | 'XCLIENT' | 'XFORWARD')[]; /** * optional boolean, if set to true then allow using STARTTLS * but do not advertise or require it. It only makes sense @@ -224,17 +224,17 @@ export interface SMTPServerOptions extends tls.TlsOptions { maxClients?: number; /** * boolean, if set to true expects to be behind a proxy that emits a - * PROXY header{http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt} (version 1 only) + * [PROXY](http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt) header (version 1 only) */ useProxy?: boolean; /** * boolean, if set to true, enables usage of - * XCLIENT{http://www.postfix.org/XCLIENT_README.html} extension to override connection properties. + * [XCLIENT](http://www.postfix.org/XCLIENT_README.html) extension to override connection properties. * See session.xClient (Map object) for the details provided by the client */ useXClient?: boolean; /** - * boolean, if set to true, enables usage of XFORWARD{http://www.postfix.org/XFORWARD_README.html} extension. + * boolean, if set to true, enables usage of [XFORWARD](http://www.postfix.org/XFORWARD_README.html) extension. * See session.xForward (Map object) for the details provided by the client */ useXForward?: boolean; @@ -248,27 +248,27 @@ export interface SMTPServerOptions extends tls.TlsOptions { socketTimeout?: ms; /** * How many millisceonds to wait before disconnecting pending - * connections once server.close() has been called (defaults to 30 seconds) + * connections once `server.close()` has been called (defaults to 30 seconds) */ closeTimeout?: ms; /** - * The callback to handle authentications (see details https://github.com/andris9/smtp-server#handling-authentication) + * The callback to handle authentications ([see details](https://github.com/andris9/smtp-server#handling-authentication)) */ - onAuth?(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response: SMTPServerAuthenticationResponse) => void): void; + onAuth?(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response?: SMTPServerAuthenticationResponse) => void): void; /** - * The callback to handle the client connection. (see details https://github.com/andris9/smtp-server#validating-client-connection) + * The callback to handle the client connection. ([see details](https://github.com/andris9/smtp-server#validating-client-connection)) */ onConnect?(session: SMTPServerSession, callback: (err?: Error | null) => void): void; /** - * the callback to validate MAIL FROM commands (see details https://github.com/andris9/smtp-server#validating-sender-addresses) + * the callback to validate MAIL FROM commands ([see details](https://github.com/andris9/smtp-server#validating-sender-addresses)) */ onMailFrom?(address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void): void; /** - * The callback to validate RCPT TO commands (see details https://github.com/andris9/smtp-server#validating-recipient-addresses) + * The callback to validate RCPT TO commands ([see details](https://github.com/andris9/smtp-server#validating-recipient-addresses)) */ onRcptTo?(address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void): void; /** - * the callback to handle incoming messages (see details https://github.com/andris9/smtp-server#processing-incoming-message) + * the callback to handle incoming messages ([see details](https://github.com/andris9/smtp-server#processing-incoming-message)) */ onData?(stream: Readable, session: SMTPServerSession, callback: (err?: Error | null) => void): void; /** @@ -299,16 +299,21 @@ export class SMTPServer extends EventEmitter { listen(handle: any, listeningListener?: () => void): net.Server; // tslint:disable-line unified-signatures /** Closes the server */ - close(callback: (err?: Error | null) => void): void; + close(callback: () => void): void; updateSecureContext(options: tls.TlsOptions): void; /** Authentication handler. Override this */ - onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response: SMTPServerAuthenticationResponse) => void): void; + onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response?: SMTPServerAuthenticationResponse) => void): void; + /** Override this */ onClose(session: SMTPServerSession, callback: (err?: Error | null) => void): void; + /** Override this */ onConnect(session: SMTPServerSession, callback: (err?: Error | null) => void): void; + /** Override this */ onData(stream: Readable, session: SMTPServerSession, callback: (err?: Error | null) => void): void; + /** Override this */ onMailFrom(address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void): void; + /** Override this */ onRcptTo(address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void): void; addListener(event: 'close', listener: () => void): this; @@ -317,6 +322,14 @@ export class SMTPServer extends EventEmitter { emit(event: 'close'): boolean; emit(event: 'error', err: Error): boolean; + listenerCount(event: 'close' | 'error'): number; + + listeners(event: 'close'): Array<() => void>; + listeners(event: 'error'): Array<(err: Error) => void>; + + off(event: 'close', listener: () => void): this; + off(event: 'error', listener: (err: Error) => void): this; + on(event: 'close', listener: () => void): this; on(event: 'error', listener: (err: Error) => void): this; @@ -329,6 +342,11 @@ export class SMTPServer extends EventEmitter { prependOnceListener(event: 'close', listener: () => void): this; prependOnceListener(event: 'error', listener: (err: Error) => void): this; - listeners(event: 'close'): Array<() => void>; - listeners(event: 'error'): Array<(err: Error) => void>; + rawListeners(event: 'close'): Array<() => void>; + rawListeners(event: 'error'): Array<(err: Error) => void>; + + removeAllListener(event: 'close' | 'error'): this; + + removeListener(event: 'close', listener: () => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; } diff --git a/types/smtp-server/smtp-server-tests.ts b/types/smtp-server/smtp-server-tests.ts index 839d4ee3bc..52578ad4a8 100644 --- a/types/smtp-server/smtp-server-tests.ts +++ b/types/smtp-server/smtp-server-tests.ts @@ -2,76 +2,159 @@ import { AddressInfo } from 'net'; import { SMTPServer, SMTPServerAddress, SMTPServerAuthentication, SMTPServerAuthenticationResponse, SMTPServerOptions, SMTPServerSession } from 'smtp-server'; import { Readable } from 'stream'; -const options: SMTPServerOptions = { - hideSTARTTLS: true, - onConnect, - onMailFrom, - onRcptTo, - onData, - onClose, -}; +function test_with_handlers_as_options() { + const options: SMTPServerOptions = { + hideSTARTTLS: true, + onConnect, + onMailFrom, + onRcptTo, + onData, + onClose, + }; -const port = 2525; + const port = 2525; -function onConnect(session: SMTPServerSession, callback: (err?: Error) => void): void { - console.log(`[${session.id}] onConnect`); - callback(); -} - -function onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | undefined, response?: SMTPServerAuthenticationResponse) => void): void { - if (auth.method === 'PLAIN' && auth.username === 'username' && auth.password === 'password') { - callback(undefined, { user: auth.username }); - } else { - callback(new Error('Invalid username or password')); - } -} - -function onMailFrom(from: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { - console.log(`[${session.id}] onMailFrom ${from.address}`); - if (from.address.split('@')[1] === 'spammer.com') { - // code 421 disconnects SMTP session immediately - callback(Object.assign(new Error('we do not like spam!'), { responseCode: 421 })); - } else { + function onConnect(session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onConnect`); callback(); } -} -function onRcptTo(to: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { - console.log(`[${session.id}] onRcptTo ${to.address}`); - callback(); -} + function onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | undefined, response?: SMTPServerAuthenticationResponse) => void): void { + if (auth.method === 'PLAIN' && auth.username === 'username' && auth.password === 'password') { + callback(undefined, { user: auth.username }); + } else { + callback(new Error('Invalid username or password')); + } + } -function onData(stream: Readable, session: SMTPServerSession, callback: (err?: Error) => void): void { - console.log(`[${session.id}] onData started`); + function onMailFrom(from: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onMailFrom ${from.address}`); + if (from.address.split('@')[1] === 'spammer.com') { + // code 421 disconnects SMTP session immediately + callback(Object.assign(new Error('we do not like spam!'), { responseCode: 421 })); + } else { + callback(); + } + } - let messageLength = 0; + function onRcptTo(to: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onRcptTo ${to.address}`); + callback(); + } - stream.on('data', (chunk: Buffer) => { - console.log(`[${session.id}] onData got data chunk ${chunk.length} bytes`); - messageLength += chunk.length; + function onData(stream: Readable, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onData started`); + + let messageLength = 0; + + stream.on('data', (chunk: Buffer) => { + console.log(`[${session.id}] onData got data chunk ${chunk.length} bytes`); + messageLength += chunk.length; + }); + + stream.once('end', () => { + console.log(`[${session.id}] onData finished after reading ${messageLength} bytes`); + callback(); + }); + } + + function onClose(session: SMTPServerSession) { + console.log(`[${session.id}] onClose`); + } + + const server = new SMTPServer(options); + + server.on('error', (err) => { + console.log(`Server got error:`, err); }); - stream.once('end', () => { - console.log(`[${session.id}] onData finished after reading ${messageLength} bytes`); - callback(); + server.on('close', () => { + console.log('Server closed'); + }); + + server.listen(port, () => { + const address = server.server.address() as AddressInfo; + console.log(`Listening on [${address.address}]:${address.port}`); + }); + + server.close(() => { + console.log('Server closed'); }); } -function onClose(session: SMTPServerSession) { - console.log(`[${session.id}] onClose`); +function test_with_handlers_in_subclass() { + class MySMTPServer extends SMTPServer { + onConnect(session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onConnect`); + callback(); + } + + onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response?: SMTPServerAuthenticationResponse) => void): void { + if (auth.method === 'PLAIN' && auth.username === 'username' && auth.password === 'password') { + callback(undefined, { user: auth.username }); + } else { + callback(new Error('Invalid username or password')); + } + } + + onMailFrom(from: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onMailFrom ${from.address}`); + if (from.address.split('@')[1] === 'spammer.com') { + // code 421 disconnects SMTP session immediately + callback(Object.assign(new Error('we do not like spam!'), { responseCode: 421 })); + } else { + callback(); + } + } + + onRcptTo(to: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onRcptTo ${to.address}`); + callback(); + } + + onData(stream: Readable, session: SMTPServerSession, callback: (err?: Error) => void): void { + console.log(`[${session.id}] onData started`); + + let messageLength = 0; + + stream.on('data', (chunk: Buffer) => { + console.log(`[${session.id}] onData got data chunk ${chunk.length} bytes`); + messageLength += chunk.length; + }); + + stream.once('end', () => { + console.log(`[${session.id}] onData finished after reading ${messageLength} bytes`); + callback(); + }); + } + + onClose(session: SMTPServerSession) { + console.log(`[${session.id}] onClose`); + } + } + + const options: SMTPServerOptions = { + hideSTARTTLS: true + }; + + const port = 2525; + + const server = new MySMTPServer(options); + + server.on('error', (err) => { + console.log(`Server got error:`, err); + }); + + server.on('close', () => { + console.log('Server closed'); + }); + + server.listen(port, () => { + const address = server.server.address() as AddressInfo; + console.log(`Listening on [${address.address}]:${address.port}`); + }); + + server.close(() => { + console.log('Server closed'); + }); } - -const server = new SMTPServer(options); - -server.on('error', (err) => { - console.log(`Server got error:`, err); -}); - -server.on('close', () => { - console.log('Server closed'); -}); - -server.listen(port, () => { - const address = server.server.address() as AddressInfo; - console.log(`Listening on [${address.address}]:${address.port}`); -}); From 69768dc0c3a5264d04b084ecff683fdc4e4af10b Mon Sep 17 00:00:00 2001 From: Sibelius Seraphini Date: Fri, 14 Sep 2018 13:05:35 -0300 Subject: [PATCH 03/68] feat(kue): add missing workerId and _error to kue Job, fix #28760 (#28762) * feat(kue): add missing workerId and _error to kue Job, fix #28760 * use private for _error --- types/kue/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/kue/index.d.ts b/types/kue/index.d.ts index 4117ef0a82..9153039ff0 100644 --- a/types/kue/index.d.ts +++ b/types/kue/index.d.ts @@ -78,6 +78,8 @@ export declare class Job extends events.EventEmitter { public failed_at: string | number; public started_at: string | number; public client: redisClientFactory.RedisClient; + public workerId: string; + private _error: string; private _max_attempts; static priorities: Priorities; From a9c13cdfe777eb8759c1e46a7d5010990e2a9e23 Mon Sep 17 00:00:00 2001 From: Dilip Date: Fri, 14 Sep 2018 13:06:13 -0300 Subject: [PATCH 04/68] [three] Added 'context' to WebGLRendererParameters for using an existing WebGLRenderingContext in `new WebGLRenderer` as seen in THREE.JS docs (#28856) * Added 'context' to WebGLRendererParameters in three * Added WebGLRenderingContext test --- types/three/index.d.ts | 1 + .../webgl/webgl_geometries_with_context.ts | 185 ++++++++++++++++++ types/three/three-core.d.ts | 8 + types/three/tsconfig.json | 1 + 4 files changed, 195 insertions(+) create mode 100644 types/three/test/webgl/webgl_geometries_with_context.ts diff --git a/types/three/index.d.ts b/types/three/index.d.ts index 5b4a156e4b..a392532e95 100644 --- a/types/three/index.d.ts +++ b/types/three/index.d.ts @@ -20,6 +20,7 @@ // Seth Kingsley , // Ethan Kay , // Methuselah96 +// Dilip Ramirez // Definitions: https://github.com//DefinitelyTyped export * from "./three-core"; diff --git a/types/three/test/webgl/webgl_geometries_with_context.ts b/types/three/test/webgl/webgl_geometries_with_context.ts new file mode 100644 index 0000000000..20e18f715a --- /dev/null +++ b/types/three/test/webgl/webgl_geometries_with_context.ts @@ -0,0 +1,185 @@ +// https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometries.html + +() => { + if (!Detector.webgl) Detector.addGetWebGLMessage(); + + var container: HTMLDivElement, stats: Stats; + + var camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer; + + init(); + animate(); + + function init() { + + container = document.createElement('div'); + document.body.appendChild(container); + + camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 2000); + camera.position.y = 400; + + scene = new THREE.Scene(); + + var light: THREE.DirectionalLight, object: THREE.Mesh | THREE.AxesHelper | THREE.ArrowHelper; + + scene.add(new THREE.AmbientLight(0x404040)); + + light = new THREE.DirectionalLight(0xffffff); + light.position.set(0, 1, 0); + scene.add(light); + + var map = THREE.ImageUtils.loadTexture('textures/UV_Grid_Sm.jpg'); + map.wrapS = map.wrapT = THREE.RepeatWrapping; + map.anisotropy = 16; + + var material = new THREE.MeshLambertMaterial({ map: map, side: THREE.DoubleSide }); + + // + + object = new THREE.Mesh(new THREE.SphereGeometry(75, 20, 10), material); + object.position.set(-400, 0, 200); + scene.add(object); + + object = new THREE.Mesh(new THREE.IcosahedronGeometry(75, 1), material); + object.position.set(-200, 0, 200); + scene.add(object); + + object = new THREE.Mesh(new THREE.OctahedronGeometry(75, 2), material); + object.position.set(0, 0, 200); + scene.add(object); + + object = new THREE.Mesh(new THREE.TetrahedronGeometry(75, 0), material); + object.position.set(200, 0, 200); + scene.add(object); + + // + + object = new THREE.Mesh(new THREE.PlaneGeometry(100, 100, 4, 4), material); + object.position.set(-400, 0, 0); + scene.add(object); + + object = new THREE.Mesh(new THREE.BoxGeometry(100, 100, 100, 4, 4, 4), material); + object.position.set(-200, 0, 0); + scene.add(object); + + object = new THREE.Mesh(new THREE.CircleGeometry(50, 20, 0, Math.PI * 2), material); + object.position.set(0, 0, 0); + scene.add(object); + + object = new THREE.Mesh(new THREE.RingGeometry(10, 50, 20, 5, 0, Math.PI * 2), material); + object.position.set(200, 0, 0); + scene.add(object); + + object = new THREE.Mesh(new THREE.CylinderGeometry(25, 75, 100, 40, 5), material); + object.position.set(400, 0, 0); + scene.add(object); + + // + + var points: THREE.Vector2[] = []; + + for (var i = 0; i < 50; i++) { + + points.push(new THREE.Vector2(Math.sin(i * 0.2) * Math.sin(i * 0.1) * 15 + 50, 0)); + + } + + object = new THREE.Mesh(new THREE.LatheGeometry(points, 20), material); + object.position.set(-400, 0, -200); + scene.add(object); + + object = new THREE.Mesh(new THREE.TorusGeometry(50, 20, 20, 20), material); + object.position.set(-200, 0, -200); + scene.add(object); + + object = new THREE.Mesh(new THREE.TorusKnotGeometry(50, 10, 50, 20), material); + object.position.set(0, 0, -200); + scene.add(object); + + + object = new THREE.Mesh( + new THREE.ParametricGeometry( + (u:number, v:number, dest:THREE.Vector3):void => { + dest.set(u, v, 0); + }, + 25, + 25 + ) + ); + + object = new THREE.AxesHelper(50); + object.position.set(200, 0, -200); + scene.add(object); + + object = new THREE.ArrowHelper(new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, 0), 50); + object.position.set(400, 0, -200); + scene.add(object); + + // + /* + * Inserting a new Canvas' WebGL rendering context + * (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext) + */ + const canvas = document.createElement('canvas'); + const gl = canvas.getContext('webgl'); + + renderer = new THREE.WebGLRenderer({ antialias: true, context: gl }); + renderer.setPixelRatio(window.devicePixelRatio); + renderer.setSize(window.innerWidth, window.innerHeight); + + container.appendChild(renderer.domElement); + + stats = new Stats(); + stats.dom.style.position = 'absolute'; + stats.dom.style.top = '0px'; + container.appendChild(stats.dom); + + // + + window.addEventListener('resize', onWindowResize, false); + + } + + function onWindowResize() { + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + + renderer.setSize(window.innerWidth, window.innerHeight); + + } + + // + + function animate() { + + requestAnimationFrame(animate); + + render(); + stats.update(); + + } + + function render() { + + var timer = Date.now() * 0.0001; + + camera.position.x = Math.cos(timer) * 800; + camera.position.z = Math.sin(timer) * 800; + + camera.lookAt(scene.position); + + for (var i = 0, l = scene.children.length; i < l; i++) { + + var object = scene.children[i]; + + object.rotation.x = timer * 5; + object.rotation.y = timer * 2.5; + + } + + renderer.render(scene, camera); + + } + +} diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index 51fbee2a54..24bf1364f7 100755 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -5425,6 +5425,14 @@ export interface WebGLRendererParameters { */ canvas?: HTMLCanvasElement; + + /** + * A WebGL Rendering Context. + * (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext) + * Default is null + */ + context?: WebGLRenderingContext + /** * shader precision. Can be "highp", "mediump" or "lowp". */ diff --git a/types/three/tsconfig.json b/types/three/tsconfig.json index 6a403c7ed4..a7a79e68f5 100644 --- a/types/three/tsconfig.json +++ b/types/three/tsconfig.json @@ -29,6 +29,7 @@ "test/webgl/webgl_camera.ts", "test/webgl/webgl_custom_attributes.ts", "test/webgl/webgl_geometries.ts", + "test/webgl/webgl_geometries_with_context.ts", "test/webgl/webgl_helpers.ts", "test/webgl/webgl_interactive_cubes.ts", "test/webgl/webgl_interactive_raycasting_points.ts", From 5dc54928ef79498d730ef634fbd89a114027f910 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 09:06:43 -0700 Subject: [PATCH 05/68] [ember] refactor @ember/debug types into their own package (#28817) * [ember] fix: runInDebug should return void fixes https://github.com/typed-ember/ember-cli-typescript/issues/284 * [ember] tests for DataAdapter and ContainerDebugAdapter * [ember] more specific observable handlers in tests * [ember] refactor @ember/debug types into their own package --- types/ember/index.d.ts | 54 +++++++++++++------ types/ember/test/data-adapter.ts | 53 ++++++++++++++++++ types/ember/test/debug.ts | 53 ++++++++++++++++++ types/ember/test/private/observable-tests.ts | 4 +- types/ember/tsconfig.json | 4 +- .../ember__debug/container-debug-adapter.d.ts | 2 + types/ember__debug/data-adapter.d.ts | 3 ++ types/ember__debug/ember__debug-tests.ts | 45 ++++++++++++++++ types/ember__debug/index.d.ts | 14 +++++ types/ember__debug/tsconfig.json | 31 +++++++++++ types/ember__debug/tslint.json | 4 ++ 11 files changed, 248 insertions(+), 19 deletions(-) create mode 100644 types/ember/test/data-adapter.ts create mode 100644 types/ember/test/debug.ts create mode 100644 types/ember__debug/container-debug-adapter.d.ts create mode 100644 types/ember__debug/data-adapter.d.ts create mode 100644 types/ember__debug/ember__debug-tests.ts create mode 100644 types/ember__debug/index.d.ts create mode 100644 types/ember__debug/tsconfig.json create mode 100644 types/ember__debug/tslint.json diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 6d79e1df8b..5b059a0ee4 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -739,7 +739,7 @@ declare module 'ember' { class ContainerDebugAdapter extends Object { resolver: Resolver; canCatalogEntriesByType(type: string): boolean; - catalogEntriesByType(type: string): any[]; + catalogEntriesByType(type: string): string[]; } /** * Additional methods for the Controller. @@ -1004,32 +1004,54 @@ declare module 'ember' { * The container-debug-adapter which is used * to list all models. */ - containerDebugAdapter: any; + containerDebugAdapter: ContainerDebugAdapter; /** * Ember Data > v1.0.0-beta.18 * requires string model names to be passed * around instead of the actual factories. */ - acceptsModelName: any; + acceptsModelName: boolean; /** * Specifies how records can be filtered. * Records returned will need to have a `filterValues` * property with a key for every name in the returned array. */ - getFilters(): any[]; + getFilters(): DataAdapter.Column[]; /** * Fetch the model types and observe them for changes. */ - watchModelTypes(typesAdded: Function, typesUpdated: Function): Function; + watchModelTypes( + typesAdded: (types: DataAdapter.WrappedType[]) => void, + typesUpdated: (types: DataAdapter.WrappedType[]) => void + ): () => void; /** * Fetch the records of a given type and observe them for changes. */ watchRecords( modelName: string, - recordsAdded: Function, - recordsUpdated: Function, - recordsRemoved: Function - ): Function; + recordsAdded: (records: DataAdapter.WrappedRecord[]) => void, + recordsUpdated: (records: DataAdapter.WrappedRecord[]) => void, + recordsRemoved: (idx: number, count: number) => void + ): () => void; + } + namespace DataAdapter { + interface Column { + name: string; + desc: string; + } + interface WrappedRecord { + columnValues: object; + object: object; + } + interface WrappedType { + type: { + name: string; + count: number; + columns: Column[]; + object: typeof Object; + }; + release: () => void; + } } const Debug: { /** @@ -1038,14 +1060,14 @@ declare module 'ember' { * The following example demonstrates its usage by registering a handler that throws an error if the * message contains the word "should", otherwise defers to the default handler. */ - registerDeprecationHandler(handler: Function): any; + registerDeprecationHandler(handler: (message: string, options: { id: string, until: string }, next: () => void) => void): void; /** * Allows for runtime registration of handler functions that override the default warning behavior. * Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). * The following example demonstrates its usage by registering a handler that does nothing overriding Ember's * default warning behavior. */ - registerWarnHandler(handler: Function): any; + registerWarnHandler(handler: (message: string, options: { id: string }, next: () => void) => void): void; }; /** * The DefaultResolver defines the default lookup rules to resolve @@ -3017,20 +3039,20 @@ declare module 'ember' { /** * Run a function meant for debugging. */ - function runInDebug(func: () => void): any; + function runInDebug(func: () => any): void; /** * Display a warning with the provided message. */ - function warn(message: string, test: boolean, options: { id: string }): any; - function warn(message: string, options: { id: string }): any; + function warn(message: string, test: boolean, options: { id: string }): void; + function warn(message: string, options: { id: string }): void; /** * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options */ - function warn(message: string, test: boolean, options?: { id?: string }): any; + function warn(message: string, test: boolean, options?: { id?: string }): void; /** * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options */ - function warn(message: string, options?: { id?: string }): any; + function warn(message: string, options?: { id?: string }): void; /** * Global helper method to create a new binding. Just pass the root object * along with a `to` and `from` path to create and connect the binding. diff --git a/types/ember/test/data-adapter.ts b/types/ember/test/data-adapter.ts new file mode 100644 index 0000000000..ea77b27e70 --- /dev/null +++ b/types/ember/test/data-adapter.ts @@ -0,0 +1,53 @@ +import Ember from 'ember'; + +const da = Ember.DataAdapter.create(); + +const filters = da.getFilters(); +filters.includes({ name: 'foo', desc: 'bar'}); // $ExpectType boolean +filters.includes({}); // $ExpectError + +filters[0].name; // $ExpectType string +filters[0].desc; // $ExpectType string + +da.watchModelTypes(// $ExpectType () => void + function added(wrappedTypes) { + wrappedTypes; + wrappedTypes[0].release; // $ExpectType () => void + wrappedTypes[0].type.columns[0].desc; // $ExpectType string + wrappedTypes[0].type.columns[0].name; // $ExpectType string + wrappedTypes[0].type.count; // $ExpectType number + wrappedTypes[0].type.name; // $ExpectType string + }, + function updated(wrappedTypes) { + wrappedTypes; + wrappedTypes[0].release; // $ExpectType () => void + wrappedTypes[0].type.columns[0].desc; // $ExpectType string + wrappedTypes[0].type.columns[0].name; // $ExpectType string + wrappedTypes[0].type.count; // $ExpectType number + wrappedTypes[0].type.name; // $ExpectType string + } +); +da.watchModelTypes(() => void); // $ExpectError + +da.watchRecords('house', // $ExpectType () => void + function added(records) { + records[0].object; // $ExpectType object + records[0].columnValues; // $ExpectType object + }, + function updated(records) { + records[0].object; // $ExpectType object + records[0].columnValues; // $ExpectType object + }, + function removed(idx, count) { + idx; // $ExpectType number + count; // $ExpectType number + } +); +da.watchRecords(() => void); // $ExpectError + +da.acceptsModelName; // $ExpectType boolean +da.containerDebugAdapter; // $ExpectType ContainerDebugAdapter + +const ca: Ember.ContainerDebugAdapter = da.containerDebugAdapter; +ca.canCatalogEntriesByType('controller'); // $ExpectType boolean +ca.catalogEntriesByType('controller'); // $ExpectType string[] diff --git a/types/ember/test/debug.ts b/types/ember/test/debug.ts new file mode 100644 index 0000000000..b3f4bb5f17 --- /dev/null +++ b/types/ember/test/debug.ts @@ -0,0 +1,53 @@ +import Ember from 'ember'; + +const { + runInDebug, + warn, + debug, + assert, + Debug: { registerDeprecationHandler, registerWarnHandler } +} = Ember; + +/** + * @ember/debug tests + */ +runInDebug(); // $ExpectError +let x = runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void + +// Log a warning if we have more than 3 tomsters +const tomsterCount = 2; +warn('Too many tomsters!'); // $ExpectType void +warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void +warn('Too many tomsters!', tomsterCount <= 3, { // $ExpectType void + id: 'ember-debug.too-many-tomsters' +}); + +debug(); // $ExpectError +debug('Too many tomsters!'); // $ExpectType void +debug('Too many tomsters!', 'foo'); // $ExpectError + +// Test for truthiness +const str = 'hello'; +assert('Must pass a string', typeof str === 'string'); // $ExpectType void + +// Fail unconditionally +assert('This code path should never be run'); // $ExpectType void + +// next is not called, so no warnings get the default behavior +registerWarnHandler(); // $ExpectError +registerWarnHandler(() => {}); // $ExpectType void +registerWarnHandler((message, { id }, next) => { // $ExpectType void + message; // $ExpectType string + id; // $ExpectType string + next; // $ExpectType () => void +}); + +// next is not called, so no warnings get the default behavior +registerDeprecationHandler(); // $ExpectError +registerDeprecationHandler(() => {}); // $ExpectType void +registerDeprecationHandler((message, { id, until }, next) => { // $ExpectType void + message; // $ExpectType string + id; // $ExpectType string + until; // $ExpectType string + next; // $ExpectType () => void +}); diff --git a/types/ember/test/private/observable-tests.ts b/types/ember/test/private/observable-tests.ts index 015be1057b..be3d4bd69f 100644 --- a/types/ember/test/private/observable-tests.ts +++ b/types/ember/test/private/observable-tests.ts @@ -69,12 +69,12 @@ class DemoObservable implements Observable { notifyPropertyChange(keyName: string): this { throw new Error("Method not implemented."); } - addObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: keyof this, value: any, rev: number) => void)): void; + addObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void; addObserver(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): void; addObserver(key: any, target: any, method?: any) { throw new Error("Method not implemented."); } - removeObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: keyof this, value: any, rev: number) => void)): void; + removeObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void; removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): void; removeObserver(key: any, target: any, method?: any): void { throw new Error("Method not implemented."); diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index 6619ea0e47..a267c26dd5 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -40,6 +40,8 @@ "test/core-object.ts", "test/create-negative.ts", "test/create.ts", + "test/data-adapter.ts", + "test/debug.ts", "test/detect-instance.ts", "test/detect.ts", "test/ember-tests.ts", @@ -58,8 +60,8 @@ "test/route.ts", "test/router.ts", "test/run.ts", - "test/string.ts", "test/string-ext.ts", + "test/string.ts", "test/test.ts", "test/transition.ts", "test/utils.ts", diff --git a/types/ember__debug/container-debug-adapter.d.ts b/types/ember__debug/container-debug-adapter.d.ts new file mode 100644 index 0000000000..4bd24103a4 --- /dev/null +++ b/types/ember__debug/container-debug-adapter.d.ts @@ -0,0 +1,2 @@ +import Ember from 'ember'; +export default class ContainerDebugAdapter extends Ember.ContainerDebugAdapter { } diff --git a/types/ember__debug/data-adapter.d.ts b/types/ember__debug/data-adapter.d.ts new file mode 100644 index 0000000000..bc86573991 --- /dev/null +++ b/types/ember__debug/data-adapter.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export default class DataAdapter extends Ember.DataAdapter {} diff --git a/types/ember__debug/ember__debug-tests.ts b/types/ember__debug/ember__debug-tests.ts new file mode 100644 index 0000000000..0fbdcbc174 --- /dev/null +++ b/types/ember__debug/ember__debug-tests.ts @@ -0,0 +1,45 @@ +import { runInDebug, warn, debug, assert, registerWarnHandler, registerDeprecationHandler } from "@ember/debug"; + +/** + * @ember/debug tests + */ +runInDebug(); // $ExpectError +runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void + +// Log a warning if we have more than 3 tomsters +const tomsterCount = 2; +warn('Too many tomsters!'); // $ExpectType void +warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void +warn('Too many tomsters!', tomsterCount <= 3, { // $ExpectType void + id: 'ember-debug.too-many-tomsters' +}); + +debug(); // $ExpectError +debug('Too many tomsters!'); // $ExpectType void +debug('Too many tomsters!', 'foo'); // $ExpectError + +// Test for truthiness +const str = 'hello'; +assert('Must pass a string', typeof str === 'string'); // $ExpectType void + +// Fail unconditionally +assert('This code path should never be run'); // $ExpectType void + +// next is not called, so no warnings get the default behavior +registerWarnHandler(); // $ExpectError +registerWarnHandler(() => {}); // $ExpectType void +registerWarnHandler((message, { id }, next) => { // $ExpectType void + message; // $ExpectType string + id; // $ExpectType string + next; // $ExpectType () => void +}); + +// next is not called, so no warnings get the default behavior +registerDeprecationHandler(); // $ExpectError +registerDeprecationHandler(() => {}); // $ExpectType void +registerDeprecationHandler((message, { id, until }, next) => { // $ExpectType void + message; // $ExpectType string + id; // $ExpectType string + until; // $ExpectType string + next; // $ExpectType () => void +}); diff --git a/types/ember__debug/index.d.ts b/types/ember__debug/index.d.ts new file mode 100644 index 0000000000..8f1352baff --- /dev/null +++ b/types/ember__debug/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for @ember/debug 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; +export const assert: typeof Ember.assert; +export const debug: typeof Ember.debug; +export const inspect: typeof Ember.inspect; +export const registerDeprecationHandler: typeof Ember.Debug.registerDeprecationHandler; +export const registerWarnHandler: typeof Ember.Debug.registerWarnHandler; +export const runInDebug: typeof Ember.runInDebug; +export const warn: typeof Ember.warn; diff --git a/types/ember__debug/tsconfig.json b/types/ember__debug/tsconfig.json new file mode 100644 index 0000000000..c7688e6861 --- /dev/null +++ b/types/ember__debug/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/debug": ["ember__debug"], + "@ember/debug/*": ["ember__debug/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "data-adapter.d.ts", + "container-debug-adapter.d.ts", + "ember__debug-tests.ts" + ] +} diff --git a/types/ember__debug/tslint.json b/types/ember__debug/tslint.json new file mode 100644 index 0000000000..1a60b8a5dd --- /dev/null +++ b/types/ember__debug/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": { } +} From d6387166ee52959b7298cce251fd9d0f45d7a30f Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 09:07:09 -0700 Subject: [PATCH 06/68] [ember] tests and type fixes for DataAdapter & ContainerDebugAdapter (#28801) * [ember] fix: runInDebug should return void fixes https://github.com/typed-ember/ember-cli-typescript/issues/284 * [ember] tests for DataAdapter and ContainerDebugAdapter * [ember] more specific observable handlers in tests From b4143a7b477e5ad4de5295e0b9ce2eff4e103e78 Mon Sep 17 00:00:00 2001 From: meikidd Date: Sat, 15 Sep 2018 00:08:17 +0800 Subject: [PATCH 07/68] fix: @types/video.js has no default export (#28776) * fix: @types/video.js has no default export related #28418 * change video.js version back to 7.2 --- types/video.js/index.d.ts | 3 ++- types/video.js/video.js-tests.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 1981528a55..09f9b28d0d 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -8,6 +8,7 @@ // Grzegorz Błaszczyk // Stéphane Roucheray // Adam Eisenreich +// Mei Qingguang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -32,7 +33,7 @@ * @return A player instance */ declare function videojs(id: any, options?: videojs.PlayerOptions, ready?: () => void): videojs.Player; -export = videojs; +export default videojs; export as namespace videojs; declare namespace videojs { diff --git a/types/video.js/video.js-tests.ts b/types/video.js/video.js-tests.ts index 7249d1601e..378a7150f3 100644 --- a/types/video.js/video.js-tests.ts +++ b/types/video.js/video.js-tests.ts @@ -1,4 +1,4 @@ -import * as videojs from 'video.js'; +import videojs from 'video.js'; videojs("example_video_1").ready(function() { // EXAMPLE: Start playing the video. From 82a2833b4e34f9280d758efa2cfbe35ec6ec8b71 Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 14 Sep 2018 09:10:16 -0700 Subject: [PATCH 08/68] [react-native] Fix declarations related to prop types e.g. requireNativeComponent (#28871) Fixes `requireNativeComponent`, which was conflating the type of PropTypes maps with the type of prop maps. That is, these are not of the same type: `{ x: PropTypes.string }` and `{ x: "hello" }`. Also fixes the type of the `ViewPropTypes` object. It is a map of PropTypes, not a single PropType. Additionally, made the types of the other PropType exports more precise instead of `PropType.any`. Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). If changing an existing definition: - [x] Provide a URL to documentation or source code which provides context for the suggested changes: **N/A** -- these are fixes - [x] Increase the version number in the header if appropriate. **N/A** - [x] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. **N/A** --- types/react-native/index.d.ts | 13 +++++++------ types/react-native/test/index.tsx | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index ad8abe57fd..98f6c92c3f 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -31,6 +31,7 @@ /// /// +import * as PropTypes from 'prop-types'; import * as React from 'react'; type Constructor = new(...args: any[]) => T; @@ -8936,7 +8937,7 @@ export const PixelRatio: PixelRatioStatic; export interface ComponentInterface

{ name?: string; displayName?: string; - propTypes: P; + propTypes: PropTypes.ValidationMap

; } /** @@ -8958,7 +8959,7 @@ export function requireNativeComponent

( viewName: string, componentInterface?: ComponentInterface

, extraConfig?: { nativeOnly?: any } -): React.ComponentClass

; +): React.ComponentClass>>; export function findNodeHandle( componentOrHandle: null | number | React.Component | React.ComponentClass @@ -9001,10 +9002,10 @@ export namespace addons { // // Prop Types // -export const ColorPropType: React.Requireable; -export const EdgeInsetsPropType: React.Requireable; -export const PointPropType: React.Requireable; -export const ViewPropTypes: React.Requireable; +export const ColorPropType: React.Validator; +export const EdgeInsetsPropType: React.Validator; +export const PointPropType: React.Validator; +export const ViewPropTypes: React.ValidationMap; declare global { function require(name: string): any; diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 8bc6757c48..b2b66ee2da 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -20,6 +20,7 @@ import { BackAndroid, BackHandler, Button, + ColorPropType, DataSourceAssetCallback, DeviceEventEmitterStatic, Dimensions, @@ -73,6 +74,7 @@ import { KeyboardAvoidingView, Modal, TimePickerAndroid, + ViewPropTypes, } from "react-native"; declare module "react-native" { @@ -186,13 +188,20 @@ const testNativeSyntheticEvent = (e: NativeSyntheticEvent): voi e.nativeEvent; } +type ElementProps = C extends React.Component ? P : never; + class CustomView extends React.Component { render() { return Custom View; } } -class Welcome extends React.Component { +class Welcome extends React.Component & { color: string }> { + static propTypes = { + ...ViewPropTypes, + color: ColorPropType, + }; + refs: { [key: string]: any; rootView: View; @@ -218,8 +227,9 @@ class Welcome extends React.Component { } render() { + const { color, ...props } = this.props; return ( - + Welcome to React Native To get started, edit index.ios.js From 8ce5ce4c30caf1740754e8dda68fa0fc18576ffd Mon Sep 17 00:00:00 2001 From: Sean O'Neill Date: Fri, 14 Sep 2018 12:10:35 -0400 Subject: [PATCH 09/68] add dateIcon type (#28862) --- types/react-widgets/lib/DateTimePicker.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/react-widgets/lib/DateTimePicker.d.ts b/types/react-widgets/lib/DateTimePicker.d.ts index 65a683b1fe..2823a95234 100644 --- a/types/react-widgets/lib/DateTimePicker.d.ts +++ b/types/react-widgets/lib/DateTimePicker.d.ts @@ -48,6 +48,10 @@ interface DateTimePickerProps extends ReactWidgetsCommonDropdownProps Date: Fri, 14 Sep 2018 18:11:39 +0200 Subject: [PATCH 10/68] [parity-pmr] Fix tests for ts@next (#28833) --- types/parity-pmr/parity-pmr-tests.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/parity-pmr/parity-pmr-tests.ts b/types/parity-pmr/parity-pmr-tests.ts index 03bcc3534d..4fbb2b31b4 100644 --- a/types/parity-pmr/parity-pmr-tests.ts +++ b/types/parity-pmr/parity-pmr-tests.ts @@ -17,9 +17,7 @@ format({}); // Invalid sub type // $ExpectError -format({ - messageType: 1 -}); +format({ messageType: 1 }); // $ExpectType PMRMessage parse(buffer); From 8722b52e269037032948342cc4ff3bec29e02e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= Date: Fri, 14 Sep 2018 18:21:12 +0200 Subject: [PATCH 11/68] [parity-poe] Fix tests for ts@next (#28831) --- types/parity-poe/parity-poe-tests.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/types/parity-poe/parity-poe-tests.ts b/types/parity-poe/parity-poe-tests.ts index c5b50d5189..fb9c267572 100644 --- a/types/parity-poe/parity-poe-tests.ts +++ b/types/parity-poe/parity-poe-tests.ts @@ -21,9 +21,7 @@ formatInbound({}); // Invalid sub type // $ExpectError -formatInbound({ - messageType: 1 -}); +formatInbound({ messageType: 1 }); /** * parseInbound tests @@ -52,9 +50,7 @@ formatOutbound({}); // Invalid sub type // $ExpectError -formatOutbound({ - messageType: 1 -}); +formatOutbound({ messageType: 1 }); /** * parseOutbound tests From 0a509d74e62fd369d04cf8147bf0bd98d51a2650 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 14 Sep 2018 19:22:20 +0300 Subject: [PATCH 12/68] screenfull: Fix general type. (#28815) --- types/screenfull/index.d.ts | 5 +++-- types/screenfull/screenfull-tests.ts | 32 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/types/screenfull/index.d.ts b/types/screenfull/index.d.ts index 26b9188bde..0ca3d642b9 100644 --- a/types/screenfull/index.d.ts +++ b/types/screenfull/index.d.ts @@ -1,11 +1,12 @@ -// Type definitions for screenfull.js 3.3.0 +// Type definitions for screenfull.js 3.3.3 // Project: https://github.com/sindresorhus/screenfull.js // Definitions by: Ilia Choly // lionelb // Joel Shepherd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.5 -declare var screenfull: IScreenfull; +declare var screenfull: IScreenfull | false; interface IScreenfullRaw { requestFullscreen?: string; diff --git a/types/screenfull/screenfull-tests.ts b/types/screenfull/screenfull-tests.ts index efb03da1ab..db6f2a1b25 100644 --- a/types/screenfull/screenfull-tests.ts +++ b/types/screenfull/screenfull-tests.ts @@ -1,40 +1,40 @@ import screenfull = require('screenfull'); function test_fullscreen_page() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.request(); } } function test_fullscreen_element() { var elem = document.getElementById('target'); - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.request(elem); } } function test_toggle() { var elem = document.getElementById('target'); - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.toggle(elem); } } function test_exit() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.request(); } document.getElementById('target').addEventListener('click', function () { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.exit(); } }) } function test_raw_detect_change() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { document.addEventListener(screenfull.raw.fullscreenchange, function () { - if (screenfull.isFullscreen) { + if (screenfull && screenfull.isFullscreen) { console.log('fullscreen'); } else { console.log('not fullscreen'); @@ -44,7 +44,7 @@ function test_raw_detect_change() { } function test_raw_error() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { document.addEventListener(screenfull.raw.fullscreenerror, function (event) { console.error('Failed to enable fullscreen', event); }); @@ -52,9 +52,9 @@ function test_raw_error() { } function test_detect_change() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.onchange(function () { - if (screenfull.isFullscreen) { + if (screenfull && screenfull.isFullscreen) { console.log('fullscreen'); } else { console.log('not fullscreen'); @@ -64,7 +64,7 @@ function test_detect_change() { } function test_detect_error() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.onerror(function (event) { console.error('Failed to enable fullscreen', event); }); @@ -72,9 +72,9 @@ function test_detect_error() { } function test_listener_on() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.on('change', function () { - if (screenfull.isFullscreen) { + if (screenfull && screenfull.isFullscreen) { console.log('fullscreen'); } else { console.log('not fullscreen'); @@ -87,9 +87,9 @@ function test_listener_on() { } function test_listener_off() { - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.off('change', function () { - if (screenfull.isFullscreen) { + if (screenfull && screenfull.isFullscreen) { console.log('fullscreen'); } else { console.log('not fullscreen'); @@ -103,7 +103,7 @@ function test_listener_off() { function test_access_element() { var elem = document.getElementById('target'); - if (screenfull.enabled) { + if (screenfull && screenfull.enabled) { screenfull.request(elem); if (elem !== screenfull.element) { alert('incorrect element property'); From 5f3d6a6b431ab084489862350889bef72d439e41 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 09:23:58 -0700 Subject: [PATCH 13/68] adds typings for the `elliptic` package (#28865) --- types/elliptic/elliptic-tests.ts | 47 +++++++++ types/elliptic/index.d.ts | 158 +++++++++++++++++++++++++++++++ types/elliptic/tsconfig.json | 23 +++++ types/elliptic/tslint.json | 3 + 4 files changed, 231 insertions(+) create mode 100644 types/elliptic/elliptic-tests.ts create mode 100644 types/elliptic/index.d.ts create mode 100644 types/elliptic/tsconfig.json create mode 100644 types/elliptic/tslint.json diff --git a/types/elliptic/elliptic-tests.ts b/types/elliptic/elliptic-tests.ts new file mode 100644 index 0000000000..d587be5e8d --- /dev/null +++ b/types/elliptic/elliptic-tests.ts @@ -0,0 +1,47 @@ +import elliptic = require('elliptic'); + +const ec = new elliptic.ec('secp256k1'); + +// Generate keys +const key = ec.genKeyPair(); + +// Sign the message's hash (input must be an array, or a hex-string) +const msgHash = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +const signature = key.sign(msgHash); + +// Export DER encoded signature in Array +const derSign = signature.toDER(); + +// Verify signature +console.log(key.verify(msgHash, derSign)); + +// CHECK WITH NO PRIVATE KEY + +const pubPoint = key.getPublic(); +const x = pubPoint.getX(); +const y = pubPoint.getY(); + +// Public Key MUST be either: +// 1) '04' + hex string of x + hex string of y; or +// 2) object with two hex string properties (x and y); or +// 3) object with two buffer properties (x and y) +const pub = pubPoint.encode('hex'); // case 1 +const aPub = { x: x.toString('hex'), y: y.toString('hex') }; // case 2 +const bPub = { x: x.toBuffer(), y: y.toBuffer() }; // case 3 +const cPub = { x: x.toArrayLike(Buffer), y: y.toArrayLike(Buffer) }; // case 3 + +// Import public key +const newKey = ec.keyFromPublic(pub, 'hex'); + +// Signature MUST be either: +// 1) DER-encoded signature as hex-string; or +// 2) DER-encoded signature as buffer; or +// 3) object with two hex-string properties (r and s); or +// 4) object with two buffer properties (r and s) + +// const signature = '3046022100...'; // case 1 +// const signature = new Buffer('...'); // case 2 +// const signature = { r: 'b1fc...', s: '9c42...' }; // case 3 + +// Verify signature +console.log(key.verify(msgHash, signature)); diff --git a/types/elliptic/index.d.ts b/types/elliptic/index.d.ts new file mode 100644 index 0000000000..f819d17497 --- /dev/null +++ b/types/elliptic/index.d.ts @@ -0,0 +1,158 @@ +// Type definitions for elliptic 6.4 +// Project: https://github.com/indutny/elliptic +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import BN = require('bn.js'); + +// incomplete typings +export const utils: any; +export const rand: any; +export const eddsa: any; + +export type BNInput = string | BN | number | Buffer | number[]; + +export const version: number; + +export namespace curve { + class BaseCurve { + constructor(type: string, conf: BaseCurve.BaseCurveOptions) + p: BN; + type: string; + red: any; // ? + zero: any; // ? + one: any; // ? + two: any; // ? + n: BN | undefined | null; + g: any; // ? + redN: any; // ? + decodePoint(bytes: any, enc: string): any; // ? + } + + namespace BaseCurve { + class BasePoint { + constructor(curve: any, type: string); + curve: any; + type: string; + precomputed: PrecomputedValues | null; + encode(enc: string, compact: boolean): BN; + encodeCompressed(enc: string): BN; + validate(): boolean; + precompute(power: number): BasePoint; + dblp(k: any): any; // ? + } + + interface BaseCurveOptions { + p: number | string | number[] | Buffer | BN; + prime?: BN | string; + n?: number | BN | Buffer; + g?: any; // ? + gRed?: any; // ? + } + + interface PrecomputedValues { + doubles: any; // ? + naf: any; // ? + beta: any; // ? + } + } +} + +export namespace curves { + class PresetCurve { + constructor(options: PresetCurve.Options) + type: string; + g: any; // ? + n: BN | undefined | null; + hash: any; // ? + } + + namespace PresetCurve { + interface Options { + type: string; + prime: string | null; + p: string; + a: string; + b: string; + n: string; + hash: any; + gRed: boolean; + g: any; // ? + beta?: string; + lambda?: string; + basis?: any; // ? + } + } +} + +export class ec { + constructor(options: string | curves.PresetCurve) + curve: any; + n: BN | undefined | null; + nh: any; + g: any; + hash: any; + + keyPair(options: ec.KeyPairOptions): ec.KeyPair; + keyFromPrivate(priv: Buffer | ec.KeyPair, enc?: string): ec.KeyPair; + keyFromPublic(pub: Buffer | ec.KeyPair, enc?: string): ec.KeyPair; + genKeyPair(options?: ec.GenKeyPairOptions): ec.KeyPair; + sign(msg: BNInput, key: Buffer | ec.KeyPair, enc: string, options?: ec.SignOptions): ec.Signature; + sign(msg: BNInput, key: Buffer | ec.KeyPair, options?: ec.SignOptions): ec.Signature; + verify(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, key: Buffer | ec.KeyPair, enc?: string): boolean; + recoverPubKey(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, j: number, enc?: string): any; + getKeyRecoveryParam(e: Error | undefined, signature: ec.Signature | ec.SignatureOptions, Q: BN, enc?: string): number; +} + +export namespace ec { + interface GenKeyPairOptions { + pers: any; + entropy: any; + persEnc?: string; + entropyEnc?: string; + } + + interface SignOptions { + pers: any; + persEnc?: string; + canonical?: boolean; + k?: BN; + } + + class KeyPair { + static fromPublic(ec: ec, pub: Buffer | KeyPair, enc?: string): KeyPair; + static fromPrivate(ec: ec, priv: Buffer | KeyPair, enc?: string): KeyPair; + constructor(ec: ec, options: KeyPairOptions) + ec: ec; + validate(): { readonly result: boolean, readonly reason: string }; + getPublic(compact: boolean, enc?: string): any; // ? + getPublic(enc?: string): any; // ? + getPrivate(enc?: 'hex'): Buffer | BN | string; + derive(pub: any): any; // ? + sign(msg: BNInput, enc: string, options?: SignOptions): Signature; + sign(msg: BNInput, options?: SignOptions): Signature; + verify(msg: BNInput, signature: Signature | SignatureOptions): boolean; + inspect(): string; + } + + class Signature { + constructor(options: SignatureOptions | Signature, enc?: string) + r: BN; + s: BN; + recoveryParam: number | null; + toDER(enc?: string | null): any; // ? + } + + interface SignatureOptions { + r: number; + s: number; + recoveryParam?: number; + } + + interface KeyPairOptions { + priv?: Buffer; + privEnc?: string; + pub?: Buffer; + pubEnc?: string; + } +} diff --git a/types/elliptic/tsconfig.json b/types/elliptic/tsconfig.json new file mode 100644 index 0000000000..505cd03374 --- /dev/null +++ b/types/elliptic/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "elliptic-tests.ts" + ] +} diff --git a/types/elliptic/tslint.json b/types/elliptic/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/elliptic/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 6e1f5ed8f742d607f4df8e1cffd190e8eed3271b Mon Sep 17 00:00:00 2001 From: Michael Nahkies Date: Fri, 14 Sep 2018 17:31:49 +0100 Subject: [PATCH 14/68] Create type definitions for native-toast@2.0 (#28855) * create type definitions for native-toast@2.0 * fix lint / write as external module --- types/native-toast/index.d.ts | 34 ++++++++++++++++++++++++ types/native-toast/native-toast-tests.ts | 20 ++++++++++++++ types/native-toast/tsconfig.json | 24 +++++++++++++++++ types/native-toast/tslint.json | 1 + 4 files changed, 79 insertions(+) create mode 100644 types/native-toast/index.d.ts create mode 100644 types/native-toast/native-toast-tests.ts create mode 100644 types/native-toast/tsconfig.json create mode 100644 types/native-toast/tslint.json diff --git a/types/native-toast/index.d.ts b/types/native-toast/index.d.ts new file mode 100644 index 0000000000..1b9e532255 --- /dev/null +++ b/types/native-toast/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for native-toast 2.0 +// Project: https://github.com/egoist/native-toast +// Definitions by: Michael Nahkies +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const toast: { + (options: ToastOptions): Toast, + success: (options: ToastOptions) => Toast, + warning: (options: ToastOptions) => Toast, + info: (options: ToastOptions) => Toast, + error: (options: ToastOptions) => Toast, +}; + +export default toast; + +export interface ToastOptions { + message?: string; + position?: "center" | "west" | "east" | "south" | "south-west" | "south-east" | "north" | "north-west" | "north-east"; + timeout?: number; + el?: HTMLElement; + rounded?: boolean; + type?: "success" | "warning" | "info" | "error"; + debug?: boolean; + edge?: boolean; + icon?: boolean; + closeOnClick?: boolean; + elements?: HTMLElement[]; +} + +export interface Toast { + show(): void; + hide(): void; + destroy(): void; +} diff --git a/types/native-toast/native-toast-tests.ts b/types/native-toast/native-toast-tests.ts new file mode 100644 index 0000000000..73d6890549 --- /dev/null +++ b/types/native-toast/native-toast-tests.ts @@ -0,0 +1,20 @@ +import toast, { Toast, ToastOptions } from "native-toast"; + +let t: Toast; + +t = toast({ + message: "Team created", + position: "north-east", + timeout: 5000, + type: "success", +}); + +t.hide(); +t.show(); + +const o: ToastOptions = { + message: "test", + position: "west" +}; + +toast.success(o); diff --git a/types/native-toast/tsconfig.json b/types/native-toast/tsconfig.json new file mode 100644 index 0000000000..d36ee00fd9 --- /dev/null +++ b/types/native-toast/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "native-toast-tests.ts" + ] +} diff --git a/types/native-toast/tslint.json b/types/native-toast/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/native-toast/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 211edbdab64e6f75126396e0dc7a6fa6cbbc3e76 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 09:32:21 -0700 Subject: [PATCH 15/68] [ember] refactor @ember/application types into their own package (#28846) * [ember] failing test - relax ObserverMethod property name arg * [ember] relax ObserverMethod property name arg * [ember] @ember/application types refactored into their own package --- types/ember-resolver/ember-resolver-tests.ts | 4 +- types/ember-resolver/index.d.ts | 6 +-- .../ember-resolver/v4/ember-resolver-tests.ts | 4 +- types/ember-resolver/v4/index.d.ts | 6 +-- types/ember__application/deprecations.d.ts | 4 ++ .../ember__application/globals-resolver.d.ts | 3 ++ types/ember__application/index.d.ts | 13 ++++++ types/ember__application/instance.d.ts | 3 ++ types/ember__application/resolver.d.ts | 3 ++ .../test/application-instance.ts | 29 +++++++++++++ types/ember__application/test/application.ts | 41 +++++++++++++++++++ types/ember__application/test/deprecations.ts | 14 +++++++ .../test/globals-resolver.ts | 6 +++ types/ember__application/test/resolver.ts | 3 ++ types/ember__application/tsconfig.json | 37 +++++++++++++++++ types/ember__application/tslint.json | 4 ++ 16 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 types/ember__application/deprecations.d.ts create mode 100644 types/ember__application/globals-resolver.d.ts create mode 100644 types/ember__application/index.d.ts create mode 100644 types/ember__application/instance.d.ts create mode 100644 types/ember__application/resolver.d.ts create mode 100644 types/ember__application/test/application-instance.ts create mode 100755 types/ember__application/test/application.ts create mode 100644 types/ember__application/test/deprecations.ts create mode 100644 types/ember__application/test/globals-resolver.ts create mode 100644 types/ember__application/test/resolver.ts create mode 100644 types/ember__application/tsconfig.json create mode 100644 types/ember__application/tslint.json diff --git a/types/ember-resolver/ember-resolver-tests.ts b/types/ember-resolver/ember-resolver-tests.ts index d22a0d31be..6973daeda0 100644 --- a/types/ember-resolver/ember-resolver-tests.ts +++ b/types/ember-resolver/ember-resolver-tests.ts @@ -1,5 +1,5 @@ -import Application from '@ember/application'; import EmberResolver from 'ember-resolver'; +import { Ember } from 'ember'; const MyResolver = EmberResolver.extend({ pluralizedTypes: { @@ -7,6 +7,6 @@ const MyResolver = EmberResolver.extend({ } }); -const App = Application.extend({ +const App = Ember.Application.extend({ Resolver: MyResolver }); diff --git a/types/ember-resolver/index.d.ts b/types/ember-resolver/index.d.ts index 4fe466ae13..f2ede7fe32 100644 --- a/types/ember-resolver/index.d.ts +++ b/types/ember-resolver/index.d.ts @@ -5,11 +5,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -/// - -import Resolver from '@ember/application/resolver'; +import Ember from 'ember'; /** * An Ember `Resolver` implementation used by ember-cli. */ -export default class EmberResolver extends Resolver {} +export default class EmberResolver extends Ember.Resolver {} diff --git a/types/ember-resolver/v4/ember-resolver-tests.ts b/types/ember-resolver/v4/ember-resolver-tests.ts index d22a0d31be..db834b1985 100644 --- a/types/ember-resolver/v4/ember-resolver-tests.ts +++ b/types/ember-resolver/v4/ember-resolver-tests.ts @@ -1,4 +1,4 @@ -import Application from '@ember/application'; +import Ember from 'ember'; import EmberResolver from 'ember-resolver'; const MyResolver = EmberResolver.extend({ @@ -7,6 +7,6 @@ const MyResolver = EmberResolver.extend({ } }); -const App = Application.extend({ +const App = Ember.Application.extend({ Resolver: MyResolver }); diff --git a/types/ember-resolver/v4/index.d.ts b/types/ember-resolver/v4/index.d.ts index 8047dc1bc2..fd5359cff4 100644 --- a/types/ember-resolver/v4/index.d.ts +++ b/types/ember-resolver/v4/index.d.ts @@ -5,11 +5,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -/// - -import Resolver from '@ember/application/resolver'; +import Ember from 'ember'; /** * An Ember `Resolver` implementation used by ember-cli. */ -export default class EmberResolver extends Resolver {} +export default class EmberResolver extends Ember.Resolver {} diff --git a/types/ember__application/deprecations.d.ts b/types/ember__application/deprecations.d.ts new file mode 100644 index 0000000000..608ba5c7f7 --- /dev/null +++ b/types/ember__application/deprecations.d.ts @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export const deprecate: typeof Ember.deprecate; +export const deprecateFunc: typeof Ember.deprecateFunc; diff --git a/types/ember__application/globals-resolver.d.ts b/types/ember__application/globals-resolver.d.ts new file mode 100644 index 0000000000..e51f4681ed --- /dev/null +++ b/types/ember__application/globals-resolver.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export default class GlobalsResolver extends Ember.DefaultResolver { } diff --git a/types/ember__application/index.d.ts b/types/ember__application/index.d.ts new file mode 100644 index 0000000000..cdef372444 --- /dev/null +++ b/types/ember__application/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for @ember/application 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +export default class Application extends Ember.Application { } +export const getOwner: typeof Ember.getOwner; +export const onLoad: typeof Ember.onLoad; +export const runLoadHooks: typeof Ember.runLoadHooks; +export const setOwner: typeof Ember.setOwner; diff --git a/types/ember__application/instance.d.ts b/types/ember__application/instance.d.ts new file mode 100644 index 0000000000..0d01298d52 --- /dev/null +++ b/types/ember__application/instance.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export default class ApplicationInstance extends Ember.ApplicationInstance { } diff --git a/types/ember__application/resolver.d.ts b/types/ember__application/resolver.d.ts new file mode 100644 index 0000000000..a218fcd3e7 --- /dev/null +++ b/types/ember__application/resolver.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export default class Resolver extends Ember.Resolver { } diff --git a/types/ember__application/test/application-instance.ts b/types/ember__application/test/application-instance.ts new file mode 100644 index 0000000000..4ee5cb2027 --- /dev/null +++ b/types/ember__application/test/application-instance.ts @@ -0,0 +1,29 @@ +import ApplicationInstance from '@ember/application/instance'; +import hbs from 'htmlbars-inline-precompile'; + +const appInstance = ApplicationInstance.create(); +appInstance.register('some:injection', class Foo {}); + +appInstance.register('some:injection', class Foo {}, { + singleton: true, +}); + +appInstance.register('some:injection', class Foo {}, { + instantiate: false, +}); + +appInstance.register('templates:foo/bar', hbs`

Hello World

`); + +appInstance.register('some:injection', class Foo {}, { + singleton: false, + instantiate: true, +}); + +appInstance.factoryFor('router:main'); +appInstance.lookup('route:basic'); + +appInstance.boot(); + +(async () => { + await appInstance.boot(); +})(); diff --git a/types/ember__application/test/application.ts b/types/ember__application/test/application.ts new file mode 100755 index 0000000000..21d0237b71 --- /dev/null +++ b/types/ember__application/test/application.ts @@ -0,0 +1,41 @@ +import Application from "@ember/application"; +import EmberObject from "@ember/object"; + +const BaseApp = Application.extend({ + modulePrefix: 'my-app' +}); + +BaseApp.initializer({ + name: 'my-initializer', + initialize(app) { + app.register('foo:bar', EmberObject.extend({ foo: 'bar' })); + } +}); + +BaseApp.instanceInitializer({ + name: 'my-instance-initializer', + initialize(app) { + app.lookup('foo:bar').get('foo'); + } +}); + +const App1 = BaseApp.create({ + rootElement: '#app-one', + customEvents: { + paste: 'paste' + } +}); + +const App2 = BaseApp.create({ + rootElement: '#app-two', + customEvents: { + mouseenter: null, + mouseleave: null + } +}); + +const App3 = BaseApp.create(); + +const App3Instance1 = App3.buildInstance(); // $ExpectType ApplicationInstance + +const App3Instance2 = App3.buildInstance({ foo: 'bar' }); // $ExpectType ApplicationInstance diff --git a/types/ember__application/test/deprecations.ts b/types/ember__application/test/deprecations.ts new file mode 100644 index 0000000000..12639ad0b5 --- /dev/null +++ b/types/ember__application/test/deprecations.ts @@ -0,0 +1,14 @@ +import { deprecate, deprecateFunc } from '@ember/application/deprecations'; + +deprecate('this is no longer advised', false, { + id: 'no-longer-advised', + until: 'v4.0' +}); +deprecate('this is no longer advised', false); + +deprecateFunc('this is no longer advised', () => {}); +deprecateFunc( + 'this is no longer advised', + { id: 'no-longer-do-this', until: 'v4.0' }, + () => {} +); diff --git a/types/ember__application/test/globals-resolver.ts b/types/ember__application/test/globals-resolver.ts new file mode 100644 index 0000000000..c0efb5579b --- /dev/null +++ b/types/ember__application/test/globals-resolver.ts @@ -0,0 +1,6 @@ +import GlobalsResolver from "@ember/application/globals-resolver"; + +const gr = GlobalsResolver.create(); + +gr.resolve('App.IndexController'); +gr.resolve(); // $ExpectError diff --git a/types/ember__application/test/resolver.ts b/types/ember__application/test/resolver.ts new file mode 100644 index 0000000000..20413aa5a4 --- /dev/null +++ b/types/ember__application/test/resolver.ts @@ -0,0 +1,3 @@ +import Resolver from "@ember/application/resolver"; + +const res = Resolver.create(); diff --git a/types/ember__application/tsconfig.json b/types/ember__application/tsconfig.json new file mode 100644 index 0000000000..833859d183 --- /dev/null +++ b/types/ember__application/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "deprecations.d.ts", + "globals-resolver.d.ts", + "index.d.ts", + "instance.d.ts", + "resolver.d.ts", + "test/application.ts", + "test/deprecations.ts", + "test/resolver.ts", + "test/globals-resolver.ts", + "test/application-instance.ts" + ] +} diff --git a/types/ember__application/tslint.json b/types/ember__application/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/ember__application/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} From 6eafee412d40b91fbaa728ccd9aab5844b9fe4bf Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 09:33:08 -0700 Subject: [PATCH 16/68] adds typings for the 'memdown' package (#28832) --- types/memdown/index.d.ts | 20 ++++++++++++++++++++ types/memdown/memdown-tests.ts | 16 ++++++++++++++++ types/memdown/tsconfig.json | 23 +++++++++++++++++++++++ types/memdown/tslint.json | 3 +++ 4 files changed, 62 insertions(+) create mode 100644 types/memdown/index.d.ts create mode 100644 types/memdown/memdown-tests.ts create mode 100644 types/memdown/tsconfig.json create mode 100644 types/memdown/tslint.json diff --git a/types/memdown/index.d.ts b/types/memdown/index.d.ts new file mode 100644 index 0000000000..ab7b8dfe36 --- /dev/null +++ b/types/memdown/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for memdown 3.0 +// Project: https://github.com/Level/memdown +// Definitions by: Meirion Hughes +// Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { AbstractLevelDOWN } from 'abstract-leveldown'; + +export interface MemDown extends AbstractLevelDOWN {} + +export interface MemDownConstructor { + // tslint:disable-next-line no-unnecessary-generics + new (): MemDown; + // tslint:disable-next-line no-unnecessary-generics + (): MemDown; +} + +export const MemDown: MemDownConstructor; +export default MemDown; diff --git a/types/memdown/memdown-tests.ts b/types/memdown/memdown-tests.ts new file mode 100644 index 0000000000..f93a4bb779 --- /dev/null +++ b/types/memdown/memdown-tests.ts @@ -0,0 +1,16 @@ +import MemDown from 'memdown'; + +const test = (db: MemDown) => { + db.open(() => { + db.put("key", "value", (err?: Error) => { }); + db.get("key", (err?: Error) => { }); + db.get("key", (err: Error | undefined, value: string) => { }); + db.close(() => {}); + }); +}; + +// doesn't need `new` and can be called as a function +test(new MemDown()); +test(new MemDown()); +test(MemDown()); +test(MemDown()); diff --git a/types/memdown/tsconfig.json b/types/memdown/tsconfig.json new file mode 100644 index 0000000000..dd3aa17b6c --- /dev/null +++ b/types/memdown/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "memdown-tests.ts" + ] +} \ No newline at end of file diff --git a/types/memdown/tslint.json b/types/memdown/tslint.json new file mode 100644 index 0000000000..256ee54775 --- /dev/null +++ b/types/memdown/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From fcfdccd4c31783fc81adec839312125c30bdb636 Mon Sep 17 00:00:00 2001 From: Vinicius Carvalho Date: Fri, 14 Sep 2018 13:36:07 -0300 Subject: [PATCH 17/68] Update index.d.ts (#28575) According #28574, the FakerStatic interface must have optional parameters in the system. --- types/faker/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/faker/index.d.ts b/types/faker/index.d.ts index 248a0ba96c..a9d044cfcb 100644 --- a/types/faker/index.d.ts +++ b/types/faker/index.d.ts @@ -201,8 +201,8 @@ declare namespace Faker { }; system: { - fileName(ext: string, type: string): string; - commonFileName(ext: string, type: string): string; + fileName(ext?: string, type?: string): string; + commonFileName(ext: string, type?: string): string; mimeType(): string; commonFileType(): string; commonFileExt(): string; From 7050908e2f6d44b0e7553157dc4da93b6f0b7661 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 09:36:27 -0700 Subject: [PATCH 18/68] changes type of `key` from ReadonlyArray to string (#28823) --- types/scrypt-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/scrypt-js/index.d.ts b/types/scrypt-js/index.d.ts index fde3c0a444..e3ee7fa68f 100644 --- a/types/scrypt-js/index.d.ts +++ b/types/scrypt-js/index.d.ts @@ -15,7 +15,7 @@ declare function scrypt( callback: ( error: Error | undefined | null, progress: number, - key?: ReadonlyArray, + key?: string, ) => void ): void; From b49e87cd192f2eb2c0369c1ee723f5cb0d0c8222 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 09:45:37 -0700 Subject: [PATCH 19/68] [ember] @ember/array types refactored into their own package (#28836) --- types/ember__array/index.d.ts | 13 +++++ types/ember__array/mutable.d.ts | 5 ++ types/ember__array/proxy.d.ts | 3 + types/ember__array/test/array-ext.ts | 22 ++++++++ types/ember__array/test/array-proxy.ts | 27 +++++++++ types/ember__array/test/array.ts | 56 +++++++++++++++++++ types/ember__array/test/lib/assert.ts | 5 ++ types/ember__array/tsconfig.json | 35 ++++++++++++ types/ember__array/tslint.json | 4 ++ .../types/prototype-extensions.d.ts | 3 + 10 files changed, 173 insertions(+) create mode 100644 types/ember__array/index.d.ts create mode 100644 types/ember__array/mutable.d.ts create mode 100644 types/ember__array/proxy.d.ts create mode 100755 types/ember__array/test/array-ext.ts create mode 100644 types/ember__array/test/array-proxy.ts create mode 100755 types/ember__array/test/array.ts create mode 100755 types/ember__array/test/lib/assert.ts create mode 100644 types/ember__array/tsconfig.json create mode 100644 types/ember__array/tslint.json create mode 100644 types/ember__array/types/prototype-extensions.d.ts diff --git a/types/ember__array/index.d.ts b/types/ember__array/index.d.ts new file mode 100644 index 0000000000..991f7961f2 --- /dev/null +++ b/types/ember__array/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for @ember/array 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +type EmberArray = Ember.Array; +export const EmberArray: typeof Ember.Array; +export default EmberArray; +export const A: typeof Ember.A; +export const isArray: typeof Ember.isArray; diff --git a/types/ember__array/mutable.d.ts b/types/ember__array/mutable.d.ts new file mode 100644 index 0000000000..a477c92f69 --- /dev/null +++ b/types/ember__array/mutable.d.ts @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +type MutableArray = Ember.MutableArray; +export const MutableArray: typeof Ember.MutableArray; +export default MutableArray; diff --git a/types/ember__array/proxy.d.ts b/types/ember__array/proxy.d.ts new file mode 100644 index 0000000000..ced7b5c14c --- /dev/null +++ b/types/ember__array/proxy.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export default class ArrayProxy extends Ember.ArrayProxy { } diff --git a/types/ember__array/test/array-ext.ts b/types/ember__array/test/array-ext.ts new file mode 100755 index 0000000000..72e9098100 --- /dev/null +++ b/types/ember__array/test/array-ext.ts @@ -0,0 +1,22 @@ +import { assertType } from './lib/assert'; +import EmberObject from '@ember/object'; +import { ArrayPrototypeExtensions } from '@ember/array/types/prototype-extensions'; + +declare global { + interface Array extends ArrayPrototypeExtensions {} +} + +class Person extends EmberObject { + name: string; +} + +const person = Person.create({ name: 'Joe' }); +const array = [person]; + +assertType(array.get('length')); +assertType(array.get('firstObject')); +assertType(array.mapBy('name')); +assertType(array.map(p => p.get('name'))); +assertType(array.sortBy('name')); +assertType(array.uniq()); +assertType(array.uniqBy('name')); diff --git a/types/ember__array/test/array-proxy.ts b/types/ember__array/test/array-proxy.ts new file mode 100644 index 0000000000..f4ca116e14 --- /dev/null +++ b/types/ember__array/test/array-proxy.ts @@ -0,0 +1,27 @@ +import { assertType } from './lib/assert'; +import ArrayProxy from '@ember/array/proxy'; +import { A } from '@ember/array'; + +const pets = ['dog', 'cat', 'fish']; +const proxy = ArrayProxy.create({ content: A(pets) }); + +proxy.get('firstObject'); // 'dog' +proxy.set('content', A(['amoeba', 'paramecium'])); +proxy.get('firstObject'); // 'amoeba' + +const overridden = ArrayProxy.create({ + content: A(pets), + objectAtContent(idx: number): string { + return this.get('content').objectAt(idx)!.toUpperCase(); + } +}); + +overridden.get('firstObject'); // 'DOG' + +class MyNewProxy extends ArrayProxy { + isNew = true; +} + +const x = MyNewProxy.create({ content: A([1, 2, 3]) }) as MyNewProxy; +assertType(x.get('firstObject')); +assertType(x.isNew); diff --git a/types/ember__array/test/array.ts b/types/ember__array/test/array.ts new file mode 100755 index 0000000000..5d578e4319 --- /dev/null +++ b/types/ember__array/test/array.ts @@ -0,0 +1,56 @@ +import { assertType } from './lib/assert'; +import EmberObject from '@ember/object'; +import EmberArray, { A } from '@ember/array'; +import MutableArray from '@ember/array/mutable'; + +type Person = typeof Person.prototype; +const Person = EmberObject.extend({ + name: '', + isHappy: false +}); + +const people = A([ + Person.create({ name: 'Yehuda', isHappy: true }), + Person.create({ name: 'Majd', isHappy: false }), +]); + +assertType(people.get('length')); +assertType(people.get('lastObject')); +assertType(people.get('firstObject')); +assertType(people.isAny('isHappy')); +assertType(people.isAny('isHappy', 'false')); + +const persons1: Person[] = people.filterBy('isHappy'); +const persons2: MutableArray = people.filterBy('isHappy'); +const persons3: Person[] = people.rejectBy('isHappy'); +const persons4: MutableArray = people.rejectBy('isHappy'); +const persons5: Person[] = people.filter((person) => person.get('name') === 'Yehuda'); +const persons6: MutableArray = people.filter((person) => person.get('name') === 'Yehuda'); + +assertType(people.get('[]')); +assertType(people.get('[]').get('firstObject')); // $ExpectType any + +assertType>(people.mapBy('isHappy')); // $ExpectType Array +assertType(people.mapBy('name.length')); + +const last = people.get('lastObject'); // $ExpectType ({ name: string; isHappy: boolean; } & EmberObject & { name: string; isHappy: boolean; }) | undefined +if (last) { + assertType(last.get('name')); +} + +const first = people.get('lastObject'); +if (first) { + assertType(first.get('isHappy')); +} + +const letters: EmberArray = A(['a', 'b', 'c']); +const codes: number[] = letters.map((item, index, enumerable) => { + assertType(item); + assertType(index); + return item.charCodeAt(0); +}); + +const value = '1,2,3'; +const filters = A(value.split(',')); +filters.push('4'); +filters.sort(); diff --git a/types/ember__array/test/lib/assert.ts b/types/ember__array/test/lib/assert.ts new file mode 100755 index 0000000000..262d18bc2c --- /dev/null +++ b/types/ember__array/test/lib/assert.ts @@ -0,0 +1,5 @@ +/** Static assertion that `value` has type `T` */ +// Disable tslint here b/c the generic is used to let us do a type coercion and +// validate that coercion works for the type value "passed into" the function. +// tslint:disable-next-line:no-unnecessary-generics +export declare function assertType(value: T): T; diff --git a/types/ember__array/tsconfig.json b/types/ember__array/tsconfig.json new file mode 100644 index 0000000000..e6c8d509e0 --- /dev/null +++ b/types/ember__array/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/array": ["ember__array"], + "@ember/array/*": ["ember__array/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mutable.d.ts", + "proxy.d.ts", + "types/prototype-extensions.d.ts", + "test/lib/assert.ts", + "test/array.ts", + "test/array-ext.ts", + "test/array-proxy.ts" + ] +} diff --git a/types/ember__array/tslint.json b/types/ember__array/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/ember__array/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} diff --git a/types/ember__array/types/prototype-extensions.d.ts b/types/ember__array/types/prototype-extensions.d.ts new file mode 100644 index 0000000000..a6197166ef --- /dev/null +++ b/types/ember__array/types/prototype-extensions.d.ts @@ -0,0 +1,3 @@ +import Ember from 'ember'; + +export interface ArrayPrototypeExtensions extends Ember.MutableArray, Ember.Observable, Ember.Copyable {} From 8f134e436f5562fbd08d13dd8b9783c444fa67e6 Mon Sep 17 00:00:00 2001 From: aldentaylor Date: Fri, 14 Sep 2018 09:48:11 -0700 Subject: [PATCH 20/68] feat(jest-when): types for jest-when at https://github.com/timkindberg/jest-when (#28773) --- types/jest-when/index.d.ts | 22 ++++++++++++ types/jest-when/jest-when-tests.ts | 57 ++++++++++++++++++++++++++++++ types/jest-when/tsconfig.json | 23 ++++++++++++ types/jest-when/tslint.json | 1 + 4 files changed, 103 insertions(+) create mode 100644 types/jest-when/index.d.ts create mode 100644 types/jest-when/jest-when-tests.ts create mode 100644 types/jest-when/tsconfig.json create mode 100644 types/jest-when/tslint.json diff --git a/types/jest-when/index.d.ts b/types/jest-when/index.d.ts new file mode 100644 index 0000000000..af62a95830 --- /dev/null +++ b/types/jest-when/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for jest-when 1.1 +// Project: https://github.com/timkindberg/jest-when#readme +// Definitions by: Alden Taylor +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export interface PartialMockInstance { + mockReturnValue: jest.MockInstance['mockReturnValue']; +} + +export interface When { + (fn: jest.Mocked | jest.Mock): When; + // due to no-unnecessary-generics lint rule, the generics have been replaced with 'any' + // calledWith(...matchers: any[]): PartialMockInstance; + // expectCalledWith(...matchers: any[]): PartialMockInstance; + calledWith(...matchers: any[]): PartialMockInstance; + expectCalledWith(...matchers: any[]): PartialMockInstance; +} + +export const when: When; diff --git a/types/jest-when/jest-when-tests.ts b/types/jest-when/jest-when-tests.ts new file mode 100644 index 0000000000..13da65928d --- /dev/null +++ b/types/jest-when/jest-when-tests.ts @@ -0,0 +1,57 @@ +import { when } from 'jest-when'; + +describe('mock-when test', () => { + it('basic usage:', () => { + const fn = jest.fn(); + when(fn).calledWith(1).mockReturnValue('yay!'); + + const result = fn(1); + expect(result).toEqual('yay!'); + }); + + it('Supports multiple args:', () => { + const fn = jest.fn(); + when(fn).calledWith(1, true, 'foo').mockReturnValue('yay!'); + + const result = fn(1, true, 'foo'); + expect(result).toEqual('yay!'); + }); + + it('Supports jest matchers:', () => { + const fn = jest.fn(); + when(fn).calledWith( + expect.anything(), + expect.any(Number), + expect.arrayContaining([false]) + ).mockReturnValue('yay!'); + + const result = fn('whatever', 100, [true, false]); + expect(result).toEqual('yay!'); + }); + + it('Supports compound declarations:', () => { + const fn = jest.fn(); + when(fn).calledWith(1).mockReturnValue('no'); + when(fn).calledWith(2).mockReturnValue('way?'); + when(fn).calledWith(3).mockReturnValue('yes'); + when(fn).calledWith(4).mockReturnValue('way!'); + + expect(fn(1)).toEqual('no'); + expect(fn(2)).toEqual('way?'); + expect(fn(3)).toEqual('yes'); + expect(fn(4)).toEqual('way!'); + expect(fn(5)).toEqual(undefined); + }); + + it('Assert the args:', () => { + const fn = jest.fn(); + when(fn).expectCalledWith(1).mockReturnValue('x'); + let testPassed = false; + try { + fn(2); // Will throw a helpful jest assertion error with args diff + } catch (e) { + testPassed = true; + } + expect(testPassed).toBeTruthy(); + }); +}); diff --git a/types/jest-when/tsconfig.json b/types/jest-when/tsconfig.json new file mode 100644 index 0000000000..46c037813f --- /dev/null +++ b/types/jest-when/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jest-when-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jest-when/tslint.json b/types/jest-when/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jest-when/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From dde8922b4cecd2545dbf3d114ab53aae84db5381 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Fri, 14 Sep 2018 18:48:37 +0200 Subject: [PATCH 21/68] redux-little-routers: remove typings, they are now upstream (#28681) See https://github.com/FormidableLabs/redux-little-router/pull/269 --- notNeededPackages.json | 6 + types/redux-little-router/index.d.ts | 171 ------------------ types/redux-little-router/package.json | 6 - .../redux-little-router-tests.tsx | 93 ---------- types/redux-little-router/tsconfig.json | 25 --- types/redux-little-router/tslint.json | 1 - 6 files changed, 6 insertions(+), 296 deletions(-) delete mode 100644 types/redux-little-router/index.d.ts delete mode 100644 types/redux-little-router/package.json delete mode 100644 types/redux-little-router/redux-little-router-tests.tsx delete mode 100644 types/redux-little-router/tsconfig.json delete mode 100644 types/redux-little-router/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index e0e880c3e6..e1a2f2e6cd 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1278,6 +1278,12 @@ "sourceRepoURL": "https://github.com/zalmoxisus/redux-devtools-extension", "asOfVersion": "2.13.2" }, + { + "libraryName": "redux-little-router", + "typingsPackageName": "redux-little-router", + "sourceRepoURL": "https://github.com/FormidableLabs/redux-little-router", + "asOfVersion": "15.1.0" + }, { "libraryName": "redux-persist", "typingsPackageName": "redux-persist", diff --git a/types/redux-little-router/index.d.ts b/types/redux-little-router/index.d.ts deleted file mode 100644 index 5ea39ce138..0000000000 --- a/types/redux-little-router/index.d.ts +++ /dev/null @@ -1,171 +0,0 @@ -// Type definitions for redux-little-router 14.0 -// Project: https://github.com/FormidableLabs/redux-little-router -// Definitions by: priecint -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 - -import * as React from "react"; -import { Reducer, Middleware, StoreEnhancer } from "redux"; - -export interface Routes { - [index: string]: RouteDefinition; -} - -export interface RouteDefinition { - [index: string]: string | RouteDefinition; -} - -export interface LocationOptions { - persistQuery?: boolean; -} - -export interface Query { - [key: string]: string; -} - -export interface Params { - [key: string]: string; -} - -export interface Location { - pathname?: string; - options?: LocationOptions; - params?: Params; - previous?: Location; - query?: Query; - result?: TResult; - hash?: string; -} - -export interface BrowserRouterOptions { - routes: Routes; - basename?: string; -} - -export interface RouterState { - router: Location; -} - -export function routerForBrowser(options: BrowserRouterOptions): { - reducer: Reducer; - middleware: Middleware; - enhancer: StoreEnhancer; -}; - -export interface ServerRouterOptions { - routes: Routes; - request: { - path: string; - baseUrl: string; - url: string; - query: { - [key: string]: string; - } - }; -} - -export function routerForExpress(options: ServerRouterOptions): { - reducer: Reducer; - middleware: Middleware; - enhancer: StoreEnhancer; -}; - -export interface HapiRouterOptions { - routes: Routes; - request: { - path: string; - url: string; - query: { - [key: string]: string; - } - }; -} - -export function routerForHapi(options: HapiRouterOptions): { - reducer: Reducer; - middleware: Middleware; - enhancer: StoreEnhancer; -}; - -export function initializeCurrentLocation(location: Location): { - type: string; - payload: Location; -}; - -export interface PersistentQueryLinkProps { - className?: string; - href: Href; - persistQuery?: boolean; - target?: string; - onClick?: React.EventHandler>; -} - -export interface LinkProps extends PersistentQueryLinkProps { - replaceState?: boolean; -} - -export class Link extends React.Component { -} - -export class PersistentQueryLink extends React.Component { -} - -export interface FragmentPropsForRoute { - forRoute: string; -} - -export interface FragmentPropsWithConditions { - withConditions: (location: Location) => boolean; -} - -// https://stackoverflow.com/q/37688318 -export type FragmentProps = FragmentPropsForRoute | FragmentPropsWithConditions | (FragmentPropsForRoute & FragmentPropsWithConditions); - -export class Fragment extends React.Component { -} - -export type Href = string | Location; - -export function push(href: Href, options?: LocationOptions): { - type: string; - payload: Location & { - state: { - reduxLittleRouter: { - query: {}; - options: LocationOptions; - }; - }; - }; -}; - -export function replace(href: Href, options?: LocationOptions): { - type: string; - payload: Location & { - state: { - reduxLittleRouter: { - query: {}; - options: LocationOptions; - }; - }; - }; -}; - -export function go(index: number): { - type: string; - payload: number; -}; - -export function goBack(): { - type: string; -}; - -export function goForward(): { - type: string; -}; - -export const LOCATION_CHANGED: string; -export const PUSH: string; -export const REPLACE: string; -export const GO: string; -export const GO_BACK: string; -export const GO_FORWARD: string; diff --git a/types/redux-little-router/package.json b/types/redux-little-router/package.json deleted file mode 100644 index 6d68bf2f9b..0000000000 --- a/types/redux-little-router/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "redux": "^3.6.0" - } -} diff --git a/types/redux-little-router/redux-little-router-tests.tsx b/types/redux-little-router/redux-little-router-tests.tsx deleted file mode 100644 index ad65cc399d..0000000000 --- a/types/redux-little-router/redux-little-router-tests.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import * as React from "react"; -import { createStore, compose, combineReducers, applyMiddleware, Reducer, Dispatch } from "redux"; -import { connect } from "react-redux"; - -import { - Fragment, - go, - GO, - GO_BACK, - GO_FORWARD, - goBack, - goForward, - Href, - initializeCurrentLocation, - Link, - Location, - LOCATION_CHANGED, - LocationOptions, - Params, - push, - PUSH, - replace, - REPLACE, - routerForBrowser, - RouterState -} from "redux-little-router"; - -const goBackActionType: string = GO_BACK; -const goForwardActionType: string = GO_FORWARD; -const locationChangedActionType: string = LOCATION_CHANGED; -const pushActionType: string = PUSH; -const replaceActionType: string = REPLACE; - -const { - reducer, - middleware, - enhancer -} = routerForBrowser({ - routes: { - "/": { - title: "Home" - } - } -}); - -const store = createStore( - combineReducers({ router: reducer }), - { router: {} }, - compose(enhancer, applyMiddleware(middleware)) -); - -const initialLocation = store.getState().router; - -if (initialLocation) { - store.dispatch(initializeCurrentLocation(initialLocation)); -} - -interface TestProps { - currentPath?: string; -} - -interface DispatchProps { - go: (index: number) => void; - goBack: () => void; - goForward: () => void; - push: (path: string) => void; - replace: (path: string) => void; -} - -const TestComponent: React.SFC = ({ currentPath }) => ( -
- -
- Current Path: {currentPath} - -
-
-
-); - -const mapStateToProps = (state: RouterState): TestProps => ({ - currentPath: state.router.pathname -}); - -const mapDispatchToProps = (dispatch: Dispatch<{}>): DispatchProps => ({ - go: index => dispatch(go(index)), - goBack: () => dispatch(goBack()), - goForward: () => dispatch(goForward()), - push: path => dispatch(push(path)), - replace: path => dispatch(replace(path)) -}); - -const connectedTest = connect(mapStateToProps)(TestComponent); diff --git a/types/redux-little-router/tsconfig.json b/types/redux-little-router/tsconfig.json deleted file mode 100644 index 30884e8741..0000000000 --- a/types/redux-little-router/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "jsx": "react", - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "redux-little-router-tests.tsx" - ] -} \ No newline at end of file diff --git a/types/redux-little-router/tslint.json b/types/redux-little-router/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/redux-little-router/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From bb215703f2561cc8b940c9e7cd59bccc7f7b3015 Mon Sep 17 00:00:00 2001 From: Kanitkorn Sujautra Date: Fri, 14 Sep 2018 23:52:00 +0700 Subject: [PATCH 22/68] [react-intl] Add missing children props to formatting components (#28738) Ref: https://github.com/yahoo/react-intl/wiki/Components#date-formatting-components https://github.com/yahoo/react-intl/wiki/Components#number-formatting-components --- types/react-intl/index.d.ts | 6 + types/react-intl/react-intl-tests.tsx | 210 +++++++++++++++++--------- 2 files changed, 144 insertions(+), 72 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index c1dff99d71..899859a69d 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -8,6 +8,7 @@ // Brian Houser , // Krister Kari // Martin Raedlinger +// Kanitkorn Sujautra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -94,6 +95,7 @@ declare namespace ReactIntl { interface Props extends PropsBase { value: DateSource; + children?: (formattedDate: string) => React.ReactNode; } } @@ -104,6 +106,7 @@ declare namespace ReactIntl { interface Props extends PropsBase { value: DateSource; + children?: (formattedTime: string) => React.ReactNode; } } class FormattedTime extends React.Component { } @@ -125,6 +128,7 @@ declare namespace ReactIntl { interface Props extends PropsBase { value: DateSource; + children?: (formattedRelative: string) => React.ReactNode; } } @@ -154,6 +158,7 @@ declare namespace ReactIntl { interface Props extends PropsBase { value: number; + children?: (formattedNumber: string) => React.ReactNode; } } class FormattedNumber extends React.Component { } @@ -177,6 +182,7 @@ declare namespace ReactIntl { interface Props extends PropsBase { value: number; + children?: (formattedPlural: React.ReactNode) => React.ReactNode; } } class FormattedPlural extends React.Component { } diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index b69c59bd74..d3d30757a1 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -96,6 +96,17 @@ class SomeComponent extends React.Component + + {formattedRelative => formattedRelative.toUpperCase()} + + + + {formattedNum => ( + {formattedNum} + )} + + - - - - - - - - - - {(formattedNum: string) => ( - {formattedNum} + + {formattedPlural => ( + {formattedPlural} )} - + + + + + + + + {formattedDate => formattedDate.toUpperCase()} + + + + + + + + {formattedTime => formattedTime.toUpperCase()} + ; } } From 92abd0cd3d229b3be03c6890febb46827850f4ae Mon Sep 17 00:00:00 2001 From: Robin van Tienhoven <40362967+RobinvanTienhoven@users.noreply.github.com> Date: Fri, 14 Sep 2018 18:52:53 +0200 Subject: [PATCH 23/68] StripeJS Typings fix (Typings were not imported correctly) (#28854) * Quick fix + Element was not included so the native Element was used instead. This caused a warning when trying to use the StripeJS functions with the StripeJS Element object * Element fix + Renamed Element to StripeElement in order to avoid confusion with the native 'Element' object. + Fixed unit test where the Native Element was used instead of the 'StripeElement' object --- types/stripejs/element.d.ts | 4 ++-- types/stripejs/index.d.ts | 6 +++--- types/stripejs/stripejs-tests.ts | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/stripejs/element.d.ts b/types/stripejs/element.d.ts index 82317b9adf..9a1b8b17e2 100644 --- a/types/stripejs/element.d.ts +++ b/types/stripejs/element.d.ts @@ -33,7 +33,7 @@ export interface ElementFactory { create( type: ElementType, options: CardElementOptions | IBANElementOptions | IdealBankOptions | PaymentButtonOptions - ): Element; + ): StripeElement; } export interface ElementCreatorOptions { @@ -107,7 +107,7 @@ export interface FontConfigElement { } // --- ELEMENT --- // -export interface Element { +export interface StripeElement { /** * Mount the element to the DOM * @see https://stripe.com/docs/stripe-js/reference#element-mount diff --git a/types/stripejs/index.d.ts b/types/stripejs/index.d.ts index ed4f8686bf..f2a7ab21aa 100644 --- a/types/stripejs/index.d.ts +++ b/types/stripejs/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -import { ElementCreatorOptions, ElementFactory } from './element'; +import { StripeElement, ElementCreatorOptions, ElementFactory } from './element'; import { StripePaymentOptions, StripePaymentRequest } from './payment'; import { BankTokenData, PiiTokenData, TokenData, IBANTokenData, TokenResult } from './token'; import { SourceData, SourceResult } from './source'; @@ -60,7 +60,7 @@ export interface StripeJS { * * @return an object containing the generated token or an error */ - createToken(element: Element, data?: TokenData | IBANTokenData): Promise; + createToken(element: StripeElement, data?: TokenData | IBANTokenData): Promise; createToken(type: 'bank_account', data: BankTokenData): Promise; createToken(type: 'pii', data: PiiTokenData): Promise; @@ -75,7 +75,7 @@ export interface StripeJS { * * @return an object containing the generated Source or an error */ - createSource(element: Element, data: SourceData): Promise; + createSource(element: StripeElement, data: SourceData): Promise; createSource(data: SourceData): Promise; /** diff --git a/types/stripejs/stripejs-tests.ts b/types/stripejs/stripejs-tests.ts index 7c705e6ec0..06799c2df5 100644 --- a/types/stripejs/stripejs-tests.ts +++ b/types/stripejs/stripejs-tests.ts @@ -1,4 +1,5 @@ import { StripeJS } from "stripejs"; +import { StripeElement } from "stripejs/element"; import { CanMakePaymentResult, StripePaymentResponse } from "stripejs/payment"; import { BankTokenData, IBANTokenData, TokenData, TokenResult } from "stripejs/token"; import { SourceData, SourceResult } from "stripejs/source"; @@ -52,7 +53,7 @@ describe('StripeJS', () => { }); it('Should be possible to create a token', () => { - const element: Element = {} as any; + const element: StripeElement = {} as any; const data: TokenData = { name: '', currency: 'eur', @@ -83,7 +84,7 @@ describe('StripeJS', () => { }); it('Should be possible to create a source object', () => { - const element: Element = {} as any; + const element: StripeElement = {} as any; const data: SourceData = { type: 'alipay', flow: 'none', From 0c694b22fbb3d325df1106f455bd283e5b0b2b8b Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 09:56:14 -0700 Subject: [PATCH 24/68] [ember] refactor @ember/polyfills types into their own package (#28797) * [ember] refactor @ember/polyfills into its own module fixes https://github.com/typed-ember/ember-cli-typescript/issues/273 * [ember] delay activation of some tests until after future improvements to Ember.assign/merge --- .../ember__polyfills-tests.ts | 25 +++++++++++++++++ types/ember__polyfills/index.d.ts | 10 +++++++ types/ember__polyfills/tsconfig.json | 28 +++++++++++++++++++ types/ember__polyfills/tslint.json | 4 +++ 4 files changed, 67 insertions(+) create mode 100644 types/ember__polyfills/ember__polyfills-tests.ts create mode 100644 types/ember__polyfills/index.d.ts create mode 100644 types/ember__polyfills/tsconfig.json create mode 100644 types/ember__polyfills/tslint.json diff --git a/types/ember__polyfills/ember__polyfills-tests.ts b/types/ember__polyfills/ember__polyfills-tests.ts new file mode 100644 index 0000000000..044ed0413c --- /dev/null +++ b/types/ember__polyfills/ember__polyfills-tests.ts @@ -0,0 +1,25 @@ +import { assign, merge } from '@ember/polyfills'; + +(() => { /* assign */ + assign({}, { a: 'b'}); + assign({}, { a: 'b'}).a; // $ExpectType string + assign({ a: 6 }, { a: 'b'}).a; // $ExpectType string + assign({ a: 6 }, {}).a; // $ExpectType number + assign({ b: 6 }, {}).a; // $ExpectError + // TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291 + // assign({}, { b: 6 }, {}).b; // $ExpectType number + assign({ a: 'hello' }, { b: 6 }, {}).a; // $ExpectType string + // TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291 + // assign({ a: 'hello' }, { b: 6 }, { a: true }).a; // $ExpectType boolean + // TODO enable after https://github.com/typed-ember/ember-cli-typescript/issues/291 + // assign({ a: 'hello' }, '', { a: true }).a; // $ExpectError + assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d; // $ExpectType string[] +})(); + +(() => { /* merge */ + merge({}, { a: 'b'}); + merge({}, { a: 'b'}).a; // $ExpectType string + merge({ a: 6 }, { a: 'b'}).a; // $ExpectType string + merge({ a: 6 }, {}).a; // $ExpectType number + merge({ b: 6 }, {}).a; // $ExpectError +})(); diff --git a/types/ember__polyfills/index.d.ts b/types/ember__polyfills/index.d.ts new file mode 100644 index 0000000000..2a3c9b4a93 --- /dev/null +++ b/types/ember__polyfills/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @ember/polyfills 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +export const assign: typeof Ember.assign; +export const merge: typeof Ember.merge; diff --git a/types/ember__polyfills/tsconfig.json b/types/ember__polyfills/tsconfig.json new file mode 100644 index 0000000000..a2a6bd371b --- /dev/null +++ b/types/ember__polyfills/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/polyfills": ["ember__polyfills"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember__polyfills-tests.ts" + ] +} diff --git a/types/ember__polyfills/tslint.json b/types/ember__polyfills/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/ember__polyfills/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} From b59997949eec0114f8ed693bdaf8ecabc2602008 Mon Sep 17 00:00:00 2001 From: mickaelw Date: Fri, 14 Sep 2018 16:57:07 +0000 Subject: [PATCH 25/68] Added type definitions for React Navigation (#28742) --- types/react-navigation/index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 57a386ec14..1e6211926e 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -23,6 +23,7 @@ // Jake // Gustavo Brunoro // Denis Frezzato +// Mickael Wegerich // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -457,10 +458,16 @@ export type NavigationTabAction = | NavigationNavigateAction | NavigationBackAction; +export type NavigationDrawerAction = + | NavigationOpenDrawerAction + | NavigationCloseDrawerAction + | NavigationToggleDrawerAction; + export type NavigationAction = | NavigationInitAction | NavigationStackAction - | NavigationTabAction; + | NavigationTabAction + | NavigationDrawerAction; export type NavigationRouteConfig = | NavigationComponent From 9d99876185f7bd85e9784c639413ef34acafb4c2 Mon Sep 17 00:00:00 2001 From: Rich Armstrong <4429914+AgWillow@users.noreply.github.com> Date: Fri, 14 Sep 2018 11:58:56 -0500 Subject: [PATCH 26/68] chart.js - Add missing animation properties (#28730) Added animateRotate and animateScale (both boolean) to ChartAnimationOptions. These apply only to doughnut/pie and polar-area charts --- types/chart.js/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index aa6cd54eb7..49027a2bea 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -391,6 +391,8 @@ declare namespace Chart { easing?: string; onProgress?(chart: any): void; onComplete?(chart: any): void; + animateRotate?: boolean; + animateScale?: boolean; } interface ChartElementsOptions { From 58451091ce1e7cb8c9eb8ff296f20de4ed5734f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Kadi=C5=A1a?= <8273932+martynaskadisa@users.noreply.github.com> Date: Fri, 14 Sep 2018 20:16:25 +0300 Subject: [PATCH 27/68] [react-window] add typings (#28824) * Add react-window types and tests * bump ts version to match react ts version * Use github project url --- types/react-window/index.d.ts | 404 ++++++++++++++++++++++ types/react-window/react-window-tests.tsx | 197 +++++++++++ types/react-window/tsconfig.json | 25 ++ types/react-window/tslint.json | 1 + 4 files changed, 627 insertions(+) create mode 100644 types/react-window/index.d.ts create mode 100644 types/react-window/react-window-tests.tsx create mode 100644 types/react-window/tsconfig.json create mode 100644 types/react-window/tslint.json diff --git a/types/react-window/index.d.ts b/types/react-window/index.d.ts new file mode 100644 index 0000000000..168551cc94 --- /dev/null +++ b/types/react-window/index.d.ts @@ -0,0 +1,404 @@ +// Type definitions for react-window 1.1 +// Project: https://github.com/bvaughn/react-window/ +// Definitions by: Martynas Kadiša +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Component, ComponentType, CSSProperties, Ref, Key } from "react"; + +export type Direction = "vertical" | "horizontal"; +export type ScrollDirection = "forward" | "backward"; +export type Align = "auto" | "center" | "end" | "start"; + +export interface ListChildComponentProps { + index: number; + style: CSSProperties; +} + +export interface GridChildComponentProps { + columnIndex: number; + rowIndex: number; + style: CSSProperties; +} + +export interface CommonProps { + /** + * Optional CSS class to attach to outermost
element. + */ + className?: string; + /** + * Ref to attach to the inner container element. This is an advanced property. + */ + innerRef?: Ref; + /** + * Tag name passed to document.createElement to create the inner container element. This is an advanced property; in most cases, the default ("div") should be used. + */ + innerTagName?: string; + /** + * Contextual data to be passed to the item renderer as a data prop. This is a light-weight alternative to React's built-in context API. + * + * Item data is useful for item renderers that are class components. + */ + itemData?: any; + /** + * Ref to attach to the outer container element. This is an advanced property. + */ + outerRef?: Ref; + /** + * Tag name passed to document.createElement to create the outer container element. This is an advanced property; in most cases, the default ("div") should be used. + */ + outerTagName?: string; + /** + * The number of items (rows or columns) to render outside of the visible area. This property can be important for two reasons: + * + * - Overscanning by one row or column allows the tab key to focus on the next (not yet visible) item. + * - Overscanning slightly can reduce or prevent a flash of empty space when a user first starts scrolling. + * + * Note that overscanning too much can negatively impact performance. By default, List overscans by one item. + */ + overscanCount?: number; + /** + * Optional inline style to attach to outermost
element. + */ + style?: CSSProperties; + /** + * Adds an additional isScrolling parameter to the children render function. This parameter can be used to show a placeholder row or column while the list is being scrolled. + * + * Note that using this parameter will result in an additional render call after scrolling has stopped (whenisScrolling changse from true to false). + */ + useIsScrolling?: boolean; +} + +export type ListItemKeySelector = (index: number) => Key; + +export interface ListOnItemsRenderedProps { + overscanStartIndex: number; + overscanStopIndex: number; + visibleStartIndex: number; + visibleStopIndex: number; +} + +export interface ListOnScrollProps { + scrollDirection: ScrollDirection; + scrollOffset: number; + scrollUpdateWasRequested: boolean; +} + +export interface ListProps extends CommonProps { + /** + * React component responsible for rendering the individual item specified by an index prop. This component also receives a style prop (used for positioning). + * + * If useIsScrolling is enabled for the list, the component also receives an additional isScrolling boolean prop. + */ + children: ComponentType; + /** + * Height of the list. + * + * For vertical lists, this must be a number. It affects the number of rows that will be rendered (and displayed) at any given time. + * + * For horizontal lists, this can be a number or a string (e.g. "50%"). + */ + height: number | string; + /** + * Total number of items in the list. Note that only a few items will be rendered and displayed at a time. + */ + itemCount: number; + /** + * Width of the list. + * + * For horizontal lists, this must be a number. It affects the number of columns that will be rendered (and displayed) at any given time. + * + * For vertical lists, this can be a number or a string (e.g. "50%"). + */ + width: number | string; + /** + * Primary scroll direction of the list. Acceptable values are: + * + * - vertical (default) - Up/down scrolling. + * - horizontal - Left/right scrolling. + * + * Note that lists may scroll in both directions (depending on CSS) but content will only be windowed in the primary direction. + */ + direction?: Direction; + /** + * Scroll offset for initial render. + * + * For vertical lists, this affects scrollTop. For horizontal lists, this affects scrollLeft. + */ + initialScrollOffset?: number; + /** + * By default, lists will use an item's index as its key. This is okay if: + * + * - Your collections of items is never sorted or modified + * - Your item renderer is not stateful and does not extend PureComponent + * + * If your list does not satisfy the above constraints, use the itemKey property to specify your own keys for items + */ + itemKey?: ListItemKeySelector; + /** + * Called when the items rendered by the list change. + */ + onItemsRendered?: (props: ListOnItemsRenderedProps) => any; + /** + * Called when the list scroll positions changes, as a result of user scrolling or scroll-to method calls. + */ + onScroll?: (props: ListOnScrollProps) => any; +} + +export type GridItemKeySelector = ( + params: { columnIndex: number; rowIndex: number } +) => Key; + +export interface GridOnItemsRenderedProps { + overscanColumnStartIndex: number; + overscanColumnStopIndex: number; + overscanRowStartIndex: number; + overscanRowStopIndex: number; + visibleColumnStartIndex: number; + visibleColumnStopIndex: number; + visibleRowStartIndex: number; + visibleRowStopIndex: number; +} + +export interface GridOnScrollProps { + horizontalScrollDirection: ScrollDirection; + scrollLeft: number; + scrollTop: number; + scrollUpdateWasRequested: boolean; + verticalScrollDirection: ScrollDirection; +} + +export interface GridProps extends CommonProps { + /** + * React component responsible for rendering the individual item specified by an index prop. This component also receives a style prop (used for positioning). + * + * If useIsScrolling is enabled for the list, the component also receives an additional isScrolling boolean prop. + */ + children: ComponentType; + /** + * Number of columns in the grid. Note that only a few columns will be rendered and displayed at a time. + */ + columnCount: number; + /** + * Height of the grid. This affects the number of rows that will be rendered (and displayed) at any given time. + */ + height: number; + /** + * Horizontal scroll offset for initial render. + */ + initialScrollLeft?: number; + /** + * Vertical scroll offset for initial render. + */ + initialScrollTop?: number; + /** + * By default, grids will use an item's indices as its key. This is okay if: + * + * - Your collections of items is never sorted or modified + * - Your item renderer is not stateful and does not extend PureComponent + * + * If your grid does not satisfy the above constraints, use the itemKey property to specify your own keys for items. + */ + itemKey?: GridItemKeySelector; + /** + * Called when the items rendered by the grid change. + */ + onItemsRendered?: (props: GridOnItemsRenderedProps) => any; + /** + * Called when the grid scroll positions changes, as a result of user scrolling or scroll-to method calls. + */ + onScroll?: (props: GridOnScrollProps) => any; + /** + * Number of rows in the grid. Note that only a few rows will be rendered and displayed at a time. + */ + rowCount: number; + /** + * Width of the grid. This affects the number of columns that will be rendered (and displayed) at any given time. + */ + width: number; +} + +export interface FixedSizeListProps extends ListProps { + /** + * Size of a item in the direction being windowed. For vertical lists, this is the row height. For horizontal lists, this is the column width. + */ + itemSize: number; +} + +export interface VariableSizeListProps extends ListProps { + /** + * Estimated size of a item in the direction being windowed. For vertical lists, this is the row height. For horizontal lists, this is the column width. + * + * This value is used to calculated the estimated total size of a list before its items have all been measured. The total size impacts user scrolling behavior. + * It is updated whenever new items are measured. + */ + estimatedItemSize?: number; + /** + * Returns the size of a item in the direction being windowed. For vertical lists, this is the row height. For horizontal lists, this is the column width. + */ + itemSize: (index: number) => number; +} + +export interface FixedSizeGridProps extends GridProps { + /** + * Width of an individual column within the grid. + */ + columnWidth: number; + /** + * Height of an individual row within the grid. + */ + rowHeight: number; +} + +export interface VariableSizeGridProps extends GridProps { + /** + * Returns the width of the specified column. + */ + columnWidth: (index: number) => number; + /** + * Average (or estimated) column width for unrendered columns. + * + * This value is used to calculated the estimated total width of a Grid before its columns have all been measured. + * The estimated width impacts user scrolling behavior. It is updated whenever new columns are measured. + */ + estimatedColumnWidth?: number; + /** + * Average (or estimated) row height for unrendered rows. + * + * This value is used to calculated the estimated total height of a Grid before its rows have all been measured. + * The estimated height impacts user scrolling behavior. It is updated whenever new rows are measured. + */ + estimatedRowHeight?: number; + /** + * Returns the height of the specified row. + */ + rowHeight: (index: number) => number; +} + +export class FixedSizeList extends Component { + /** + * Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop). + */ + scrollTo(scrollOffset: number): void; + /** + * Scroll to the specified item. + * + * By default, the List will scroll as little as possible to ensure the item is visible. + * You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are: + * + * - auto (default) - Scroll as little as possible to ensure the item is visible. (If the item is already visible, it won't scroll at all.) + * - center - Center align the item within the list. + * - end - Align the item to the end of the list (the bottom for vertical lists or the right for horizontal lists). + * - start - Align the item to the beginning of the list (the top for vertical lists or the left for horizontal lists). + */ + scrollToItem(index: number, align?: Align): void; +} + +export class VariableSizeList extends Component { + /** + * Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop). + */ + scrollTo(scrollOffset: number): void; + /** + * Scroll to the specified item. + * + * By default, the List will scroll as little as possible to ensure the item is visible. + * You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are: + * + * - auto (default) - Scroll as little as possible to ensure the item is visible. (If the item is already visible, it won't scroll at all.) + * - center - Center align the item within the list. + * - end - Align the item to the end of the list (the bottom for vertical lists or the right for horizontal lists). + * - start - Align the item to the beginning of the list (the top for vertical lists or the left for horizontal lists). + */ + scrollToItem(index: number, align?: Align): void; + /** + * VariableSizeList caches offsets and measurements for each index for performance purposes. + * This method clears that cached data for all items after (and including) the specified index. + * It should be called whenever a item's size changes. (Note that this is not a typical occurrance.) + * + * By default the list will automatically re-render after the index is reset. + * If you would like to delay this re-render until e.g. a state update has completed in the parent component, + * specify a value offalsefor the second, optional parameter. + */ + resetAfterIndex(index: number, shouldForceUpdate: boolean): void; +} + +export class FixedSizeGrid extends Component { + /** + * Scroll to the specified offsets. + */ + scrollTo(params: { scrollLeft: number; scrollTop: number }): void; + /** + * Scroll to the specified item. + * + * By default, the Grid will scroll as little as possible to ensure the item is visible. + * You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are: + * + * - auto (default) - Scroll as little as possible to ensure the item is visible. (If the item is already visible, it won't scroll at all.) + * - center - Center align the item within the grid. + * - end - Align the item to the bottom, right hand side of the grid. + * - start - Align the item to the top, left hand of the grid. + */ + scrollToItem(params: { + align?: Align; + columnIndex: number; + rowIndex: number; + }): void; +} + +export class VariableSizeGrid extends Component { + /** + * Scroll to the specified offsets. + */ + scrollTo(params: { scrollLeft: number; scrollTop: number }): void; + /** + * Scroll to the specified item. + * + * By default, the Grid will scroll as little as possible to ensure the item is visible. + * You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are: + * + * - auto (default) - Scroll as little as possible to ensure the item is visible. (If the item is already visible, it won't scroll at all.) + * - center - Center align the item within the grid. + * - end - Align the item to the bottom, right hand side of the grid. + * - start - Align the item to the top, left hand of the grid. + */ + scrollToItem(params: { + align?: Align; + columnIndex: number; + rowIndex: number; + }): void; + /** + * VariableSizeGrid caches offsets and measurements for each column index for performance purposes. + * This method clears that cached data for all columns after (and including) the specified index. + * It should be called whenever a column's width changes. (Note that this is not a typical occurrance.) + * + * By default the grid will automatically re-render after the index is reset. + * If you would like to delay this re-render until e.g. a state update has completed in the parent component, + * specify a value offalse for the second, optional parameter. + */ + resetAfterColumnIndex(index: number, shouldForceUpdate?: boolean): void; + /** + * VariableSizeGrid caches offsets and measurements for each item for performance purposes. + * This method clears that cached data for all items after (and including) the specified indices. + * It should be called whenever an items size changes. (Note that this is not a typical occurrance.) + * + * By default the grid will automatically re-render after the index is reset. + * If you would like to delay this re-render until e.g. a state update has completed in the parent component, + * specify a value offalse for the optional shouldForceUpdate parameter. + */ + resetAfterIndices(params: { + columnIndex: number; + rowIndex: number; + shouldForceUpdate?: boolean; + }): void; + /** + * VariableSizeGrid caches offsets and measurements for each row index for performance purposes. + * This method clears that cached data for all rows after (and including) the specified index. + * It should be called whenever a row's height changes. (Note that this is not a typical occurrance.) + * + * By default the grid will automatically re-render after the index is reset. + * If you would like to delay this re-render until e.g. a state update has completed in the parent component, + * specify a value offalse for the second, optional parameter. + */ + resetAfterRowIndex(index: number, shouldForceUpdate?: boolean): void; +} diff --git a/types/react-window/react-window-tests.tsx b/types/react-window/react-window-tests.tsx new file mode 100644 index 0000000000..d9aba8bf8b --- /dev/null +++ b/types/react-window/react-window-tests.tsx @@ -0,0 +1,197 @@ +import { + FixedSizeList, + VariableSizeList, + FixedSizeGrid, + VariableSizeGrid +} from "react-window"; +import * as React from "react"; + +const FixedSizeListTestRequiredProps: React.SFC = () => ( + + {({ style, index }) =>
Test {index}
} +
+); + +const VariableSizeListTestRequiredProps: React.SFC = () => ( + 0} height={0} itemCount={0} width={0}> + {({ style, index }) =>
Test {index}
} +
+); + +const FixedSizeGridTestRequiredProps: React.SFC = () => ( + + {({ style, columnIndex, rowIndex }) => ( +
+ Test {rowIndex} {columnIndex} +
+ )} +
+); + +const VariableSizeGridTestRequiredProps: React.SFC = () => ( + 0} + rowCount={0} + rowHeight={index => 0} + height={0} + width={0} + > + {({ style, columnIndex, rowIndex }) => ( +
+ Test {rowIndex} {columnIndex} +
+ )} +
+); + +const FixedSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ + testBool +}) => ( + "foo" + index.toString()} + onItemsRendered={({ + overscanStartIndex, + overscanStopIndex, + visibleStartIndex, + visibleStopIndex + }) => + overscanStartIndex + + overscanStopIndex + + visibleStartIndex + + visibleStopIndex + } + useIsScrolling={true} + outerTagName="div" + style={{ color: "cyan" }} + overscanCount={0} + outerRef="outerRef" + ref="ref" + onScroll={({ + scrollDirection, + scrollOffset, + scrollUpdateWasRequested + }) => + scrollDirection === "forward" + ? scrollUpdateWasRequested + : scrollOffset + } + > + {({ style, index }) =>
Test {index}
} +
+); + +const VariableSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ + testBool +}) => ( + 0} + height={0} + itemCount={0} + width={0} + className="" + direction={testBool ? "vertical" : "horizontal"} + initialScrollOffset={0} + innerRef="innerRef" + innerTagName="div" + itemData={{ foo: "bar" }} + itemKey={index => "foo" + index.toString()} + onItemsRendered={({ + overscanStartIndex, + overscanStopIndex, + visibleStartIndex, + visibleStopIndex + }) => + overscanStartIndex + + overscanStopIndex + + visibleStartIndex + + visibleStopIndex + } + useIsScrolling={true} + outerTagName="div" + style={{ color: "cyan" }} + overscanCount={0} + outerRef="outerRef" + ref="ref" + onScroll={({ + scrollDirection, + scrollOffset, + scrollUpdateWasRequested + }) => + scrollDirection === "forward" + ? scrollUpdateWasRequested + : scrollOffset + } + estimatedItemSize={0} + > + {({ style, index }) =>
Test {index}
} +
+); + +const VariableSizeGridTestOptionalProps: React.SFC = () => ( + 0} + rowCount={0} + rowHeight={index => 0} + height={0} + width={0} + className="" + estimatedColumnWidth={0} + estimatedRowHeight={0} + initialScrollLeft={0} + initialScrollTop={0} + innerRef="innerRef" + innerTagName="div" + itemData={{ foo: "bar" }} + itemKey={({ columnIndex, rowIndex }) => + columnIndex.toString() + rowIndex.toString() + } + onItemsRendered={({ + overscanColumnStartIndex, + overscanColumnStopIndex, + overscanRowStartIndex, + overscanRowStopIndex, + visibleColumnStartIndex, + visibleColumnStopIndex, + visibleRowStartIndex, + visibleRowStopIndex + }) => undefined} + onScroll={({ + horizontalScrollDirection, + scrollLeft, + scrollTop, + scrollUpdateWasRequested, + verticalScrollDirection + }) => undefined} + outerRef="outerRef" + outerTagName="div" + overscanCount={5} + ref="ref" + style={{ color: "red" }} + useIsScrolling={true} + > + {({ style, columnIndex, rowIndex }) => ( +
+ Test {rowIndex} {columnIndex} +
+ )} +
+); diff --git a/types/react-window/tsconfig.json b/types/react-window/tsconfig.json new file mode 100644 index 0000000000..c884cc3461 --- /dev/null +++ b/types/react-window/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-window-tests.tsx" + ] +} diff --git a/types/react-window/tslint.json b/types/react-window/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-window/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a3b77778782fa1c66d2b0c434349894e4914f7a6 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 10:18:51 -0700 Subject: [PATCH 28/68] adds typings for the 'bloom-filter' package (#28838) --- types/bloom-filter/bloom-filter-tests.ts | 28 +++++++++++++++++ types/bloom-filter/index.d.ts | 38 ++++++++++++++++++++++++ types/bloom-filter/tsconfig.json | 19 ++++++++++++ types/bloom-filter/tslint.json | 3 ++ 4 files changed, 88 insertions(+) create mode 100644 types/bloom-filter/bloom-filter-tests.ts create mode 100644 types/bloom-filter/index.d.ts create mode 100644 types/bloom-filter/tsconfig.json create mode 100644 types/bloom-filter/tslint.json diff --git a/types/bloom-filter/bloom-filter-tests.ts b/types/bloom-filter/bloom-filter-tests.ts new file mode 100644 index 0000000000..0b836a0f84 --- /dev/null +++ b/types/bloom-filter/bloom-filter-tests.ts @@ -0,0 +1,28 @@ +import BloomFilter = require('bloom-filter'); + +const numElements = 3; +const falsePositiveRate = 0.01; +const filter = BloomFilter.create(numElements, falsePositiveRate); + +// elements +const a = Buffer.from('99108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex'); +const c = Buffer.from('b5a2c786d9ef4658287ced5914b37a1b4aa32eee', 'hex'); + +// insert elements +// $ExpectType void +filter.insert(a); + +// $ExpectType boolean +!filter.contains(c); + +// reinstantiate from an object +const serialized = filter.toObject(); +const woahFilter = new BloomFilter(serialized); + +// initialize directly +const newFilter = new BloomFilter({ + vData: Buffer.from('123', 'hex'), // the data of the filter + nHashFuncs: 3, // the number of hash functions to use + nTweak: 2147483649, // the seed used for the hash fuctions + nFlags: 0 // flags used to update the filter when matched +}); diff --git a/types/bloom-filter/index.d.ts b/types/bloom-filter/index.d.ts new file mode 100644 index 0000000000..22841f066b --- /dev/null +++ b/types/bloom-filter/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for bloom-filter 0.2 +// Project: https://github.com/bitpay/bloom-filter +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare class Filter { + constructor(options: Filter.FilterOptions); + static create(elements: number, falsePositiveRate: number, nTweak?: number, nFlags?: number): Filter; + toObject(): Filter.FilterOptions; + hash(nHashNum: number, vDataToHash: Buffer): number; + insert(data: Buffer): void; + contains(data: Buffer): boolean; + clear(): void; + inspect(): string; + BLOOM_UPDATE_NONE: number; + BLOOM_UPDATE_ALL: number; + BLOOM_UPDATE_P2PUBKEY_ONLY: number; + MAX_BLOOM_FILTER_SIZE: number; + MAX_HASH_FUNCS: number; + MIN_HASH_FUNCS: number; + LN2SQUARED: number; + LN2: number; +} + +declare namespace Filter { + interface FilterOptions { + vData: Buffer; + nHashFuncs: number; + nTweak?: number; + nFlags?: number; + } + + function MurmurHash3(seed: number, data: Buffer): number; +} + +export = Filter; diff --git a/types/bloom-filter/tsconfig.json b/types/bloom-filter/tsconfig.json new file mode 100644 index 0000000000..788542822b --- /dev/null +++ b/types/bloom-filter/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bloom-filter-tests.ts" + ] +} diff --git a/types/bloom-filter/tslint.json b/types/bloom-filter/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/bloom-filter/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From c43bcd9fd79979424220c530ef43f429b094c2ef Mon Sep 17 00:00:00 2001 From: Dyma <32801166+dymafr@users.noreply.github.com> Date: Fri, 14 Sep 2018 19:22:28 +0200 Subject: [PATCH 29/68] Add findByIdAndDelete() method (#28893) findByIdAndDelete() recommended method is missing. Mongoose docs: https://mongoosejs.com/docs/api.html#model_Model.findByIdAndDelete MongoDb docs: https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/ --- types/mongoose/index.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 3534f82f49..70a4247d07 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -2759,6 +2759,24 @@ declare module "mongoose" { /** sets the document fields to return */ select?: any; }, callback?: (err: any, res: T | null) => void): DocumentQuery; + + + /** + * Issue a mongodb findOneAndDelete command by a document's _id field. + * findByIdAndDelete(id, ...) is equivalent to findByIdAndDelete({ _id: id }, ...). + * Finds a matching document, removes it, passing the found document (if any) to the callback. + * Executes immediately if callback is passed, else a Query object is returned. + * @param id value of _id to query by + */ + findByIdAndDelete(): DocumentQuery; + findByIdAndDelete(id: any | number | string, + callback?: (err: any, res: T | null) => void): DocumentQuery; + findByIdAndDelete(id: any | number | string, options: { + /** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */ + sort?: any; + /** sets the document fields to return */ + select?: any; + }, callback?: (err: any, res: T | null) => void): DocumentQuery; /** * Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) From 614492e26b045362a0781e5251f4e722e4e98d95 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 10:23:36 -0700 Subject: [PATCH 30/68] [ember] refactor @ember/string types into their own package (#28791) * [@types/ember__string] refactor types out of @types/ember, add additional tests * [@ember/string] enable all TSLint rules --- types/ember__string/ember__string-tests.ts | 33 ++++++++++++++++++++++ types/ember__string/index.d.ts | 18 ++++++++++++ types/ember__string/tsconfig.json | 28 ++++++++++++++++++ types/ember__string/tslint.json | 4 +++ 4 files changed, 83 insertions(+) create mode 100644 types/ember__string/ember__string-tests.ts create mode 100644 types/ember__string/index.d.ts create mode 100644 types/ember__string/tsconfig.json create mode 100644 types/ember__string/tslint.json diff --git a/types/ember__string/ember__string-tests.ts b/types/ember__string/ember__string-tests.ts new file mode 100644 index 0000000000..f9f7dbef50 --- /dev/null +++ b/types/ember__string/ember__string-tests.ts @@ -0,0 +1,33 @@ +import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } from '@ember/string'; + +dasherize(); // $ExpectError +dasherize('blue man group'); // $ExpectType string +dasherize('', ''); // $ExpectError + +camelize(); // $ExpectError +camelize('blue man group'); // $ExpectType string +camelize('', ''); // $ExpectError + +decamelize(); // $ExpectError +decamelize('blue man group'); // $ExpectType string +decamelize('', ''); // $ExpectError + +underscore(); // $ExpectError +underscore('blue man group'); // $ExpectType string +underscore('', ''); // $ExpectError + +w(); // $ExpectError +w('blue man group'); // $ExpectType string[] +w('', ''); // $ExpectError + +classify(); // $ExpectError +classify('blue man group'); // $ExpectType string +classify('', ''); // $ExpectError + +capitalize(); // $ExpectError +capitalize('blue man group'); // $ExpectType string +capitalize('', ''); // $ExpectError + +loc(); // $ExpectError +loc("_Hello World"); // $ExpectType string +loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string diff --git a/types/ember__string/index.d.ts b/types/ember__string/index.d.ts new file mode 100644 index 0000000000..1586b4dcc4 --- /dev/null +++ b/types/ember__string/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for @ember/string 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +export const camelize: typeof Ember.String.camelize; +export const capitalize: typeof Ember.String.capitalize; +export const classify: typeof Ember.String.classify; +export const dasherize: typeof Ember.String.dasherize; +export const decamelize: typeof Ember.String.decamelize; +export const htmlSafe: typeof Ember.String.htmlSafe; +export const isHTMLSafe: typeof Ember.String.isHTMLSafe; +export const loc: typeof Ember.String.loc; +export const underscore: typeof Ember.String.underscore; +export const w: typeof Ember.String.w; diff --git a/types/ember__string/tsconfig.json b/types/ember__string/tsconfig.json new file mode 100644 index 0000000000..100fad10f5 --- /dev/null +++ b/types/ember__string/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/string": ["ember__string"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember__string-tests.ts" + ] +} diff --git a/types/ember__string/tslint.json b/types/ember__string/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/ember__string/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} From 1da1401566f1a73acbfa9ca193eff1fe4b264ca3 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 10:24:01 -0700 Subject: [PATCH 31/68] [ember] refactor @ember/error out into a separate module (#28792) * [ember] refactor @ember/error out into a seperate module fixes: https://github.com/typed-ember/ember-cli-typescript/issues/269 * [@ember/error] enable all tslint rules --- types/ember__error/ember__error-tests.ts | 3 +++ types/ember__error/index.d.ts | 10 +++++++++ types/ember__error/tsconfig.json | 28 ++++++++++++++++++++++++ types/ember__error/tslint.json | 5 +++++ 4 files changed, 46 insertions(+) create mode 100644 types/ember__error/ember__error-tests.ts create mode 100644 types/ember__error/index.d.ts create mode 100644 types/ember__error/tsconfig.json create mode 100644 types/ember__error/tslint.json diff --git a/types/ember__error/ember__error-tests.ts b/types/ember__error/ember__error-tests.ts new file mode 100644 index 0000000000..a5e605cfee --- /dev/null +++ b/types/ember__error/ember__error-tests.ts @@ -0,0 +1,3 @@ +import Error from '@ember/error'; + +new Error('Fuuuuuuuu'); // $ExpectType Error diff --git a/types/ember__error/index.d.ts b/types/ember__error/index.d.ts new file mode 100644 index 0000000000..40a660ae0e --- /dev/null +++ b/types/ember__error/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @ember/error 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +declare const Error: typeof Ember.Error; +export default Error; diff --git a/types/ember__error/tsconfig.json b/types/ember__error/tsconfig.json new file mode 100644 index 0000000000..92f8f7f0ca --- /dev/null +++ b/types/ember__error/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/error": ["ember__error"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember__error-tests.ts" + ] +} diff --git a/types/ember__error/tslint.json b/types/ember__error/tslint.json new file mode 100644 index 0000000000..495d29983d --- /dev/null +++ b/types/ember__error/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + } +} From 2c67d74e1e58ec9cedf1960518d5cceb6e05ac52 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 10:24:21 -0700 Subject: [PATCH 32/68] [ember] refactor @ember/test types into their own module (#28804) fixes https://github.com/typed-ember/ember-cli-typescript/issues/278 --- types/ember__test/adapter.d.ts | 2 ++ types/ember__test/ember__test-tests.ts | 39 ++++++++++++++++++++++++++ types/ember__test/index.d.ts | 12 ++++++++ types/ember__test/tsconfig.json | 30 ++++++++++++++++++++ types/ember__test/tslint.json | 4 +++ 5 files changed, 87 insertions(+) create mode 100644 types/ember__test/adapter.d.ts create mode 100644 types/ember__test/ember__test-tests.ts create mode 100644 types/ember__test/index.d.ts create mode 100644 types/ember__test/tsconfig.json create mode 100644 types/ember__test/tslint.json diff --git a/types/ember__test/adapter.d.ts b/types/ember__test/adapter.d.ts new file mode 100644 index 0000000000..5f312cf381 --- /dev/null +++ b/types/ember__test/adapter.d.ts @@ -0,0 +1,2 @@ +import Ember from 'ember'; +export default class TestAdapter extends Ember.Test.Adapter { } diff --git a/types/ember__test/ember__test-tests.ts b/types/ember__test/ember__test-tests.ts new file mode 100644 index 0000000000..b98ab26a01 --- /dev/null +++ b/types/ember__test/ember__test-tests.ts @@ -0,0 +1,39 @@ +import { registerWaiter, registerHelper, registerAsyncHelper } from '@ember/test'; +import TestAdapter from '@ember/test/adapter'; + +const pending = 0; +registerWaiter(() => pending !== 0); + +declare const MyDb: { + hasPendingTransactions(): boolean; +}; + +registerWaiter(MyDb, MyDb.hasPendingTransactions); +registerWaiter(); // $ExpectError + +registerHelper('boot', app => { + app.advanceReadiness(); // $ExpectType void + app.deferReadiness(); // $ExpectType void + app.register('foo', class {}); // $ExpectType void + app.register('foo'); // $ExpectError + app.register(); // $ExpectError +}); + +registerAsyncHelper('boot', app => { + app.advanceReadiness(); + app.deferReadiness(); + app.register('foo', class {}); +}); + +registerAsyncHelper('waitForPromise', (app, promise) => { + app.advanceReadiness(); + app.deferReadiness(); + app.register('foo', class {}); + return new Promise(() => { + const adapter = new TestAdapter(); + adapter.asyncStart(); + return promise.then(() => { + adapter.asyncEnd(); + }); + }); +}); diff --git a/types/ember__test/index.d.ts b/types/ember__test/index.d.ts new file mode 100644 index 0000000000..94bc312566 --- /dev/null +++ b/types/ember__test/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for @ember/test 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; +export const registerAsyncHelper: typeof Ember.Test.registerAsyncHelper; +export const registerHelper: typeof Ember.Test.registerHelper; +export const registerWaiter: typeof Ember.Test.registerWaiter; +export const unregisterHelper: typeof Ember.Test.unregisterHelper; +export const unregisterWaiter: typeof Ember.Test.unregisterWaiter; diff --git a/types/ember__test/tsconfig.json b/types/ember__test/tsconfig.json new file mode 100644 index 0000000000..89f8c76b60 --- /dev/null +++ b/types/ember__test/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/test": ["ember__test"], + "@ember/test/*": ["ember__test/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "adapter.d.ts", + "ember__test-tests.ts" + ] +} diff --git a/types/ember__test/tslint.json b/types/ember__test/tslint.json new file mode 100644 index 0000000000..1a60b8a5dd --- /dev/null +++ b/types/ember__test/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": { } +} From 38b392f591c49ec030f4d78a0829e7cd32c4c944 Mon Sep 17 00:00:00 2001 From: Mike North Date: Fri, 14 Sep 2018 10:24:46 -0700 Subject: [PATCH 33/68] [ember] copy @ember/runloop types into their own module (#28805) --- types/ember__runloop/ember__runloop-tests.ts | 203 +++++++++++++++++++ types/ember__runloop/index.d.ts | 21 ++ types/ember__runloop/tsconfig.json | 28 +++ types/ember__runloop/tslint.json | 4 + 4 files changed, 256 insertions(+) create mode 100644 types/ember__runloop/ember__runloop-tests.ts create mode 100644 types/ember__runloop/index.d.ts create mode 100644 types/ember__runloop/tsconfig.json create mode 100644 types/ember__runloop/tslint.json diff --git a/types/ember__runloop/ember__runloop-tests.ts b/types/ember__runloop/ember__runloop-tests.ts new file mode 100644 index 0000000000..132d687bbd --- /dev/null +++ b/types/ember__runloop/ember__runloop-tests.ts @@ -0,0 +1,203 @@ +import Ember from 'ember'; +import RSVP from 'rsvp'; +import { run } from '@ember/runloop'; + +Ember.run.queues; // $ExpectType EmberRunQueues[] +const queues: string[] = Ember.run.queues; + +function testRun() { + run(() => { // $ExpectType number + // code to be executed within a RunLoop + return 123; + }); + + function destroyApp(application: Ember.Application) { + Ember.run(application, 'destroy'); + run(application, function() { + this.destroy(); + }); + } +} + +function testBind() { + Ember.Component.extend({ + init() { + const bound = Ember.run.bind(this, this.setupEditor); + bound(); + }, + + editor: null as string | null, + + setupEditor(editor: string) { + this.set('editor', editor); + } + }); +} + +function testCancel() { + const myContext = {}; + + const runNext = run.next(myContext, () => { + // will not be executed + }); + + run.cancel(runNext); + + const runLater = run.later(myContext, () => { + // will not be executed + }, 500); + + run.cancel(runLater); + + const runScheduleOnce = run.scheduleOnce('afterRender', myContext, () => { + // will not be executed + }); + + run.cancel(runScheduleOnce); + + const runOnce = run.once(myContext, () => { + // will not be executed + }); + + run.cancel(runOnce); + + const throttle = run.throttle(myContext, () => { + // will not be executed + }, 1, false); + + run.cancel(throttle); + + const debounce = run.debounce(myContext, () => { + // will not be executed + }, 1); + + run.cancel(debounce); + + const debounceImmediate = run.debounce(myContext, () => { + // will be executed since we passed in true (immediate) + }, 100, true); + + // the 100ms delay until this method can be called again will be canceled + run.cancel(debounceImmediate); +} + +function testDebounce() { + function runIt() { + } + + const myContext = { name: 'debounce' }; + + run.debounce(runIt, 150); + run.debounce(myContext, runIt, 150); + run.debounce(myContext, runIt, 150, true); + + Ember.Component.extend({ + searchValue: 'test', + fetchResults(value: string) {}, + + actions: { + handleTyping() { + // the fetchResults function is passed into the component from its parent + Ember.run.debounce(this, this.get('fetchResults'), this.get('searchValue'), 250); + } + } + }); +} + +function testBegin() { + run.begin(); + // code to be executed within a RunLoop + run.end(); +} + +function testJoin() { + run.join(() => { + // creates a new run-loop + }); + + run(() => { + // creates a new run-loop + run.join(() => { + // joins with the existing run-loop, and queues for invocation on + // the existing run-loops action queue. + }); + }); + + new RSVP.Promise((resolve) => { + Ember.run.later(() => { + resolve({ msg: 'Hold Your Horses' }); + }, 3000); + }); +} + +function testLater() { + const myContext = {}; + run.later(myContext, () => { + // code here will execute within a RunLoop in about 500ms with this == myContext + }, 500); +} + +function testNext() { + const myContext = {}; + run.next(myContext, () => { + // code to be executed in the next run loop, + // which will be scheduled after the current one + }); +} + +function testOnce() { + Ember.Component.extend({ + init() { + Ember.run.once(this, 'processFullName'); + }, + + processFullName() { + } + }); +} + +function testSchedule() { + Ember.Component.extend({ + init() { + run.schedule('sync', this, () => { + // this will be executed in the first RunLoop queue, when bindings are synced + console.log('scheduled on sync queue'); + }); + + run.schedule('actions', this, () => { + // this will be executed in the 'actions' queue, after bindings have synced. + console.log('scheduled on actions queue'); + }); + } + }); + + Ember.run.schedule('actions', () => { + // Do more things + }); +} + +function testScheduleOnce() { + function sayHi() { + console.log('hi'); + } + + const myContext = {}; + run(() => { + run.scheduleOnce('afterRender', myContext, sayHi); + run.scheduleOnce('afterRender', myContext, sayHi); + // sayHi will only be executed once, in the afterRender queue of the RunLoop + }); + run.scheduleOnce('actions', myContext, () => { + console.log('Closure'); + }); +} + +function testThrottle() { + function runIt() { + } + + const myContext = { name: 'throttle' }; + + run.throttle(runIt, 150); + run.throttle(myContext, runIt, 150); +} diff --git a/types/ember__runloop/index.d.ts b/types/ember__runloop/index.d.ts new file mode 100644 index 0000000000..acc8c3ad8a --- /dev/null +++ b/types/ember__runloop/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for @ember/runloop 3.0 +// Project: http://emberjs.com/ +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import Ember from 'ember'; + +export const begin: typeof Ember.run.begin; +export const bind: typeof Ember.run.bind; +export const cancel: typeof Ember.run.cancel; +export const debounce: typeof Ember.run.debounce; +export const end: typeof Ember.run.end; +export const join: typeof Ember.run.join; +export const later: typeof Ember.run.later; +export const next: typeof Ember.run.next; +export const once: typeof Ember.run.once; +export const run: typeof Ember.run; +export const schedule: typeof Ember.run.schedule; +export const scheduleOnce: typeof Ember.run.scheduleOnce; +export const throttle: typeof Ember.run.throttle; diff --git a/types/ember__runloop/tsconfig.json b/types/ember__runloop/tsconfig.json new file mode 100644 index 0000000000..ef1e325ff4 --- /dev/null +++ b/types/ember__runloop/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@ember/runloop": ["ember__runloop"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember__runloop-tests.ts" + ] +} diff --git a/types/ember__runloop/tslint.json b/types/ember__runloop/tslint.json new file mode 100644 index 0000000000..1a60b8a5dd --- /dev/null +++ b/types/ember__runloop/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": { } +} From 21d31fd064a24437797c9fe7f7c27340870f54a2 Mon Sep 17 00:00:00 2001 From: Sean Date: Sat, 15 Sep 2018 03:28:13 +1000 Subject: [PATCH 34/68] Replace JSX.Element with React.ComponentType (#28706) Is meant to be `React.ComponentType` (see https://github.com/storybooks/storybook/tree/master/addons/info). `JSX.Element` is the type of an instance of a component (e.g. ``), while `React.ComponentType` is the type of the component class itself (e.g. `MyComponent`). --- types/storybook__addon-info/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/storybook__addon-info/index.d.ts b/types/storybook__addon-info/index.d.ts index b460823f50..111f7dc54d 100644 --- a/types/storybook__addon-info/index.d.ts +++ b/types/storybook__addon-info/index.d.ts @@ -19,8 +19,8 @@ export interface Options { header?: boolean; inline?: boolean; source?: boolean; - propTables?: JSX.Element[] | false; - propTablesExclude?: JSX.Element[]; + propTables?: React.ComponentType[] | false; + propTablesExclude?: React.ComponentType[]; styles?: object; marksyConf?: object; maxPropsIntoLine?: number; From 192edcd269a4c35254b0eebd1ac577c1f35c8e46 Mon Sep 17 00:00:00 2001 From: Larry1123 Date: Fri, 14 Sep 2018 13:34:19 -0400 Subject: [PATCH 35/68] Extend screenshot encoding support (#28713) Overloaded the screenshot methods to define the return type based on what kind of encoding is used. Edited the test and made sure normal ScreenshotOptions worked as normal still, the two new extended interfaces can be used for objects to pass in also but did not add test for that directly, should be handled right with the current test cases. --- types/puppeteer/index.d.ts | 14 +++++++++++++- types/puppeteer/puppeteer-tests.ts | 8 ++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index e66ee97dfa..eab93cf2eb 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -592,6 +592,14 @@ export interface ScreenshotOptions { encoding?: "base64" | "binary"; } +export interface BinaryScreenShotOptions extends ScreenshotOptions { + encoding?: "binary"; +} + +export interface Base64ScreenShotOptions extends ScreenshotOptions { + encoding: "base64"; +} + /** Options for `addStyleTag` */ export interface StyleTagOptions { /** Url of the tag. */ @@ -747,7 +755,9 @@ export interface ElementHandle extends JSHandle, Ev * If the element is detached from DOM, the method throws an error. * @param options Same options as in page.screenshot. */ - screenshot(options?: ScreenshotOptions): Promise; + screenshot(options?: Base64ScreenShotOptions): Promise; + screenshot(options?: BinaryScreenShotOptions): Promise; + screenshot(options?: ScreenshotOptions): Promise; /** * This method scrolls element into view if needed, and then uses touchscreen.tap to tap in the center of the element. * If the element is detached from DOM, the method throws an error. @@ -1346,6 +1356,8 @@ export interface Page extends EventEmitter, FrameBase { * Captures a screenshot of the page. * @param options The screenshot options. */ + screenshot(options?: Base64ScreenShotOptions): Promise; + screenshot(options?: BinaryScreenShotOptions): Promise; screenshot(options?: ScreenshotOptions): Promise; /** diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 1e3d35737b..fb0c283d4b 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -403,8 +403,12 @@ puppeteer.launch().then(async browser => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto("https://example.com"); - const base64string: string = (await page.screenshot({ encoding: "base64" })) as string; - const buffer: Buffer = (await page.screenshot({ encoding: "binary" })) as Buffer; + const base64string: string = await page.screenshot({ encoding: "base64" }); + const buffer: Buffer = await page.screenshot({ encoding: "binary" }); + const screenshotOptions: puppeteer.ScreenshotOptions = { + fullPage: true, + }; + const stringOrBuffer: string | Buffer = await page.screenshot(screenshotOptions); browser.close(); })(); From e50bb9f5566d9ee4255cf0cf0c419e1f0d190912 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Fri, 14 Sep 2018 10:36:43 -0700 Subject: [PATCH 36/68] adds typings for the 'vorpal' package (#28870) --- types/vorpal/index.d.ts | 82 ++++++++++++++++++++++++++++++++++++ types/vorpal/tsconfig.json | 23 ++++++++++ types/vorpal/tslint.json | 3 ++ types/vorpal/vorpal-tests.ts | 16 +++++++ 4 files changed, 124 insertions(+) create mode 100644 types/vorpal/index.d.ts create mode 100644 types/vorpal/tsconfig.json create mode 100644 types/vorpal/tslint.json create mode 100644 types/vorpal/vorpal-tests.ts diff --git a/types/vorpal/index.d.ts b/types/vorpal/index.d.ts new file mode 100644 index 0000000000..ee2bf2ac42 --- /dev/null +++ b/types/vorpal/index.d.ts @@ -0,0 +1,82 @@ +// Type definitions for vorpal 1.11 +// Project: https://github.com/dthree/vorpal +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +declare class Vorpal { + parse(argv: ReadonlyArray): this; + delimiter(value: string): this; + show(): this; + hide(): this; + find(command: string): Vorpal.Command; + exec(command: string): Promise<{}>; + execSync(command: string): Promise<{}>; + log(value: string, ...values: string[]): this; + history(id: string): this; + localStorage(id: string): object; + help(value: (cmd: string) => string): this; + pipe(value: (stdout: string) => string): this; + use(extension: Vorpal.Extension): this; + catch(command: string, description?: string): Vorpal.Catch; + command(command: string, description?: string): Vorpal.Command; + version(version: string): this; + sigint(value: () => void): this; + ui: Vorpal.UI; + activeCommand: Vorpal.CommandInstance; +} + +declare namespace Vorpal { + interface Args { + [key: string]: any; + options: { + [key: string]: any; + }; + } + + type Action = (args: Args) => Promise; + type Cancel = () => void; + + class Command { + _name: string; + _fn: Action; + _cancel: Cancel | undefined; + alias(command: string): this; + parse(value: (command: string, args: Args) => string): this; + option(option: string, description: string, autocomplete?: ReadonlyArray): this; + types(types: { string?: ReadonlyArray }): this; + hidden(): this; + remove(): this; + help(value: (args: Args) => void): this; + validate(value: (args: Args) => boolean | string): this; + autocomplete(values: ReadonlyArray | { data: () => Promise> }): this; + action(action: Action): this; + cancel(cancel: Cancel): this; + allowUnknownOptions(): this; + } + + class Catch extends Command { } + + class Extension { } + + class UI { + delimiter(text?: string): string; + input(text?: string): string; + imprint(): void; + submit(command: string): string; + cancel(): void; + redraw: { + (text: string, ...texts: string[]): void; + clear(): void; + done(): void; + }; + } + + class CommandInstance { + log(value: string, ...values: string[]): void; + prompt(prompt: object | ReadonlyArray): Promise; + delimiter(value: string): void; + } +} + +export = Vorpal; diff --git a/types/vorpal/tsconfig.json b/types/vorpal/tsconfig.json new file mode 100644 index 0000000000..8c44d56707 --- /dev/null +++ b/types/vorpal/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vorpal-tests.ts" + ] +} diff --git a/types/vorpal/tslint.json b/types/vorpal/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/vorpal/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/vorpal/vorpal-tests.ts b/types/vorpal/vorpal-tests.ts new file mode 100644 index 0000000000..4499365fd0 --- /dev/null +++ b/types/vorpal/vorpal-tests.ts @@ -0,0 +1,16 @@ +import Vorpal = require('vorpal'); + +// example from README + +const vorpal = new Vorpal(); + +vorpal + .command('foo', 'Outputs "bar".') + .action((action) => { + vorpal.log('bar'); + return Promise.resolve(); + }); + +vorpal + .delimiter('myapp$') + .show(); From 5a86a73eec28891f05b070034d068fa616fc5c51 Mon Sep 17 00:00:00 2001 From: Norbert Bartos Date: Fri, 14 Sep 2018 19:38:36 +0200 Subject: [PATCH 37/68] [Enzyme] Add simulateError method (#28698) Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If changing an existing definition: - [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <> - [ ] Increase the version number in the header if appropriate. - [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. --- types/enzyme/enzyme-tests.tsx | 4 ++++ types/enzyme/index.d.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/types/enzyme/enzyme-tests.tsx b/types/enzyme/enzyme-tests.tsx index e1762b843e..0711243d0c 100644 --- a/types/enzyme/enzyme-tests.tsx +++ b/types/enzyme/enzyme-tests.tsx @@ -363,6 +363,10 @@ function ShallowWrapperTest() { shallowWrapper.simulate('click', args); } + function test_simulateError(error: any) { + shallowWrapper.simulateError(error); + } + function test_setState() { shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }, () => console.log('state updated')); } diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index a91f60b3c6..60262e3d04 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -221,6 +221,13 @@ export interface CommonWrapper

> { */ simulate(event: string, ...args: any[]): this; + /** + * Used to simulate throwing a rendering error. Pass an error to throw. + * Returns itself. + * @param error + */ + simulateError(error: any): this; + /** * A method to invoke setState() on the root component instance similar to how you might in the definition of * the component, and re-renders. This method is useful for testing your component in hard to achieve states, From c472319d6ddd65c6fdd3e4c8213ea87a67dfe619 Mon Sep 17 00:00:00 2001 From: Dario Blanco Date: Fri, 14 Sep 2018 19:39:32 +0200 Subject: [PATCH 38/68] twilio-video 2.0.0-beta1 types fix (#28882) After developing a bit more the production application with the new types, and had the need of using manual local tracks, I discovered a few fixes to be made: - Two missing functions in `LocalParticipant`: `unpublishTrack` and `unpublishTracks`. See [LocalParticipant documentation](https://media.twiliocdn.com/sdk/js/video/releases/2.0.0-beta1/docs/LocalParticipant.html). - When creating a single track using `createLocalVideoTrack` or `createLocalAudioTrack`, the documentation defines a non optional `logLevel`, but the examples don't specify it and the code works without it. See [Examples](https://media.twiliocdn.com/sdk/js/video/releases/2.0.0-beta1/docs/global.html#createLocalVideoTrack__anchor). Therefore, `logLevel` is optional in `CreateLocalTrackOptions` as well (and documented in the code). - `CreateLocalTrackOptions` should extend `MediaTrackConstraints`. Currently, it will complain when writing our own video and audio constraints. [CreateLocalTrackOptions](https://media.twiliocdn.com/sdk/js/video/releases/2.0.0-beta1/docs/global.html#CreateLocalTrackOptions) - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). If changing an existing definition: - [x] Provide a URL to documentation or source code which provides context for the suggested changes: https://media.twiliocdn.com/sdk/js/video/releases/2.0.0-beta1/docs - [x] Increase the version number in the header if appropriate. - [x] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. --- types/twilio-video/index.d.ts | 11 ++++--- types/twilio-video/twilio-video-tests.ts | 42 ++++++++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/types/twilio-video/index.d.ts b/types/twilio-video/index.d.ts index cc65da2c2c..83d3d27111 100644 --- a/types/twilio-video/index.d.ts +++ b/types/twilio-video/index.d.ts @@ -94,7 +94,7 @@ export class LocalParticipant extends Participant { tracks: Map; videoTracks: Map; - publishTrack(localTrack: LocalTrack): Promise; + publishTrack(track: LocalTrack): Promise; publishTrack( mediaStreamTrack: MediaStreamTrack, options?: LocalTrackOptions, ): Promise; @@ -102,6 +102,8 @@ export class LocalParticipant extends Participant { tracks: LocalTrack[] | MediaStreamTrack[], ): Promise; setParameters(encodingParameters?: EncodingParameters | null): LocalParticipant; + unpublishTrack(track: LocalTrack): LocalTrackPublication; + unpublishTracks(tracks: LocalTrack): LocalTrackPublication[]; } export class LocalTrackPublication extends TrackPublication { isTrackEnabled: boolean; @@ -472,10 +474,11 @@ export interface ConnectOptions { tracks?: LocalTrack[] | MediaStreamTrack[]; video?: boolean | CreateLocalTrackOptions; } -export interface CreateLocalTrackOptions { - logLevel: LogLevel | LogLevels; +export interface CreateLocalTrackOptions extends MediaTrackConstraints { + // In API reference logLevel is not optional, but in the Twilio examples it is + logLevel?: LogLevel | LogLevels; name?: string; - workaroundWebKitBug180748?: boolean; // Lol + workaroundWebKitBug180748?: boolean; } export interface CreateLocalTracksOptions { audio?: boolean | CreateLocalTrackOptions; diff --git a/types/twilio-video/twilio-video-tests.ts b/types/twilio-video/twilio-video-tests.ts index b5cfe43e01..b06bf9b168 100644 --- a/types/twilio-video/twilio-video-tests.ts +++ b/types/twilio-video/twilio-video-tests.ts @@ -2,12 +2,37 @@ import * as Video from 'twilio-video'; // Examples taken from https://twilio.github.io/twilio-video/ (v2.x) -Video.connect('$TOKEN', { name: 'room-name' }).then(room => { - room.participants.forEach(participantConnected); - room.on('participantConnected', participantConnected); - room.on('participantDisconnected', participantDisconnected); - room.once('disconnected', error => room.participants.forEach(participantDisconnected)); -}); +let room: Video.Room | null = null; +let localVideoTrack: Video.LocalVideoTrack | null = null; +let localAudioTrack: Video.LocalAudioTrack | null = null; + +async function initRoom() { + // Connect to Twilio without creating audio and video track + room = await Video.connect('$TOKEN', { name: 'room-name', video: false, audio: false }); + // Create local video track from default input + localVideoTrack = await Video.createLocalVideoTrack({ name: 'camera' }); + // Create local audio track from default input + localAudioTrack = await Video.createLocalAudioTrack({ name: 'microphone' }); + // Publish audio track + room.localParticipant.publishTrack(localAudioTrack); + // Subscribe to remote participant tracks + room.participants.forEach(participantConnected); + // Set up listeners + room.on('participantConnected', participantConnected); + room.on('participantDisconnected', participantDisconnected); + room.once('disconnected', (room: Video.Room, error: Video.TwilioError) => { + room.participants.forEach(participantDisconnected); + room.localParticipant.tracks.forEach((publication: Video.LocalTrackPublication) => { + publication.unpublish(); + if (publication.track.kind !== 'data') trackUnsubscribed(publication.track); + }); + }); +} + +function unpublishTracks() { + if (room && localVideoTrack) room.localParticipant.unpublishTrack(localVideoTrack); + if (room && localAudioTrack) room.localParticipant.unpublishTrack(localAudioTrack); +} function participantConnected(participant: Video.Participant) { participant.on('trackSubscribed', trackSubscribed); @@ -43,3 +68,8 @@ function trackUnsubscribed(track: Video.VideoTrack | Video.AudioTrack) { function insertDomElement(element: any) { // Do something with the dom element } + +initRoom(); +// Do something with your video +// You can call unpublish tracks +unpublishTracks(); From 5099333846e466f1583b5e254dea18c9b7384325 Mon Sep 17 00:00:00 2001 From: Will Garcia Date: Fri, 14 Sep 2018 13:40:52 -0400 Subject: [PATCH 39/68] @types/joi add dataUri type definition (#28727) --- types/joi/index.d.ts | 14 ++++++++++++++ types/joi/joi-tests.ts | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 5af6969665..166be7d526 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -13,6 +13,8 @@ // Rafael Kallis // Conan Lai // Peter Thorson +// Will Garcia +// Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -147,6 +149,13 @@ export interface UriOptions { relativeOnly?: boolean; } +export interface DataUriOptions { + /** + * optional parameter defaulting to true which will require = padding if true or make padding optional if false + */ + paddingRequired?: boolean; +} + export interface Base64Options { /** * optional parameter defaulting to true which will require = padding if true or make padding optional if false @@ -630,6 +639,11 @@ export interface StringSchema extends AnySchema { */ uri(options?: UriOptions): this; + /** + * Requires the string value to be a valid data URI string. + */ + dataUri(options?: DataUriOptions): this; + /** * Requires the string value to be a valid GUID. */ diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index 5defe20cc1..c9805e1fc3 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -120,6 +120,12 @@ base64Opts = { paddingRequired: bool }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- +let dataUriOpts: Joi.DataUriOptions = null; + +dataUriOpts = { paddingRequired: bool }; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + let whenOpts: Joi.WhenOptions = null; whenOpts = { is: x }; @@ -818,6 +824,8 @@ strSchema = strSchema.normalize(); strSchema = strSchema.normalize('NFKC'); strSchema = strSchema.base64(); strSchema = strSchema.base64(base64Opts); +strSchema = strSchema.dataUri(); +strSchema = strSchema.dataUri(dataUriOpts); { // common strSchema = strSchema.allow(x); From 9a4fd80c8ca45e6ba927772bb3634d9e5ec40d9e Mon Sep 17 00:00:00 2001 From: Mike North Date: Sun, 16 Sep 2018 15:00:28 -0700 Subject: [PATCH 40/68] [@ember/polyfills] Move types from ember (#28923) https://github.com/typed-ember/ember-cli-typescript/issues/299 --- types/ember/index.d.ts | 22 ++++------------------ types/ember/tsconfig.json | 3 +++ types/ember__polyfills/index.d.ts | 17 ++++++++++++++--- types/ember__polyfills/tsconfig.json | 4 +++- types/ember__polyfills/types.d.ts | 4 ++++ 5 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 types/ember__polyfills/types.d.ts diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 5b059a0ee4..5a2a654cbc 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -34,6 +34,7 @@ declare module 'ember' { import { Registry as ServiceRegistry } from '@ember/service'; import { Registry as ControllerRegistry } from '@ember/controller'; import ModuleComputed from '@ember/object/computed'; + import * as EmberPolyfills from '@ember/polyfills'; // Get an alias to the global Array type to use in inner scope below. type GlobalArray = T[]; @@ -3138,11 +3139,7 @@ declare module 'ember' { * A value is present if it not `isBlank`. */ function isPresent(obj?: any): boolean; - /** - * Merge the contents of two objects together into the first object. - * @deprecated Use Object.assign - */ - function merge(original: T, updates: U): Mix; + const merge: typeof EmberPolyfills.merge; /** * Makes a method available via an additional name. */ @@ -3289,14 +3286,12 @@ declare module 'ember' { function typeOf(value: T): KeysOfType; function typeOf(): 'undefined'; function typeOf(item: any): string; + // TODO: replace with an es6 reexport when declare module 'ember' is removed /** * Copy properties from a source object to a target object. * @deprecated Use Object.assign */ - function assign(target: T, source: U): Mix; - function assign(target: T, source1: U, source2: V): Mix3; - function assign(target: T, source1: U, source2: V, source3: W): Mix4; - + const assign: typeof EmberPolyfills.assign; /** * Polyfill for Object.create * @deprecated Use Object.create @@ -3790,15 +3785,6 @@ declare module '@ember/object/proxy' { export default class ObjectProxy extends Ember.ObjectProxy { } } -declare module '@ember/polyfills' { - import Ember from 'ember'; - export const assign: typeof Ember.assign; - export const create: typeof Ember.create; - export const hasPropertyAccessors: typeof Ember.platform.hasPropertyAccessors; - export const keys: typeof Ember.keys; - export const merge: typeof Ember.merge; -} - declare module '@ember/routing/auto-location' { import Ember from 'ember'; export default class AutoLocation extends Ember.AutoLocation { } diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index a267c26dd5..ed3a4345ff 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,6 +14,9 @@ "typeRoots": [ "../" ], + "paths": { + "@ember/polyfills": ["ember__polyfills"] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/ember__polyfills/index.d.ts b/types/ember__polyfills/index.d.ts index 2a3c9b4a93..1bca6dbba4 100644 --- a/types/ember__polyfills/index.d.ts +++ b/types/ember__polyfills/index.d.ts @@ -4,7 +4,18 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import Ember from 'ember'; +import { Mix, Mix3, Mix4 } from './types'; -export const assign: typeof Ember.assign; -export const merge: typeof Ember.merge; +/** + * Copy properties from a source object to a target object. + * @deprecated Use Object.assign + */ +export function assign(target: T, source: U): Mix; +export function assign(target: T, source1: U, source2: V): Mix3; +export function assign(target: T, source1: U, source2: V, source3: W): Mix4; + +/** + * Merge the contents of two objects together into the first object. + * @deprecated Use Object.assign + */ +export function merge(original: T, updates: U): Mix; diff --git a/types/ember__polyfills/tsconfig.json b/types/ember__polyfills/tsconfig.json index a2a6bd371b..ab08b95d99 100644 --- a/types/ember__polyfills/tsconfig.json +++ b/types/ember__polyfills/tsconfig.json @@ -15,7 +15,8 @@ "../" ], "paths": { - "@ember/polyfills": ["ember__polyfills"] + "@ember/polyfills": ["ember__polyfills"], + "@ember/polyfills/*": ["ember__polyfills/*"] }, "types": [], "noEmit": true, @@ -23,6 +24,7 @@ }, "files": [ "index.d.ts", + "types.d.ts", "ember__polyfills-tests.ts" ] } diff --git a/types/ember__polyfills/types.d.ts b/types/ember__polyfills/types.d.ts new file mode 100644 index 0000000000..d1c8cf2306 --- /dev/null +++ b/types/ember__polyfills/types.d.ts @@ -0,0 +1,4 @@ +export type Mix = B & Pick>; +export type Mix3 = Mix, C>; +export type Mix4 = Mix3, C, D>; +export default Mix; From d9c8fecb5fba5b177fd7dbd6eb3087370e74e357 Mon Sep 17 00:00:00 2001 From: Mike North Date: Sun, 16 Sep 2018 15:00:45 -0700 Subject: [PATCH 41/68] [ember] addObserver, removeObserver should return functions (#28921) Fixes https://github.com/typed-ember/ember-cli-typescript/issues/290 --- types/ember/index.d.ts | 34 ++++++++++---------- types/ember/test/private/observable-tests.ts | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 5a2a654cbc..3c0d3c15cf 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -1734,11 +1734,11 @@ declare module 'ember' { key: keyof this, target: Target, method: ObserverMethod - ): void; + ): this; addObserver( key: keyof this, method: ObserverMethod - ): void; + ): this; /** * Remove an observer you have previously registered on this object. Pass * the same key, target, and method you passed to `addObserver()` and your @@ -1748,11 +1748,11 @@ declare module 'ember' { key: keyof this, target: Target, method: ObserverMethod - ): any; + ): this; removeObserver( key: keyof this, method: ObserverMethod - ): any; + ): this; /** * Retrieves the value of a property, or a default value in the case that the * property returns `undefined`. @@ -3147,33 +3147,33 @@ declare module 'ember' { /** * Specify a method that observes property changes. */ - function observer(key1: string, func: (target: any, key: string) => void): void; - function observer( + function observer void>(key1: string, func: Fn): Fn; + function observer void>( key1: string, key2: string, - func: (target: any, key: string) => void - ): void; - function observer( + func: Fn + ): Fn; + function observer void>( key1: string, key2: string, key3: string, - func: (target: any, key: string) => void - ): void; - function observer( + func: Fn + ): Fn; + function observer void>( key1: string, key2: string, key3: string, key4: string, - func: (target: any, key: string) => void - ): void; - function observer( + func: Fn + ): Fn; + function observer void>( key1: string, key2: string, key3: string, key4: string, key5: string, - func: (target: any, key: string) => void - ): void; + func: Fn + ): Fn; /** * Adds an observer on a property. */ diff --git a/types/ember/test/private/observable-tests.ts b/types/ember/test/private/observable-tests.ts index be3d4bd69f..1a789cc114 100644 --- a/types/ember/test/private/observable-tests.ts +++ b/types/ember/test/private/observable-tests.ts @@ -69,13 +69,13 @@ class DemoObservable implements Observable { notifyPropertyChange(keyName: string): this { throw new Error("Method not implemented."); } - addObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void; - addObserver(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): void; + addObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): any; + addObserver(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): any; addObserver(key: any, target: any, method?: any) { throw new Error("Method not implemented."); } - removeObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void; - removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): void; + removeObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): any; + removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): any; removeObserver(key: any, target: any, method?: any): void { throw new Error("Method not implemented."); } From 5016fdb13a1c4000f1d1e0eec01452e0c51b479c Mon Sep 17 00:00:00 2001 From: tamnguyenvt Date: Mon, 17 Sep 2018 14:29:59 +0700 Subject: [PATCH 42/68] papaparse: Allow to change papa.SCRIPT_PATH (#28932) --- types/papaparse/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index de820c771f..4e52dd66a4 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -50,7 +50,8 @@ export const UNIT_SEP: string; export const WORKERS_SUPPORTED: boolean; // The relative path to Papa Parse. This is automatically detected when Papa Parse is loaded synchronously. -export const SCRIPT_PATH: string; +// Assign it a value to override auto-detected path. +export let SCRIPT_PATH: string; // When passed to Papa Parse a Readable stream is returned. export const NODE_STREAM_INPUT = 1; From 373eab6d1c0e9bf37c5bbfecf51da6d46d0168cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Monnot?= Date: Mon, 17 Sep 2018 09:31:09 +0200 Subject: [PATCH 43/68] Update definitions for react-vertical-timeline-component (#28909) --- types/react-vertical-timeline-component/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-vertical-timeline-component/index.d.ts b/types/react-vertical-timeline-component/index.d.ts index 44a9fb3116..7939abd43a 100644 --- a/types/react-vertical-timeline-component/index.d.ts +++ b/types/react-vertical-timeline-component/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-vertical-timeline-component 2.1 +// Type definitions for react-vertical-timeline-component 2.2 // Project: https://github.com/stephane-monnot/react-vertical-timeline // Definitions by: Stéphane Monnot // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -20,6 +20,7 @@ export interface VerticalTimelineElementProps { icon?: React.ReactNode; position?: string; style?: React.CSSProperties; + visibilitySensorProps?: any; } export class VerticalTimeline extends React.Component { } From e42f9330816b732a24caa8fd0c89c287aac0153c Mon Sep 17 00:00:00 2001 From: tyfkda Date: Mon, 17 Sep 2018 16:31:43 +0900 Subject: [PATCH 44/68] Change md5 declaration to accepts Array (#28891) md5 accepts not only `string | Buffer`, but also `Array` from the beginning: https://github.com/pvorb/node-md5/blob/master/md5.js#L19 --- types/md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/md5/index.d.ts b/types/md5/index.d.ts index 7cfed0ca35..071c5306fc 100644 --- a/types/md5/index.d.ts +++ b/types/md5/index.d.ts @@ -11,7 +11,7 @@ * @param {(string | Buffer)} message - a string or buffer to hash * @returns {string} the resultant MD5 hash of the given message */ -declare function md5(message: string | Buffer): string; +declare function md5(message: string | Buffer | Array): string; declare namespace md5 {} From 91886422ba81a660de918a5de5acd35be3b0eed6 Mon Sep 17 00:00:00 2001 From: Jinesh Shah Date: Mon, 17 Sep 2018 03:32:34 -0400 Subject: [PATCH 45/68] Fix exports to allow named exports (#28902) * Fix exports Fix exports so they can be name for "declaration: true" tsconfigs * Updated tests * Update tsconfig.json * Update tslint.json --- types/postmark/index.d.ts | 267 ++++++++++++++++++++++++------- types/postmark/postmark-tests.ts | 120 +++++++------- types/postmark/tsconfig.json | 19 +-- types/postmark/tslint.json | 7 +- 4 files changed, 278 insertions(+), 135 deletions(-) diff --git a/types/postmark/index.d.ts b/types/postmark/index.d.ts index 24810299a7..b2b7ac0cfc 100644 --- a/types/postmark/index.d.ts +++ b/types/postmark/index.d.ts @@ -1,12 +1,10 @@ // Type definitions for postmark 1.4 // Project: http://wildbit.github.io/postmark.js -// Definitions by: Ben Bayard +// Definitions by: Ben Bayard +// Jinesh Shah // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -export = postmark; - -declare const postmark: Postmark.Postmark; declare namespace Postmark { const defaults: Options; @@ -87,7 +85,9 @@ declare namespace Postmark { InlineCssForHtmlTestRender?: boolean; } - type PostmarkCallback = ((e: PostmarkError, ret: T) => undefined) | undefined; + type PostmarkCallback = + | ((e: PostmarkError, ret: T) => undefined) + | undefined; interface SimpleOptions { ssl: boolean; @@ -109,36 +109,64 @@ declare namespace Postmark { constructor(serverKey: string, options?: Partial); send(message: PostmarkMessage): Promise; - send(message: PostmarkMessage, callback: PostmarkCallback): undefined; + send( + message: PostmarkMessage, + callback: PostmarkCallback + ): undefined; - sendEmailWithTemplate(message: PostmarkMessageWithTemplate): Promise; - sendEmailWithTemplate(message: PostmarkMessageWithTemplate, callback: PostmarkCallback): undefined; + sendEmailWithTemplate( + message: PostmarkMessageWithTemplate + ): Promise; + sendEmailWithTemplate( + message: PostmarkMessageWithTemplate, + callback: PostmarkCallback + ): undefined; batch(message: PostmarkMessage[]): Promise; - batch(message: PostmarkMessage[], callback: PostmarkCallback): undefined; + batch( + message: PostmarkMessage[], + callback: PostmarkCallback + ): undefined; sendEmail(message: PostmarkMessage): Promise; - sendEmail(message: PostmarkMessage, callback: PostmarkCallback): undefined; + sendEmail( + message: PostmarkMessage, + callback: PostmarkCallback + ): undefined; sendEmailBatch(message: PostmarkMessage[]): Promise; - sendEmailBatch(message: PostmarkMessage[], callback: PostmarkCallback): undefined; + sendEmailBatch( + message: PostmarkMessage[], + callback: PostmarkCallback + ): undefined; // stats getDeliveryStatistics(): Promise; - getDeliveryStatistics(callback: PostmarkCallback): undefined; + getDeliveryStatistics( + callback: PostmarkCallback + ): undefined; // bounces getBounces(filter: BounceFilter): Promise; - getBounces(filter: BounceFilter, callback?: PostmarkCallback): undefined; + getBounces( + filter: BounceFilter, + callback?: PostmarkCallback + ): undefined; getBounce(id: number): Promise; getBounce(id: number, callback?: PostmarkCallback): undefined; getBounceDump(id: number): Promise; - getBounceDump(id: number, callback?: PostmarkCallback): undefined; + getBounceDump( + id: number, + callback?: PostmarkCallback + ): undefined; activateBounce(id: number): Promise; - activateBounce(id: number, callback?: PostmarkCallback): undefined; + activateBounce( + id: number, + callback?: PostmarkCallback + ): undefined; getBounceTags(): Promise; getBounceTags(callback?: PostmarkCallback): undefined; @@ -148,54 +176,112 @@ declare namespace Postmark { getServer(callback?: PostmarkCallback): undefined; editServer(server: Partial): Promise; - editServer(server: Partial, callback?: PostmarkCallback): undefined; + editServer( + server: Partial, + callback?: PostmarkCallback + ): undefined; // message info - getOutboundMessages(filter: OutboundMessageFilter): Promise; - getOutboundMessages(filter: OutboundMessageFilter, callback?: PostmarkCallback): undefined; + getOutboundMessages( + filter: OutboundMessageFilter + ): Promise; + getOutboundMessages( + filter: OutboundMessageFilter, + callback?: PostmarkCallback + ): undefined; getOutboundMessageDetails(id: number): Promise; - getOutboundMessageDetails(id: number, callback?: PostmarkCallback): undefined; + getOutboundMessageDetails( + id: number, + callback?: PostmarkCallback + ): undefined; getMessageOpens(filter: OpenMessageFilter): Promise; - getMessageOpens(filter: OpenMessageFilter, callback?: PostmarkCallback): undefined; + getMessageOpens( + filter: OpenMessageFilter, + callback?: PostmarkCallback + ): undefined; - getMessageOpensForSingleMessage(id: number, filter: Filter): Promise; - getMessageOpensForSingleMessage(id: number, filter: Filter, callback?: PostmarkCallback): undefined; + getMessageOpensForSingleMessage( + id: number, + filter: Filter + ): Promise; + getMessageOpensForSingleMessage( + id: number, + filter: Filter, + callback?: PostmarkCallback + ): undefined; - getInboundMessages(filter: InboundMessageFilter): Promise; - getInboundMessages(filter: InboundMessageFilter, callback?: PostmarkCallback): undefined; + getInboundMessages( + filter: InboundMessageFilter + ): Promise; + getInboundMessages( + filter: InboundMessageFilter, + callback?: PostmarkCallback + ): undefined; getInboundMessageDetails(id: number): Promise; - getInboundMessageDetails(id: number, callback?: PostmarkCallback): undefined; + getInboundMessageDetails( + id: number, + callback?: PostmarkCallback + ): undefined; bypassBlockedInboundMessage(id: number): Promise; - bypassBlockedInboundMessage(id: number, callback?: PostmarkCallback): undefined; + bypassBlockedInboundMessage( + id: number, + callback?: PostmarkCallback + ): undefined; getOuboundOverview(filter: BaseFilter): Promise; - getOuboundOverview(filter: BaseFilter, callback?: PostmarkCallback): undefined; + getOuboundOverview( + filter: BaseFilter, + callback?: PostmarkCallback + ): undefined; retryInboundHookForMessage(id: number): Promise; - retryInboundHookForMessage(id: number, callback?: PostmarkCallback): undefined; + retryInboundHookForMessage( + id: number, + callback?: PostmarkCallback + ): undefined; // templates getTemplate(id: number): Promise