From 452111db33f579b239e44f525cc8865fcef8b683 Mon Sep 17 00:00:00 2001 From: Duong Tran Date: Thu, 14 Jun 2018 15:00:44 +1000 Subject: [PATCH 01/66] improve static router props context --- types/react-router/index.d.ts | 8 +++++++- .../examples-from-react-router-website/StaticRouter.tsx | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 5ae92ababc..2b1e2f97c1 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -17,6 +17,7 @@ // Youen Toupin // Rahul Raina // Maksim Sharipov +// Duong Tran // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -86,10 +87,15 @@ export interface RouterProps { } export class Router extends React.Component { } +export interface StaticRouterContext { + url?: string; + action?: 'PUSH' | 'REPLACE'; + location?: object; +} export interface StaticRouterProps { basename?: string; location?: string | object; - context?: object; + context?: StaticRouterContext; } export class StaticRouter extends React.Component { } diff --git a/types/react-router/test/examples-from-react-router-website/StaticRouter.tsx b/types/react-router/test/examples-from-react-router-website/StaticRouter.tsx index c9763bdda5..3dce9a5def 100644 --- a/types/react-router/test/examples-from-react-router-website/StaticRouter.tsx +++ b/types/react-router/test/examples-from-react-router-website/StaticRouter.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import { StaticRouter, Route } from 'react-router-dom'; +import { StaticRouterContext } from 'react-router'; -interface StaticContext { +interface StaticContext extends StaticRouterContext { statusCode?: number; } From 86f3c3d26c91638ef8069c70228275767869617e Mon Sep 17 00:00:00 2001 From: felix-hoc Date: Fri, 10 Aug 2018 10:44:01 +0200 Subject: [PATCH 02/66] Add types for winston-syslog v2.0.0, move existing types to v1/ --- types/winston-syslog/index.d.ts | 55 +++++++++++-------- types/winston-syslog/package.json | 2 +- types/winston-syslog/tsconfig.json | 4 +- types/winston-syslog/v1/index.d.ts | 25 +++++++++ types/winston-syslog/v1/package.json | 6 ++ types/winston-syslog/v1/tsconfig.json | 32 +++++++++++ types/winston-syslog/v1/tslint.json | 3 + .../winston-syslog/v1/winston-syslog-tests.ts | 35 ++++++++++++ types/winston-syslog/winston-syslog-tests.ts | 19 +++---- 9 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 types/winston-syslog/v1/index.d.ts create mode 100644 types/winston-syslog/v1/package.json create mode 100644 types/winston-syslog/v1/tsconfig.json create mode 100644 types/winston-syslog/v1/tslint.json create mode 100644 types/winston-syslog/v1/winston-syslog-tests.ts diff --git a/types/winston-syslog/index.d.ts b/types/winston-syslog/index.d.ts index 816274ded8..bd0ee54cdf 100644 --- a/types/winston-syslog/index.d.ts +++ b/types/winston-syslog/index.d.ts @@ -1,25 +1,36 @@ -// Type definitions for winston-syslog 1.0 -// Project: https://github.com/indexzero/winston-syslog#readme -// Definitions by: Chris Barth +// Type definitions for winston-syslog v2.0.0 +// Project: https://github.com/winstonjs/winston-syslog +// Definitions by: Felix Hochgruber // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as winston from "winston"; -export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { - host?: string; - port?: number; - path?: string; - protocol?: string; - pid?: number; - facility?: string; - localhost?: string; - type?: string; - app_name?: string; - eol?: string; -} -export class Syslog extends winston.Transport implements winston.TransportInstance { -} -declare module "winston" { - interface Transports { - Syslog: Syslog; - } +import * as Transport from 'winston-transport'; +import * as dgram from 'dgram'; +import * as net from 'net'; + +declare module 'winston-syslog' { + + export interface SyslogTransportOptions extends Transport.TransportStreamOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; + } + + interface SyslogTransportInstance extends Transport { + + producer: any; + socket: dgram.Socket | net.Socket; + + connect(callback: (err: (true | null)) => any): void; + + new(options?: SyslogTransportOptions): SyslogTransportInstance; + } } + +export const Syslog: SyslogTransportInstance; diff --git a/types/winston-syslog/package.json b/types/winston-syslog/package.json index 33e1a4f018..0aa4cf368f 100644 --- a/types/winston-syslog/package.json +++ b/types/winston-syslog/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "@types/winston": "^2.3.9" + "winston": "^3.0.0" } } diff --git a/types/winston-syslog/tsconfig.json b/types/winston-syslog/tsconfig.json index e11a89c680..2c0a6050a4 100644 --- a/types/winston-syslog/tsconfig.json +++ b/types/winston-syslog/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "winston-syslog-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/winston-syslog/v1/index.d.ts b/types/winston-syslog/v1/index.d.ts new file mode 100644 index 0000000000..816274ded8 --- /dev/null +++ b/types/winston-syslog/v1/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for winston-syslog 1.0 +// Project: https://github.com/indexzero/winston-syslog#readme +// Definitions by: Chris Barth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as winston from "winston"; +export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; +} +export class Syslog extends winston.Transport implements winston.TransportInstance { +} +declare module "winston" { + interface Transports { + Syslog: Syslog; + } +} diff --git a/types/winston-syslog/v1/package.json b/types/winston-syslog/v1/package.json new file mode 100644 index 0000000000..33e1a4f018 --- /dev/null +++ b/types/winston-syslog/v1/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "@types/winston": "^2.3.9" + } +} diff --git a/types/winston-syslog/v1/tsconfig.json b/types/winston-syslog/v1/tsconfig.json new file mode 100644 index 0000000000..610ded1b9b --- /dev/null +++ b/types/winston-syslog/v1/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "winston-syslog": [ + "winston-syslog/v1" + ], + "winston-syslog/*": [ + "winston-syslog/v1/*" + ] + }, + "noEmit": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "winston-syslog-tests.ts" + ] +} diff --git a/types/winston-syslog/v1/tslint.json b/types/winston-syslog/v1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/winston-syslog/v1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/winston-syslog/v1/winston-syslog-tests.ts b/types/winston-syslog/v1/winston-syslog-tests.ts new file mode 100644 index 0000000000..a08b80b045 --- /dev/null +++ b/types/winston-syslog/v1/winston-syslog-tests.ts @@ -0,0 +1,35 @@ +import winston = require('winston'); +import { SyslogTransportOptions } from 'winston-syslog'; + +const str = ""; +const bool = true; +const num = 1; +const obj: any = {}; + +const syslogOptions: SyslogTransportOptions = { + host: str, + port: num, + path: str, + protocol: str, + pid: num, + facility: str, + localhost: str, + type: str, + app_name: str, + eol: str, + json: bool, + colorize: bool, + colors: str, + prettyPrint: bool, + showLevel: bool, + label: str, + depth: num, +}; + +winston.add(winston.transports.Syslog, syslogOptions); + +const logger: winston.LoggerInstance = new (winston.Logger)({ + transports: [ + new (winston.transports.Syslog)(syslogOptions), + ] +}); diff --git a/types/winston-syslog/winston-syslog-tests.ts b/types/winston-syslog/winston-syslog-tests.ts index a08b80b045..66a4a71e17 100644 --- a/types/winston-syslog/winston-syslog-tests.ts +++ b/types/winston-syslog/winston-syslog-tests.ts @@ -1,5 +1,5 @@ import winston = require('winston'); -import { SyslogTransportOptions } from 'winston-syslog'; +import { Syslog, SyslogTransportOptions } from 'winston-syslog'; const str = ""; const bool = true; @@ -16,20 +16,15 @@ const syslogOptions: SyslogTransportOptions = { localhost: str, type: str, app_name: str, - eol: str, - json: bool, - colorize: bool, - colors: str, - prettyPrint: bool, - showLevel: bool, - label: str, - depth: num, + eol: str }; -winston.add(winston.transports.Syslog, syslogOptions); +const syslogTransport = new Syslog(syslogOptions); -const logger: winston.LoggerInstance = new (winston.Logger)({ +winston.add(syslogTransport); + +const logger: winston.Logger = winston.createLogger({ transports: [ - new (winston.transports.Syslog)(syslogOptions), + syslogTransport ] }); From cb332fb8495d401358b25ae31395bc630612b2f6 Mon Sep 17 00:00:00 2001 From: felix-hoc Date: Fri, 10 Aug 2018 11:24:46 +0200 Subject: [PATCH 03/66] Fix some linting issues. --- types/winston-syslog/index.d.ts | 40 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/types/winston-syslog/index.d.ts b/types/winston-syslog/index.d.ts index bd0ee54cdf..d1517cc957 100644 --- a/types/winston-syslog/index.d.ts +++ b/types/winston-syslog/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for winston-syslog v2.0.0 +// Type definitions for winston-syslog 2.0 // Project: https://github.com/winstonjs/winston-syslog // Definitions by: Felix Hochgruber // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,30 +7,26 @@ import * as Transport from 'winston-transport'; import * as dgram from 'dgram'; import * as net from 'net'; -declare module 'winston-syslog' { +export interface SyslogTransportOptions extends Transport.TransportStreamOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; +} - export interface SyslogTransportOptions extends Transport.TransportStreamOptions { - host?: string; - port?: number; - path?: string; - protocol?: string; - pid?: number; - facility?: string; - localhost?: string; - type?: string; - app_name?: string; - eol?: string; - } +export interface SyslogTransportInstance extends Transport { + producer: any; + socket: dgram.Socket | net.Socket; - interface SyslogTransportInstance extends Transport { + connect(callback: (err: (true | null)) => any): void; - producer: any; - socket: dgram.Socket | net.Socket; - - connect(callback: (err: (true | null)) => any): void; - - new(options?: SyslogTransportOptions): SyslogTransportInstance; - } + new(options?: SyslogTransportOptions): SyslogTransportInstance; } export const Syslog: SyslogTransportInstance; From 94bf96d4288b20ee56b58b6045c5273f9b447c9c Mon Sep 17 00:00:00 2001 From: felix-hoc Date: Fri, 10 Aug 2018 11:50:28 +0200 Subject: [PATCH 04/66] Disable no-misused-new linting rule, so we can stay in line with winston's conventions. See https://github.com/winstonjs/winston-mongodb/blob/master/lib/winston-mongodb.d.ts and https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.d.ts --- types/winston-syslog/tslint.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/winston-syslog/tslint.json b/types/winston-syslog/tslint.json index f93cf8562a..bf5a9b916f 100644 --- a/types/winston-syslog/tslint.json +++ b/types/winston-syslog/tslint.json @@ -1,3 +1,8 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // This allows to be in line with winston transport types. + // See https://github.com/winstonjs/winston-mongodb/blob/master/lib/winston-mongodb.d.ts and https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.d.ts + "no-misused-new": false + } } From 77159b4b96175b2ecfabed28d35ffed83017db8c Mon Sep 17 00:00:00 2001 From: Beeno Tung Date: Sat, 18 Aug 2018 17:39:35 +0800 Subject: [PATCH 05/66] added ed25519 in pki --- types/node-forge/index.d.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index 65ff4edb47..41c573d5b8 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -73,6 +73,33 @@ declare module "node-forge" { function generateKeyPair(options?: GenerateKeyPairOptions, callback?: (err: Error, keypair: KeyPair) => void): KeyPair; } + namespace ed25519 { + + type NativeBuffer = Buffer | Uint8Array; + + namespace constants { + const PUBLIC_KEY_BYTE_LENGTH = 32; + const PRIVATE_KEY_BYTE_LENGTH = 64; + const SEED_BYTE_LENGTH = 32; + const SIGN_BYTE_LENGTH = 64; + const HASH_BYTE_LENGTH = 64; + } + + function generateKeyPair(options?: { seed?: Buffer | Uint8Array | string }): { + publicKey: NativeBuffer; + privateKey: NativeBuffer; + }; + + function publicKeyFromPrivateKey(options: { privateKey: NativeBuffer }): NativeBuffer; + + function sign(options: { privateKey: NativeBuffer }): NativeBuffer; + + function verify(options: { + signature: Buffer | Uint8Array | util.ByteBuffer | string, + publicKey: NativeBuffer + }): boolean; + } + interface CertificateFieldOptions { name?: string; type?: string; From 2df28b987367e8c93d93bbeac328a5c3bcd553d3 Mon Sep 17 00:00:00 2001 From: Adam Eisenreich Date: Mon, 20 Aug 2018 15:11:47 +0200 Subject: [PATCH 06/66] Added textTracks & remoteTextTracks to video.js --- types/video.js/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 0deb3d5a68..036aa1189b 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -3764,6 +3764,18 @@ declare namespace videojs { autoplay(): boolean | string; + /** + * Get the remote {@link TextTrackList} + * @return The current remote text track list + */ + textTracks(): TextTrackList + + /** + * Get the remote {@link TextTrackList} + * @return The current remote text track list + */ + remoteTextTracks(): TextTrackList + /** * Create a remote {@link TextTrack} and an {@link HTMLTrackElement}. It will * automatically removed from the video element whenever the source changes, unless From 779fe35d1a51e3c0261587bc0a138c2bb5526fca Mon Sep 17 00:00:00 2001 From: felix-hoc Date: Tue, 21 Aug 2018 09:17:30 +0200 Subject: [PATCH 07/66] Update owners list. --- types/winston-syslog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/winston-syslog/index.d.ts b/types/winston-syslog/index.d.ts index d1517cc957..b0409ad4c4 100644 --- a/types/winston-syslog/index.d.ts +++ b/types/winston-syslog/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for winston-syslog 2.0 // Project: https://github.com/winstonjs/winston-syslog -// Definitions by: Felix Hochgruber +// Definitions by: Chris Barth , Felix Hochgruber // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Transport from 'winston-transport'; From d962f8b98f7b08c277a7a60722c852b4fea86a74 Mon Sep 17 00:00:00 2001 From: felix-hoc Date: Tue, 21 Aug 2018 13:20:15 +0200 Subject: [PATCH 08/66] Set Typescript version to 2.9 for old version (v1). --- types/winston-syslog/v1/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/winston-syslog/v1/index.d.ts b/types/winston-syslog/v1/index.d.ts index 816274ded8..b2d5ecfb90 100644 --- a/types/winston-syslog/v1/index.d.ts +++ b/types/winston-syslog/v1/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/indexzero/winston-syslog#readme // Definitions by: Chris Barth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 import * as winston from "winston"; export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { From 328448882545bd381ff035858fe2a741c724d027 Mon Sep 17 00:00:00 2001 From: Joel Rosinbum Date: Tue, 21 Aug 2018 14:23:50 -0500 Subject: [PATCH 09/66] Add jsGraph Type --- types/jsgraph/index.d.ts | 174 +++++++++++++++++++++++++++++++++ types/jsgraph/jsgraph-tests.ts | 43 ++++++++ types/jsgraph/tsconfig.json | 24 +++++ types/jsgraph/tslint.json | 79 +++++++++++++++ 4 files changed, 320 insertions(+) create mode 100644 types/jsgraph/index.d.ts create mode 100644 types/jsgraph/jsgraph-tests.ts create mode 100644 types/jsgraph/tsconfig.json create mode 100644 types/jsgraph/tslint.json diff --git a/types/jsgraph/index.d.ts b/types/jsgraph/index.d.ts new file mode 100644 index 0000000000..fe4fa42e2f --- /dev/null +++ b/types/jsgraph/index.d.ts @@ -0,0 +1,174 @@ +// Type definitions for jsgraph 0.7 +// Project: https://github.com/Encapsule/jsgraph +// Definitions by: Joel Rosinbum +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare namespace jsgraph { + + interface jsGraphStatic { + directed: Directed; + } + + export interface VertexRequest { + u: string; + p: any + } + + export interface JsGraphResponse { + error?: any; + result?: any; + } + + export interface Edge { + u: string; + v: string + } + + export interface EdgeRequest { + e: Edge; + p: any; + } + + export interface DirectedGraph { + new(): DirectedGraph; + + setGraphName(name: string): JsGraphResponse; + + getGraphName(): string; + + setGraphDescription(description: string): JsGraphResponse; + + getGraphDescription(): string; + + verticesCount(): number; + + getVertices(): string[]; + + getEdgeCount(): number; + + getEdeges(): Edge[]; + + rootVerticesCount(): number; + + getRootVertices(): string[]; + + leafVerticesCount(): number; + + getLeafVertices(): string[]; + + toObject(): string; + + toJSON(): string; + + stringify(replacer: Function, space?: number): string; + + fromObject(graph: any): JsGraphResponse; + + + //Vertex functions + addVertex(vertex: VertexRequest): JsGraphResponse; + + removeVertex(vertex: string): boolean; + + getVertexProperty(vertex: string): any; + + setVertexProperty(vertex: VertexRequest): JsGraphResponse; + + hasVertexProperty(vertex: string): boolean; + + clearVertexProperty(vertex: string): boolean; + + inDegree(vertex: string): number; + + inEdges(vertex: string): Edge[]; + + outDegree(vertex: string): number; + + outEdges(vertex: string): Edge[]; + + //Edge functions + addEdge(request: EdgeRequest): JsGraphResponse; + + isEdge(edge: Edge): boolean; + + removeEdge(edge: Edge): JsGraphResponse; + + getEdgeProperty(edge: Edge): any; + + setEdgeProperty(request: EdgeRequest): JsGraphResponse; + + hasEdgeProperty(edge: Edge): boolean; + + clearEdgeProperty(edge: Edge): boolean; + + + } + + export interface Visitor { + initializeVertex(req: { u: string, g: DirectedGraph }): void; + + startVertex(req: { u: string, g: DirectedGraph }): void; + + discoverVertex(req: { u: string, g: DirectedGraph }): void; + + examineVertex(req: { u: string, g: DirectedGraph }): void; + + examineEdge(req: { e: Edge, g: DirectedGraph }): void; + + nonTreeEdge(req: { e: Edge, g: DirectedGraph }): void; + + grayTarget(req: { e: Edge, g: DirectedGraph }): void; + + blackTarget(req: { e: Edge, g: DirectedGraph }): void; + + finishVertex(req: { u: string, g: DirectedGraph }): void; + } + + export interface TraversalContext { + searchStatus: string; + colorMap: any; + undiscoveredMap: any; + } + + export interface TraversalOptions { + startVector: string | string[]; + allowEmptyStartVector: boolean; + signalStart: boolean; + traverseContext: TraversalContext; + } + + export interface TraversalParams { + digraph: DirectedGraph, + visitor: Visitor, + options?: TraversalOptions + } + + export interface TraversalResult { + error?: any; + result?: TraversalContext + } + + export type colors = { white: 0, gray: 1, black: 2 }; + + export interface Directed { + breadthFirstTraverse(params: TraversalParams): TraversalResult; + + colors: colors; + + create(): { result: DirectedGraph }; + + createTraversalContext(req: { dirgaph: DirectedGraph }): TraversalContext; + + depthFirstTraverse(params: TraversalParams): TraversalResult; + + transpose(graph: DirectedGraph): { error?: any, result?: DirectedGraph }; + + directedGraph: DirectedGraph; + + } +} + +declare var jsgraph: jsgraph.jsGraphStatic; + +export = jsgraph; diff --git a/types/jsgraph/jsgraph-tests.ts b/types/jsgraph/jsgraph-tests.ts new file mode 100644 index 0000000000..2fdab3c0bf --- /dev/null +++ b/types/jsgraph/jsgraph-tests.ts @@ -0,0 +1,43 @@ +import * as jsgraph from 'jsgraph'; +import {Edge, JsGraphResponse} from 'jsgraph'; + +const mygraph = jsgraph.directed.create().result; + +let name: string = 'my name'; +mygraph.setGraphName(name); +name = mygraph.getGraphName(); +let description: string = 'My desc'; +mygraph.setGraphDescription(description); +description = mygraph.getGraphDescription(); + +let count: number = mygraph.verticesCount(); +let verticies: string [] = mygraph.getVertices(); +count = mygraph.getEdgeCount(); +let edges: Edge[] = mygraph.getEdeges(); +count = mygraph.rootVerticesCount(); +verticies = mygraph.getRootVertices(); +count = mygraph.leafVerticesCount(); +verticies = mygraph.getLeafVertices(); +let json: string = mygraph.toObject(); +json = mygraph.toJSON(); +json = mygraph.stringify( () => {return}, 2); +const graph2 = mygraph.fromObject(mygraph); + +let response: JsGraphResponse = mygraph.addVertex({u: 'a', p: 'some data'}); +let bool: boolean = mygraph.removeVertex('a'); +let property: string = mygraph.getVertexProperty('a'); +mygraph.setVertexProperty({u: 'a', p: property}); +bool = mygraph.hasVertexProperty('a'); +bool = mygraph.clearVertexProperty('a'); +count = mygraph.inDegree('a'); +edges = mygraph.inEdges('a'); +count = mygraph.outDegree('a'); +edges = mygraph.outEdges('a'); + +response = mygraph.addEdge({e: {u: 'a', v:'b'}, p: 'some data'}); +bool = mygraph.isEdge({u: 'a', v:'b'}); +response = mygraph.removeEdge({u: 'a', v: 'b'}); +property = mygraph.getEdgeProperty({u: 'a', v: 'b'}); +response = mygraph.setEdgeProperty({e: {u: 'a', v: 'b'}, p: 'some data'}); +bool = mygraph.hasEdgeProperty({u: 'a', v: 'b'}); +bool = mygraph.clearEdgeProperty({u:'a', v: 'b'}); diff --git a/types/jsgraph/tsconfig.json b/types/jsgraph/tsconfig.json new file mode 100644 index 0000000000..22997eae59 --- /dev/null +++ b/types/jsgraph/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsgraph-tests.ts" + ] +} diff --git a/types/jsgraph/tslint.json b/types/jsgraph/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/jsgraph/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From fe2e689e508fc4e120cf409849606c20e3ce0bc3 Mon Sep 17 00:00:00 2001 From: Allen Gammel Date: Tue, 21 Aug 2018 16:53:48 -0500 Subject: [PATCH 10/66] added required files. --- .../expired-storage/expired-storage-tests.ts | 67 +++++++++++ types/expired-storage/index.d.ts | 108 ++++++++++++++++++ types/expired-storage/tsconfig.json | 23 ++++ types/expired-storage/tslint.json | 8 ++ 4 files changed, 206 insertions(+) create mode 100644 types/expired-storage/expired-storage-tests.ts create mode 100644 types/expired-storage/index.d.ts create mode 100644 types/expired-storage/tsconfig.json create mode 100644 types/expired-storage/tslint.json diff --git a/types/expired-storage/expired-storage-tests.ts b/types/expired-storage/expired-storage-tests.ts new file mode 100644 index 0000000000..946051e218 --- /dev/null +++ b/types/expired-storage/expired-storage-tests.ts @@ -0,0 +1,67 @@ +import { LocalStorage } from 'node-localstorage'; +import ExpiredStorage = require('expired-storage'); + +const localStorage = new LocalStorage('./scratch', Infinity); +const expiredStorage = new ExpiredStorage(localStorage); + +const mjkModel = { + firstName: 'Maynard', + middleName: 'James', + familyName: 'Keenan', +}; + +expiredStorage.clear(); + +expiredStorage.setItem('tool', '46&2', 10); + +if (expiredStorage.getItem('tool') !== '46&2') { + throw new Error('.setItem method is not working!'); +} + +expiredStorage.setJson('mjk', mjkModel, 1); + +const mjkTest = expiredStorage.getJson('mjk'); + +if (typeof mjkTest === 'undefined' || mjkTest.firstName !== mjkModel.firstName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) { + throw new Error('.setJson method is not working!'); +} + +if (expiredStorage.keys(true).length === 2) { + throw new Error('.keys method has failed.'); +} + +expiredStorage.setItem('apc', 'brena', 2); + +const goBackToSleep = expiredStorage.peek('apc'); + +if (!goBackToSleep.isExpired && goBackToSleep.value !== 'brena') { + throw new Error('.peek -- we have expired early... or our value was incorrect...'); +} + +do { + // nothing here to see +} while (!expiredStorage.isExpired('apc')); + +const expiredKeys = expiredStorage.clearExpired(); + +if (typeof expiredKeys['apc'] !== 'undefined') { + throw new Error('.clearExpired did not work..'); +} + +if (expiredStorage.getItem('apc') !== null) { + throw new Error('Expiration as a whole does not work.'); +} + +expiredStorage.setItem('puscifer', 'the humbling river', 10000); + +expiredStorage.updateExpiration('puscifer', 5000); + +if (expiredStorage.getTimeLeft('puscifer') >= 10000) { + throw new Error('.updateExpiration method is broken -- or .getTimeLeft method is broken.'); +} + +if (!expiredStorage.isExpired('mjk')) { + throw new Error('.isExpired or Expiration as a whole is not working...'); +} + +expiredStorage.clear(); diff --git a/types/expired-storage/index.d.ts b/types/expired-storage/index.d.ts new file mode 100644 index 0000000000..c7c113726e --- /dev/null +++ b/types/expired-storage/index.d.ts @@ -0,0 +1,108 @@ +// Type definitions for extended-storage v1.0.2 +// Project: https://github.com/RonenNess/ExpiredStorage/ +// Definitions by: Allen Gammel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "expired-storage" { + + export = ExpiredStorage; + + class ExpiredStorage { + constructor(); + constructor(localStorage?: any); + /** + * Clear the entire storage and all keys in it. + */ + clear(): void; + /** + * Get a json serializable value. This basically calls JSON.parse on the returned value. + * @param key Item key to get (string). + * @return Stored value (JSON.parsed), or undefined if not set / expired. + **/ + getJson(key: string): any; + /** + * Get item. + * @param key: Item key to get (string). + * @return: Stored value, or undefined if not set / expired. + */ + getItem(key: string): string | null; + /** + * Remove an item. + * @param key Item key to remove (string). + * @return Storage.removeItem() return code. + */ + removeItem(key: string): any; + /** + * Set a json serializable value. This basically calls JSON.stringify on 'val' before setting it. + * @param key Item key to set (string). + * @param value Value to store (object, will be JSON.stringified). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @param return Storage.setItem() return code. + **/ + setJson(key: string, value: object, expirationTime?: number): any; + /** + * Set item. + * @param key Item key to set (string). + * @param value Value to store (string). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @return Storage.setItem() return code. + **/ + setItem(key: string, value: string, expiration?: number): any; + /** + * Get all keys in storage, not including internal keys used to store expiration. + * @param: includeExpired: if true, will also include expired keys. + * @return: Array with keys. + */ + keys(includeExpired: boolean): Array | null; + /** + * Get item time left to live. + * @param key Item key to get (string). + * @return Time left to expire (in seconds), or null if don't have expiration date. + */ + getTimeLeft(key: string): number | null; + /** + * Clear expired keys. + * If you never call this function, expired keys will remain until you try to get them / reset a new value. + * + * @param return: List of removed keys due to expiration. + */ + clearExpired(): Array | null; + /** + * Return if an item is expired (don't remove it, even if expired). + * @param key Item key to check (string). + * @return True if expired, False otherwise. + */ + isExpired(key: string): boolean; + /** + * Get item + metadata such as time left and if expired. + * Even if item expired, will not remove it. + * @param key Item key to get (string). + * @return {ExpiredStorage.PeekInterface} PeekInterface with: {value, timeLeft, isExpired} + */ + peek(key: string): ExpiredStorage.PeekInterface; + /** + * Update expiration time for an item (note: doesn't validate that the item is set). + * @param key: Item key to update expiration for (string). + * @param expiration: New expiration time in seconds to set. + * @return: Storage.setItem() return code for setting new expiration. + **/ + updateExpiration(key: string, expiration: number): any; + } + + namespace ExpiredStorage { + export interface PeekInterface { + /** + * The value of a [key] + */ + value: string | null, + /** + * Time remaining until expiration + */ + timeLeft: number | null, + /** + * Has the [key] expired or not + */ + isExpired: boolean, + } + } +} diff --git a/types/expired-storage/tsconfig.json b/types/expired-storage/tsconfig.json new file mode 100644 index 0000000000..140265cea8 --- /dev/null +++ b/types/expired-storage/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "expired-storage-tests.ts" + ] +} \ No newline at end of file diff --git a/types/expired-storage/tslint.json b/types/expired-storage/tslint.json new file mode 100644 index 0000000000..705507d3a2 --- /dev/null +++ b/types/expired-storage/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-void-expression": false, + "no-duplicate-imports": false, + "no-unnecessary-generics": false + } +} \ No newline at end of file From 625ba4186171c2332b9c58d8bc27150f04425351 Mon Sep 17 00:00:00 2001 From: Allen Gammel Date: Tue, 21 Aug 2018 17:30:57 -0500 Subject: [PATCH 11/66] updated based on npm test results --- .../expired-storage/expired-storage-tests.ts | 8 +- types/expired-storage/index.d.ts | 185 +++++++++--------- types/expired-storage/tsconfig.json | 2 +- 3 files changed, 96 insertions(+), 99 deletions(-) diff --git a/types/expired-storage/expired-storage-tests.ts b/types/expired-storage/expired-storage-tests.ts index 946051e218..269a8a61f3 100644 --- a/types/expired-storage/expired-storage-tests.ts +++ b/types/expired-storage/expired-storage-tests.ts @@ -1,8 +1,8 @@ -import { LocalStorage } from 'node-localstorage'; +// import { LocalStorage } from 'node-localstorage'; import ExpiredStorage = require('expired-storage'); -const localStorage = new LocalStorage('./scratch', Infinity); -const expiredStorage = new ExpiredStorage(localStorage); +// const localStorage = new LocalStorage('./scratch', Infinity); +const expiredStorage = new ExpiredStorage(); const mjkModel = { firstName: 'Maynard', @@ -44,7 +44,7 @@ do { const expiredKeys = expiredStorage.clearExpired(); -if (typeof expiredKeys['apc'] !== 'undefined') { +if (expiredKeys.indexOf('apc') === -1) { throw new Error('.clearExpired did not work..'); } diff --git a/types/expired-storage/index.d.ts b/types/expired-storage/index.d.ts index c7c113726e..bc7f7eb0b5 100644 --- a/types/expired-storage/index.d.ts +++ b/types/expired-storage/index.d.ts @@ -1,108 +1,105 @@ -// Type definitions for extended-storage v1.0.2 +// Type definitions for extended-storage 1.0 // Project: https://github.com/RonenNess/ExpiredStorage/ // Definitions by: Allen Gammel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -declare module "expired-storage" { +export = ExpiredStorage; - export = ExpiredStorage; +declare class ExpiredStorage { + constructor(localStorage?: any); + /** + * Clear the entire storage and all keys in it. + */ + clear(): void; + /** + * Get a json serializable value. This basically calls JSON.parse on the returned value. + * @param key Item key to get (string). + * @return Stored value (JSON.parsed), or undefined if not set / expired. + */ + getJson(key: string): any; + /** + * Get item. + * @param key: Item key to get (string). + * @return: Stored value, or undefined if not set / expired. + */ + getItem(key: string): string | null; + /** + * Remove an item. + * @param key Item key to remove (string). + * @return Storage.removeItem() return code. + */ + removeItem(key: string): any; + /** + * Set a json serializable value. This basically calls JSON.stringify on 'val' before setting it. + * @param key Item key to set (string). + * @param value Value to store (object, will be JSON.stringified). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @param return Storage.setItem() return code. + */ + setJson(key: string, value: object, expirationTime?: number): any; + /** + * Set item. + * @param key Item key to set (string). + * @param value Value to store (string). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @return Storage.setItem() return code. + */ + setItem(key: string, value: string, expiration?: number): any; + /** + * Get all keys in storage, not including internal keys used to store expiration. + * @param: includeExpired: if true, will also include expired keys. + * @return: Array with keys. + */ + keys(includeExpired: boolean): string[] | null; + /** + * Get item time left to live. + * @param key Item key to get (string). + * @return Time left to expire (in seconds), or null if don't have expiration date. + */ + getTimeLeft(key: string): number | null; + /** + * Clear expired keys. + * If you never call this function, expired keys will remain until you try to get them / reset a new value. + * + * @param return: List of removed keys due to expiration. + */ + clearExpired(): string[]; + /** + * Return if an item is expired (don't remove it, even if expired). + * @param key Item key to check (string). + * @return True if expired, False otherwise. + */ + isExpired(key: string): boolean; + /** + * Get item + metadata such as time left and if expired. + * Even if item expired, will not remove it. + * @param key Item key to get (string). + * @return PeekInterface with: {value, timeLeft, isExpired} + */ + peek(key: string): ExpiredStorage.PeekInterface; + /** + * Update expiration time for an item (note: doesn't validate that the item is set). + * @param key: Item key to update expiration for (string). + * @param expiration: New expiration time in seconds to set. + * @return: Storage.setItem() return code for setting new expiration. + */ + updateExpiration(key: string, expiration: number): any; +} - class ExpiredStorage { - constructor(); - constructor(localStorage?: any); +declare namespace ExpiredStorage { + interface PeekInterface { /** - * Clear the entire storage and all keys in it. + * The value of a [key] */ - clear(): void; + value: string | null; /** - * Get a json serializable value. This basically calls JSON.parse on the returned value. - * @param key Item key to get (string). - * @return Stored value (JSON.parsed), or undefined if not set / expired. - **/ - getJson(key: string): any; - /** - * Get item. - * @param key: Item key to get (string). - * @return: Stored value, or undefined if not set / expired. + * Time remaining until expiration */ - getItem(key: string): string | null; + timeLeft: number | null; /** - * Remove an item. - * @param key Item key to remove (string). - * @return Storage.removeItem() return code. + * Has the [key] expired or not */ - removeItem(key: string): any; - /** - * Set a json serializable value. This basically calls JSON.stringify on 'val' before setting it. - * @param key Item key to set (string). - * @param value Value to store (object, will be JSON.stringified). - * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. - * @param return Storage.setItem() return code. - **/ - setJson(key: string, value: object, expirationTime?: number): any; - /** - * Set item. - * @param key Item key to set (string). - * @param value Value to store (string). - * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. - * @return Storage.setItem() return code. - **/ - setItem(key: string, value: string, expiration?: number): any; - /** - * Get all keys in storage, not including internal keys used to store expiration. - * @param: includeExpired: if true, will also include expired keys. - * @return: Array with keys. - */ - keys(includeExpired: boolean): Array | null; - /** - * Get item time left to live. - * @param key Item key to get (string). - * @return Time left to expire (in seconds), or null if don't have expiration date. - */ - getTimeLeft(key: string): number | null; - /** - * Clear expired keys. - * If you never call this function, expired keys will remain until you try to get them / reset a new value. - * - * @param return: List of removed keys due to expiration. - */ - clearExpired(): Array | null; - /** - * Return if an item is expired (don't remove it, even if expired). - * @param key Item key to check (string). - * @return True if expired, False otherwise. - */ - isExpired(key: string): boolean; - /** - * Get item + metadata such as time left and if expired. - * Even if item expired, will not remove it. - * @param key Item key to get (string). - * @return {ExpiredStorage.PeekInterface} PeekInterface with: {value, timeLeft, isExpired} - */ - peek(key: string): ExpiredStorage.PeekInterface; - /** - * Update expiration time for an item (note: doesn't validate that the item is set). - * @param key: Item key to update expiration for (string). - * @param expiration: New expiration time in seconds to set. - * @return: Storage.setItem() return code for setting new expiration. - **/ - updateExpiration(key: string, expiration: number): any; - } - - namespace ExpiredStorage { - export interface PeekInterface { - /** - * The value of a [key] - */ - value: string | null, - /** - * Time remaining until expiration - */ - timeLeft: number | null, - /** - * Has the [key] expired or not - */ - isExpired: boolean, - } + isExpired: boolean; } } diff --git a/types/expired-storage/tsconfig.json b/types/expired-storage/tsconfig.json index 140265cea8..035c1af35e 100644 --- a/types/expired-storage/tsconfig.json +++ b/types/expired-storage/tsconfig.json @@ -4,7 +4,7 @@ "lib": [ "es6" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, From 86c7d8d495aab98be1a264b8247281eed31687ec Mon Sep 17 00:00:00 2001 From: Adam Eisenreich Date: Wed, 22 Aug 2018 10:38:49 +0200 Subject: [PATCH 12/66] fixup! Added textTracks & remoteTextTracks to video.js --- types/video.js/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 036aa1189b..87407dc81d 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -3768,13 +3768,13 @@ declare namespace videojs { * Get the remote {@link TextTrackList} * @return The current remote text track list */ - textTracks(): TextTrackList + textTracks(): TextTrackList; /** * Get the remote {@link TextTrackList} * @return The current remote text track list */ - remoteTextTracks(): TextTrackList + remoteTextTracks(): TextTrackList; /** * Create a remote {@link TextTrack} and an {@link HTMLTrackElement}. It will From b094f321f5ddc4cabfef6b2c4df7e4dbdedceed2 Mon Sep 17 00:00:00 2001 From: Adam Eisenreich Date: Wed, 22 Aug 2018 13:56:00 +0200 Subject: [PATCH 13/66] Fixed Element event handler --- types/video.js/index.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 87407dc81d..75884ffb7d 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -2628,7 +2628,8 @@ declare namespace videojs { * the listener function; otherwise, _all_ listeners bound to the * event type(s) will be removed. */ - off(targetOrType?: string | string[], typeOrListener?: (...args: any[]) => void, listener?: (...args: any[]) => void): void; + off(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + off(type?: string | string[], listener?: (...args: any[]) => void): void; /** * Add a listener to an event (or events) on this object or another evented @@ -2653,7 +2654,8 @@ declare namespace videojs { * If the first argument was another evented object, this will be * the listener function. */ - on(targetOrType: string | string[], typeOrListener: (...args: any[]) => void, listener?: (...args: any[]) => void): void; + on(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + on(type?: string | string[], listener?: (...args: any[]) => void): void; /** * Add a listener to an event (or events) on this object or another evented @@ -2678,7 +2680,8 @@ declare namespace videojs { * If the first argument was another evented object, this will be * the listener function. */ - one(targetOrType: string | string[], typeOrListener: (...args: any[]) => void, listener?: (...args: any[]) => void): void; + one(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + one(type?: string | string[], listener?: (...args: any[]) => void): void; /** * Fire an event on this evented object, causing its listeners to be called. From 1f779ef3af4778bcbe6ee351427e60f6d4960af5 Mon Sep 17 00:00:00 2001 From: Adam Eisenreich Date: Wed, 22 Aug 2018 14:31:00 +0200 Subject: [PATCH 14/66] fixup! Fixed Element event handler --- types/video.js/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 75884ffb7d..db3697b65a 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -2628,7 +2628,7 @@ declare namespace videojs { * the listener function; otherwise, _all_ listeners bound to the * event type(s) will be removed. */ - off(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + off(target?: Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; off(type?: string | string[], listener?: (...args: any[]) => void): void; /** @@ -2654,7 +2654,7 @@ declare namespace videojs { * If the first argument was another evented object, this will be * the listener function. */ - on(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + on(target?: Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; on(type?: string | string[], listener?: (...args: any[]) => void): void; /** @@ -2680,7 +2680,7 @@ declare namespace videojs { * If the first argument was another evented object, this will be * the listener function. */ - one(target?: videojs.Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; + one(target?: Component | Element, type?: string | string[], listener?: (...args: any[]) => void): void; one(type?: string | string[], listener?: (...args: any[]) => void): void; /** From 236fe406c759dfdfae01d03462d0f2b1256b86a3 Mon Sep 17 00:00:00 2001 From: Allen Gammel Date: Wed, 22 Aug 2018 08:40:04 -0500 Subject: [PATCH 15/66] added strictNullChecks, removed addtl tslint rules, added null checks --- types/expired-storage/expired-storage-tests.ts | 13 +++++++++---- types/expired-storage/tsconfig.json | 2 +- types/expired-storage/tslint.json | 7 +------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/types/expired-storage/expired-storage-tests.ts b/types/expired-storage/expired-storage-tests.ts index 269a8a61f3..fa2dd29ef7 100644 --- a/types/expired-storage/expired-storage-tests.ts +++ b/types/expired-storage/expired-storage-tests.ts @@ -1,7 +1,8 @@ -// import { LocalStorage } from 'node-localstorage'; +// import { LocalStorage } from 'node-localstorage'; // Removed since this pkg isn't getting installed. import ExpiredStorage = require('expired-storage'); // const localStorage = new LocalStorage('./scratch', Infinity); +// const expiredStorage = new ExpiredStorage(localStorage); // ExpiredStorage requires a LocalStorage provider const expiredStorage = new ExpiredStorage(); const mjkModel = { @@ -26,7 +27,9 @@ if (typeof mjkTest === 'undefined' || mjkTest.firstName !== mjkModel.firstName | throw new Error('.setJson method is not working!'); } -if (expiredStorage.keys(true).length === 2) { +const keyCheck = expiredStorage.keys(true); + +if (keyCheck && keyCheck.length === 2) { throw new Error('.keys method has failed.'); } @@ -44,7 +47,7 @@ do { const expiredKeys = expiredStorage.clearExpired(); -if (expiredKeys.indexOf('apc') === -1) { +if (expiredKeys.indexOf('apc') !== -1) { throw new Error('.clearExpired did not work..'); } @@ -56,7 +59,9 @@ expiredStorage.setItem('puscifer', 'the humbling river', 10000); expiredStorage.updateExpiration('puscifer', 5000); -if (expiredStorage.getTimeLeft('puscifer') >= 10000) { +const checkKeyTime = expiredStorage.getTimeLeft('puscifer'); + +if (checkKeyTime && checkKeyTime >= 10000) { throw new Error('.updateExpiration method is broken -- or .getTimeLeft method is broken.'); } diff --git a/types/expired-storage/tsconfig.json b/types/expired-storage/tsconfig.json index 035c1af35e..cd1454cca7 100644 --- a/types/expired-storage/tsconfig.json +++ b/types/expired-storage/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/expired-storage/tslint.json b/types/expired-storage/tslint.json index 705507d3a2..e60c15844f 100644 --- a/types/expired-storage/tslint.json +++ b/types/expired-storage/tslint.json @@ -1,8 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-void-expression": false, - "no-duplicate-imports": false, - "no-unnecessary-generics": false - } + "extends": "dtslint/dt.json" } \ No newline at end of file From 9b711fb5ee5875be7263e774c1b6f2b95ee26997 Mon Sep 17 00:00:00 2001 From: Megan Riel-Mehan Date: Wed, 22 Aug 2018 17:01:40 -0700 Subject: [PATCH 16/66] added histogram as plot type option --- types/plotly.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index 7bdf862ea2..e4904fff98 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -423,7 +423,7 @@ export type Color = string | Array | Array Date: Wed, 22 Aug 2018 18:21:15 -0700 Subject: [PATCH 17/66] added transform interface --- types/plotly.js/index.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index e4904fff98..a14ba14aba 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -470,8 +470,39 @@ export interface ScatterData { name: string; connectgaps: boolean; visible: boolean | 'legendonly'; + transforms: Transform[]; } +/** + * These interfaces are based on attribute descriptions in + * https://github.com/plotly/plotly.js/tree/9d6144304308fc3007f0facf2535d38ea3e9b26c/src/transforms + */ + +export interface TransformStyle { + target: number | string | number[] | string[]; + value: Partial; +} + +export interface TransformAggregation { + target: string; + func?: 'count' | 'sum' | 'avg' | 'median' | 'mode' | 'rms' | 'stddev' | 'min' | 'max' | 'first' | 'last'; + funcmode?: 'sample' | 'population'; + enabled?: boolean; +} + +export interface Transform { + type: 'aggregate' | 'filter' | 'groupby' | 'sort'; + enabled?: boolean; + target?: number | string | number[] | string[]; + operation?: string; + aggregations?: TransformAggregation[]; + preservegaps?: boolean; + groups?: string | number[] | string[]; + nameformat: string; + styles?: TransformStyle[]; + value?: any; + order?: 'ascending' | 'descending'; +} /** * Any combination of "x", "y", "z", "text", "name" joined with a "+" OR "all" or "none" or "skip". * examples: "x", "y", "x+y", "x+y+z", "all" From bd493ea22415d7abf3feaa56428d4a3fc2c040b4 Mon Sep 17 00:00:00 2001 From: Megan Riel-Mehan Date: Wed, 22 Aug 2018 18:21:59 -0700 Subject: [PATCH 18/66] added additional x axes in layout interface --- types/plotly.js/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index a14ba14aba..84cad93b48 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -192,6 +192,14 @@ export interface Layout { separators: string; hidesources: boolean; xaxis: Partial; + xaxis2: Partial; + xaxis3: Partial; + xaxis4: Partial; + xaxis5: Partial; + xaxis6: Partial; + xaxis7: Partial; + xaxis8: Partial; + xaxis9: Partial; yaxis: Partial; yaxis2: Partial; yaxis3: Partial; From a1dadf7b216f65c63795ef92609b805505f510fd Mon Sep 17 00:00:00 2001 From: Megan Riel-Mehan Date: Thu, 23 Aug 2018 11:26:47 -0700 Subject: [PATCH 19/66] updated selection interface to include selection description --- types/plotly.js/index.d.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index 84cad93b48..3a5784ae21 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -49,10 +49,20 @@ export interface PlotCoordinate { pointNumber: number; } -export interface PlotSelectionEvent { - points: PlotCoordinate[]; +export interface SelectionDescription { + x: number[], + y: number[], } +export type PlotSelectedData = Partial; + +export interface PlotSelectionEvent { + points: PlotSelectedData[]; + range?: SelectionDescription; + lassoPoints?: SelectionDescription; +} + + export type PlotRestyleEvent = [ any, // update object -- attribute updated: new value number[] // array of traces updated From 13253643343e5efedd0f50f3aa9929a84f55e206 Mon Sep 17 00:00:00 2001 From: Megan Riel-Mehan Date: Thu, 23 Aug 2018 17:20:01 -0700 Subject: [PATCH 20/66] Renamed ScatterData and ScatterMarker since they're used for other plots --- types/plotly.js/index.d.ts | 820 +++++++++++++++++++------------------ 1 file changed, 411 insertions(+), 409 deletions(-) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index 3a5784ae21..0e943ef569 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -29,7 +29,7 @@ export interface Point { export interface PlotScatterDataPoint { curveNumber: number; - data: ScatterData; + data: PlotData; pointIndex: number; pointNumber: number; x: number; @@ -57,12 +57,11 @@ export interface SelectionDescription { export type PlotSelectedData = Partial; export interface PlotSelectionEvent { - points: PlotSelectedData[]; + points: PlotScatterDataPoint[]; range?: SelectionDescription; lassoPoints?: SelectionDescription; } - export type PlotRestyleEvent = [ any, // update object -- attribute updated: new value number[] // array of traces updated @@ -151,10 +150,10 @@ export interface PlotlyHTMLElement extends HTMLElement { on(event: 'plotly_sliderend', callback: (event: SliderEndEvent) => void): void; on(event: 'plotly_sliderstart', callback: (event: SliderStartEvent) => void): void; on(event: 'plotly_event', callback: (data: any) => void): void; - on(event: 'plotly_beforeplot' , callback: (event: BeforePlotEvent) => boolean): void; + on(event: 'plotly_beforeplot', callback: (event: BeforePlotEvent) => boolean): void; on(event: 'plotly_afterexport' | 'plotly_afterplot' | 'plotly_animated' | 'plotly_animationinterrupted' | 'plotly_autosize' | 'plotly_beforeexport' | 'plotly_deselect' | 'plotly_doubleclick' | 'plotly_framework' | 'plotly_redraw' | - 'plotly_transitioning' | 'plotly_transitioninterrupted' , callback: () => void): void; + 'plotly_transitioning' | 'plotly_transitioninterrupted', callback: () => void): void; } export interface ToImgopts { @@ -394,32 +393,32 @@ export interface ModeBarButton { /** name / id of the buttons (for tracking) */ name: string; - /** - * text that appears while hovering over the button, - * enter null, false or '' for no hover text - */ + /** + * text that appears while hovering over the button, + * enter null, false or '' for no hover text + */ title: string; - /** - * svg icon object associated with the button - * can be linked to Plotly.Icons to use the default plotly icons - */ + /** + * svg icon object associated with the button + * can be linked to Plotly.Icons to use the default plotly icons + */ icon: string | Icon; /** icon positioning */ gravity?: string; - /** - * click handler associated with the button, a function of - * 'gd' (the main graph object) and - * 'ev' (the event object) - */ + /** + * click handler associated with the button, a function of + * 'gd' (the main graph object) and + * 'ev' (the event object) + */ click: ButtonClickEvent; - /** - * attribute associated with button, - * use this with 'val' to keep track of the state - */ + /** + * attribute associated with button, + * use this with 'val' to keep track of the state + */ attr?: string; /** initial 'attr' value, can be a function of gd */ @@ -436,12 +435,13 @@ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int export type Dash = 'solid' | 'dot' | 'dash' | 'longdash' | 'dashdot' | 'longdashdot'; -export type Data = Partial; +export type Data = Partial; export type Color = string | Array | Array>; - +export type DataTransForm = Partial; +export type ScatterData = PlotData; // Bar Scatter -export interface ScatterData { - type: 'bar' | 'histogram' | 'pointcloud' | 'scatter' | 'scattergl' | 'scatter3d' |'surface'; +export interface PlotData { + type: 'bar' | 'histogram' | 'pointcloud' | 'scatter' | 'scattergl' | 'scatter3d' | 'surface'; x: Datum[] | Datum[][] | TypedArray; y: Datum[] | Datum[][] | TypedArray; z: Datum[] | Datum[][] | Datum[][][] | TypedArray; @@ -456,7 +456,7 @@ export interface ScatterData { 'line.shape': 'linear' | 'spline' | 'hv' | 'vh' | 'hvh' | 'vhv'; 'line.smoothing': number; 'line.simplify': boolean; - marker: Partial; + marker: Partial; 'marker.symbol': string | string[]; // Drawing.symbolList 'marker.color': Color; 'marker.opacity': number | number[]; @@ -472,15 +472,15 @@ export interface ScatterData { mode: 'lines' | 'markers' | 'text' | 'lines+markers' | 'text+markers' | 'text+lines' | 'text+lines+markers' | 'none'; hoveron: 'points' | 'fills'; hoverinfo: 'all' | 'name' | 'none' | 'skip' | 'text' | - 'x' | 'x+text' | 'x+name' | - 'x+y' | 'x+y+text' | 'x+y+name' | - 'x+y+z' | 'x+y+z+text' | 'x+y+z+name' | - 'y+x' | 'y+x+text' | 'y+x+name' | - 'y+z' | 'y+z+text' | 'y+z+name' | - 'y+x+z' | 'y+x+z+text' | 'y+x+z+name' | - 'z+x' | 'z+x+text' | 'z+x+name' | - 'z+y+x' | 'z+y+x+text' | 'z+y+x+name' | - 'z+x+y' | 'z+x+y+text' | 'z+x+y+name'; + 'x' | 'x+text' | 'x+name' | + 'x+y' | 'x+y+text' | 'x+y+name' | + 'x+y+z' | 'x+y+z+text' | 'x+y+z+name' | + 'y+x' | 'y+x+text' | 'y+x+name' | + 'y+z' | 'y+z+text' | 'y+z+name' | + 'y+x+z' | 'y+x+z+text' | 'y+x+z+name' | + 'z+x' | 'z+x+text' | 'z+x+name' | + 'z+y+x' | 'z+y+x+text' | 'z+y+x+name' | + 'z+x+y' | 'z+x+y+text' | 'z+x+y+name'; hoverlabel: Partial