From 3917abac4746cb36f83610d505279f68c1947d02 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 12 Oct 2017 11:22:36 +0900 Subject: [PATCH 001/109] Resolve N3.js lint errors --- types/n3/index.d.ts | 209 +++++++++++++++++++---------------------- types/n3/n3-tests.ts | 73 +++++++------- types/n3/tsconfig.json | 2 +- types/n3/tslint.json | 80 +--------------- 4 files changed, 135 insertions(+), 229 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index c773c85a28..0ea01c1883 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -1,125 +1,110 @@ -// Type definitions for N3 +// Type definitions for N3 0.12 // Project: https://github.com/RubenVerborgh/N3.js // Definitions by: Fred Eisele +// Ruben Taelman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// - import * as fs from "fs"; import * as stream from "stream"; -declare namespace N3 { +export type ErrorCallback = (err: Error, result: any) => void; - type ErrorCallback = (err: Error, result: any) => void; - - interface Prefixes { - [key: string]: string; - } - - interface LiteralValue { - value: string | number; - } - - interface Triple { - subject: string, - predicate: string, - object: string, - graph?: string - } - - interface BlankTriple { - predicate: string, - object: string - } - - - interface ParserConstructor { - new (options?: ParserOptions): N3Parser; - (options?: ParserOptions): N3Parser; - } - const Parser: ParserConstructor; - - interface StreamParserConstructor { - new (options?: ParserOptions): N3StreamParser; - (options?: ParserOptions): N3StreamParser; - } - const StreamParser: StreamParserConstructor; - - interface ParserOptions { - format?: string, - prefixes?: string[] - } - - interface ParseCallback { - (error: Error, triple: Triple, prefixes: Prefixes): void; - } - - interface Logger { - (message?: any, ...optionalParams: any[]): void; - } - interface N3Parser { - parse(input: string, callback: ParseCallback): void; - parse(subject: string, predicate: string, object: string): void; - parse(triple: Triple): void; - parse(stream: fs.ReadStream, log: Logger): void; - } - - interface N3StreamParser extends N3Parser, fs.WriteStream { - pipe(consumer: T): T; - } - - - interface WriterConstructor { - new (options?: WriterOptions): N3Writer; - (options?: WriterOptions): N3Writer; - - new (fd: any, options?: WriterOptions): N3Writer; - (fd: any, options?: WriterOptions): N3Writer; - } - const Writer: WriterConstructor; - - interface N3Writer { - addTriple(subject: string, predicate: string, object: string): void; - addTriple(subject: string, predicate: string, object: string[]): void; - addTriple(triple: Triple): void; - end(err?: ErrorCallback, result?: any): void; - blank(ns: string, name: string): string; - blank(triple: BlankTriple[]): string; - list(triple: string[]): string[]; - } - - function StreamWriter(options: WriterOptions): N3StreamWriter; - - interface N3StreamWriter extends N3Writer { - pipe(consumer: NodeJS.WritableStream): void; - pipe(consumer: stream.Writable): void; - } - - interface WriterOptions { - format?: string, - prefixes?: Prefixes - } - - interface N3StoreWriter extends N3Writer { - find(subject: string, predicate: string | null, object: string | null): Triple[]; - } - function Store(): N3StoreWriter; - - namespace Util { - function createLiteral(value: any): string; - function createLiteral(value: any, type: string): string; - - function isIRI(value: string): boolean; - function isLiteral(value: string): boolean; - function getLiteralValue(value: string): string; - function getLiteralLanguage(value: string): string; - function getLiteralType(value: string): string; - function isBlank(value: string): boolean; - function isPrefixedName(name: string): boolean; - function expandPrefixedName(name: string, prefixes: Prefixes): string; - } +export interface Prefixes { + [key: string]: string; } -export = N3; +export interface LiteralValue { + value: string | number; +} +export interface Triple { + subject: string; + predicate: string; + object: string; + graph?: string; +} + +export interface BlankTriple { + predicate: string; + object: string; +} + +export interface ParserConstructor { + new (options?: ParserOptions): N3Parser; + (options?: ParserOptions): N3Parser; +} +export const Parser: ParserConstructor; + +export interface StreamParserConstructor { + new (options?: ParserOptions): N3StreamParser; + (options?: ParserOptions): N3StreamParser; +} +export const StreamParser: StreamParserConstructor; + +export interface ParserOptions { + format?: string; + prefixes?: string[]; +} + +export type ParseCallback = (error: Error, triple: Triple, prefixes: Prefixes) => void; + +export type Logger = (message?: any, ...optionalParams: any[]) => void; + +export interface N3Parser { + parse(input: string, callback: ParseCallback): void; + parse(subject: string, predicate: string, object: string): void; + parse(triple: Triple): void; + parse(stream: fs.ReadStream, log: Logger): void; +} + +export interface N3StreamParser extends N3Parser, fs.WriteStream { + pipe(consumer: T): T; +} + +export interface WriterConstructor { + new (options?: WriterOptions): N3Writer; + new (fd: any, options?: WriterOptions): N3Writer; + (options?: WriterOptions): N3Writer; + (fd: any, options?: WriterOptions): N3Writer; +} +export const Writer: WriterConstructor; + +export interface N3Writer { + addTriple(subject: string, predicate: string, object: string | string[]): void; + addTriple(triple: Triple): void; + end(err?: ErrorCallback, result?: any): void; + blank(ns: string, name: string): string; + blank(triple: BlankTriple[]): string; + list(triple: string[]): string[]; +} + +export function StreamWriter(options: WriterOptions): N3StreamWriter; + +export interface N3StreamWriter extends N3Writer { + pipe(consumer: NodeJS.WritableStream | stream.Writable): void; +} + +export interface WriterOptions { + format?: string; + prefixes?: Prefixes; +} + +export interface N3StoreWriter extends N3Writer { + find(subject: string, predicate: string | null, object: string | null): Triple[]; +} +export function Store(): N3StoreWriter; + +export namespace Util { + function createLiteral(value: any, type?: string): string; + + function isIRI(value: string): boolean; + function isLiteral(value: string): boolean; + function getLiteralValue(value: string): string; + function getLiteralLanguage(value: string): string; + function getLiteralType(value: string): string; + function isBlank(value: string): boolean; + function isPrefixedName(name: string): boolean; + function expandPrefixedName(name: string, prefixes: Prefixes): string; +} diff --git a/types/n3/n3-tests.ts b/types/n3/n3-tests.ts index d3c664c61e..275e0fc039 100644 --- a/types/n3/n3-tests.ts +++ b/types/n3/n3-tests.ts @@ -3,8 +3,7 @@ import * as fs from "fs"; import * as stream from "stream"; function test_serialize() { - - var writer: N3.N3Writer = N3.Writer( + const writer: N3.N3Writer = N3.Writer( { format: "ttl", prefixes: { @@ -24,56 +23,56 @@ function test_serialize() { }); } -/** +/* The following tests are taken from ... https://github.com/RubenVerborgh/N3.js/blob/master/README.md */ function test_doc_rdf_to_triples_1() { - var parser = N3.Parser(); - parser.parse('@prefix c: .\n' + - 'c:Tom a c:Cat.\n' + - 'c:Jerry a c:Mouse;\n' + - ' c:smarterThan c:Tom.', - function (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) { + const parser = N3.Parser(); + parser.parse(`@prefix c: . + c:Tom a c:Cat. + c:Jerry a c:Mouse; + c:smarterThan c:Tom.`, + (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) => { if (triple) console.log(triple.subject, triple.predicate, triple.object, '.'); else - console.log("# That's all, folks!", prefixes) + console.log("# That's all, folks!", prefixes); }); } function test_doc_rdf_to_triples_2() { - var parser1 = N3.Parser({ format: 'N-Triples' }); - var parser2 = N3.Parser({ format: 'application/trig' }); + const parser1 = N3.Parser({ format: 'N-Triples' }); + const parser2 = N3.Parser({ format: 'application/trig' }); // Notation3 (N3) is supported only through the format argument: - var parser3 = N3.Parser({ format: 'N3' }); - var parser4 = N3.Parser({ format: 'Notation3' }); - var parser5 = N3.Parser({ format: 'text/n3' }); + const parser3 = N3.Parser({ format: 'N3' }); + const parser4 = N3.Parser({ format: 'Notation3' }); + const parser5 = N3.Parser({ format: 'text/n3' }); } function test_doc_rdf_stream_to_triples_1() { - var parser = N3.Parser(); - var rdfStream = fs.createReadStream('cartoons.ttl'); - parser.parse(rdfStream, console.log); + const parser = N3.Parser(); + const rdfStream1 = fs.createReadStream('cartoons.ttl'); + parser.parse(rdfStream1, console.log); - var streamParser = N3.StreamParser(); - var rdfStream = fs.createReadStream('cartoons.ttl'); - rdfStream.pipe(streamParser); + const streamParser = N3.StreamParser(); + const rdfStream2 = fs.createReadStream('cartoons.ttl'); + rdfStream2.pipe(streamParser); streamParser.pipe(new class SlowConsumer extends stream.Writable { constructor() { super({ objectMode: true }); - this._write = function (triple, encoding, done) { + this._write = (triple, encoding, done) => { console.log(triple); setTimeout(done, 1000); }; } - }); + }()); } function test_doc_from_triples_to_string() { - var writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); + const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); writer.addTriple('http://example.org/cartoons#Tom', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/cartoons#Cat'); @@ -82,14 +81,14 @@ function test_doc_from_triples_to_string() { predicate: 'http://example.org/cartoons#name', object: '"Tom"' }); - writer.end(function (error, result) { console.log(result); }); + writer.end((error, result) => { console.log(result); }); - var writer1 = N3.Writer({ format: 'N-Triples' }); - var writer2 = N3.Writer({ format: 'application/trig' }); + const writer1 = N3.Writer({ format: 'N-Triples' }); + const writer2 = N3.Writer({ format: 'application/trig' }); } function test_doc_from_triples_to_rdf_stream() { - var writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } }); + const writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } }); writer.addTriple('http://example.org/cartoons#Tom', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/cartoons#Cat'); @@ -102,16 +101,16 @@ function test_doc_from_triples_to_rdf_stream() { } function test_doc_from_triple_stream_to_rdf_stream() { - var streamParser = new N3.StreamParser(), - inputStream = fs.createReadStream('cartoons.ttl'), - streamWriter = /* new */ N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } }); + const streamParser = new N3.StreamParser(); + const inputStream = fs.createReadStream('cartoons.ttl'); + const streamWriter = /* new */ N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } }); inputStream.pipe(streamParser); streamParser.pipe(streamWriter); streamWriter.pipe(process.stdout); } function test_doc_blank_nodes_and_lists() { - var writer = N3.Writer({ + const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#', foaf: 'http://xmlns.com/foaf/0.1/' @@ -135,20 +134,20 @@ function test_doc_blank_nodes_and_lists() { 'http://example.org/cartoons#Tom', 'http://example.org/cartoons#Jerry' ])); - writer.end(function (error, result) { console.log(result); }); + writer.end((error, result) => { console.log(result); }); } function test_doc_storing() { - var store = N3.Store(); + const store = N3.Store(); store.addTriple('http://ex.org/Pluto', 'http://ex.org/type', 'http://ex.org/Dog'); store.addTriple('http://ex.org/Mickey', 'http://ex.org/type', 'http://ex.org/Mouse'); - var mickey = store.find('http://ex.org/Mickey', null, null)[0]; + const mickey = store.find('http://ex.org/Mickey', null, null)[0]; console.log(mickey.subject, mickey.predicate, mickey.object, '.'); } function test_doc_utility() { - var N3Util = N3.Util; + const N3Util = N3.Util; N3Util.isIRI('http://example.org/cartoons#Mickey'); // true N3Util.isLiteral('"Mickey Mouse"'); // true @@ -175,7 +174,7 @@ function test_doc_utility() { N3Util.isIRI('_:b1'); // false N3Util.isLiteral('_:b1'); // false - var prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }; + const prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }; N3Util.isPrefixedName('rdfs:label'); // true; N3Util.expandPrefixedName('rdfs:label', prefixes); // http://www.w3.org/2000/01/rdf-schema#label } diff --git a/types/n3/tsconfig.json b/types/n3/tsconfig.json index 4ba121903d..11e61e58e3 100644 --- a/types/n3/tsconfig.json +++ b/types/n3/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "n3-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/n3/tslint.json b/types/n3/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/n3/tslint.json +++ b/types/n3/tslint.json @@ -1,79 +1 @@ -{ - "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 - } -} +{ "extends": "dtslint/dt.json" } From 974a50c7f537f5b982f812c3b0b561ec1300e5c0 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 12 Oct 2017 12:10:36 +0900 Subject: [PATCH 002/109] Update n3 to 0.12 with RDFJS types --- types/n3/index.d.ts | 87 +++++++++++++++++++++++++++++++++++++------- types/n3/n3-tests.ts | 12 +++--- 2 files changed, 79 insertions(+), 20 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index 0ea01c1883..c83005e9cc 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -8,6 +8,7 @@ import * as fs from "fs"; import * as stream from "stream"; +import * as RDF from "rdf-js"; export type ErrorCallback = (err: Error, result: any) => void; @@ -15,17 +16,71 @@ export interface Prefixes { [key: string]: string; } -export interface LiteralValue { - value: string | number; +export class Term { + termType: "NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph"; + constructor(iri: string); + toJSON(): string; + equals(other: RDF.Term): boolean; + subclass(type: any): void; + static fromId(id: string): NamedNode | BlankNode | Variable | Literal; } -export interface Triple { - subject: string; - predicate: string; - object: string; - graph?: string; +export class NamedNode extends Term implements RDF.NamedNode { + termType: "NamedNode"; + value: string; + constructor(iri: string); + toJSON(): string; + equals(other: RDF.Term): boolean; } +export class BlankNode extends Term implements RDF.BlankNode { + static nextId: number; + termType: "BlankNode"; + value: string; + constructor(name: string); + toJSON(): string; + equals(other: RDF.Term): boolean; +} + +export class Variable extends Term implements RDF.Variable { + termType: "Variable"; + value: string; + constructor(name: string); + toJSON(): string; + equals(other: RDF.Term): boolean; +} + +export class Literal extends Term implements RDF.Literal { + static readonly langStringDatatype: NamedNode; + termType: "Literal"; + value: string; + language: string; + datatype: RDF.NamedNode; + datatypeString: string; + constructor(id: string); + toJSON(): string; + equals(other: RDF.Term): boolean; +} + +export class DefaultGraph extends Term implements RDF.DefaultGraph { + termType: "DefaultGraph"; + value: ""; + constructor(); + equals(other: RDF.Term): boolean; +} + +export class Quad implements RDF.Quad { + constructor(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term); + subject: RDF.Term; + predicate: RDF.Term; + object: RDF.Term; + graph: RDF.Term; + toJSON(): string; + equals(quad: RDF.Quad): boolean; +} + +export class Triple extends Quad implements RDF.Triple {} + export interface BlankTriple { predicate: string; object: string; @@ -48,15 +103,12 @@ export interface ParserOptions { prefixes?: string[]; } -export type ParseCallback = (error: Error, triple: Triple, prefixes: Prefixes) => void; +export type ParseCallback = (error: Error, quad: Quad, prefixes: Prefixes) => void; export type Logger = (message?: any, ...optionalParams: any[]) => void; export interface N3Parser { parse(input: string, callback: ParseCallback): void; - parse(subject: string, predicate: string, object: string): void; - parse(triple: Triple): void; - parse(stream: fs.ReadStream, log: Logger): void; } export interface N3StreamParser extends N3Parser, fs.WriteStream { @@ -71,9 +123,16 @@ export interface WriterConstructor { } export const Writer: WriterConstructor; +export interface N3Quad { + subject: string; + predicate: string; + object: string; + graph?: string; +} + export interface N3Writer { - addTriple(subject: string, predicate: string, object: string | string[]): void; - addTriple(triple: Triple): void; + addTriple(subject: string, predicate: string, object: string | string[], graph?: string, done?: () => void): void; + addTriple(quad: N3Quad): void; end(err?: ErrorCallback, result?: any): void; blank(ns: string, name: string): string; blank(triple: BlankTriple[]): string; @@ -92,7 +151,7 @@ export interface WriterOptions { } export interface N3StoreWriter extends N3Writer { - find(subject: string, predicate: string | null, object: string | null): Triple[]; + find(subject: string, predicate: string | null, object: string | null): N3Quad[]; } export function Store(): N3StoreWriter; diff --git a/types/n3/n3-tests.ts b/types/n3/n3-tests.ts index 275e0fc039..f7e181cc74 100644 --- a/types/n3/n3-tests.ts +++ b/types/n3/n3-tests.ts @@ -1,4 +1,5 @@ import * as N3 from "n3"; +import * as RDF from "rdf-js"; import * as fs from "fs"; import * as stream from "stream"; @@ -54,17 +55,16 @@ function test_doc_rdf_to_triples_2() { function test_doc_rdf_stream_to_triples_1() { const parser = N3.Parser(); - const rdfStream1 = fs.createReadStream('cartoons.ttl'); - parser.parse(rdfStream1, console.log); + parser.parse('abc', console.log); const streamParser = N3.StreamParser(); - const rdfStream2 = fs.createReadStream('cartoons.ttl'); - rdfStream2.pipe(streamParser); + const rdfStream = fs.createReadStream('cartoons.ttl'); + rdfStream.pipe(streamParser); streamParser.pipe(new class SlowConsumer extends stream.Writable { constructor() { super({ objectMode: true }); - this._write = (triple, encoding, done) => { - console.log(triple); + this._write = (quad: RDF.Quad, encoding, done) => { + console.log(quad); setTimeout(done, 1000); }; } From b5719fd0d2db94f6e83de67600a439825158c5bb Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 13 Oct 2017 14:39:57 +0900 Subject: [PATCH 003/109] Update n3 writer types --- types/n3/index.d.ts | 105 +++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 31 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index c83005e9cc..4621336998 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Fred Eisele // Ruben Taelman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// @@ -10,19 +11,19 @@ import * as fs from "fs"; import * as stream from "stream"; import * as RDF from "rdf-js"; -export type ErrorCallback = (err: Error, result: any) => void; - export interface Prefixes { [key: string]: string; } export class Term { termType: "NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph"; + id: string; constructor(iri: string); toJSON(): string; equals(other: RDF.Term): boolean; subclass(type: any): void; static fromId(id: string): NamedNode | BlankNode | Variable | Literal; + static toId(term: string | null | RDF.Term): string; } export class NamedNode extends Term implements RDF.NamedNode { @@ -81,9 +82,18 @@ export class Quad implements RDF.Quad { export class Triple extends Quad implements RDF.Triple {} +export type ErrorCallback = (err: Error, result: any) => void; +export type QuadCallback = (result: Quad) => void; +export type QuadPredicate = (result: Quad) => boolean; + +export type OTerm = string | null; +export type OIRI = RDF.Term | null; + +export type Logger = (message?: any, ...optionalParams: any[]) => void; + export interface BlankTriple { - predicate: string; - object: string; + predicate: RDF.Term; + object: RDF.Term; } export interface ParserConstructor { @@ -92,12 +102,6 @@ export interface ParserConstructor { } export const Parser: ParserConstructor; -export interface StreamParserConstructor { - new (options?: ParserOptions): N3StreamParser; - (options?: ParserOptions): N3StreamParser; -} -export const StreamParser: StreamParserConstructor; - export interface ParserOptions { format?: string; prefixes?: string[]; @@ -105,16 +109,25 @@ export interface ParserOptions { export type ParseCallback = (error: Error, quad: Quad, prefixes: Prefixes) => void; -export type Logger = (message?: any, ...optionalParams: any[]) => void; - export interface N3Parser { parse(input: string, callback: ParseCallback): void; } +export interface StreamParserConstructor { + new (options?: ParserOptions): N3StreamParser; + (options?: ParserOptions): N3StreamParser; +} +export const StreamParser: StreamParserConstructor; + export interface N3StreamParser extends N3Parser, fs.WriteStream { pipe(consumer: T): T; } +export interface WriterOptions { + format?: string; + prefixes?: Prefixes; +} + export interface WriterConstructor { new (options?: WriterOptions): N3Writer; new (fd: any, options?: WriterOptions): N3Writer; @@ -123,20 +136,16 @@ export interface WriterConstructor { } export const Writer: WriterConstructor; -export interface N3Quad { - subject: string; - predicate: string; - object: string; - graph?: string; -} - export interface N3Writer { - addTriple(subject: string, predicate: string, object: string | string[], graph?: string, done?: () => void): void; - addTriple(quad: N3Quad): void; + tripleToString(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): string; + triplesToString(quads: RDF.Quad[]): string; + addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addTriple(quad: RDF.Quad): void; + addTriples(quads: RDF.Quad[]): void; end(err?: ErrorCallback, result?: any): void; - blank(ns: string, name: string): string; - blank(triple: BlankTriple[]): string; - list(triple: string[]): string[]; + blank(predicate: RDF.Term, object: RDF.Term): string; + blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): string; + list(triple: RDF.Term[]): string[]; } export function StreamWriter(options: WriterOptions): N3StreamWriter; @@ -145,16 +154,50 @@ export interface N3StreamWriter extends N3Writer { pipe(consumer: NodeJS.WritableStream | stream.Writable): void; } -export interface WriterOptions { - format?: string; +export interface N3Store { + size: number; + addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addTriple(quad: RDF.Quad): void; + addTriples(quads: RDF.Quad[]): void; + addPrefix(prefix: string, iri: RDF.NamedNode): void; + addPrefixes(prefixes: Prefixes): void; + removeTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + removeTriple(quad: RDF.Quad): void; + removeTriples(quads: RDF.Quad[]): void; + getTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): Quad[]; + getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): Quad[]; + countTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number; + countTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): number; + forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void; + forEachByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): void; + every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + everyByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; + some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + someByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; + getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getSubjectsByIRI(predicate: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; + forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void; + forSubjectsByIRI(callback: QuadCallback, predicate: OIRI, object: OIRI, graph: OIRI): void; + getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getPredicatesByIRI(subject: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; + forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void; + forPredicatesByIRI(callback: QuadCallback, subject: OIRI, object: OIRI, graph: OIRI): void; + getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[]; + getObjectsByIRI(subject: OIRI, predicate: OIRI, graph: OIRI): RDF.Term[]; + forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; + forObjectsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, graph: OIRI): void; + getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; + getGraphsByIRI(subject: OIRI, predicate: OIRI, object: OIRI): RDF.Term[]; + forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; + forGraphsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI): void; + createBlankNode(suggestedName: string): BlankNode; +} +export function Store(triples?: RDF.Quad[], options?: StoreOptions): N3Store; + +export interface StoreOptions { prefixes?: Prefixes; } -export interface N3StoreWriter extends N3Writer { - find(subject: string, predicate: string | null, object: string | null): N3Quad[]; -} -export function Store(): N3StoreWriter; - export namespace Util { function createLiteral(value: any, type?: string): string; From d51d1c98efa1edc5a0d2d2474ea67aa419a66c8b Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 18 Oct 2017 15:26:20 +0900 Subject: [PATCH 004/109] Update n3 store and util types --- types/n3/index.d.ts | 51 ++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index 4621336998..75c2318743 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -86,7 +86,7 @@ export type ErrorCallback = (err: Error, result: any) => void; export type QuadCallback = (result: Quad) => void; export type QuadPredicate = (result: Quad) => boolean; -export type OTerm = string | null; +export type OString = string | RDF.Term | null; export type OIRI = RDF.Term | null; export type Logger = (message?: any, ...optionalParams: any[]) => void; @@ -155,7 +155,7 @@ export interface N3StreamWriter extends N3Writer { } export interface N3Store { - size: number; + readonly size: number; addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; addTriple(quad: RDF.Quad): void; addTriples(quads: RDF.Quad[]): void; @@ -164,31 +164,31 @@ export interface N3Store { removeTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; removeTriple(quad: RDF.Quad): void; removeTriples(quads: RDF.Quad[]): void; - getTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): Quad[]; - getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): Quad[]; - countTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number; + getTriples(subject: OString, predicate: OString, object: OString | OString[], graph: OString): Quad[]; + getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI | OIRI[], graph: OIRI): Quad[]; + countTriples(subject: OString, predicate: OString, object: OString, graph: OString): number; countTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): number; - forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void; + forEach(callback: QuadCallback, subject: OString, predicate: OString, object: OString, graph: OString): void; forEachByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): void; - every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + every(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; everyByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + some(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; someByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getSubjects(predicate: OString, object: OString, graph: OString): RDF.Term[]; getSubjectsByIRI(predicate: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void; + forSubjects(callback: QuadCallback, predicate: OString, object: OString, graph: OString): void; forSubjectsByIRI(callback: QuadCallback, predicate: OIRI, object: OIRI, graph: OIRI): void; - getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getPredicates(subject: OString, object: OString, graph: OString): RDF.Term[]; getPredicatesByIRI(subject: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void; + forPredicates(callback: QuadCallback, subject: OString, object: OString, graph: OString): void; forPredicatesByIRI(callback: QuadCallback, subject: OIRI, object: OIRI, graph: OIRI): void; - getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[]; + getObjects(subject: OString, predicate: OString, graph: OString): RDF.Term[]; getObjectsByIRI(subject: OIRI, predicate: OIRI, graph: OIRI): RDF.Term[]; - forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; + forObjects(callback: QuadCallback, subject: OString, predicate: OString, graph: OString): void; forObjectsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, graph: OIRI): void; - getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; + getGraphs(subject: OString, predicate: OString, object: OString): RDF.Term[]; getGraphsByIRI(subject: OIRI, predicate: OIRI, object: OIRI): RDF.Term[]; - forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; + forGraphs(callback: QuadCallback, subject: OString, predicate: OString, object: OString): void; forGraphsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI): void; createBlankNode(suggestedName: string): BlankNode; } @@ -199,14 +199,17 @@ export interface StoreOptions { } export namespace Util { - function createLiteral(value: any, type?: string): string; + function createLiteral(value: any, type?: string): Literal; + function createIRI(iri: string): NamedNode; - function isIRI(value: string): boolean; - function isLiteral(value: string): boolean; - function getLiteralValue(value: string): string; - function getLiteralLanguage(value: string): string; - function getLiteralType(value: string): string; - function isBlank(value: string): boolean; + function isIRI(value: RDF.Term | null): boolean; + function isLiteral(value: RDF.Term | null): boolean; + function isBlank(value: RDF.Term | null): boolean; + function isDefaultGraph(value: RDF.Term | null): boolean; + function inDefaultGraph(value: RDF.Quad): boolean; + function getLiteralValue(value: RDF.Literal): string; + function getLiteralLanguage(value: RDF.Literal): string; + function getLiteralType(value: RDF.Literal): RDF.NamedNode; function isPrefixedName(name: string): boolean; - function expandPrefixedName(name: string, prefixes: Prefixes): string; + function expandPrefixedName(name: string, prefixes: Prefixes): string | RDF.NamedNode; } From 8155227b9c7335604e1ae484078539b9aaf16982 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 13 Apr 2018 07:40:05 +0200 Subject: [PATCH 005/109] Update n3 typings to 1.0.0 --- types/n3/index.d.ts | 121 +++++++++++++++++++------------------------ types/n3/n3-tests.ts | 117 ++++++++++++++++++++--------------------- types/n3/tslint.json | 80 +++++++++++++++++++++++++++- 3 files changed, 188 insertions(+), 130 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index 75c2318743..2e038f0878 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for N3 0.12 +// Type definitions for N3 1.0 // Project: https://github.com/RubenVerborgh/N3.js // Definitions by: Fred Eisele // Ruben Taelman @@ -10,18 +10,20 @@ import * as fs from "fs"; import * as stream from "stream"; import * as RDF from "rdf-js"; +import { EventEmitter } from "events"; export interface Prefixes { [key: string]: string; } -export class Term { +export class Term implements RDF.Term { termType: "NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph"; id: string; + value: string; constructor(iri: string); toJSON(): string; equals(other: RDF.Term): boolean; - subclass(type: any): void; + static subclass(type: any): void; static fromId(id: string): NamedNode | BlankNode | Variable | Literal; static toId(term: string | null | RDF.Term): string; } @@ -30,8 +32,6 @@ export class NamedNode extends Term implements RDF.NamedNode { termType: "NamedNode"; value: string; constructor(iri: string); - toJSON(): string; - equals(other: RDF.Term): boolean; } export class BlankNode extends Term implements RDF.BlankNode { @@ -39,16 +39,12 @@ export class BlankNode extends Term implements RDF.BlankNode { termType: "BlankNode"; value: string; constructor(name: string); - toJSON(): string; - equals(other: RDF.Term): boolean; } export class Variable extends Term implements RDF.Variable { termType: "Variable"; value: string; constructor(name: string); - toJSON(): string; - equals(other: RDF.Term): boolean; } export class Literal extends Term implements RDF.Literal { @@ -59,15 +55,12 @@ export class Literal extends Term implements RDF.Literal { datatype: RDF.NamedNode; datatypeString: string; constructor(id: string); - toJSON(): string; - equals(other: RDF.Term): boolean; } export class DefaultGraph extends Term implements RDF.DefaultGraph { termType: "DefaultGraph"; value: ""; constructor(); - equals(other: RDF.Term): boolean; } export class Quad implements RDF.Quad { @@ -76,18 +69,27 @@ export class Quad implements RDF.Quad { predicate: RDF.Term; object: RDF.Term; graph: RDF.Term; + equals(other: RDF.Quad): boolean; toJSON(): string; - equals(quad: RDF.Quad): boolean; } export class Triple extends Quad implements RDF.Triple {} +export namespace DataFactory { + function namedNode(value: string): RDF.NamedNode; + function blankNode(value?: string): RDF.BlankNode; + function literal(value: string | number, languageOrDatatype?: string | RDF.NamedNode): RDF.Literal; + function variable(value: string): RDF.Variable; + function defaultGraph(): RDF.DefaultGraph; + function triple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term): RDF.Quad; + function quad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): RDF.Quad; +} + export type ErrorCallback = (err: Error, result: any) => void; export type QuadCallback = (result: Quad) => void; export type QuadPredicate = (result: Quad) => boolean; -export type OString = string | RDF.Term | null; -export type OIRI = RDF.Term | null; +export type OTerm = RDF.Term | string | null; export type Logger = (message?: any, ...optionalParams: any[]) => void; @@ -137,15 +139,15 @@ export interface WriterConstructor { export const Writer: WriterConstructor; export interface N3Writer { - tripleToString(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): string; - triplesToString(quads: RDF.Quad[]): string; - addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; - addTriple(quad: RDF.Quad): void; - addTriples(quads: RDF.Quad[]): void; + quadToString(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): string; + quadsToString(quads: RDF.Quad[]): string; + addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addQuad(quad: RDF.Quad): void; + addQuads(quads: RDF.Quad[]): void; end(err?: ErrorCallback, result?: any): void; - blank(predicate: RDF.Term, object: RDF.Term): string; - blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): string; - list(triple: RDF.Term[]): string[]; + blank(predicate: RDF.Term, object: RDF.Term): RDF.Term; + blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): RDF.Term; + list(triple: RDF.Term[]): RDF.Term[]; } export function StreamWriter(options: WriterOptions): N3StreamWriter; @@ -154,43 +156,31 @@ export interface N3StreamWriter extends N3Writer { pipe(consumer: NodeJS.WritableStream | stream.Writable): void; } -export interface N3Store { +export interface N3Store extends RDF.Sink { readonly size: number; - addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; - addTriple(quad: RDF.Quad): void; - addTriples(quads: RDF.Quad[]): void; - addPrefix(prefix: string, iri: RDF.NamedNode): void; - addPrefixes(prefixes: Prefixes): void; - removeTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; - removeTriple(quad: RDF.Quad): void; - removeTriples(quads: RDF.Quad[]): void; - getTriples(subject: OString, predicate: OString, object: OString | OString[], graph: OString): Quad[]; - getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI | OIRI[], graph: OIRI): Quad[]; - countTriples(subject: OString, predicate: OString, object: OString, graph: OString): number; - countTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): number; - forEach(callback: QuadCallback, subject: OString, predicate: OString, object: OString, graph: OString): void; - forEachByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): void; - every(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; - everyByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - some(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; - someByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - getSubjects(predicate: OString, object: OString, graph: OString): RDF.Term[]; - getSubjectsByIRI(predicate: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forSubjects(callback: QuadCallback, predicate: OString, object: OString, graph: OString): void; - forSubjectsByIRI(callback: QuadCallback, predicate: OIRI, object: OIRI, graph: OIRI): void; - getPredicates(subject: OString, object: OString, graph: OString): RDF.Term[]; - getPredicatesByIRI(subject: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forPredicates(callback: QuadCallback, subject: OString, object: OString, graph: OString): void; - forPredicatesByIRI(callback: QuadCallback, subject: OIRI, object: OIRI, graph: OIRI): void; - getObjects(subject: OString, predicate: OString, graph: OString): RDF.Term[]; - getObjectsByIRI(subject: OIRI, predicate: OIRI, graph: OIRI): RDF.Term[]; - forObjects(callback: QuadCallback, subject: OString, predicate: OString, graph: OString): void; - forObjectsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, graph: OIRI): void; - getGraphs(subject: OString, predicate: OString, object: OString): RDF.Term[]; - getGraphsByIRI(subject: OIRI, predicate: OIRI, object: OIRI): RDF.Term[]; - forGraphs(callback: QuadCallback, subject: OString, predicate: OString, object: OString): void; - forGraphsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI): void; + addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addQuad(quad: RDF.Quad): void; + addQuads(quads: RDF.Quad[]): void; + removeQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + removeQuad(quad: RDF.Quad): void; + removeQuads(quads: RDF.Quad[]): void; + getQuads(subject: OTerm, predicate: OTerm, object: OTerm | OTerm[], graph: OTerm): Quad[]; + countQuads(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number; + forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void; + every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void; + getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void; + getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[]; + forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; + getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; + forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; createBlankNode(suggestedName: string): BlankNode; + + // match, removeMatches and deleteGraph are missing for full RDF.Store adherence + remove(stream: stream.Stream): EventEmitter; } export function Store(triples?: RDF.Quad[], options?: StoreOptions): N3Store; @@ -199,17 +189,12 @@ export interface StoreOptions { } export namespace Util { - function createLiteral(value: any, type?: string): Literal; - function createIRI(iri: string): NamedNode; - - function isIRI(value: RDF.Term | null): boolean; + function isNamedNode(value: RDF.Term | null): boolean; + function isBlankNode(value: RDF.Term | null): boolean; function isLiteral(value: RDF.Term | null): boolean; - function isBlank(value: RDF.Term | null): boolean; + function isVariable(value: RDF.Term | null): boolean; function isDefaultGraph(value: RDF.Term | null): boolean; function inDefaultGraph(value: RDF.Quad): boolean; - function getLiteralValue(value: RDF.Literal): string; - function getLiteralLanguage(value: RDF.Literal): string; - function getLiteralType(value: RDF.Literal): RDF.NamedNode; - function isPrefixedName(name: string): boolean; - function expandPrefixedName(name: string, prefixes: Prefixes): string | RDF.NamedNode; + function prefix(iri: string): (suffix: string) => RDF.NamedNode; + function prefixes(defaultPrefixes: Prefixes): (iri: string) => (suffix: string) => RDF.NamedNode; } diff --git a/types/n3/n3-tests.ts b/types/n3/n3-tests.ts index f7e181cc74..cdca08b99f 100644 --- a/types/n3/n3-tests.ts +++ b/types/n3/n3-tests.ts @@ -13,11 +13,11 @@ function test_serialize() { g: "http://base.google.com/ns/1.0" } }); - writer.addTriple({ - subject: "subject-name", - predicate: "predicate-name", - object: N3.Util.createLiteral(12) - }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode("subject-name"), + N3.DataFactory.namedNode("predicate-name"), + N3.DataFactory.literal(12) + )); writer.end((error, result) => { console.log(`result ${result}`); @@ -35,9 +35,9 @@ function test_doc_rdf_to_triples_1() { c:Tom a c:Cat. c:Jerry a c:Mouse; c:smarterThan c:Tom.`, - (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) => { - if (triple) - console.log(triple.subject, triple.predicate, triple.object, '.'); + (error: Error, quad: N3.Quad, prefixes: N3.Prefixes) => { + if (quad) + console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.'); else console.log("# That's all, folks!", prefixes); }); @@ -73,14 +73,16 @@ function test_doc_rdf_stream_to_triples_1() { function test_doc_from_triples_to_string() { const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); - writer.addTriple('http://example.org/cartoons#Tom', - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple({ - subject: 'http://example.org/cartoons#Tom', - predicate: 'http://example.org/cartoons#name', - object: '"Tom"' - }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat') + )); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#name'), + N3.DataFactory.literal('Tom'), + )); writer.end((error, result) => { console.log(result); }); const writer1 = N3.Writer({ format: 'N-Triples' }); @@ -89,14 +91,16 @@ function test_doc_from_triples_to_string() { function test_doc_from_triples_to_rdf_stream() { const writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } }); - writer.addTriple('http://example.org/cartoons#Tom', - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple({ - subject: 'http://example.org/cartoons#Tom', - predicate: 'http://example.org/cartoons#name', - object: '"Tom"' - }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat'), + )); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#name'), + N3.DataFactory.literal('Tom'), + )); writer.end(); } @@ -116,65 +120,56 @@ function test_doc_blank_nodes_and_lists() { foaf: 'http://xmlns.com/foaf/0.1/' } }); - writer.addTriple(writer.blank('http://xmlns.com/foaf/0.1/givenName', '"Tom"@en'), - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple('http://example.org/cartoons#Jerry', - 'http://xmlns.com/foaf/0.1/knows', + writer.addQuad(writer.blank(N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'), N3.DataFactory.literal('Tom', 'en')), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat')); + writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Jerry'), + N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/knows'), writer.blank([{ - predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - object: 'http://example.org/cartoons#Cat' + predicate: N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + object: N3.DataFactory.namedNode('http://example.org/cartoons#Cat') }, { - predicate: 'http://xmlns.com/foaf/0.1/givenName', - object: '"Tom"@en', + predicate: N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'), + object: N3.DataFactory.literal('Tom', 'en'), }])); - writer.addTriple('http://example.org/cartoons#Mammy', - 'http://example.org/cartoons#hasPets', + writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Mammy'), + N3.DataFactory.namedNode('http://example.org/cartoons#hasPets'), writer.list([ - 'http://example.org/cartoons#Tom', - 'http://example.org/cartoons#Jerry' + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#Jerry') ])); writer.end((error, result) => { console.log(result); }); } function test_doc_storing() { const store = N3.Store(); - store.addTriple('http://ex.org/Pluto', 'http://ex.org/type', 'http://ex.org/Dog'); - store.addTriple('http://ex.org/Mickey', 'http://ex.org/type', 'http://ex.org/Mouse'); + store.addQuad(N3.DataFactory.namedNode('http://ex.org/Pluto'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Dog')); + store.addQuad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')); - const mickey = store.find('http://ex.org/Mickey', null, null)[0]; + const mickey = store.getQuads(N3.DataFactory.namedNode('http://ex.org/Mickey'), null, null, null)[0]; console.log(mickey.subject, mickey.predicate, mickey.object, '.'); } function test_doc_utility() { const N3Util = N3.Util; - N3Util.isIRI('http://example.org/cartoons#Mickey'); // true + N3Util.isNamedNode(N3.DataFactory.namedNode('http://example.org/cartoons#Mickey')); // true - N3Util.isLiteral('"Mickey Mouse"'); // true - N3Util.getLiteralValue('"Mickey Mouse"'); // 'Mickey Mouse' - N3Util.isLiteral('"Mickey Mouse"@en'); // true - N3Util.getLiteralLanguage('"Mickey Mouse"@en'); // 'en' - N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true - N3Util.getLiteralType('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // 'http://www.w3.org/2001/XMLSchema#integer' - N3Util.isLiteral('"http://example.org/"'); // true - N3Util.getLiteralValue('"http://example.org/"'); // 'http://example.org/' + N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse')); // true + N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse', 'en')); // true + N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true + N3Util.isLiteral(N3.DataFactory.literal('http://example.org/')); // true - N3Util.isLiteral('"This word is "quoted"!"'); // true - N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true + N3Util.isLiteral(N3.DataFactory.literal('This word is "quoted"!')); // true + N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true new N3.Parser().parse(' "This word is \\"quoted\\"!".', console.log); // { subject: 'a', predicate: 'b', object: '"This word is "quoted"!"' } - N3Util.createLiteral('My text', 'en-gb'); - N3Util.createLiteral('123', 'http://www.w3.org/2001/XMLSchema#integer'); - N3Util.createLiteral(123); - N3Util.createLiteral(false); - - N3Util.isBlank('_:b1'); // true - N3Util.isIRI('_:b1'); // false - N3Util.isLiteral('_:b1'); // false + N3Util.isBlankNode(N3.DataFactory.blankNode('b1')); // true + N3Util.isNamedNode(N3.DataFactory.blankNode('b1')); // false + N3Util.isLiteral(N3.DataFactory.blankNode('b1')); // false const prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }; - N3Util.isPrefixedName('rdfs:label'); // true; - N3Util.expandPrefixedName('rdfs:label', prefixes); // http://www.w3.org/2000/01/rdf-schema#label + const namedNode1: RDF.NamedNode = N3Util.prefix('http://www.w3.org/2000/01/rdf-schema#')('label'); + const namedNode2: RDF.NamedNode = N3Util.prefixes(prefixes)('rdfs')('label'); } diff --git a/types/n3/tslint.json b/types/n3/tslint.json index 3db14f85ea..886f1a8b6c 100644 --- a/types/n3/tslint.json +++ b/types/n3/tslint.json @@ -1 +1,79 @@ -{ "extends": "dtslint/dt.json" } +{ + "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 b266279babdd9a69e5495e03132adfffa3cf06c0 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Wed, 1 Aug 2018 10:35:45 +0200 Subject: [PATCH 006/109] Updated typings to match Vimeo's player.js v2.6.3, updated tests to reflect new methods, properties, and events --- types/vimeo__player/index.d.ts | 14 +++++- types/vimeo__player/vimeo__player-tests.ts | 50 +++++++++++++++++++++- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index d5f224975e..4e5b21e82d 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for @vimeo/player 2.0 +// Type definitions for @vimeo/player 2.6.3 // Project: https://github.com/vimeo/player.js // Definitions by: Denis Yılmaz // Felix Albert // Tim Chen +// Terry Mun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export function myMethod(a: string): string; @@ -22,7 +23,8 @@ export interface InvalidCuePoint extends Error {name: "InvalidCuePoint"; message export interface RangeError extends Error {name: "RangeError"; message: string; method: string; } export interface TypeError extends Error {name: "TypeError"; message: string; method: string; } -export type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" | "cuechange" | "cuepoint" | "volumechange" | "error" | "loaded" | string; +export type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | "seeked" | "texttrackchange" | + "cuechange" | "cuepoint" | "volumechange" | "playbackratechange" | "bufferstart" | "bufferend" | "error" | "loaded" | string; export type EventCallback = (data: any) => any; export class Player { @@ -51,6 +53,8 @@ export class Player { getLoop(): VimeoPromise; setLoop(loop: boolean): VimeoPromise; getPaused(): VimeoPromise; + getPlaybackRate(): VimeoPromise; + setPlaybackRate(playbackRate: number): VimeoPromise; getTextTracks(): VimeoPromise; getVideoEmbedCode(): VimeoPromise; getVideoId(): VimeoPromise; @@ -85,14 +89,20 @@ export interface Options { url?: string; autopause?: boolean; autoplay?: boolean; + background?: boolean; byline?: boolean; color?: string; height?: number; loop?: boolean; maxheight?: number; maxwidth?: number; + muted?: boolean; + playsinline?: boolean; portrait?: boolean; + responsive?: boolean; + speed?: boolean; title?: boolean; + transparent?: boolean; width?: number; } diff --git a/types/vimeo__player/vimeo__player-tests.ts b/types/vimeo__player/vimeo__player-tests.ts index bf5a637762..0dbba1a3a8 100644 --- a/types/vimeo__player/vimeo__player-tests.ts +++ b/types/vimeo__player/vimeo__player-tests.ts @@ -6,7 +6,21 @@ let player: Player ; player = new Player('handstick', { id: 19231868, - width: 640 + width: 640, + + // Use default values for settings, to test typings + autopause: true, + autoplay: false, + background: false, + byline: true, + color: '#00adef', + loop: false, + muted: false, + playsinline: true, + portrait: true, + speed: false, + title: true, + transparent: true }); const onPlay = (data: any) => { @@ -281,12 +295,33 @@ player.getPaused().then((paused) => { // an error occurred }); +player.getPlaybackRate().then((playbackRate) => { + // playbackRate = a numeric value of the current playback rate +}).catch((error) => { + // an error occurred +}); + +player.setPlaybackRate(0.5).then((playbackRate) => { + // playback rate was set +}).catch((error) => { + switch (error.name) { + case 'RangeError': + // the playback rate was less than 0.5 or greater than 2 + break; + + default: + // some other error occurred + break; + } +}); + player.getTextTracks().then((tracks) => { // tracks = an array of track objects tracks.forEach((track) => { console.log(track.label); console.log(track.kind); console.log(track.language); + console.log(track.mode); }); }).catch((error) => { // an error occurred @@ -436,6 +471,19 @@ player.on('volumechange', (data) => { console.log(data.volume); }); +player.on('playbackratechange', (data) => { + // data is an object containing properties specific to that event + console.log(data.playbackRate); +}); + +player.on('bufferstart', (data) => { + // no associated data with this event +}); + +player.on('bufferend', (data) => { + // no associated data with this event +}); + player.on('error', (data) => { // data is an object containing properties specific to that event console.log(data.message); From 2924d2ed0388c5e6c388db7686ba7a699492cbf9 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Wed, 1 Aug 2018 11:21:31 +0200 Subject: [PATCH 007/109] Cleanup of unused boilerplate lines --- types/vimeo__player/index.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index 4e5b21e82d..edf98de573 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -6,9 +6,6 @@ // Terry Mun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export function myMethod(a: string): string; -export function myOtherMethod(a: number): number; - export type CallbackFunction = (...args: any[]) => any; export interface Error {name: string; message: string; method: string; } From 2bf892910b946867fc2e83d07ad638c278969c5e Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Wed, 1 Aug 2018 11:21:46 +0200 Subject: [PATCH 008/109] setPlaybackRate may return RangeError --- types/vimeo__player/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index edf98de573..181edb4f97 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -51,7 +51,7 @@ export class Player { setLoop(loop: boolean): VimeoPromise; getPaused(): VimeoPromise; getPlaybackRate(): VimeoPromise; - setPlaybackRate(playbackRate: number): VimeoPromise; + setPlaybackRate(playbackRate: number): VimeoPromise; getTextTracks(): VimeoPromise; getVideoEmbedCode(): VimeoPromise; getVideoId(): VimeoPromise; From bbfa43d8364e412f93ba67a49666520a0f05c014 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Wed, 1 Aug 2018 12:52:32 +0200 Subject: [PATCH 009/109] options argument in constructor is optional --- types/vimeo__player/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index 181edb4f97..6fac1db7d9 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -25,7 +25,7 @@ export type EventName = "play" | "pause" | "ended" | "timeupdate" | "progress" | export type EventCallback = (data: any) => any; export class Player { - constructor(element: HTMLIFrameElement|HTMLElement|string, options: Options); + constructor(element: HTMLIFrameElement|HTMLElement|string, options?: Options); on(event: EventName, callback: EventCallback): void; off(event: EventName, callback?: EventCallback): void; From ccb674adc72864b791b0b4f12b4e522733774c6f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 10:00:58 +0200 Subject: [PATCH 010/109] Changed types for chained functions and added tests --- types/underscore/index.d.ts | 6 +++--- types/underscore/underscore-tests.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..db45cf606b 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -5692,7 +5692,7 @@ declare module _ { * Wrapped type `object`. * @see _.values **/ - values(): _Chain; + values(): _Chain; /** * Wrapped type `object`. @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..220bbcb0ef 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,20 @@ function chain_tests() { .keys() // return ['foo', 'bar'] : string[] .pairs() // return [['foo', '0'], ['bar', '1']] : string[][] .value(); + + interface IYears { + 2016: number; + 2017: number; + } + + let yearObject: IYears = {2016: 1, 2017: 2}; + let valuePerYear: number[] = _.chain(yearObject) + .values() + .value() + + let keyValuePerYear: (string|number)[][] = _.chain(yearObject) + .pairs() + .value() } var obj: { [k: string] : number } = { From 017ffb7238ce29d3a2bf9d066080c8dc18c4ab8f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:19:40 +0200 Subject: [PATCH 011/109] Updated types for pairs --- types/underscore/index.d.ts | 4 ++-- types/underscore/underscore-tests.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index db45cf606b..94ed13d099 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -3631,7 +3631,7 @@ declare module _ { * @param object Convert this object to a list of [key, value] pairs. * @return List of [key, value] pairs on `object`. **/ - pairs(object: any): any[][]; + pairs(object: any): [string, any][]; /** * Returns a copy of the object where the keys have become the values and the values the keys. @@ -4738,7 +4738,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): any[][]; + pairs(): [string, any][]; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 220bbcb0ef..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -537,10 +537,6 @@ function chain_tests() { let valuePerYear: number[] = _.chain(yearObject) .values() .value() - - let keyValuePerYear: (string|number)[][] = _.chain(yearObject) - .pairs() - .value() } var obj: { [k: string] : number } = { From 2d9422f0cbfab797ad64f786ee33627af90d7fc0 Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:22:38 +0200 Subject: [PATCH 012/109] Added my name --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 94ed13d099..27346d414d 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; From 7146aa04998d5453240fc273caa584cdf4e87d7c Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:29:05 +0200 Subject: [PATCH 013/109] Added space after comment which was removed by my editor --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 27346d414d..95ff48eddc 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } From 965956065f09d11e8b8ccf5cdbb4899c56fbd32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Mon, 6 Aug 2018 17:41:20 +0100 Subject: [PATCH 014/109] [react-navigation] Fix return type when fallback provided --- types/react-navigation/index.d.ts | 4 +++- types/react-navigation/react-navigation-tests.tsx | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 2573315c09..1713cd7eee 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -19,6 +19,7 @@ // Jérémy Magrin // Luca Campana // Ullrich Schaefer +// Linus Unnebäck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -585,7 +586,8 @@ export interface NavigationScreenProp { openDrawer: () => any; closeDrawer: () => any; toggleDrawer: () => any; - getParam: (param: T, fallback?: P[T]) => P[T]; + getParam(param: T, fallback: NonNullable): NonNullable; + getParam(param: T): P[T]; setParams: (newParams: Partial

) => boolean; addListener: ( eventName: 'willBlur' | 'willFocus' | 'didFocus' | 'didBlur', diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 78e71fb746..1c7f7420d0 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -496,6 +496,7 @@ const CustomHeaderStack = createStackNavigator({ interface ScreenProps { name: string; + optionalAge?: number; onPlay(): void; } @@ -512,9 +513,16 @@ class SetParamsTest extends React.Component> render() { const name = this.props.navigation.getParam('name'); + const age = this.props.navigation.getParam('optionalAge'); + + // $ExpectType number | undefined + this.props.navigation.getParam('optionalAge'); + + // $ExpectType number + this.props.navigation.getParam('optionalAge', 0); return ( - My name is {name} + My name is {name} and I am {age} years old. ); } } From 2d432d65822d8dda8d8fe6bc8527ac2de764a704 Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Tue, 7 Aug 2018 17:23:35 -0400 Subject: [PATCH 015/109] codemirror: Enable strictNullChecks so I can test typing changes that are only relevant with strictNullChecks enabled. --- types/codemirror/test/index.ts | 4 ++-- types/codemirror/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 39c601f159..9b9231b25c 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -13,9 +13,9 @@ var head = range.head; var from = range.from(); var to = range.to(); -var myTextArea: HTMLTextAreaElement; +var myTextArea: HTMLTextAreaElement = undefined!; var myCodeMirror3: CodeMirror.Editor = CodeMirror(function (elt) { - myTextArea.parentNode.replaceChild(elt, myTextArea); + myTextArea.parentNode!.replaceChild(elt, myTextArea); }, { value: myTextArea.value }); var myCodeMirror4: CodeMirror.Editor = CodeMirror.fromTextArea(myTextArea); diff --git a/types/codemirror/tsconfig.json b/types/codemirror/tsconfig.json index 2ff349d98e..a2c6a52430 100644 --- a/types/codemirror/tsconfig.json +++ b/types/codemirror/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From e9928ee53e6bd74af37e90acc57087bbdac412ba Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Tue, 7 Aug 2018 17:24:10 -0400 Subject: [PATCH 016/109] codemirror: EditorChangeCancellable.update is undefined for changes coming from undo/redo. --- types/codemirror/index.d.ts | 5 +++-- types/codemirror/test/index.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 6dbfef6e60..f71f741659 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -716,8 +716,9 @@ declare namespace CodeMirror { } interface EditorChangeCancellable extends CodeMirror.EditorChange { - /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */ - update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; + /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. + If the change came from undo/redo, `update` is undefined and the change cannot be modified. */ + update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; cancel(): void; } diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 9b9231b25c..431a20efb6 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -67,6 +67,15 @@ myCodeMirror.on( (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => { } ); +myCodeMirror.on( + "beforeChange", + (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => { + // $ExpectError + change.update(); + if (change.update != null) change.update(); + } +); + CodeMirror.registerHelper("lint", "javascript", {}); myCodeMirror.isReadOnly(); From 100efe4dde38a89bf3201250fb0fb39eeb27e68c Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Tue, 7 Aug 2018 17:24:40 -0400 Subject: [PATCH 017/109] codemirror: Define the type of keymaps. --- types/codemirror/index.d.ts | 12 ++++++++---- types/codemirror/test/index.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index f71f741659..5ece4f497e 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -15,7 +15,7 @@ declare function CodeMirror(callback: (host: HTMLElement) => void , options?: Co declare namespace CodeMirror { export var Doc : CodeMirror.DocConstructor; export var Pos: CodeMirror.PositionConstructor; - export var Pass: any; + export var Pass: {toString(): "CodeMirror.PASS"}; function countColumn(line: string, index: number | null, tabSize: number): number; function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea; @@ -129,6 +129,10 @@ declare namespace CodeMirror { state: any; } + interface KeyMap { + [keyName: string]: false | string | ((instance: Editor) => void | typeof Pass); + } + interface Editor { /** Tells you whether the editor currently has focus. */ @@ -159,11 +163,11 @@ declare namespace CodeMirror { Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, in which case they end up below other keymaps added with this method. */ - addKeyMap(map: any, bottom?: boolean): void; + addKeyMap(map: string | KeyMap, bottom?: boolean): void; /** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, which will be compared against the name property of the active keymaps. */ - removeKeyMap(map: any): void; + removeKeyMap(map: string | KeyMap): void; /** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting. For example, the search add - on uses it to highlight the term that's currently being searched. @@ -781,7 +785,7 @@ declare namespace CodeMirror { keyMap?: string; /** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */ - extraKeys?: any; + extraKeys?: string | KeyMap; /** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */ lineWrapping?: boolean; diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 431a20efb6..bd2aefac88 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -4,7 +4,18 @@ var myCodeMirror: CodeMirror.Editor = CodeMirror(document.body); var myCodeMirror2: CodeMirror.Editor = CodeMirror(document.body, { value: "function myScript(){return 100;}\n", - mode: "javascript" + mode: "javascript", + extraKeys: { + Enter: (cm) => { console.log("save"); }, + Esc: (cm) => { return CodeMirror.Pass; } + } +}); + +// $ExpectError +var myCodeMirror2_1: CodeMirror.Editor = CodeMirror(document.body, { + extraKeys: { + "Shift-Enter": (cm) => { return 42; } // not a valid return value + } }); var range = myCodeMirror2.findWordAt(CodeMirror.Pos(0, 2)); From 89eff5086697c1a254da6e0fe63aa46f8d61b543 Mon Sep 17 00:00:00 2001 From: Confusus Date: Wed, 8 Aug 2018 09:14:15 +0200 Subject: [PATCH 018/109] Changed pairs of chain from any to [string, any] --- types/underscore/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 95ff48eddc..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`. From a4956b02df1620315c0246ebfde78796d9d262e9 Mon Sep 17 00:00:00 2001 From: Junyoung Clare Jang Date: Wed, 8 Aug 2018 05:30:42 -0400 Subject: [PATCH 019/109] Update inquirer filter and validate to use any --- types/inquirer/index.d.ts | 5 +++-- types/inquirer/inquirer-tests.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index d00c037c71..5d976e896d 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -8,6 +8,7 @@ // Synarque // Justin Rockwood // Keith Kelly +// Junyoung Clare Jang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -116,12 +117,12 @@ declare namespace inquirer { * Receive the user input and should return true if the value is valid, and an error message (String) * otherwise. If false is returned, a default error message is provided. */ - validate?(input: string, answers?: T): boolean | string | Promise; + validate?(input: any, answers?: T): boolean | string | Promise; /** * Receive the user input and return the filtered value to be used inside the program. * The value returned will be added to the Answers hash. */ - filter?(input: string): string | Promise; + filter?(input: string): any; /** * Receive the user input and return the transformed value to be displayed to the user. The * transformation only impacts what is shown while editing. It does not impact the answers diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index 85a81d761e..4c8ba9491f 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -670,3 +670,17 @@ var questions = [ inquirer.createPromptModule({ output: process.stderr })(questions, function(answers) { console.log(JSON.stringify(answers, null, " ")); }); + +// Work with JS inquirer but rejected by typing. +inquirer.prompt([ + { + type: "input", + name: "listOfThings", + filter(value: string): string[] { + return ["abc", "def"]; + }, + validate(value: string[]): boolean { + return value.length > 0; + } + } +]); From f239ccde3717c2b9e24034f91d883ff15d231564 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 8 Jun 2018 14:14:34 +0200 Subject: [PATCH 020/109] Update N3 typings to n3 1.0.0-beta1 --- types/n3/index.d.ts | 50 ++++++++++++++++++++++++++++------------ types/n3/n3-tests.ts | 54 +++++++++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index 2e038f0878..dd2d5ca394 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -13,7 +13,7 @@ import * as RDF from "rdf-js"; import { EventEmitter } from "events"; export interface Prefixes { - [key: string]: string; + [key: string]: RDF.NamedNode; } export class Term implements RDF.Term { @@ -24,8 +24,6 @@ export class Term implements RDF.Term { toJSON(): string; equals(other: RDF.Term): boolean; static subclass(type: any): void; - static fromId(id: string): NamedNode | BlankNode | Variable | Literal; - static toId(term: string | null | RDF.Term): string; } export class NamedNode extends Term implements RDF.NamedNode { @@ -107,6 +105,8 @@ export const Parser: ParserConstructor; export interface ParserOptions { format?: string; prefixes?: string[]; + factory?: RDF.DataFactory; + baseIRI?: string; } export type ParseCallback = (error: Error, quad: Quad, prefixes: Prefixes) => void; @@ -121,8 +121,20 @@ export interface StreamParserConstructor { } export const StreamParser: StreamParserConstructor; -export interface N3StreamParser extends N3Parser, fs.WriteStream { - pipe(consumer: T): T; +export interface N3StreamParser extends RDF.Stream, NodeJS.WritableStream, RDF.Sink { + // Below are the NodeJS.ReadableStream methods, + // we can not extend the interface directly, + // as `read` clashes with RDF.Sink. + readable: boolean; + // read(size?: number): string | Buffer; // Overwritten by RDF.Stream + setEncoding(encoding: string | null): void; + pause(): this; + resume(): this; + isPaused(): boolean; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: NodeJS.WritableStream | RDF.Stream): void; + unshift(chunk: string | Buffer): void; + wrap(oldStream: NodeJS.ReadableStream | RDF.Stream): NodeJS.ReadableStream; } export interface WriterOptions { @@ -144,17 +156,21 @@ export interface N3Writer { addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; addQuad(quad: RDF.Quad): void; addQuads(quads: RDF.Quad[]): void; - end(err?: ErrorCallback, result?: any): void; + end(err?: ErrorCallback, result?: string): void; blank(predicate: RDF.Term, object: RDF.Term): RDF.Term; blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): RDF.Term; list(triple: RDF.Term[]): RDF.Term[]; } -export function StreamWriter(options: WriterOptions): N3StreamWriter; - -export interface N3StreamWriter extends N3Writer { - pipe(consumer: NodeJS.WritableStream | stream.Writable): void; +export interface StreamWriterConstructor { + new (options?: WriterOptions): N3StreamWriter; + new (fd: any, options?: WriterOptions): N3StreamWriter; + (options?: WriterOptions): N3StreamWriter; + (fd: any, options?: WriterOptions): N3StreamWriter; } +export const StreamWriter: StreamWriterConstructor; + +export interface N3StreamWriter extends NodeJS.ReadWriteStream, RDF.Source {} export interface N3Store extends RDF.Sink { readonly size: number; @@ -177,15 +193,19 @@ export interface N3Store extends RDF.Sink { forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; - createBlankNode(suggestedName: string): BlankNode; + createBlankNode(suggestedName?: string): BlankNode; // match, removeMatches and deleteGraph are missing for full RDF.Store adherence remove(stream: stream.Stream): EventEmitter; } -export function Store(triples?: RDF.Quad[], options?: StoreOptions): N3Store; +export interface StoreConstructor { + new (triples?: RDF.Quad[], options?: StoreOptions): N3Store; + (triples?: RDF.Quad[], options?: StoreOptions): N3Store; +} +export const Store: StoreConstructor; export interface StoreOptions { - prefixes?: Prefixes; + factory?: RDF.DataFactory; } export namespace Util { @@ -195,6 +215,6 @@ export namespace Util { function isVariable(value: RDF.Term | null): boolean; function isDefaultGraph(value: RDF.Term | null): boolean; function inDefaultGraph(value: RDF.Quad): boolean; - function prefix(iri: string): (suffix: string) => RDF.NamedNode; - function prefixes(defaultPrefixes: Prefixes): (iri: string) => (suffix: string) => RDF.NamedNode; + function prefix(iri: string, factory?: RDF.DataFactory): (suffix: string) => RDF.NamedNode; + function prefixes(defaultPrefixes: Prefixes, factory?: RDF.DataFactory): (iri: string) => (suffix: string) => RDF.NamedNode; } diff --git a/types/n3/n3-tests.ts b/types/n3/n3-tests.ts index cdca08b99f..367b602c8a 100644 --- a/types/n3/n3-tests.ts +++ b/types/n3/n3-tests.ts @@ -4,7 +4,7 @@ import * as fs from "fs"; import * as stream from "stream"; function test_serialize() { - const writer: N3.N3Writer = N3.Writer( + const writer: N3.N3Writer = new N3.Writer( { format: "ttl", prefixes: { @@ -30,12 +30,12 @@ https://github.com/RubenVerborgh/N3.js/blob/master/README.md */ function test_doc_rdf_to_triples_1() { - const parser = N3.Parser(); + const parser: N3.N3Parser = new N3.Parser(); parser.parse(`@prefix c: . c:Tom a c:Cat. c:Jerry a c:Mouse; c:smarterThan c:Tom.`, - (error: Error, quad: N3.Quad, prefixes: N3.Prefixes) => { + (error: Error, quad: RDF.Quad, prefixes: N3.Prefixes) => { if (quad) console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.'); else @@ -44,22 +44,23 @@ function test_doc_rdf_to_triples_1() { } function test_doc_rdf_to_triples_2() { - const parser1 = N3.Parser({ format: 'N-Triples' }); - const parser2 = N3.Parser({ format: 'application/trig' }); + const parser1: N3.N3Parser = new N3.Parser({ format: 'N-Triples' }); + const parser2: N3.N3Parser = new N3.Parser({ format: 'application/trig' }); // Notation3 (N3) is supported only through the format argument: - const parser3 = N3.Parser({ format: 'N3' }); - const parser4 = N3.Parser({ format: 'Notation3' }); - const parser5 = N3.Parser({ format: 'text/n3' }); + const parser3: N3.N3Parser = N3.Parser({ format: 'N3' }); + const parser4: N3.N3Parser = N3.Parser({ format: 'Notation3' }); + const parser5: N3.N3Parser = N3.Parser({ format: 'text/n3' }); } function test_doc_rdf_stream_to_triples_1() { - const parser = N3.Parser(); + const parser: N3.N3Parser = new N3.Parser(); parser.parse('abc', console.log); - const streamParser = N3.StreamParser(); + const streamParser: N3.N3StreamParser = N3.StreamParser(); + const quad: RDF.Quad = streamParser.read(); const rdfStream = fs.createReadStream('cartoons.ttl'); - rdfStream.pipe(streamParser); + const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser); streamParser.pipe(new class SlowConsumer extends stream.Writable { constructor() { super({ objectMode: true }); @@ -72,7 +73,7 @@ function test_doc_rdf_stream_to_triples_1() { } function test_doc_from_triples_to_string() { - const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); + const writer: N3.N3Writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); writer.addQuad(N3.DataFactory.quad( N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), @@ -83,14 +84,14 @@ function test_doc_from_triples_to_string() { N3.DataFactory.namedNode('http://example.org/cartoons#name'), N3.DataFactory.literal('Tom'), )); - writer.end((error, result) => { console.log(result); }); + writer.end((error, result: string) => { console.log(result); }); - const writer1 = N3.Writer({ format: 'N-Triples' }); - const writer2 = N3.Writer({ format: 'application/trig' }); + const writer1: N3.N3Writer = N3.Writer({ format: 'N-Triples' }); + const writer2: N3.N3Writer = N3.Writer({ format: 'application/trig' }); } function test_doc_from_triples_to_rdf_stream() { - const writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } }); + const writer: N3.N3Writer = new N3.Writer(process.stdout, { prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } }); writer.addQuad(N3.DataFactory.quad( N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), @@ -105,16 +106,16 @@ function test_doc_from_triples_to_rdf_stream() { } function test_doc_from_triple_stream_to_rdf_stream() { - const streamParser = new N3.StreamParser(); + const streamParser: N3.N3StreamParser = new N3.StreamParser(); const inputStream = fs.createReadStream('cartoons.ttl'); - const streamWriter = /* new */ N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } }); + const streamWriter: N3.N3StreamWriter = new N3.StreamWriter({ prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } }); inputStream.pipe(streamParser); streamParser.pipe(streamWriter); streamWriter.pipe(process.stdout); } function test_doc_blank_nodes_and_lists() { - const writer = N3.Writer({ + const writer: N3.N3Writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#', foaf: 'http://xmlns.com/foaf/0.1/' @@ -142,11 +143,18 @@ function test_doc_blank_nodes_and_lists() { } function test_doc_storing() { - const store = N3.Store(); + const store: N3.N3Store = new N3.Store(); store.addQuad(N3.DataFactory.namedNode('http://ex.org/Pluto'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Dog')); - store.addQuad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')); + store.addQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))); + store.addQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]); + store.removeQuad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')); + store.removeQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))); + store.removeQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]); - const mickey = store.getQuads(N3.DataFactory.namedNode('http://ex.org/Mickey'), null, null, null)[0]; + const bnode1: RDF.BlankNode = store.createBlankNode(); + const bnode2: RDF.BlankNode = store.createBlankNode('abc'); + + const mickey: RDF.Quad = store.getQuads(N3.DataFactory.namedNode('http://ex.org/Mickey'), null, null, null)[0]; console.log(mickey.subject, mickey.predicate, mickey.object, '.'); } @@ -169,7 +177,7 @@ function test_doc_utility() { N3Util.isNamedNode(N3.DataFactory.blankNode('b1')); // false N3Util.isLiteral(N3.DataFactory.blankNode('b1')); // false - const prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }; + const prefixes: N3.Prefixes = { rdfs: N3.DataFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#') }; const namedNode1: RDF.NamedNode = N3Util.prefix('http://www.w3.org/2000/01/rdf-schema#')('label'); const namedNode2: RDF.NamedNode = N3Util.prefixes(prefixes)('rdfs')('label'); } From 094f7394b1506af12d18a777b879b07c0f00405c Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Fri, 3 Aug 2018 21:07:41 +0800 Subject: [PATCH 021/109] CopyWebpackPlugin accepts string[] too --- types/copy-webpack-plugin/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index eedf42f450..59c1b8d0cb 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -61,7 +61,7 @@ interface CopyWebpackPluginConfiguration { } interface CopyWebpackPlugin { - new (patterns?: CopyPattern[], options?: CopyWebpackPluginConfiguration): Plugin + new (patterns?: (string | CopyPattern)[], options?: CopyWebpackPluginConfiguration): Plugin } declare const copyWebpackPlugin: CopyWebpackPlugin From 641c48d48e5cbe1b9fd22cb3677c32eddf275ad7 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Thu, 9 Aug 2018 11:55:41 +0200 Subject: [PATCH 022/109] Add types for ttf2woff2 --- types/ttf2woff2/index.d.ts | 10 ++++++++++ types/ttf2woff2/tsconfig.json | 23 +++++++++++++++++++++++ types/ttf2woff2/tslint.json | 1 + types/ttf2woff2/ttf2woff2-tests.ts | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 types/ttf2woff2/index.d.ts create mode 100644 types/ttf2woff2/tsconfig.json create mode 100644 types/ttf2woff2/tslint.json create mode 100644 types/ttf2woff2/ttf2woff2-tests.ts diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts new file mode 100644 index 0000000000..be49b9099d --- /dev/null +++ b/types/ttf2woff2/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ttf2woff2 2.0 +// Project: https://github.com/nfroidure/ttf2woff2 +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function ttf2woff2(inputContent: Buffer): Buffer; + +export = ttf2woff2; diff --git a/types/ttf2woff2/tsconfig.json b/types/ttf2woff2/tsconfig.json new file mode 100644 index 0000000000..0b6fc9778b --- /dev/null +++ b/types/ttf2woff2/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "ttf2woff2-tests.ts" + ] +} diff --git a/types/ttf2woff2/tslint.json b/types/ttf2woff2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ttf2woff2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ttf2woff2/ttf2woff2-tests.ts b/types/ttf2woff2/ttf2woff2-tests.ts new file mode 100644 index 0000000000..71b5a16d65 --- /dev/null +++ b/types/ttf2woff2/ttf2woff2-tests.ts @@ -0,0 +1,4 @@ +import ttf2woff2 = require('ttf2woff2'); + +const input = Buffer.alloc(10); +const result: Buffer = ttf2woff2(input); From bd9ef16dc64641c01241e2800959d10e40b3fc2b Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:00:34 -0600 Subject: [PATCH 023/109] Fix return types for SObject.delete --- types/jsforce/salesforce-object.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index ab3e398891..1c79b367eb 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -43,9 +43,9 @@ export class SObject { count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise; create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; createBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - del(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - delete(ids: string | string[], callback?: (err: Error, ret: any) => void): void; + del(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; + destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; + delete(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; deleteBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; destroyBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; destroyHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; From 5cab80238224c47376e329a93d307f3763164349 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:01:37 -0600 Subject: [PATCH 024/109] Fix return type for SObject.find --- types/jsforce/salesforce-object.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 1c79b367eb..e3e91e11b9 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -19,9 +19,9 @@ export class SObject { upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; upsertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[] | BatchResultInfo[]) => void): Batch; - find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query; findOne(query?: any, callback?: (err: Error, ret: T) => void): Query; findOne(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query; From 6000babd03674f891b4eb3f4b64b2e7674c0a080 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:10:28 -0600 Subject: [PATCH 025/109] Add SObject.updated --- types/jsforce/salesforce-object.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index e3e91e11b9..1f5d9fe691 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -15,6 +15,7 @@ export class SObject { retrieve(ids: SalesforceId[], options?: Object, callback?: (err: Error, ret: Array>) => void): Promise>>; update(record: Partial, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; update(records: Array>, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; + updated(start: string | Date, end: string | Date, callback?: (err: Error, ret: UpdatedRecordsInfo) => void): Promise; upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; upsertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[] | BatchResultInfo[]) => void): Batch; @@ -75,6 +76,11 @@ export class SObject { select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: (err: Error, ret: Array>) => void): Query>>; } +export interface UpdatedRecordsInfo { + latestDateCovered: string; + ids: string[]; +} + export interface ApprovalLayoutInfo { approvalLayouts: Object[]; } From 5435c92c4e3166b261e6043dd6d41887c22867d1 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:17:09 -0600 Subject: [PATCH 026/109] Fix callback types for SObject cached calls --- types/jsforce/salesforce-object.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 1f5d9fe691..b440f35ffb 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -30,14 +30,14 @@ export class SObject { approvalLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */ - (callback?: (layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; + (callback?: (err: Error, layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; clear(): void; } approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch; compactLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ - (callback?: CompactLayoutInfo): CompactLayoutInfo; + (callback?: (err: Error, layoutInfo: CompactLayoutInfo) => void): CompactLayoutInfo; clear(): void; } compactLayouts(callback?: CompactLayoutInfo): Promise; From f8e512b1a58be12c3dc33ac2523b22899a381aae Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:25:18 -0600 Subject: [PATCH 027/109] Add SObject.updateBulk --- types/jsforce/salesforce-object.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index b440f35ffb..3927633ab4 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -15,6 +15,7 @@ export class SObject { retrieve(ids: SalesforceId[], options?: Object, callback?: (err: Error, ret: Array>) => void): Promise>>; update(record: Partial, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; update(records: Array>, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; + updateBulk(input?: Record[] | stream.Stream | string, callback?: (err: Error, ret: RecordResult[]) => void): Batch; updated(start: string | Date, end: string | Date, callback?: (err: Error, ret: UpdatedRecordsInfo) => void): Promise; upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; From 6c3c77049cadebd2474379ef41b843f66e582039 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:29:47 -0600 Subject: [PATCH 028/109] Update SObject.bulkload signature --- types/jsforce/salesforce-object.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 3927633ab4..4664846033 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -35,7 +35,7 @@ export class SObject { clear(): void; } approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; - bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch; + bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[]) => void): Batch; compactLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ (callback?: (err: Error, layoutInfo: CompactLayoutInfo) => void): CompactLayoutInfo; From d8bb141cf5fa85fd8378f965b1ae0d6a7b477599 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:32:13 -0600 Subject: [PATCH 029/109] Update return type for SObject.count --- types/jsforce/salesforce-object.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 4664846033..96dd3258f9 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -42,7 +42,7 @@ export class SObject { clear(): void; } compactLayouts(callback?: CompactLayoutInfo): Promise; - count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise; + count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Query; create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; createBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; del(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; From 5710e1b5c8bdb88f28895101a7d5887078acdf32 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 12:50:52 -0600 Subject: [PATCH 030/109] Update SObject.destroy methods --- types/jsforce/salesforce-object.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 96dd3258f9..560a16bffd 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -45,9 +45,12 @@ export class SObject { count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Query; create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; createBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - del(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; - destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; - delete(ids: string | string[], callback?: (err: Error, ret: any) => void): Promise; + del(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; + del(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; + destroy(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; + destroy(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; + delete(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; + delete(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; deleteBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; destroyBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; destroyHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; From 534d41d8624ec4431ed990e3bb1a5d1923d80a3a Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 14:12:15 -0600 Subject: [PATCH 031/109] Add QuickAction class and use Callback type The callback definitions for all of these methods were a mess. I created a Callback type and had every callback parameter use this type for consistency. I also went through and added comments for places where the types do not match the documentation --- types/jsforce/global.d.ts | 1 + types/jsforce/quick-action.d.ts | 52 ++++++++++++ types/jsforce/salesforce-object.d.ts | 113 ++++++++++++++++----------- 3 files changed, 119 insertions(+), 47 deletions(-) create mode 100644 types/jsforce/global.d.ts create mode 100644 types/jsforce/quick-action.d.ts diff --git a/types/jsforce/global.d.ts b/types/jsforce/global.d.ts new file mode 100644 index 0000000000..2c30ae64bb --- /dev/null +++ b/types/jsforce/global.d.ts @@ -0,0 +1 @@ +export type Callback = (err: Error | null, ret: T) => void; diff --git a/types/jsforce/quick-action.d.ts b/types/jsforce/quick-action.d.ts new file mode 100644 index 0000000000..aa6036993a --- /dev/null +++ b/types/jsforce/quick-action.d.ts @@ -0,0 +1,52 @@ +import { Callback } from './global'; +import { Record } from './record'; + +export class QuickAction { + /** + * Retrieve default field values in the action for the given record + * @param contextId Id of record + * @param callback Callback function + */ + defaultValues(contextId: string, callback?: Callback): Promise; + /** Retrieve default field values in the action */ + defaultValues(callback?: Callback): Promise; + /** + * Describe the action's information (including layout, etc.) + * @param callback Callback function + */ + describe(callback?: Callback): Promise; + /** + * Execute the action for given context id and record information + * @param contextId Context record ID of the action + * @param record Input record information for the action + * @param callback Callback function + */ + execute(contextId: string, record: Record, callback?: Callback): Promise; +} + +// TODO: figure out the actual shape of this. the docs don't have it +export type QuickActionResult = object; + +export interface QuickActionInfo { + /** Type of the action (e.g. Create, Update, Post, LogACall) */ + type: string; + /** Name of the action */ + name: string; + /** Label of the action */ + label: string; + /** Endpoint URL information of the action */ + urls: object; +} + +export interface QuickActionDescribeInfo { + /** Object type used for the action */ + contextSobjectType: string; + /** Object type of the action to target */ + targetSobjectType: string; + /** Field name in the target object which refers parent(context) object record ID */ + targetParentField: string; + /** Record type of the targeted record */ + targetRecordTypeId: string; + /** Layout sections that comprise an action */ + layout: object; +} diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 560a16bffd..262788de29 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -5,79 +5,97 @@ import { DescribeSObjectResult } from './describe-result'; import { Query } from './query'; import { Record, RecordReference } from './record'; import { RecordResult } from './record-result'; -import { Connection } from './connection'; +import { Connection, Callback } from './connection'; import { SalesforceId } from './salesforce-id'; import { Batch, BatchResultInfo } from './batch'; +import { QuickAction, QuickActionInfo } from './quick-action'; export class SObject { record(id: SalesforceId): RecordReference; - retrieve(id: SalesforceId, options?: Object, callback?: (err: Error, record: Record) => void): Promise>; - retrieve(ids: SalesforceId[], options?: Object, callback?: (err: Error, ret: Array>) => void): Promise>>; - update(record: Partial, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; - update(records: Array>, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; - updateBulk(input?: Record[] | stream.Stream | string, callback?: (err: Error, ret: RecordResult[]) => void): Batch; - updated(start: string | Date, end: string | Date, callback?: (err: Error, ret: UpdatedRecordsInfo) => void): Promise; - upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; - upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; - upsertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[] | BatchResultInfo[]) => void): Batch; + retrieve(id: SalesforceId, options?: Object, callback?: Callback>): Promise>; + retrieve(ids: SalesforceId[], options?: Object, callback?: Callback>>): Promise>>; + update(record: Partial, options?: Object, callback?: Callback): Promise; + update(records: Array>, options?: Object, callback?: Callback): Promise; + // FIXME: should input really be optional? the documentation says so, but how can you actually update without it? + updateBulk(input?: Record[] | stream.Stream | string, callback?: Callback): Batch; + updated(start: string | Date, end: string | Date, callback?: Callback): Promise; + upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: Callback): Promise; + upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: Callback): Promise; + upsertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; - find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: object | string, callback?: Callback>>): Query>>; + find(query?: object | string, fields?: Object | string[] | string, callback?: Callback>>): Query>>; + find(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback>>): Query>>; - findOne(query?: any, callback?: (err: Error, ret: T) => void): Query; - findOne(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query; - findOne(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): Query; + findOne(query?: object | string, callback?: Callback>): Query>; + findOne(query?: object | string, fields?: Object | string[] | string, callback?: Callback>): Query>; + findOne(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback>): Query>; approvalLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */ - (callback?: (err: Error, layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; + (callback?: Callback): ApprovalLayoutInfo; clear(): void; } - approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; - bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[]) => void): Batch; + approvalLayouts(callback?: Callback): Promise; + bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream | string, callback?: Callback): Batch; compactLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ - (callback?: (err: Error, layoutInfo: CompactLayoutInfo) => void): CompactLayoutInfo; + (callback?: Callback): CompactLayoutInfo; clear(): void; } - compactLayouts(callback?: CompactLayoutInfo): Promise; - count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Query; - create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; - createBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - del(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; - del(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; - destroy(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; - destroy(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; - delete(id: string, callback?: (err: Error, ret: RecordResult) => void): Promise; - delete(ids: string[], callback?: (err: Error, ret: RecordResult[]) => void): Promise; - deleteBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - destroyBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - destroyHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise; - deleteHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise; + compactLayouts(callback?: Callback): Promise; + count(conditions?: Object | string, callback?: Callback): Query; + create(record: Record, options: object, callback?: Callback): Promise; + create(record: Record, callback?: Callback): Promise; + create(record: Array>, options: object, callback?: Callback): Promise; + create(record: Array>, callback?: Callback): Promise; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + del(id: string, callback?: Callback): Promise; + del(ids: string[], callback?: Callback): Promise; + destroy(id: string, callback?: Callback): Promise; + destroy(ids: string[], callback?: Callback): Promise; + delete(id: string, callback?: Callback): Promise; + delete(ids: string[], callback?: Callback): Promise; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + deleteBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + destroyBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + destroyHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + deleted(start: Date | string, end: Date | string, callback?: Callback): Promise; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + deleteHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + describe(callback?: Callback): Promise; describe$: { /** Returns a value from the cache if it exists, otherwise calls SObject.describe */ - (callback?: (err: Error, ret: DescribeSObjectResult) => void): DescribeSObjectResult; + (callback?: Callback): DescribeSObjectResult; clear(): void; } - insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; - insertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; + insert(record: Record, callback?: Callback): Promise; + insert(records: Array>, callback?: Callback): Promise; + insertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; /** Returns a value from the cache if it exists, otherwise calls SObject.layouts */ layouts$: { - (layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): LayoutInfo; + (layoutName?: string, callback?: Callback): LayoutInfo; clear(): void; } - layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise; + layouts(layoutName?: string, callback?: Callback): Promise; listview(id: string): ListView; - listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise; + listviews(callback?: Callback): Promise; quickAction(actionName: string): QuickAction; - quickActions(callback?: (err: Error, info: any) => void): Promise; - recent(callback?: (err: Error, ret: RecordResult) => void): Promise; - select(callback?: (err: Error, ret: T[]) => void): Query; + quickActions(callback?: Callback): Promise; + // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? + recent(callback?: Callback): Promise; + select(callback?: Callback): Query; // TODO:use a typed pluck to turn `fields` into a subset of T's fields so that the output is slimmed down appropriately - select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: (err: Error, ret: Array>) => void): Query>>; + select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: Callback>>): Query>>; +} + +export interface FindOptions { + limit?: number; + offset?: number; + skip?: number; } export interface UpdatedRecordsInfo { @@ -114,4 +132,5 @@ export class ListView { } export class ListViewsInfo { } -export class QuickAction { } +// TODO: Remove this export +export { QuickAction } // for compatibility if anyone had imported it from this file From 692c933823f2a2f1604de0c107ec445005c33f24 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 14:18:12 -0600 Subject: [PATCH 032/109] Fix SObject.create signature that broke tests --- types/jsforce/salesforce-object.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 262788de29..ce2f996829 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -45,10 +45,10 @@ export class SObject { } compactLayouts(callback?: Callback): Promise; count(conditions?: Object | string, callback?: Callback): Query; - create(record: Record, options: object, callback?: Callback): Promise; - create(record: Record, callback?: Callback): Promise; - create(record: Array>, options: object, callback?: Callback): Promise; - create(record: Array>, callback?: Callback): Promise; + create(record: T, options: object, callback?: Callback): Promise; + create(record: T, callback?: Callback): Promise; + create(record: Array, options: object, callback?: Callback): Promise; + create(record: Array, callback?: Callback): Promise; // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; del(id: string, callback?: Callback): Promise; From bc74bacf347022d31a614e04cc5895a33430bf24 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Thu, 9 Aug 2018 17:28:37 -0600 Subject: [PATCH 033/109] Write tests for SObject and move Callback back to connection.d.ts --- types/jsforce/connection.d.ts | 31 ++- types/jsforce/global.d.ts | 1 - types/jsforce/http-api.d.ts | 5 + types/jsforce/index.d.ts | 2 +- types/jsforce/jsforce-tests.ts | 363 ++++++++++++++++++++++----- types/jsforce/quick-action.d.ts | 2 +- types/jsforce/salesforce-object.d.ts | 25 +- 7 files changed, 350 insertions(+), 79 deletions(-) delete mode 100644 types/jsforce/global.d.ts create mode 100644 types/jsforce/http-api.d.ts diff --git a/types/jsforce/connection.d.ts b/types/jsforce/connection.d.ts index fcf614eb92..e7fd593b01 100644 --- a/types/jsforce/connection.d.ts +++ b/types/jsforce/connection.d.ts @@ -10,8 +10,16 @@ import { Metadata } from './api/metadata'; import { Bulk } from './bulk'; import { Cache } from './cache' import { OAuth2, Streaming } from '.'; +import { HttpApiOptions } from './http-api' -export type Callback = (err: Error, result: T) => void; +export type Callback = (err: Error | null, result: T) => void; +// The type for these options was determined by looking at the usage +// of the options object in Connection.create and other methods +// go to http://jsforce.github.io/jsforce/doc/connection.js.html#line568 +// and search for options +export interface RestApiOptions { + headers?: { [x: string]: string } +} // These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49 // the oauth options can either be in the `oauth2` proeprty OR spread across the main connection @@ -93,24 +101,24 @@ export type ConnectionEvent = "refresh"; */ export abstract class BaseConnection extends EventEmitter { _baseUrl(): string; - request(info: RequestInfo | string, options?: Object, callback?: (err: Error, Object: object) => void): Promise; + request(info: RequestInfo | string, options?: HttpApiOptions, callback?: (err: Error, Object: object) => void): Promise; query(soql: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult) => void): Query>; queryMore(locator: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult) => void): Promise>; - create(type: string, records: Record | Array>, options?: Object, + create(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - insert(type: string, records: Record | Array>, options?: Object, + insert(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - retrieve(type: string, ids: string | string[], options?: Object, + retrieve(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: Record | Array>) => void): Promise<(Record | Array>)>; - update(type: string, records: Record | Array>, options?: Object, + update(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | Array>) => void): Promise<(RecordResult | RecordResult[])>; - upsert(type: string, records: Record | Array>, extIdField: string, options?: Object, + upsert(type: string, records: Record | Array>, extIdField: string, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - del(type: string, ids: string | string[], options?: Object, + del(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - delete(type: string, ids: string | string[], options?: Object, + delete(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - destroy(type: string, ids: string | string[], options?: Object, + destroy(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; describe$: { /** Returns a value from the cache if it exists, otherwise calls Connection.describe */ @@ -124,7 +132,8 @@ export abstract class BaseConnection extends EventEmitter { clear(): void; } describeGlobal(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise; - sobject(resource: string): SObject; + // we want any object to be accepted if the user doesn't decide to give an explicit type + sobject(resource: string): SObject; } export class Connection extends BaseConnection { diff --git a/types/jsforce/global.d.ts b/types/jsforce/global.d.ts deleted file mode 100644 index 2c30ae64bb..0000000000 --- a/types/jsforce/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type Callback = (err: Error | null, ret: T) => void; diff --git a/types/jsforce/http-api.d.ts b/types/jsforce/http-api.d.ts new file mode 100644 index 0000000000..1986ce0c75 --- /dev/null +++ b/types/jsforce/http-api.d.ts @@ -0,0 +1,5 @@ +export interface HttpApiOptions { + responseType?: string; + transport?: object; + noContentResponse?: object +} diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts index ddcb0d8260..d92677a5eb 100644 --- a/types/jsforce/index.d.ts +++ b/types/jsforce/index.d.ts @@ -6,7 +6,7 @@ // Tim Noonan // Abraham White // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 export * from './api/analytics'; export * from './api/chatter'; diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 8eb97aebc7..886bd012c0 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -4,12 +4,9 @@ import * as express from 'express'; import * as glob from 'glob'; import * as sf from 'jsforce'; - -export interface DummyRecord { - thing: boolean; - other: number; - person: string; -} +import { RecordReference, Record } from 'jsforce/record'; +import { SObject } from 'jsforce/salesforce-object'; +import { RecordResult } from 'jsforce/record-result'; const salesforceConnection: sf.Connection = new sf.Connection({ instanceUrl: '', @@ -20,7 +17,304 @@ const salesforceConnection: sf.Connection = new sf.Connection({ }, }); -salesforceConnection.sobject("Dummy").select(["thing", "other"]); +async function testSObject(connection: sf.Connection) { + interface DummyRecord { + thing: boolean; + other: number; + person: string; + } + + const dummySObject: SObject = connection.sobject('Dummy'); + + // currently untyped, but some future change may make this stricter + const restApiOptions = { + headers: { Bearer: 'I have no idea what this wants' } + }; + + { // Test SObject.record + // $ExpectType RecordReference + dummySObject.record('50130000000014C'); + } + + { // Test SObject.retrieve + // with single id + // $ExpectType Record + await dummySObject.retrieve('50130000000014C'); + // with single id and rest api options + // $ExpectType Record + await dummySObject.retrieve('50130000000014C', restApiOptions); + + // with single id and callback + dummySObject.retrieve('50130000000014C', restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType Record + }); + + // with ids array + // $ExpectType Record[] + await dummySObject.retrieve(['IIIIDDD']); + // with ids array and rest api options + // $ExpectType Record[] + await dummySObject.retrieve(['IIIIDDD'], restApiOptions); + + // with ids array and callback + dummySObject.retrieve(['50130000000014C'], restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType Record[] + }); + + salesforceConnection.sobject("ContentVersion").retrieve("world", { + test: "test" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType any + }); + } + + { // Test SObject.update + // if we require that records have an id field this will fail + // //$ExpectError + await dummySObject.update({ thing: false }); + + // If we require that the records have an Id field + // await dummySObject.update({ thing: false, Id: 'asdf' }); // $ExpectType RecordResult + + // invalid field + // $ExpectError + await dummySObject.update({ asdf: false }); + + // with rest api options + // $ExpectType RecordResult + await dummySObject.update({ thing: false }, restApiOptions); + + // with callback + dummySObject.update({ thing: false }, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult + }); + + dummySObject.update({ thing: false }, restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult + }); + + // with multiple records + // $ExpectType RecordResult[] + await dummySObject.update([{ thing: false }]); + + // with multiple records and api options + // $ExpectType RecordResult[] + await dummySObject.update([{ thing: false }], restApiOptions); + + // with multiple records and callback + dummySObject.update([{ thing: false }], restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + dummySObject.update([{ thing: false }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.updated + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated(new Date(), new Date()); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated(new Date(), 'hi'); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated('hi', new Date()); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated('hi', 'hi'); + + dummySObject.updated(new Date(), 'hi', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType UpdatedRecordsInfo + }); + } + + { // Test SObject.upsert + const updateData = { + Id: 'Some ID', + thing: true, + other: 1, + person: 'hi' + }; + // $ExpectType RecordResult + await dummySObject.upsert(updateData, 'Id'); + + // $ExpectType RecordResult + await dummySObject.upsert(updateData, 'Id', restApiOptions); + + // $ExpectType RecordResult[] + await dummySObject.upsert([updateData], 'Id'); + + // $ExpectType RecordResult[] + await dummySObject.upsert([updateData], 'Id', restApiOptions); + + dummySObject.upsert(updateData, 'Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.upsert(updateData, 'Id', restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.upsert([updateData], 'Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + dummySObject.upsert([updateData], 'Id', restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.find + } + + { // Test SObject.findOne + salesforceConnection.sobject("ContentVersion").findOne({ Id: '' }, (err, contentVersion) => { + err; // $ExpectType Error | null + contentVersion; // $ExpectType any + }); + } + + { // Test SObject.select + + dummySObject.select(["thing", "other"]); + + // note the following should never compile: + // $ExpectError + dummySObject.select(["lol"]); + } + + { // Test SObject.create + // $ExpectType RecordResult + await dummySObject.create({ + thing: true, + other: 1, + person: 'hi' + }); + + // $ExpectType RecordResult + await dummySObject.create({ + thing: true, + other: 1, + person: 'hi' + }, restApiOptions); + + // $ExpectType RecordResult[] + await dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }]); + + // $ExpectType RecordResult[] + await dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], restApiOptions); + + dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + salesforceConnection.sobject("Account").create({ + Name: "Test Acc 2", + BillingStreet: "Maplestory street", + BillingPostalCode: "ME4 666" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + // callback and rest api options + salesforceConnection.sobject("ContentVersion").create({ + OwnerId: '', + Title: 'hello', + PathOnClient: './hello-world.jpg', + VersionData: '{ Test: Data }' + }, restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + salesforceConnection.sobject("ContentDocumentLink").create({ + ContentDocumentId: '', + LinkedEntityId: '', + ShareType: "I" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + } + + { // Test SObject.destroy and aliases + // $ExpectType RecordResult + await dummySObject.del('Id'); + // $ExpectType RecordResult + await dummySObject.destroy('Id'); + // $ExpectType RecordResult + await dummySObject.delete('Id'); + + // $ExpectType RecordResult[] + await dummySObject.del(['Id']); + // $ExpectType RecordResult[] + await dummySObject.destroy(['Id']); + // $ExpectType RecordResult[] + await dummySObject.delete(['Id']); + + dummySObject.del('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + dummySObject.destroy('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + dummySObject.delete('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.del(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + dummySObject.destroy(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + dummySObject.delete(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + } +} const requestInfo: sf.RequestInfo = { body: '', @@ -38,51 +332,6 @@ const queryOptions: sf.ExecuteOptions = { }; salesforceConnection.query('SELECT Id, Name FROM Account', queryOptions); -// note the following should never compile: -// salesforceConnection.sobject("Dummy").select(["lol"]); - -salesforceConnection.sobject("Account").create({ - Name: "Test Acc 2", - BillingStreet: "Maplestory street", - BillingPostalCode: "ME4 666" -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").create({ - OwnerId: '', - Title: 'hello', - PathOnClient: './hello-world.jpg', - VersionData: '{ Test: Data }' -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").retrieve("world", { - test: "test" -}, (err: Error, ret) => { - if (err) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").findOne({ Id: '' }, (err, contentVersion) => { -}); - -salesforceConnection.sobject("ContentDocumentLink").create({ - ContentDocumentId: '', - LinkedEntityId: '', - ShareType: "I" -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - sf.Date.YESTERDAY; salesforceConnection.sobject('Coverage__c') @@ -230,7 +479,7 @@ async function testChatter(conn: sf.Connection): Promise { }, feedElementType: 'FeedItem', subjectId: 'me' - }, (err: Error, result: any) => { + }, (err: Error | null, result: any) => { if (err) { throw err; } @@ -242,7 +491,7 @@ async function testChatter(conn: sf.Connection): Promise { text: 'This is new comment on the post' }] } - }, (err: Error, result: any) => { + }, (err: Error | null, result: any) => { if (err) { throw err; } @@ -366,13 +615,15 @@ async function testDescribe() { object.fields.forEach(field => { const type: sf.FieldType = field.type; // following should never compile - // const fail = type === 'hey' + // $ExpectError + const fail = type === 'hey'; const isString = type === 'string'; }); // following should never compile (if StrictNullChecks is on) - // object.keyPrefix.length; + // $ExpectError + object.keyPrefix.length; console.log(`${sobject.name} Label: `, object.label); diff --git a/types/jsforce/quick-action.d.ts b/types/jsforce/quick-action.d.ts index aa6036993a..a67f4d4e08 100644 --- a/types/jsforce/quick-action.d.ts +++ b/types/jsforce/quick-action.d.ts @@ -1,4 +1,4 @@ -import { Callback } from './global'; +import { Callback } from './connection'; import { Record } from './record'; export class QuickAction { diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index ce2f996829..2015f5d79b 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -5,22 +5,29 @@ import { DescribeSObjectResult } from './describe-result'; import { Query } from './query'; import { Record, RecordReference } from './record'; import { RecordResult } from './record-result'; -import { Connection, Callback } from './connection'; +import { Connection, RestApiOptions, Callback } from './connection'; import { SalesforceId } from './salesforce-id'; import { Batch, BatchResultInfo } from './batch'; import { QuickAction, QuickActionInfo } from './quick-action'; export class SObject { record(id: SalesforceId): RecordReference; - retrieve(id: SalesforceId, options?: Object, callback?: Callback>): Promise>; - retrieve(ids: SalesforceId[], options?: Object, callback?: Callback>>): Promise>>; - update(record: Partial, options?: Object, callback?: Callback): Promise; - update(records: Array>, options?: Object, callback?: Callback): Promise; + retrieve(id: SalesforceId, callback?: Callback>): Promise>; + retrieve(id: SalesforceId, options?: object, callback?: Callback>): Promise>; + retrieve(ids: SalesforceId[], callback?: Callback>>): Promise>>; + retrieve(ids: SalesforceId[], options?: object, callback?: Callback>>): Promise>>; + // Should update require that the record Id field be provided? + update(record: Partial, callback?: Callback): Promise; + update(record: Partial, options?: RestApiOptions, callback?: Callback): Promise; + update(records: Array>, callback?: Callback): Promise; + update(records: Array>, options?: RestApiOptions, callback?: Callback): Promise; // FIXME: should input really be optional? the documentation says so, but how can you actually update without it? updateBulk(input?: Record[] | stream.Stream | string, callback?: Callback): Batch; updated(start: string | Date, end: string | Date, callback?: Callback): Promise; - upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: Callback): Promise; - upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: Callback): Promise; + upsert(records: Record, extIdField: string, callback?: Callback): Promise; + upsert(records: Record, extIdField: string, options?: RestApiOptions, callback?: Callback): Promise; + upsert(records: Array>, extIdField: string, callback?: Callback): Promise; + upsert(records: Array>, extIdField: string, options?: RestApiOptions, callback?: Callback): Promise; upsertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; find(query?: object | string, callback?: Callback>>): Query>>; @@ -45,9 +52,9 @@ export class SObject { } compactLayouts(callback?: Callback): Promise; count(conditions?: Object | string, callback?: Callback): Query; - create(record: T, options: object, callback?: Callback): Promise; + create(record: T, options?: RestApiOptions, callback?: Callback): Promise; create(record: T, callback?: Callback): Promise; - create(record: Array, options: object, callback?: Callback): Promise; + create(record: Array, options?: RestApiOptions, callback?: Callback): Promise; create(record: Array, callback?: Callback): Promise; // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; From 8f1ce6502bdbfde6179e19c2a27d284a3d1be04e Mon Sep 17 00:00:00 2001 From: thomas-b Date: Fri, 10 Aug 2018 15:56:02 +0200 Subject: [PATCH 034/109] [hapi] Correct the server.table() return type --- types/hapi/index.d.ts | 2 +- types/hapi/test/server/server-table.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 23aaf3608c..9f348332ea 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -3790,7 +3790,7 @@ export class Server extends Podium { * * path - the route path. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) */ - table(host?: string): Array<{settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}>; // TODO I am not sure if the ServerRoute is the object expected here + table(host?: string): RequestRoute[]; } /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/types/hapi/test/server/server-table.ts b/types/hapi/test/server/server-table.ts index ab14938be4..79726118b5 100644 --- a/types/hapi/test/server/server-table.ts +++ b/types/hapi/test/server/server-table.ts @@ -19,4 +19,11 @@ server.route({ server.start(); const table = server.table(); console.log(table); +console.log(table[0].method); +console.log(table[0].path); +console.log(table[0].vhost); +console.log(table[0].realm); +console.log(table[0].settings); +console.log(table[0].fingerprint); +console.log(table[0].auth); console.log('Server started at: ' + server.info.uri); From 8aad19dfb14764fd2f99b3d90eb3b89875d0cecb Mon Sep 17 00:00:00 2001 From: Alex Van Camp Date: Fri, 10 Aug 2018 17:09:15 -0500 Subject: [PATCH 035/109] p-retry: Update for v2.0 --- types/p-retry/index.d.ts | 13 +++++++++++-- types/p-retry/p-retry-tests.ts | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/types/p-retry/index.d.ts b/types/p-retry/index.d.ts index 784f637549..c1791fcc63 100644 --- a/types/p-retry/index.d.ts +++ b/types/p-retry/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for p-retry 1.0 +// Type definitions for p-retry 2.0 // Project: https://github.com/sindresorhus/p-retry#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,7 +8,7 @@ import { OperationOptions } from 'retry'; export = pRetry; -declare function pRetry(input: (attemptCount: number) => PromiseLike | T, options?: OperationOptions): Promise; +declare function pRetry(input: (attemptCount: number) => PromiseLike | T, options?: pRetry.Options): Promise; declare namespace pRetry { class AbortError extends Error { @@ -16,4 +16,13 @@ declare namespace pRetry { readonly originalError: Error; constructor(message: string | Error); } + + interface FailedAttemptError extends Error { + attemptNumber: number; + attemptsLeft: number; + } + + interface Options extends OperationOptions { + onFailedAttempt?: (error: FailedAttemptError) => void; + } } diff --git a/types/p-retry/p-retry-tests.ts b/types/p-retry/p-retry-tests.ts index 72962d553e..1b58960e95 100644 --- a/types/p-retry/p-retry-tests.ts +++ b/types/p-retry/p-retry-tests.ts @@ -11,6 +11,11 @@ const run = () => fetch('https://sindresorhus.com/unicorn') return response.text(); }); -pRetry(run, {retries: 5}).then(result => { +pRetry(run, { + retries: 5, + onFailedAttempt: error => { + console.log(`Attempt ${error.attemptNumber} failed. There are ${error.attemptsLeft} attempts left.`); + } +}).then(result => { const str: string = result; }); From fa4eab07a9106a3a80c89810d062847f4f6aa501 Mon Sep 17 00:00:00 2001 From: Nathan Phillip Brink Date: Sat, 11 Aug 2018 04:10:47 +0000 Subject: [PATCH 036/109] uid-safe: Set Promise type to string. --- types/uid-safe/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/uid-safe/index.d.ts b/types/uid-safe/index.d.ts index ee7b13491f..20a85ae899 100644 --- a/types/uid-safe/index.d.ts +++ b/types/uid-safe/index.d.ts @@ -8,7 +8,7 @@ declare namespace UID { export interface Generate { (byteLength: number, callback: (err: any, str: string) => any): void; - (byteLength: number): Promise; + (byteLength: number): Promise; sync(byteLength: number): string; } From 9963d9aed650243d24e6a3cf6ab5a4d2e44d203a Mon Sep 17 00:00:00 2001 From: Nicholas Pappagalo Date: Sat, 11 Aug 2018 11:43:32 -0700 Subject: [PATCH 037/109] enable transformValue to take a parameter --- types/styled-system/dist/util.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/styled-system/dist/util.d.ts b/types/styled-system/dist/util.d.ts index f91b2b6620..ae90de60f8 100644 --- a/types/styled-system/dist/util.d.ts +++ b/types/styled-system/dist/util.d.ts @@ -19,7 +19,7 @@ export interface LowLevelStylefunctionArguments { cssProperty?: string; key?: string; getter?: () => any; - transformValue?: () => any; + transformValue?: (n: string|number) => any; scale?: Array; } From 9bfe9a148c26cd2bcaf7d1e1c356e2b08bfdbfc6 Mon Sep 17 00:00:00 2001 From: Nicholas Pappagalo Date: Sat, 11 Aug 2018 12:11:15 -0700 Subject: [PATCH 038/109] add self to definitions by section of package header --- types/styled-system/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index d9c386242c..38cda70448 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -7,6 +7,7 @@ // Eloy Durán // Matthieu Vachon // Adam Lavin +// Nicholas Pappagalo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 From 748a58c8d2f69ee002cc00f6554e6af0abf826ef Mon Sep 17 00:00:00 2001 From: Zlatkovsky Date: Sat, 11 Aug 2018 17:57:11 -0700 Subject: [PATCH 039/109] Update Office.js d.ts based on latest sources of codegen truth and slight tweaks --- types/office-js/index.d.ts | 995 ++++++++++++++++++++++++------------- 1 file changed, 662 insertions(+), 333 deletions(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index f3bd6b3681..3a40742a68 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -15817,25 +15817,24 @@ declare namespace Excel { */ function run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise; /** - * Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. - * - * @remarks - * - * In addition to this signature, the method also has the following signatures: - * - * `run(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * @param context - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". - * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. - */ - function run(context: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise): Promise; - function createWorkbook(base64?: string): Promise; + * Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * + * @remarks + * + * In addition to this signature, the method also has the following signatures: + * + * `run(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * @param context - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(context: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise): Promise; /** * * Provides information about the binding that raised the SelectionChanged event. @@ -16434,7 +16433,7 @@ declare namespace Excel { getActiveCell(): Excel.Range; /** * - * Gets the currently selected range from the workbook. + * Gets the currently selected single range from the workbook. If there are multiple ranges selected, this method will throw an error. * * [Api set: ExcelApi 1.1] */ @@ -16732,11 +16731,11 @@ declare namespace Excel { getPreviousOrNullObject(visibleOnly?: boolean): Excel.Worksheet; /** * - * Gets the range object specified by the address or name. + * Gets the range object, representing a single rectangular block of cells, specified by the address or name. * * [Api set: ExcelApi 1.1] * - * @param address Optional. The address or the name of the range. If not specified, the entire worksheet range is returned. + * @param address Optional. The string representing the address or name of the range. For example, "A1:B2". If not specified, the entire worksheet range is returned. */ getRange(address?: string): Excel.Range; /** @@ -17220,7 +17219,7 @@ declare namespace Excel { readonly worksheet: Excel.Worksheet; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -17449,7 +17448,7 @@ declare namespace Excel { getAbsoluteResizedRange(numRows: number, numColumns: number): Excel.Range; /** * - * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E16". + * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E15". * * [Api set: ExcelApi 1.1] * @@ -17662,7 +17661,6 @@ declare namespace Excel { /** * * Selects the specified range in the Excel UI. - If true, a multi-area range can be selected; otherwise, only the first area will be selected. Default is false. * * [Api set: ExcelApi 1.1] */ @@ -19073,10 +19071,10 @@ declare namespace Excel { * * Represents a collection of all the rows that are part of the table. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -19094,10 +19092,10 @@ declare namespace Excel { * * Adds one or more rows to the table. The return object will be the top of the newly added row(s). - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1 for adding a single row; 1.4 allows adding of multiple rows.] * @@ -19116,10 +19114,10 @@ declare namespace Excel { * * Gets a row based on its position in the collection. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] * @@ -19150,10 +19148,10 @@ declare namespace Excel { * * Represents a row in a table. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -19747,7 +19745,7 @@ declare namespace Excel { * @param sourceData The Range object corresponding to the source data. * @param seriesBy Optional. Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details. */ - add(type: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap", sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): Excel.Chart; + add(type: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel", sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): Excel.Chart; /** * * Returns the number of charts in the worksheet. @@ -19865,7 +19863,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -19966,7 +19964,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.1] * - * @param sourceData The range corresponding to the source data. + * @param sourceData The range object corresponding to the source data. * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, and Columns. See Excel.ChartSeriesBy for details. */ setData(sourceData: Range, seriesBy?: Excel.ChartSeriesBy): void; @@ -19976,7 +19974,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.1] * - * @param sourceData The range corresponding to the source data. + * @param sourceData The range object corresponding to the source data. * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, and Columns. See Excel.ChartSeriesBy for details. */ setData(sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): void; @@ -20174,7 +20172,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -23832,14 +23830,14 @@ declare namespace Excel { delete(): void; /** * - * Returns the range the conditonal format is applied to. Read-only. + * Returns the range the conditonal format is applied to. Throws an error if the conditional format is applied to multiple ranges. Read-only. * * [Api set: ExcelApi 1.6] */ getRange(): Excel.Range; /** * - * Returns the range the conditonal format is applied to or a null object if the range is discontiguous. Read-only. + * Returns the range the conditonal format is applied to, or a null object if the conditional format is applied to multiple ranges. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -26521,7 +26519,7 @@ declare namespace Excel { worksheetCalculated = "WorksheetCalculated", /** * - * ChartActivated represents the type of event registered on Chart or ChartCollection, and occurs when chart activates. + * VisualSelectionChanged represents the type of event registered on VisualCollection, and occurs when visual selection changes. * */ visualSelectionChanged = "VisualSelectionChanged", @@ -31102,7 +31100,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -31182,7 +31180,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -33120,7 +33118,7 @@ declare namespace Excel { worksheet?: Excel.Interfaces.WorksheetData; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -33939,7 +33937,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -34040,7 +34038,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -36251,7 +36249,7 @@ declare namespace Excel { worksheet?: Excel.Interfaces.WorksheetLoadOptions; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -36294,7 +36292,7 @@ declare namespace Excel { /** * * Represents the formula in A1-style notation. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36302,7 +36300,7 @@ declare namespace Excel { /** * * Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36310,7 +36308,7 @@ declare namespace Excel { /** * * Represents the formula in R1C1-style notation. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.2] */ @@ -36346,7 +36344,7 @@ declare namespace Excel { /** * * Represents Excel's number format code for the given range. - When setting number format to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting number format to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36354,7 +36352,7 @@ declare namespace Excel { /** * * Represents Excel's number format code for the given range as a string in the language of the user. - When setting number format local to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting number format local to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.7] */ @@ -36383,8 +36381,8 @@ declare namespace Excel { /** * * Represents the style of the current range. - If the styles of the cells are inconsistent, null will be returned. - For custom styles, the style name will be returned. For built-in styles, a string representing a value in the BuiltInStyle enum will be returned. + If the styles of the cells are inconsistent, null will be returned. + For custom styles, the style name will be returned. For built-in styles, a string representing a value in the BuiltInStyle enum will be returned. * * [Api set: ExcelApi 1.7] */ @@ -36406,7 +36404,7 @@ declare namespace Excel { /** * * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. - When setting values to a range, the value argument can be either a single value (string, number or boolean) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting values to a range, the value argument can be either a single value (string, number or boolean) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -37162,11 +37160,11 @@ declare namespace Excel { /** * * Represents a collection of all the rows that are part of the table. - - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -37190,11 +37188,11 @@ declare namespace Excel { /** * * Represents a row in a table. - - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -37275,8 +37273,8 @@ declare namespace Excel { /** * * Gets or sets the text orientation of all the cells within the range. - The text orientation should be an integer either from -90 to 90, or 180 for vertically-oriented text. - If the orientation within a range are not uniform, then null will be returned. + The text orientation should be an integer either from -90 to 90, or 180 for vertically-oriented text. + If the orientation within a range are not uniform, then null will be returned. * * [Api set: ExcelApi 1.7] */ @@ -37284,9 +37282,9 @@ declare namespace Excel { /** * * Determines if the row height of the Range object equals the standard height of the sheet. - Returns True if the row height of the Range object equals the standard height of the sheet. - Returns Null if the range contains more than one row and the rows aren't all the same height. - Returns False otherwise. + Returns True if the row height of the Range object equals the standard height of the sheet. + Returns Null if the range contains more than one row and the rows aren't all the same height. + Returns False otherwise. * * [Api set: ExcelApi 1.7] */ @@ -37294,9 +37292,9 @@ declare namespace Excel { /** * * Indicates whether the column width of the Range object equals the standard width of the sheet. - Returns True if the column width of the Range object equals the standard width of the sheet. - Returns Null if the range contains more than one column and the columns aren't all the same height. - Returns False otherwise. + Returns True if the column width of the Range object equals the standard width of the sheet. + Returns Null if the range contains more than one column and the columns aren't all the same height. + Returns False otherwise. * * [Api set: ExcelApi 1.7] */ @@ -37763,7 +37761,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. - Throws an invalid argument exception on invalid charts. + Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -37778,7 +37776,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Represents the gap width of a chart series. Only valid on bar and column charts, as well as - specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. + specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -37879,7 +37877,7 @@ declare namespace Excel { /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. - Throws an invalid argument exception on invalid charts. + Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -37894,7 +37892,7 @@ declare namespace Excel { /** * * Represents the gap width of a chart series. Only valid on bar and column charts, as well as - specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. + specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -39186,8 +39184,8 @@ declare namespace Excel { /** * * A scoped collection of custom XML parts. - A scoped collection is the result of some operation, e.g. filtering by namespace. - A scoped collection cannot be scoped any further. + A scoped collection is the result of some operation, e.g. filtering by namespace. + A scoped collection cannot be scoped any further. * * [Api set: ExcelApi 1.5] */ @@ -39471,7 +39469,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39479,7 +39477,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39557,7 +39555,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39565,7 +39563,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39573,7 +39571,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39581,7 +39579,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39596,10 +39594,10 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: The priority (or index) within the conditional format collection that this conditional format currently exists in. Changing this also - changes other conditional formats' priorities, to allow for a contiguous priority order. - Use a negative priority to begin from the back. - Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. - Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. + changes other conditional formats' priorities, to allow for a contiguous priority order. + Use a negative priority to begin from the back. + Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. + Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -39607,7 +39605,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. - Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these + Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these * * [Api set: ExcelApi 1.6] */ @@ -39631,7 +39629,7 @@ declare namespace Excel { /** * * Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39639,7 +39637,7 @@ declare namespace Excel { /** * * Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39717,7 +39715,7 @@ declare namespace Excel { /** * * Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39725,7 +39723,7 @@ declare namespace Excel { /** * * Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39733,7 +39731,7 @@ declare namespace Excel { /** * * Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39741,7 +39739,7 @@ declare namespace Excel { /** * * Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39756,10 +39754,10 @@ declare namespace Excel { /** * * The priority (or index) within the conditional format collection that this conditional format currently exists in. Changing this also - changes other conditional formats' priorities, to allow for a contiguous priority order. - Use a negative priority to begin from the back. - Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. - Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. + changes other conditional formats' priorities, to allow for a contiguous priority order. + Use a negative priority to begin from the back. + Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. + Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -39767,7 +39765,7 @@ declare namespace Excel { /** * * If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. - Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these + Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these * * [Api set: ExcelApi 1.6] */ @@ -39805,7 +39803,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the Axis line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "" (empty string) if no axis is present or set. + "" (empty string) if no axis is present or set. * * [Api set: ExcelApi 1.6] */ @@ -39857,7 +39855,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "" (empty string) if no border is present or set. + "" (empty string) if no border is present or set. * * [Api set: ExcelApi 1.6] */ @@ -39888,7 +39886,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "Empty String" if no border is present or set. + "Empty String" if no border is present or set. * * [Api set: ExcelApi 1.6] */ @@ -40776,10 +40774,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly type: Word.BodyType | "Unknown" | "MainDoc" | "Section" | "Header" | "Footer" | "TableCell"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Body): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.BodyUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Body): void; + set(properties: Word.Body): void; /** * * Clears the contents of the body object. The user can perform the undo operation on the cleared content. @@ -40996,7 +41004,7 @@ declare namespace Word { * * [Api set: WordApi 1.1] * - * @param searchText Required. The search text. + * @param searchText Required. The search text. Can be a maximum of 255 characters. * @param searchOptions Optional. Options for the search. */ search(searchText: string, searchOptions?: Word.SearchOptions | { @@ -41028,6 +41036,18 @@ declare namespace Word { select(selectionMode?: "Select" | "Start" | "End"): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Body` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Body` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Body` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.BodyLoadOptions): Word.Body; load(option?: string | string[]): Word.Body; @@ -41241,10 +41261,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly type: Word.ContentControlType | "Unknown" | "RichTextInline" | "RichTextParagraphs" | "RichTextTableCell" | "RichTextTableRow" | "RichTextTable" | "PlainTextInline" | "PlainTextParagraph" | "Picture" | "BuildingBlockGallery" | "CheckBox" | "ComboBox" | "DropDownList" | "DatePicker" | "RepeatingSection" | "RichText" | "PlainText"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.ContentControl): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ContentControlUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: ContentControl): void; + set(properties: Word.ContentControl): void; /** * * Clears the contents of the content control. The user can perform the undo operation on the cleared content. @@ -41517,6 +41547,18 @@ declare namespace Word { split(delimiters: string[], multiParagraphs?: boolean, trimDelimiters?: boolean, trimSpacing?: boolean): Word.RangeCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ContentControl` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ContentControl` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ContentControl` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ContentControlLoadOptions): Word.ContentControl; load(option?: string | string[]): Word.ContentControl; @@ -41613,6 +41655,18 @@ declare namespace Word { getItem(index: number): Word.ContentControl; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ContentControlCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ContentControlCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ContentControlCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ContentControlCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ContentControlCollection; load(option?: string | string[]): Word.ContentControlCollection; @@ -41655,10 +41709,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ value: any; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.CustomProperty): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.CustomPropertyUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: CustomProperty): void; + set(properties: Word.CustomProperty): void; /** * * Deletes the custom property. @@ -41668,6 +41732,18 @@ declare namespace Word { delete(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.CustomProperty` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.CustomProperty` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.CustomProperty` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.CustomPropertyLoadOptions): Word.CustomProperty; load(option?: string | string[]): Word.CustomProperty; @@ -41738,6 +41814,18 @@ declare namespace Word { getItemOrNullObject(key: string): Word.CustomProperty; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.CustomPropertyCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.CustomPropertyCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.CustomPropertyCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.CustomPropertyCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.CustomPropertyCollection; load(option?: string | string[]): Word.CustomPropertyCollection; @@ -41794,10 +41882,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly saved: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Document): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Document): void; + set(properties: Word.Document): void; /** * * Gets the current selection of the document. Multiple selections are not supported. @@ -41814,6 +41912,18 @@ declare namespace Word { save(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Document` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Document` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Document` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentLoadOptions): Word.Document; load(option?: string | string[]): Word.Document; @@ -41873,10 +41983,20 @@ declare namespace Word { * [Api set: WordApiHiddenDocument 1.3] */ readonly saved: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.DocumentCreated): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentCreatedUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: DocumentCreated): void; + set(properties: Word.DocumentCreated): void; /** * * Opens the document. @@ -41893,6 +42013,18 @@ declare namespace Word { save(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.DocumentCreated` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.DocumentCreated` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.DocumentCreated` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentCreatedLoadOptions): Word.DocumentCreated; load(option?: string | string[]): Word.DocumentCreated; @@ -42043,12 +42175,34 @@ declare namespace Word { * [Api set: WordApi 1.3] */ title: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.DocumentProperties): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentPropertiesUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: DocumentProperties): void; + set(properties: Word.DocumentProperties): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.DocumentProperties` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.DocumentProperties` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.DocumentProperties` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentPropertiesLoadOptions): Word.DocumentProperties; load(option?: string | string[]): Word.DocumentProperties; @@ -42150,12 +42304,34 @@ declare namespace Word { * [Api set: WordApi 1.1] */ underline: Word.UnderlineType | "Mixed" | "None" | "Hidden" | "DotLine" | "Single" | "Word" | "Double" | "Thick" | "Dotted" | "DottedHeavy" | "DashLine" | "DashLineHeavy" | "DashLineLong" | "DashLineLongHeavy" | "DotDashLine" | "DotDashLineHeavy" | "TwoDotDashLine" | "TwoDotDashLineHeavy" | "Wave" | "WaveHeavy" | "WaveDouble"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Font): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.FontUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Font): void; + set(properties: Word.Font): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Font` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Font` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Font` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.FontLoadOptions): Word.Font; load(option?: string | string[]): Word.Font; @@ -42271,10 +42447,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.InlinePicture): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.InlinePictureUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: InlinePicture): void; + set(properties: Word.InlinePicture): void; /** * * Deletes the inline picture from the document. @@ -42488,6 +42674,18 @@ declare namespace Word { select(selectionMode?: "Select" | "Start" | "End"): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.InlinePicture` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.InlinePicture` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.InlinePicture` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.InlinePictureLoadOptions): Word.InlinePicture; load(option?: string | string[]): Word.InlinePicture; @@ -42530,6 +42728,18 @@ declare namespace Word { getFirstOrNullObject(): Word.InlinePicture; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.InlinePictureCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.InlinePictureCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.InlinePictureCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.InlinePictureCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.InlinePictureCollection; load(option?: string | string[]): Word.InlinePictureCollection; @@ -42706,6 +42916,18 @@ declare namespace Word { setLevelStartingNumber(level: number, startingNumber: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.List` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.List` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.List` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListLoadOptions): Word.List; load(option?: string | string[]): Word.List; @@ -42775,6 +42997,18 @@ declare namespace Word { getItem(index: number): Word.List; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ListCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ListCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ListCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ListCollection; load(option?: string | string[]): Word.ListCollection; @@ -42817,10 +43051,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly siblingIndex: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.ListItem): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ListItemUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: ListItem): void; + set(properties: Word.ListItem): void; /** * * Gets the list item parent, or the closest ancestor if the parent does not exist. Throws if the list item has no ancestor. @@ -42850,6 +43094,18 @@ declare namespace Word { getDescendants(directChildrenOnly?: boolean): Word.ParagraphCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ListItem` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ListItem` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ListItem` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListItemLoadOptions): Word.ListItem; load(option?: string | string[]): Word.ListItem; @@ -43084,10 +43340,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly text: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Paragraph): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ParagraphUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Paragraph): void; + set(properties: Word.Paragraph): void; /** * * Lets the paragraph join an existing list at the specified level. Fails if the paragraph cannot join the list or if the paragraph is already a list item. @@ -43416,6 +43682,18 @@ declare namespace Word { startNewList(): Word.List; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Paragraph` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Paragraph` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Paragraph` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ParagraphLoadOptions): Word.Paragraph; load(option?: string | string[]): Word.Paragraph; @@ -43472,6 +43750,18 @@ declare namespace Word { getLastOrNullObject(): Word.Paragraph; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ParagraphCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ParagraphCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ParagraphCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ParagraphCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ParagraphCollection; load(option?: string | string[]): Word.ParagraphCollection; @@ -43619,10 +43909,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly text: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Range): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.RangeUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Range): void; + set(properties: Word.Range): void; /** * * Clears the contents of the range object. The user can perform the undo operation on the cleared content. @@ -43972,6 +44272,18 @@ declare namespace Word { split(delimiters: string[], multiParagraphs?: boolean, trimDelimiters?: boolean, trimSpacing?: boolean): Word.RangeCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Range` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Range` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Range` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.RangeLoadOptions): Word.Range; load(option?: string | string[]): Word.Range; @@ -44014,6 +44326,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Range; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.RangeCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.RangeCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.RangeCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.RangeCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.RangeCollection; load(option?: string | string[]): Word.RangeCollection; @@ -44085,12 +44409,34 @@ declare namespace Word { * [Api set: WordApi 1.1] */ matchWildcards: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.SearchOptions): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.SearchOptionsUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: SearchOptions): void; + set(properties: Word.SearchOptions): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.SearchOptions` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.SearchOptions` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.SearchOptions` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SearchOptionsLoadOptions): Word.SearchOptions; load(option?: string | string[]): Word.SearchOptions; @@ -44118,10 +44464,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly body: Word.Body; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Section): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.SectionUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Section): void; + set(properties: Word.Section): void; /** * * Gets one of the section's footers. @@ -44174,6 +44530,18 @@ declare namespace Word { getNextOrNullObject(): Word.Section; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Section` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Section` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Section` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SectionLoadOptions): Word.Section; load(option?: string | string[]): Word.Section; @@ -44216,6 +44584,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Section; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.SectionCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.SectionCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.SectionCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SectionCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.SectionCollection; load(option?: string | string[]): Word.SectionCollection; @@ -44426,10 +44806,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Table): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Table): void; + set(properties: Word.Table): void; /** * * Adds columns to the start or end of the table, using the first or last existing column as a template. This is applicable to uniform tables. The string values, if specified, are set in the newly inserted rows. @@ -44747,6 +45137,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Table` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Table` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Table` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableLoadOptions): Word.Table; load(option?: string | string[]): Word.Table; @@ -44789,6 +45191,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Table; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableCollection; load(option?: string | string[]): Word.TableCollection; @@ -44887,10 +45301,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ verticalAlignment: Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableRow): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableRowUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableRow): void; + set(properties: Word.TableRow): void; /** * * Clears the contents of the row. @@ -45035,6 +45459,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableRow` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableRow` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableRow` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableRowLoadOptions): Word.TableRow; load(option?: string | string[]): Word.TableRow; @@ -45077,6 +45513,18 @@ declare namespace Word { getFirstOrNullObject(): Word.TableRow; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableRowCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableRowCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableRowCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableRowCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableRowCollection; load(option?: string | string[]): Word.TableRowCollection; @@ -45175,10 +45623,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableCell): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableCellUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableCell): void; + set(properties: Word.TableCell): void; /** * * Deletes the column containing this cell. This is applicable to uniform tables. @@ -45309,6 +45767,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCell` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCell` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCell` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCellLoadOptions): Word.TableCell; load(option?: string | string[]): Word.TableCell; @@ -45351,6 +45821,18 @@ declare namespace Word { getFirstOrNullObject(): Word.TableCell; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCellCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCellCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCellCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCellCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableCellCollection; load(option?: string | string[]): Word.TableCellCollection; @@ -45393,12 +45875,34 @@ declare namespace Word { * [Api set: WordApi 1.3] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableBorder): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableBorderUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableBorder): void; + set(properties: Word.TableBorder): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableBorder` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableBorder` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableBorder` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableBorderLoadOptions): Word.TableBorder; load(option?: string | string[]): Word.TableBorder; @@ -46230,8 +46734,17 @@ declare namespace Word { notImplemented = "NotImplemented", } module Interfaces { + /** + * Provides ways to load properties of only a subset of members of a collection. + */ interface CollectionLoadOptions { + /** + * Specify the number of items in the queried collection to be included in the result. + */ $top?: number; + /** + * Specify the number of items in the collection that are to be skipped and not included in the result. If top is specified, the selection of result will start after skipping the specified number of items. + */ $skip?: number; } /** An interface for updating data on the Body object, for use in "body.set({ ... })". */ @@ -54420,15 +54933,6 @@ declare namespace OneNote { */ numberType: OneNote.NumberType | "None" | "Arabic" | "UCRoman" | "LCRoman" | "UCLetter" | "LCLetter" | "Ordinal" | "Cardtext" | "Ordtext" | "Hex" | "ChiManSty" | "DbNum1" | "DbNum2" | "Aiueo" | "Iroha" | "DbChar" | "SbChar" | "DbNum3" | "DbNum4" | "Circlenum" | "DArabic" | "DAiueo" | "DIroha" | "ArabicLZ" | "Bullet" | "Ganada" | "Chosung" | "GB1" | "GB2" | "GB3" | "GB4" | "Zodiac1" | "Zodiac2" | "Zodiac3" | "TpeDbNum1" | "TpeDbNum2" | "TpeDbNum3" | "TpeDbNum4" | "ChnDbNum1" | "ChnDbNum2" | "ChnDbNum3" | "ChnDbNum4" | "KorDbNum1" | "KorDbNum2" | "KorDbNum3" | "KorDbNum4" | "Hebrew1" | "Arabic1" | "Hebrew2" | "Arabic2" | "Hindi1" | "Hindi2" | "Hindi3" | "Thai1" | "Thai2" | "NumInDash" | "LCRus" | "UCRus" | "LCGreek" | "UCGreek" | "Lim" | "Custom"; } - /** - * [Api set: OneNoteApi 1.1] - */ - enum EntityType { - notebook = "Notebook", - sectionGroup = "SectionGroup", - section = "Section", - page = "Page", - } /** * [Api set: OneNoteApi 1.1] */ @@ -55690,6 +56194,7 @@ declare namespace OneNote { interface TableCellCollectionData { items?: OneNote.Interfaces.TableCellData[]; } + /** * * Represents the top-level object that contains all globally addressable OneNote objects such as notebooks, the active notebook, and the active section. @@ -57361,182 +57866,6 @@ declare namespace OneNote { */ shadingColor?: boolean; } - /** - * - * Represents a OneNote accessibility violation. - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationLoadOptions { - $all?: boolean; - /** - * - * Gets the ID of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * Gets the location of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - location?: boolean; - /** - * - * Gets the name of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - name?: boolean; - /** - * - * Gets the type of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - type?: boolean; - } - /** - * - * Represents the collection of AccessibilityViolations - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationCollectionLoadOptions { - $all?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the ID of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the location of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - location?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the name of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - name?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the type of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - type?: boolean; - } - /** - * - * A OneNote structure that stores metadata about accessibility violations for an entity. - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationsByEntityLoadOptions { - $all?: boolean; - /** - * - * Gets the parent section section group (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionGroupOrNull?: OneNote.Interfaces.SectionGroupLoadOptions; - /** - * - * Gets the parent section (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionOrNull?: OneNote.Interfaces.SectionLoadOptions; - /** - * - * Gets the name of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityName?: boolean; - /** - * - * Gets the type of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityType?: boolean; - /** - * - * Gets the ID of the AccessibilityViolationsByEntity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * Gets the count of accessibility violations for the entity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - violationsCount?: boolean; - } - /** - * - * Represents the collection of AccessibilityViolationsByEntity - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationsByEntityCollectionLoadOptions { - $all?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the parent section section group (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionGroupOrNull?: OneNote.Interfaces.SectionGroupLoadOptions; - /** - * - * For EACH ITEM in the collection: Gets the parent section (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionOrNull?: OneNote.Interfaces.SectionLoadOptions; - /** - * - * For EACH ITEM in the collection: Gets the name of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityName?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the type of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityType?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the ID of the AccessibilityViolationsByEntity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the count of accessibility violations for the entity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - violationsCount?: boolean; - } } } declare namespace OneNote { @@ -60156,4 +60485,4 @@ declare namespace Visio { //////////////////////////////////////////////////////////////// ////////////////////// End PowerPoint APIs ///////////////////// -//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// \ No newline at end of file From 983aa9cc647da43c68428840fd722d3e6d7c7be7 Mon Sep 17 00:00:00 2001 From: LauR3y Date: Mon, 13 Aug 2018 13:28:00 +0200 Subject: [PATCH 040/109] Support for dispatching NavigationCompleteTransitionAction --- types/react-navigation/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 6e286c2217..4e342130e9 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -446,7 +446,8 @@ export type NavigationStackAction = | NavigationReplaceAction | NavigationPopAction | NavigationPushAction - | NavigationPopToTopAction; + | NavigationPopToTopAction + | NavigationCompleteTransitionAction; export type NavigationTabAction = | NavigationInitAction From 1b962508348c0904128ffbad01cd9040938a1a47 Mon Sep 17 00:00:00 2001 From: David Brockman Smoliansky Date: Mon, 13 Aug 2018 17:29:03 +0200 Subject: [PATCH 041/109] add types for package varint Add types for [varint](https://github.com/chrisdickinson/varint) --- types/varint/index.d.ts | 46 ++++++++++++++++++++++++++++++++++++ types/varint/tsconfig.json | 16 +++++++++++++ types/varint/tslint.json | 1 + types/varint/varint-tests.ts | 17 +++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 types/varint/index.d.ts create mode 100644 types/varint/tsconfig.json create mode 100644 types/varint/tslint.json create mode 100644 types/varint/varint-tests.ts diff --git a/types/varint/index.d.ts b/types/varint/index.d.ts new file mode 100644 index 0000000000..ec490a2e70 --- /dev/null +++ b/types/varint/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for varint 5.0 +// Project: https://github.com/chrisdickinson/varint#readme +// Definitions by: David Brockman Smoliansky +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export const encode: { + /** + * Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, buffer: Buffer, offset?: number): Buffer; + + /** + * Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it. + * If `array` is not provided, it will default to a new array. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, array?: number[], offset?: number): number[]; + + /** + * Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). + * You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode. + */ + bytes: number; +}; + +export const decode: { + /** + * Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer. + * Throws a `RangeError` when `data` does not represent a valid encoding. + */ + (buf: Buffer | number[], offset?: number): number; + + /** + * If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. + * This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode. + */ + bytes: number; +}; + +/** + * returns the number of bytes this number will be encoded as, up to a maximum of 8. + */ +export function encodingLength(num: number): number; diff --git a/types/varint/tsconfig.json b/types/varint/tsconfig.json new file mode 100644 index 0000000000..269a7016fe --- /dev/null +++ b/types/varint/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "varint-tests.ts"] +} diff --git a/types/varint/tslint.json b/types/varint/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/varint/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/varint/varint-tests.ts b/types/varint/varint-tests.ts new file mode 100644 index 0000000000..4ef8c91753 --- /dev/null +++ b/types/varint/varint-tests.ts @@ -0,0 +1,17 @@ +import { decode, encode, encodingLength } from 'varint'; + +encode(0); // $ExpectType number[] +encode(0, []); // $ExpectType number[] +encode(0, [], 0); // $ExpectType number[] + +encode(0, Buffer.alloc(1)); // $ExpectType Buffer +encode(0, Buffer.alloc(1), 0); // $ExpectType Buffer + +encode.bytes; // $ExpectType number + +decode(Buffer.alloc(1)); // $ExpectType number +decode(Buffer.alloc(1), 0); // $ExpectType number + +decode.bytes; // $ExpectType number + +encodingLength(0); // $ExpectType number From b48b1c803bf0eeeaad90579404450b24a3afa437 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Mon, 13 Aug 2018 17:56:46 +0200 Subject: [PATCH 042/109] Add author note --- types/ttf2woff2/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts index be49b9099d..180c64f93e 100644 --- a/types/ttf2woff2/index.d.ts +++ b/types/ttf2woff2/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for ttf2woff2 2.0 // Project: https://github.com/nfroidure/ttf2woff2 -// Definitions by: My Self +// Definitions by: Thomas den Hollander // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From f77583e076ca67f11e533b54e6a7e972c2ed1233 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Mon, 13 Aug 2018 14:34:47 -0400 Subject: [PATCH 043/109] [graphql-resolve-batch] Batch resolvers receive ResolveInfo --- types/graphql-resolve-batch/graphql-resolve-batch-tests.ts | 4 +++- types/graphql-resolve-batch/index.d.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts index 9043cdaf0e..51f8964423 100644 --- a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< SomeTestResult, SomeTestArgs, SomeTestContext ->(async (sources, args, context) => { +>(async (sources, args, context, info) => { // $ExpectType ReadonlyArray const verifySources = sources; // $ExpectType string const verifyArgs = args.someArg; // $ExpectType string const verifyContext = context.someContextProp; + // $ExpectType GraphQLResolveInfo + const verifyInfo = info; const result = await asyncBatchFunction(sources); return result; diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts index ea90a83555..9908b7082a 100644 --- a/types/graphql-resolve-batch/index.d.ts +++ b/types/graphql-resolve-batch/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +import { GraphQLResolveInfo } from 'graphql'; + /** * Creates a GraphQL.js field resolver that batches together multiple resolves * together that share the *exact* same GraphQL field selection. @@ -45,5 +47,6 @@ export type ResolverFunction = ( export type BatchResolveFunction = ( sources: ReadonlyArray, args: TArgs, - context: TContext + context: TContext, + info: GraphQLResolveInfo ) => TReturn[] | Promise; From 181f4d59223d0aee1b272908576211433af69a82 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:23:10 +0200 Subject: [PATCH 044/109] Added typings for react-router-hash-link --- types/react-router-hash-link/index.d.ts | 18 +++++++++++++++ .../react-router-hash-link-tests.ts | 23 +++++++++++++++++++ types/react-router-hash-link/tsconfig.json | 23 +++++++++++++++++++ types/react-router-hash-link/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/react-router-hash-link/index.d.ts create mode 100644 types/react-router-hash-link/react-router-hash-link-tests.ts create mode 100644 types/react-router-hash-link/tsconfig.json create mode 100644 types/react-router-hash-link/tslint.json diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts new file mode 100644 index 0000000000..545a31cc71 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for react-router-hash-link 1.2 +// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Sam Baeck +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; +import { LinkProps, NavLinkProps } from 'react-router-dom'; + +export interface HashLinkProps extends LinkProps { + smooth?: boolean; + scroll?: (element: HTMLElement) => void; +} + +export class HashLink extends React.Component {} + +export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {} + +export class NavHashLink extends React.Component {} diff --git a/types/react-router-hash-link/react-router-hash-link-tests.ts b/types/react-router-hash-link/react-router-hash-link-tests.ts new file mode 100644 index 0000000000..7825bbf6c4 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.ts @@ -0,0 +1,23 @@ +import * as H from 'history'; +import * as React from 'react'; +import { match } from 'react-router'; +import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link'; + +interface Props extends NavHashLinkProps { + extraProp: string; +} + +const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; + +export default function (props: Props) { + const {extraProp, ...rest} = props; + const isActive = getIsActive(extraProp); + return ( + +); +} + + + +const acceptRef = (node: HTMLAnchorElement | null) => {}; +; \ No newline at end of file diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..71c139a0f0 --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.ts" + ] +} diff --git a/types/react-router-hash-link/tslint.json b/types/react-router-hash-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-hash-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e04532a2b1e77c4b9e9276b54313e397e96caae9 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:30:23 +0200 Subject: [PATCH 045/109] added strictFunctionTypes": true to tsconfig --- types/react-router-hash-link/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 71c139a0f0..892d3999e3 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From d29b89c1a85b0d7379affaab5abdd45aa68effb1 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:49:28 +0200 Subject: [PATCH 046/109] updated tsconfig, fixed broken tests --- types/react-router-hash-link/index.d.ts | 1 + ...link-tests.ts => react-router-hash-link-tests.tsx} | 11 ++++++----- types/react-router-hash-link/tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) rename types/react-router-hash-link/{react-router-hash-link-tests.ts => react-router-hash-link-tests.tsx} (72%) diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts index 545a31cc71..9480f1aef0 100644 --- a/types/react-router-hash-link/index.d.ts +++ b/types/react-router-hash-link/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) // Definitions by: Sam Baeck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 import * as React from 'react'; import { LinkProps, NavLinkProps } from 'react-router-dom'; diff --git a/types/react-router-hash-link/react-router-hash-link-tests.ts b/types/react-router-hash-link/react-router-hash-link-tests.tsx similarity index 72% rename from types/react-router-hash-link/react-router-hash-link-tests.ts rename to types/react-router-hash-link/react-router-hash-link-tests.tsx index 7825bbf6c4..4c64a1b5c3 100644 --- a/types/react-router-hash-link/react-router-hash-link-tests.ts +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -9,15 +9,16 @@ interface Props extends NavHashLinkProps { const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; -export default function (props: Props) { +export default function(props: Props) { const {extraProp, ...rest} = props; const isActive = getIsActive(extraProp); return ( -); + ); } - +; -const acceptRef = (node: HTMLAnchorElement | null) => {}; -; \ No newline at end of file +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 892d3999e3..fc830ac41d 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -19,6 +19,6 @@ }, "files": [ "index.d.ts", - "react-router-hash-link-tests.ts" + "react-router-hash-link-tests.tsx" ] } From 9debe9348817c64984a21226d4d31069e41a3de9 Mon Sep 17 00:00:00 2001 From: Abraham White Date: Mon, 13 Aug 2018 16:32:14 -0600 Subject: [PATCH 047/109] Fix SObject bulk operation signatures --- types/jsforce/jsforce-tests.ts | 86 ++++++++++++++++++++++++++++ types/jsforce/salesforce-object.d.ts | 24 +++----- 2 files changed, 95 insertions(+), 15 deletions(-) diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 886bd012c0..8e572448b4 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -273,6 +273,92 @@ async function testSObject(connection: sf.Connection) { }); } + { // Test SObject.createBulk + // $ExpectType Batch + dummySObject.createBulk(); + // $ExpectType Batch + dummySObject.createBulk('hi.csv'); + // $ExpectType Batch + dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.createBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.deleteBulk and aliases + // $ExpectType Batch + dummySObject.deleteBulk(); + // $ExpectType Batch + dummySObject.deleteBulk('hi.csv'); + // $ExpectType Batch + dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.deleteBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + // $ExpectType Batch + dummySObject.destroyBulk(); + // $ExpectType Batch + dummySObject.destroyBulk('hi.csv'); + // $ExpectType Batch + dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.destroyBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.deleteHardBulk and aliases + // $ExpectType Batch + dummySObject.deleteHardBulk(); + // $ExpectType Batch + dummySObject.deleteHardBulk('hi.csv'); + // $ExpectType Batch + dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.deleteHardBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + // $ExpectType Batch + dummySObject.destroyHardBulk(); + // $ExpectType Batch + dummySObject.destroyHardBulk('hi.csv'); + // $ExpectType Batch + dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.destroyHardBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + { // Test SObject.destroy and aliases // $ExpectType RecordResult await dummySObject.del('Id'); diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 2015f5d79b..a2f1c5dffd 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -21,7 +21,7 @@ export class SObject { update(record: Partial, options?: RestApiOptions, callback?: Callback): Promise; update(records: Array>, callback?: Callback): Promise; update(records: Array>, options?: RestApiOptions, callback?: Callback): Promise; - // FIXME: should input really be optional? the documentation says so, but how can you actually update without it? + // should input really be optional? the documentation says so, but how can you actually update without it? updateBulk(input?: Record[] | stream.Stream | string, callback?: Callback): Batch; updated(start: string | Date, end: string | Date, callback?: Callback): Promise; upsert(records: Record, extIdField: string, callback?: Callback): Promise; @@ -51,28 +51,23 @@ export class SObject { clear(): void; } compactLayouts(callback?: Callback): Promise; - count(conditions?: Object | string, callback?: Callback): Query; + count(conditions?: object | string, callback?: Callback): Query; create(record: T, options?: RestApiOptions, callback?: Callback): Promise; create(record: T, callback?: Callback): Promise; create(record: Array, options?: RestApiOptions, callback?: Callback): Promise; create(record: Array, callback?: Callback): Promise; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; del(id: string, callback?: Callback): Promise; del(ids: string[], callback?: Callback): Promise; destroy(id: string, callback?: Callback): Promise; destroy(ids: string[], callback?: Callback): Promise; delete(id: string, callback?: Callback): Promise; delete(ids: string[], callback?: Callback): Promise; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - deleteBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - destroyBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - destroyHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + deleteBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + destroyBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + destroyHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; deleted(start: Date | string, end: Date | string, callback?: Callback): Promise; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - deleteHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + deleteHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; describe(callback?: Callback): Promise; describe$: { /** Returns a value from the cache if it exists, otherwise calls SObject.describe */ @@ -81,7 +76,7 @@ export class SObject { } insert(record: Record, callback?: Callback): Promise; insert(records: Array>, callback?: Callback): Promise; - insertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + insertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; /** Returns a value from the cache if it exists, otherwise calls SObject.layouts */ layouts$: { (layoutName?: string, callback?: Callback): LayoutInfo; @@ -92,8 +87,7 @@ export class SObject { listviews(callback?: Callback): Promise; quickAction(actionName: string): QuickAction; quickActions(callback?: Callback): Promise; - // FIXME: why does the callback return a single RecordResult instead of an array as in the documentation? - recent(callback?: Callback): Promise; + recent(callback?: Callback): Promise; select(callback?: Callback): Query; // TODO:use a typed pluck to turn `fields` into a subset of T's fields so that the output is slimmed down appropriately select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: Callback>>): Query>>; From d74f769a0a0e805b599fd99c5967ae4b4bedc580 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Tue, 14 Aug 2018 00:22:58 +0100 Subject: [PATCH 048/109] styled-system: Remove styled-components as a dependency for tests --- types/styled-system/package.json | 6 ------ types/styled-system/styled-system-tests.tsx | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 types/styled-system/package.json diff --git a/types/styled-system/package.json b/types/styled-system/package.json deleted file mode 100644 index da1a3181d0..0000000000 --- a/types/styled-system/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "styled-components": "^3.3.2" - } -} diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index 6062948a50..d931fd34f8 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -1,6 +1,5 @@ // Example uses styled-components, but styled-system works with most other css-in-js libraries as well import * as React from "react"; -import styled from "styled-components"; import { themeGet, space, @@ -125,6 +124,11 @@ import { MixedProps, } from "styled-system"; +// tslint:disable-next-line:strict-export-declare-modifiers +declare type StyledFunction = (...props: any[]) => React.ComponentType; +// tslint:disable-next-line:strict-export-declare-modifiers +declare const styled: StyledFunction; + const boxStyle = variant({ prop: 'boxStyle', key: 'box', @@ -168,9 +172,8 @@ interface BoxProps MixedProps { boxStyle?: string; } -const Box = styled.div.attrs({})` - -border-radius: ${themeGet("radii.small", "4px")}; +const Box: React.ComponentType = styled` + border-radius: ${themeGet("radii.small", "4px")}; ${space} ${width} ${fontSize} @@ -226,7 +229,7 @@ interface TextProps LineHeightProps, FontWeightProps, LetterSpacingProps {} -const Text = styled.div.attrs({})` +const Text: React.ComponentType = styled` ${fontSize}; ${fontFamily}; ${textAlign}; @@ -242,7 +245,7 @@ interface FlexComponentProps FlexWrapProps, FlexBasisProps, FlexDirectionProps {} -const Flex = styled.div.attrs({})` +const Flex: React.ComponentType = styled` ${alignItems}; ${alignContent}; ${justifyContent}; @@ -262,7 +265,7 @@ interface GridComponentProps GridAutoRowsProps, GridTemplatesRowsProps, GridTemplatesColumnsProps {} -const Grid = styled.div.attrs({})` +const Grid: React.ComponentType = styled` ${gridGap}; ${gridRowGap}; ${gridColumnGap}; @@ -279,7 +282,7 @@ interface ButtonProps extends SpaceProps, ButtonStyleProps {} -const TestButton = styled.button.attrs({})` +const TestButton: React.ComponentType = styled` ${buttonStyle} ${space} `; From b73a0d38b81c40d6ba8ddfff03a0f9c38b42bbc4 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Tue, 14 Aug 2018 00:27:17 +0100 Subject: [PATCH 049/109] Remove unnecessary type in test --- types/styled-system/styled-system-tests.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index d931fd34f8..e16b90665d 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -125,9 +125,7 @@ import { } from "styled-system"; // tslint:disable-next-line:strict-export-declare-modifiers -declare type StyledFunction = (...props: any[]) => React.ComponentType; -// tslint:disable-next-line:strict-export-declare-modifiers -declare const styled: StyledFunction; +declare const styled: (...props: any[]) => React.ComponentType; const boxStyle = variant({ prop: 'boxStyle', From 8f3a3fe440e9a9b84650f222580a05f92ebe7804 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:15:29 -0700 Subject: [PATCH 050/109] Add definition for shallow-equals --- .github/CODEOWNERS | 1 + types/shallow-equals/index.d.ts | 16 ++++++++++++++++ types/shallow-equals/shallow-equals-tests.ts | 10 ++++++++++ types/shallow-equals/tsconfig.json | 16 ++++++++++++++++ types/shallow-equals/tslint.json | 3 +++ 5 files changed, 46 insertions(+) create mode 100644 types/shallow-equals/index.d.ts create mode 100644 types/shallow-equals/shallow-equals-tests.ts create mode 100644 types/shallow-equals/tsconfig.json create mode 100644 types/shallow-equals/tslint.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8c7f823a07..d15d79bc9d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3968,6 +3968,7 @@ /types/set-value/ @DanielRosenwasser /types/settings/ @shreyjain1994 /types/sha1/ @arcdev1 +/types/shallow-equals/ @rsolomon /types/shallowequal/ @seansfkelley /types/shapefile/ @DenisCarriere /types/sharedworker/ @nakakura diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts new file mode 100644 index 0000000000..126366f74f --- /dev/null +++ b/types/shallow-equals/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for shallow-equals v1.0.0 +// Project: https://github.com/hughsk/shallow-equals +// Definitions by: Ross Solomon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function shallowEquals( + a?: A, + b?: B, + compare?: (objA?: A, objB?: B) => boolean, +): boolean; + +declare namespace shallowEquals { + +} + +export = shallowEquals; diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts new file mode 100644 index 0000000000..092e3557e1 --- /dev/null +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -0,0 +1,10 @@ +import shallowEquals = require('shallow-equals'); + +const a = {}; +const b = {}; +function compare(a: object, b: object) { + return false; +} + +shallowEquals(a, b); +shallowEquals(a, b, compare); diff --git a/types/shallow-equals/tsconfig.json b/types/shallow-equals/tsconfig.json new file mode 100644 index 0000000000..74f59acd72 --- /dev/null +++ b/types/shallow-equals/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "shallow-equals-tests.ts"] +} diff --git a/types/shallow-equals/tslint.json b/types/shallow-equals/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/shallow-equals/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 193bd151a15c9bbd81f938136eea24a26b575c5a Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:26:00 -0700 Subject: [PATCH 051/109] Use generator --- types/shallow-equals/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 126366f74f..87c4145585 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -3,14 +3,14 @@ // Definitions by: Ross Solomon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function shallowEquals( +export = shallow_equals; + +declare function shallow_equals( a?: A, b?: B, compare?: (objA?: A, objB?: B) => boolean, ): boolean; -declare namespace shallowEquals { +declare namespace shallow_equals { } - -export = shallowEquals; From 2fe4a041ad416d25f667aa421e1f7d572dd20582 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:40:37 -0700 Subject: [PATCH 052/109] Fix prettier mistakes --- types/shallow-equals/index.d.ts | 12 +++++------- types/shallow-equals/shallow-equals-tests.ts | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 87c4145585..69e1a6c552 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shallow-equals v1.0.0 +// Type definitions for shallow-equals 1.0 // Project: https://github.com/hughsk/shallow-equals // Definitions by: Ross Solomon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,11 +6,9 @@ export = shallow_equals; declare function shallow_equals( - a?: A, - b?: B, - compare?: (objA?: A, objB?: B) => boolean, + a?: A, + b?: B, + compare?: (objA?: A, objB?: B) => boolean, ): boolean; -declare namespace shallow_equals { - -} +declare namespace shallow_equals {} diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts index 092e3557e1..87512c9f43 100644 --- a/types/shallow-equals/shallow-equals-tests.ts +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -1,9 +1,18 @@ import shallowEquals = require('shallow-equals'); -const a = {}; -const b = {}; -function compare(a: object, b: object) { - return false; +interface A { + foo: string; +} + +interface B { + foo: string; + bar?: string; +} + +const a: A = { foo: 'bar' }; +const b: B = { foo: 'baz' }; +function compare(a: A, b: B) { + return false; } shallowEquals(a, b); From aeb446e0bfc0ae94268414cd005ae52881b0a5ca Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 19:45:09 -0500 Subject: [PATCH 053/109] Update emoji-mart types for v2.8.0 --- .../dist-es/components/category.d.ts | 7 +- .../emoji-mart/dist-es/components/emoji.d.ts | 31 ------- .../dist-es/components/emoji/emoji.d.ts | 8 ++ .../components/emoji/nimble-emoji.d.ts | 12 +++ .../emoji-mart/dist-es/components/index.d.ts | 6 +- .../emoji-mart/dist-es/components/picker.d.ts | 54 ------------ .../components/picker/nimble-picker.d.ts | 11 +++ .../dist-es/components/picker/picker.d.ts | 7 ++ types/emoji-mart/dist-es/index.d.ts | 26 ++++-- types/emoji-mart/dist-es/utils/data.d.ts | 73 ++++++++++++++++ .../emoji-mart/dist-es/utils/emoji-index.d.ts | 25 ------ .../utils/emoji-index/emoji-index.d.ts | 14 ++++ .../dist-es/utils/emoji-index/index.d.ts | 2 + .../utils/emoji-index/nimble-emoji-index.d.ts | 40 +++++++++ .../dist-es/utils/shared-props.d.ts | 83 +++++++++++++++++++ types/emoji-mart/emoji-mart-tests.tsx | 4 +- types/emoji-mart/index.d.ts | 7 +- types/emoji-mart/tsconfig.json | 12 ++- 18 files changed, 291 insertions(+), 131 deletions(-) delete mode 100644 types/emoji-mart/dist-es/components/emoji.d.ts create mode 100644 types/emoji-mart/dist-es/components/emoji/emoji.d.ts create mode 100644 types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts delete mode 100644 types/emoji-mart/dist-es/components/picker.d.ts create mode 100644 types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts create mode 100644 types/emoji-mart/dist-es/components/picker/picker.d.ts create mode 100644 types/emoji-mart/dist-es/utils/data.d.ts delete mode 100644 types/emoji-mart/dist-es/utils/emoji-index.d.ts create mode 100644 types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts create mode 100644 types/emoji-mart/dist-es/utils/emoji-index/index.d.ts create mode 100644 types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts create mode 100644 types/emoji-mart/dist-es/utils/shared-props.d.ts diff --git a/types/emoji-mart/dist-es/components/category.d.ts b/types/emoji-mart/dist-es/components/category.d.ts index 8cd4ceefbb..cde72441bf 100644 --- a/types/emoji-mart/dist-es/components/category.d.ts +++ b/types/emoji-mart/dist-es/components/category.d.ts @@ -1,12 +1,11 @@ -import React = require('react'); +import * as React from 'react'; -import { EmojiData } from '..'; - -import { Emoji, EmojiProps, I18n } from '.'; +import { Emoji, EmojiData, EmojiProps, I18n } from '..'; export interface Props { emojis?: Array; hasStickyPosition?: boolean; + id: string; name: string; native: boolean; perLine: number; diff --git a/types/emoji-mart/dist-es/components/emoji.d.ts b/types/emoji-mart/dist-es/components/emoji.d.ts deleted file mode 100644 index 030ff7ce12..0000000000 --- a/types/emoji-mart/dist-es/components/emoji.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import React = require('react'); - -import { EmojiData, EmojiSkin } from '..'; - -export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string; -export type EmojiSet = 'apple'|'google'|'twitter'|'emojione'|'messenger'|'facebook'; -export type EmojiSheetSize = 16|20|32|64; - -export interface Props { - onOver?(emoji: EmojiData, e: React.MouseEvent): void; - onLeave?(emoji: EmojiData, e: React.MouseEvent): void; - onClick?(emoji: EmojiData, e: React.MouseEvent): void; - /** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */ - backgroundImageFn?: BackgroundImageFn; - native?: boolean; - forceSize?: boolean; - tooltip?: boolean; - /** defaults to 1 */ - skin?: EmojiSkin; - /** defaults to 64 */ - sheetSize?: EmojiSheetSize; - /** defaults to 'apple' */ - set?: EmojiSet; - size: number; - emoji: string|EmojiData; -} - -// tslint:disable-next-line strict-export-declare-modifiers -declare const Emoji: React.SFC; - -export { Emoji as default }; diff --git a/types/emoji-mart/dist-es/components/emoji/emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts new file mode 100644 index 0000000000..78ca216af6 --- /dev/null +++ b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts @@ -0,0 +1,8 @@ +import * as React from 'react'; + +import { EmojiProps } from '../..'; + +// tslint:disable-next-line strict-export-declare-modifiers +declare const Emoji: React.StatelessComponent; + +export { Emoji as default }; diff --git a/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts new file mode 100644 index 0000000000..03b9d3730f --- /dev/null +++ b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts @@ -0,0 +1,12 @@ +import * as React from 'react'; + +import { EmojiProps, Data } from '../..'; + +export interface NimbleEmojiProps extends EmojiProps { + data: Data; +} + +// tslint:disable-next-line strict-export-declare-modifiers +declare const NimbleEmoji: React.SFC; + +export { NimbleEmoji as default }; diff --git a/types/emoji-mart/dist-es/components/index.d.ts b/types/emoji-mart/dist-es/components/index.d.ts index 6fc29ecd54..3f05ca5c82 100644 --- a/types/emoji-mart/dist-es/components/index.d.ts +++ b/types/emoji-mart/dist-es/components/index.d.ts @@ -1,4 +1,6 @@ // The other exports on the components folder are not public API export { default as Category, Props as CategoryProps } from './category'; -export { default as Emoji, Props as EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from './emoji'; -export { default as Picker, Props as PickerProps, I18n, PartialI18n, CustomEmoji } from './picker'; +export { default as Emoji } from './emoji/emoji'; +export { default as NimbleEmoji, NimbleEmojiProps } from './emoji/nimble-emoji'; +export { default as Picker } from './picker/picker'; +export { default as NimblePicker, NimblePickerProps } from './picker/nimble-picker'; diff --git a/types/emoji-mart/dist-es/components/picker.d.ts b/types/emoji-mart/dist-es/components/picker.d.ts deleted file mode 100644 index 9f9132df05..0000000000 --- a/types/emoji-mart/dist-es/components/picker.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -import React = require('react'); - -import { EmojiData, EmojiSkin } from '..'; - -import { Category, Emoji, EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from '.'; - -// tslint:disable-next-line interface-name -export interface I18n { - search: string; - categories: Record<'search'|'recent'|'people'|'nature'|'foods'|'activity'|'places'|'objects'|'symbols'|'flags'|'custom', string>; - notfound: string; -} - -export type PartialI18n = Partial & { categories: Partial}>; - -export interface CustomEmoji { - // id is overridden by short_names[0] - name: string; - /** Must contain at least one name. The first name is used as the unique id. */ - short_names: string[]; - emoticons?: string[]; - keywords?: string[]; - imageUrl: string; -} - -export interface Props { - /** NOTE: default is not preventable */ - onClick?(emoji: EmojiData, e: React.MouseEvent): void; - perLine?: number; - emojiSize?: number; - i18n?: PartialI18n; - style?: React.CSSProperties; - title?: string; - emoji?: string; - color?: string; - set?: EmojiSet; - skin?: EmojiSkin; - native?: boolean; - backgroundImageFn?: BackgroundImageFn; - sheetSize?: EmojiSheetSize; - emojisToShowFilter?(emoji: EmojiData): boolean; - showPreview?: boolean; - emojiTooltip?: boolean; - include?: string[]; - exclude?: string[]; - recent?: string[]; - autoFocus?: boolean; - /** NOTE: custom emoji are copied into a singleton object on every new mount */ - custom: CustomEmoji[]; -} - -export default class Picker extends React.PureComponent { - // everything inside it is supposed to be private -} diff --git a/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts new file mode 100644 index 0000000000..4f286a12ca --- /dev/null +++ b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts @@ -0,0 +1,11 @@ +import * as React from 'react'; + +import { Data, PickerProps } from '../..'; + +export interface NimblePickerProps extends PickerProps { + data: Data; +} + +export default class NimblePicker extends React.PureComponent { + // everything inside it is supposed to be private +} diff --git a/types/emoji-mart/dist-es/components/picker/picker.d.ts b/types/emoji-mart/dist-es/components/picker/picker.d.ts new file mode 100644 index 0000000000..81841b19d6 --- /dev/null +++ b/types/emoji-mart/dist-es/components/picker/picker.d.ts @@ -0,0 +1,7 @@ +import * as React from 'react'; + +import { PickerProps } from '../..'; + +export default class Picker extends React.PureComponent { + // everything inside it is supposed to be private +} diff --git a/types/emoji-mart/dist-es/index.d.ts b/types/emoji-mart/dist-es/index.d.ts index e49d37fcf6..bfc61354dd 100644 --- a/types/emoji-mart/dist-es/index.d.ts +++ b/types/emoji-mart/dist-es/index.d.ts @@ -1,15 +1,29 @@ -export { default as emojiIndex, EmojiData, EmojiSkin } from './utils/emoji-index'; export { default as store, StoreHandlers } from './utils/store'; export { default as frequently } from './utils/frequently'; +export { Data } from './utils/data'; + +export { + PickerProps, + EmojiProps, + I18n, + PartialI18n +} from './utils/shared-props'; + +export { + emojiIndex, + nimbleEmojiIndex, + EmojiData, + CustomEmoji, + EmojiSkin +} from './utils/emoji-index'; export { Picker, - PickerProps, - I18n, - PartialI18n, - CustomEmoji, + NimblePicker, + NimblePickerProps, Emoji, - EmojiProps, + NimbleEmoji, + NimbleEmojiProps, Category, CategoryProps } from './components'; diff --git a/types/emoji-mart/dist-es/utils/data.d.ts b/types/emoji-mart/dist-es/utils/data.d.ts new file mode 100644 index 0000000000..ad1bc0d229 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/data.d.ts @@ -0,0 +1,73 @@ +export interface Data { + compressed: boolean; + categories: Category[]; + emojis: { [key: string]: Emoji }; + aliases: { [key: string]: string }; +} + +export interface Category { + id: string; + name: string; + emojis: string[]; +} + +export interface Emoji { + name?: string; + a?: string; + unified?: string; + b?: string; + non_qualified?: string; + c?: string; + has_img_apple?: boolean; + d?: boolean; + has_img_google?: boolean; + e?: boolean; + has_img_twitter?: boolean; + f?: boolean; + has_img_emojione?: boolean; + g?: boolean; + has_img_facebook?: boolean; + h?: boolean; + has_img_messenger?: boolean; + i?: boolean; + keywords?: string[]; + j?: string[]; + sheet?: number[]; + k?: number[]; + emoticons?: string[]; + l?: string[]; + text?: string; + m?: string; + short_names?: string[]; + n?: string[]; + added_in?: number; + o?: number; + sheet_x?: number; + sheet_y?: number; + skin_variations?: { [key: string]: SkinVariation }; + obsoleted_by?: string; + obsoletes?: string; +} + +export interface SkinVariation { + unified: string; + non_qualified: null | string; + image: string; + sheet_x: number; + sheet_y: number; + added_in: string; + has_img_apple: boolean; + has_img_google: boolean; + has_img_twitter: boolean; + has_img_emojione: boolean; + has_img_facebook: boolean; + has_img_messenger: boolean; + obsoleted_by?: string; + obsoletes?: string; +} + +export function buildSearch(emoji: Emoji): string; + +export function compress(emoji: Emoji): void; + +export function uncompress(data: Data): void; diff --git a/types/emoji-mart/dist-es/utils/emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index.d.ts deleted file mode 100644 index c6499e663c..0000000000 --- a/types/emoji-mart/dist-es/utils/emoji-index.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -export type EmojiSkin = 1|2|3|4|5|6; - -export interface EmojiData { - id: string; - name: string; - colons: string; - /** Reverse mapping to keyof emoticons */ - emoticons: string[]; - unified: string; - skin: EmojiSkin|null; - native: string; -} - -// tslint:disable-next-line strict-export-declare-modifiers -declare const _default: { - search(query: ''): null - search(query: string): EmojiData|null - - emojis: { [emoji: string]: EmojiData } - - /** Mapping of string to keyof emojis */ - emoticons: { [emoticon: string]: string } -}; - -export { _default as default }; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts new file mode 100644 index 0000000000..0d1d6b8881 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts @@ -0,0 +1,14 @@ +import { EmojiData } from './nimble-emoji-index'; + +// tslint:disable-next-line strict-export-declare-modifiers +declare const _default: { + search(query: ''): null; + search(query: string): EmojiData|null; + + emojis: { [emoji: string]: EmojiData }; + + /** Mapping of string to keyof emojis */ + emoticons: { [emoticon: string]: string }; +}; + +export { _default as default }; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts new file mode 100644 index 0000000000..576a5d0cb7 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts @@ -0,0 +1,2 @@ +export { default as emojiIndex } from './emoji-index'; +export { default as nimbleEmojiIndex, EmojiData, CustomEmoji, EmojiSkin } from './nimble-emoji-index'; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts new file mode 100644 index 0000000000..010c313d19 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts @@ -0,0 +1,40 @@ +import { Data } from "../data"; + +import { CategoryName } from '../shared-props'; + +export type EmojiSkin = 1 | 2 | 3 | 4 | 5 | 6; + +export interface BaseEmoji { + id: string; + name: string; + colons: string; + /** Reverse mapping to keyof emoticons */ + emoticons: string[]; + unified: string; + skin: EmojiSkin | null; + native: string; +} + +export interface CustomEmoji { + // id is overridden by short_names[0] + id?: string; + // colons is overridden by :id: + colons?: string; + name: string; + /** Must contain at least one name. The first name is used as the unique id. */ + short_names: string[]; + emoticons?: string[]; + keywords?: string[]; + imageUrl: string; +} + +export type EmojiData = BaseEmoji | CustomEmoji; + +export default class NimbleEmojiIndex { + constructor(data: Data); + search(query: ''): null; + search(query: string): EmojiData[]|null; + emojis: { [emoji: string]: EmojiData }; + /** Mapping of string to keyof emojis */ + emoticons: { [emoticon: string]: string }; +} diff --git a/types/emoji-mart/dist-es/utils/shared-props.d.ts b/types/emoji-mart/dist-es/utils/shared-props.d.ts new file mode 100644 index 0000000000..aed45486c5 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/shared-props.d.ts @@ -0,0 +1,83 @@ +import * as React from 'react'; + +import { Data } from './data'; +import { EmojiData, EmojiSkin, CustomEmoji } from './emoji-index/nimble-emoji-index'; + +export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string; +export type EmojiSet = 'apple' | 'google' | 'twitter' | 'emojione' | 'messenger' | 'facebook'; +export type EmojiSheetSize = 16 | 20 | 32 | 64; + +export interface EmojiProps { + onOver?(emoji: EmojiData, e: React.MouseEvent): void; + onLeave?(emoji: EmojiData, e: React.MouseEvent): void; + onClick?(emoji: EmojiData, e: React.MouseEvent): void; + fallback?(emoji: EmojiData, props: EmojiProps): React.Component; + /** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */ + backgroundImageFn?: BackgroundImageFn; + native?: boolean; + forceSize?: boolean; + tooltip?: boolean; + /** defaults to 1 */ + skin?: EmojiSkin; + /** defaults to 64 */ + sheetSize?: EmojiSheetSize; + /** defaults to 52 */ + sheetColumns?: number; + /** defaults to 52 */ + sheetRows?: number; + /** defaults to 'apple' */ + set?: EmojiSet; + size: number; + emoji: string | EmojiData; + html?: boolean; +} + +export type CategoryName = 'search' | 'recent' | 'people' | 'nature' | 'foods' | 'activity' | 'places' | 'objects' | 'symbols' | 'flags' | 'custom'; + +// tslint:disable-next-line interface-name +export interface I18n { + search: string; + categories: Record; + notfound: string; + skintext: string; +} + +export type PartialI18n = Partial & { categories: Partial }>; + +export interface CustomIcons { + categories: Record React.Component>; +} + +export interface PickerProps { + /** NOTE: default is not preventable */ + onClick?(emoji: EmojiData, e: React.MouseEvent): void; + onSelect?(emoji: EmojiData): void; + onSkinChange?(skin: EmojiSkin): void; + perLine?: number; + emojiSize?: number; + i18n?: PartialI18n; + style?: React.CSSProperties; + title?: string; + emoji?: string; + color?: string; + set?: EmojiSet; + skin?: EmojiSkin; + defaultSkin?: EmojiSkin; + native?: boolean; + backgroundImageFn?: BackgroundImageFn; + sheetSize?: EmojiSheetSize; + emojisToShowFilter?(emoji: EmojiData): boolean; + showPreview?: boolean; + showSkinTones?: boolean; + emojiTooltip?: boolean; + include?: CategoryName[]; + exclude?: CategoryName[]; + recent?: string[]; + autoFocus?: boolean; + /** NOTE: custom emoji are copied into a singleton object on every new mount */ + custom: CustomEmoji[]; + skinEmoji?: string; + notFound?(): React.Component; + notFoundEmoji?: string; + icons?: CustomIcons; +} diff --git a/types/emoji-mart/emoji-mart-tests.tsx b/types/emoji-mart/emoji-mart-tests.tsx index 7b7b8d0471..afd8e8b3ac 100644 --- a/types/emoji-mart/emoji-mart-tests.tsx +++ b/types/emoji-mart/emoji-mart-tests.tsx @@ -1,6 +1,6 @@ -// Port of https://github.com/missive/emoji-mart/blob/master/src/components/emoji.js +// Port of https://missive.github.io/emoji-mart/ -import React = require('react'); +import * as React from 'react'; import { Picker, Emoji, EmojiProps, CustomEmoji } from 'emoji-mart'; diff --git a/types/emoji-mart/index.d.ts b/types/emoji-mart/index.d.ts index 22c17731f3..a2911119d8 100644 --- a/types/emoji-mart/index.d.ts +++ b/types/emoji-mart/index.d.ts @@ -1,9 +1,8 @@ -// Type definitions for emoji-mart 2.2 +// Type definitions for emoji-mart 2.8 // Project: https://github.com/missive/emoji-mart // Definitions by: Diogo Franco +// Nick Winans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 - -// These definitions should work with 2.3, but the tests doesn't pass on 2.3. +// TypeScript Version: 2.9 export * from './dist-es'; diff --git a/types/emoji-mart/tsconfig.json b/types/emoji-mart/tsconfig.json index 6ecc944e77..d929a3cc01 100644 --- a/types/emoji-mart/tsconfig.json +++ b/types/emoji-mart/tsconfig.json @@ -20,11 +20,17 @@ "files": [ "index.d.ts", "dist-es/components/category.d.ts", - "dist-es/components/emoji.d.ts", + "dist-es/components/emoji/emoji.d.ts", + "dist-es/components/emoji/nimble-emoji.d.ts", "dist-es/components/index.d.ts", - "dist-es/components/picker.d.ts", - "dist-es/utils/emoji-index.d.ts", + "dist-es/components/picker/picker.d.ts", + "dist-es/components/picker/nimble-picker.d.ts", + "dist-es/utils/emoji-index/emoji-index.d.ts", + "dist-es/utils/emoji-index/nimble-emoji-index.d.ts", + "dist-es/utils/emoji-index/index.d.ts", + "dist-es/utils/data.d.ts", "dist-es/utils/frequently.d.ts", + "dist-es/utils/shared-props.d.ts", "dist-es/utils/store.d.ts", "dist-es/index.d.ts", "emoji-mart-tests.tsx" From 6daee807ab903c6730dce84e172b934f3a48e4ca Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 20:32:38 -0500 Subject: [PATCH 054/109] Set TypeScript version back to 2.8 --- types/emoji-mart/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/emoji-mart/index.d.ts b/types/emoji-mart/index.d.ts index a2911119d8..38acd9e021 100644 --- a/types/emoji-mart/index.d.ts +++ b/types/emoji-mart/index.d.ts @@ -3,6 +3,6 @@ // Definitions by: Diogo Franco // Nick Winans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.9 +// TypeScript Version: 2.8 export * from './dist-es'; From 6d06564862353038a6e13c4a70d44a1651735dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Th=C3=A9riault?= Date: Mon, 13 Aug 2018 21:49:44 -0400 Subject: [PATCH 055/109] Type def. for is-uuid npm package --- types/is-uuid/index.d.ts | 46 ++++++++++++++++++++++++++++++++++ types/is-uuid/is-uuid-tests.ts | 10 ++++++++ types/is-uuid/tsconfig.json | 23 +++++++++++++++++ types/is-uuid/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/is-uuid/index.d.ts create mode 100644 types/is-uuid/is-uuid-tests.ts create mode 100644 types/is-uuid/tsconfig.json create mode 100644 types/is-uuid/tslint.json diff --git a/types/is-uuid/index.d.ts b/types/is-uuid/index.d.ts new file mode 100644 index 0000000000..f6e1f8626b --- /dev/null +++ b/types/is-uuid/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for is-uuid 1.0 +// Project: https://github.com/afram/is-uuid#readme +// Definitions by: André Thériault +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Returns true if the value is a v1 UUID + * @param value The value to test + */ +export function v1(value: string): boolean; + +/** + * Returns true if the value is a v2 UUID + * @param value The value to test + */ +export function v2(value: string): boolean; + +/** + * Returns true if the value is a v3 UUID + * @param value The value to test + */ +export function v3(value: string): boolean; + +/** + * Returns true if the value is a v4 UUID + * @param value The value to test + */ +export function v4(value: string): boolean; + +/** + * Returns true if the value is a v5 UUID + * @param value The value to test + */ +export function v5(value: string): boolean; + +/** + * Returns true if the value is a nil UUID + * @param value The value to test + */ +export function nil(value: string): boolean; + +/** + * Returns true for v1 - v5 UUID. Will return false for nil UUID + * @param value The value to test + */ +export function anyNonNil(value: string): boolean; diff --git a/types/is-uuid/is-uuid-tests.ts b/types/is-uuid/is-uuid-tests.ts new file mode 100644 index 0000000000..4e07b10905 --- /dev/null +++ b/types/is-uuid/is-uuid-tests.ts @@ -0,0 +1,10 @@ +import * as isUUID from 'is-uuid'; + +isUUID.v1('857b3f0a-a777-11e5-bf7f-feff819cdc9f'); +isUUID.v2('9a7b330a-a736-21e5-af7f-feaf819cdc9f'); +isUUID.v3('0a7b330a-a736-35ea-8f7f-feaf019cdc00'); +isUUID.v4('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.v5('5a2de30a-a736-5aea-8f7f-ad0f019cdc00'); + +isUUID.anyNonNil('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.nil('00000000-0000-0000-0000-000000000000'); diff --git a/types/is-uuid/tsconfig.json b/types/is-uuid/tsconfig.json new file mode 100644 index 0000000000..eec8e9597a --- /dev/null +++ b/types/is-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "is-uuid-tests.ts" + ] +} diff --git a/types/is-uuid/tslint.json b/types/is-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d99219134eb26a4779568d89b7de59e05dda846a Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 20:56:32 -0500 Subject: [PATCH 056/109] Various fixes and changes --- types/emoji-mart/dist-es/components/category.d.ts | 6 +++--- types/emoji-mart/dist-es/components/emoji/emoji.d.ts | 2 +- types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts | 2 +- .../emoji-mart/dist-es/components/picker/nimble-picker.d.ts | 2 +- types/emoji-mart/dist-es/components/picker/picker.d.ts | 2 +- types/emoji-mart/dist-es/index.d.ts | 3 ++- types/emoji-mart/dist-es/utils/shared-props.d.ts | 3 ++- types/emoji-mart/emoji-mart-tests.tsx | 4 ++-- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/types/emoji-mart/dist-es/components/category.d.ts b/types/emoji-mart/dist-es/components/category.d.ts index cde72441bf..efa52e9988 100644 --- a/types/emoji-mart/dist-es/components/category.d.ts +++ b/types/emoji-mart/dist-es/components/category.d.ts @@ -1,11 +1,11 @@ -import * as React from 'react'; +import React = require('react'); -import { Emoji, EmojiData, EmojiProps, I18n } from '..'; +import { Emoji, EmojiData, EmojiProps, I18n, CategoryName } from '..'; export interface Props { emojis?: Array; hasStickyPosition?: boolean; - id: string; + id: CategoryName; name: string; native: boolean; perLine: number; diff --git a/types/emoji-mart/dist-es/components/emoji/emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts index 78ca216af6..d86d2b686f 100644 --- a/types/emoji-mart/dist-es/components/emoji/emoji.d.ts +++ b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React = require('react'); import { EmojiProps } from '../..'; diff --git a/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts index 03b9d3730f..77888f5a94 100644 --- a/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts +++ b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React = require('react'); import { EmojiProps, Data } from '../..'; diff --git a/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts index 4f286a12ca..cc564b2a5e 100644 --- a/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts +++ b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React = require('react'); import { Data, PickerProps } from '../..'; diff --git a/types/emoji-mart/dist-es/components/picker/picker.d.ts b/types/emoji-mart/dist-es/components/picker/picker.d.ts index 81841b19d6..01f8a41f8b 100644 --- a/types/emoji-mart/dist-es/components/picker/picker.d.ts +++ b/types/emoji-mart/dist-es/components/picker/picker.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React = require('react'); import { PickerProps } from '../..'; diff --git a/types/emoji-mart/dist-es/index.d.ts b/types/emoji-mart/dist-es/index.d.ts index bfc61354dd..bb0c79be3e 100644 --- a/types/emoji-mart/dist-es/index.d.ts +++ b/types/emoji-mart/dist-es/index.d.ts @@ -6,7 +6,8 @@ export { PickerProps, EmojiProps, I18n, - PartialI18n + PartialI18n, + CategoryName } from './utils/shared-props'; export { diff --git a/types/emoji-mart/dist-es/utils/shared-props.d.ts b/types/emoji-mart/dist-es/utils/shared-props.d.ts index aed45486c5..bbd5966610 100644 --- a/types/emoji-mart/dist-es/utils/shared-props.d.ts +++ b/types/emoji-mart/dist-es/utils/shared-props.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React = require('react'); import { Data } from './data'; import { EmojiData, EmojiSkin, CustomEmoji } from './emoji-index/nimble-emoji-index'; @@ -30,6 +30,7 @@ export interface EmojiProps { size: number; emoji: string | EmojiData; html?: boolean; + /** data is omitted here as it should be used for NimbleEmoji only - not emoji */ } export type CategoryName = 'search' | 'recent' | 'people' | 'nature' | 'foods' | 'activity' | 'places' | 'objects' | 'symbols' | 'flags' | 'custom'; diff --git a/types/emoji-mart/emoji-mart-tests.tsx b/types/emoji-mart/emoji-mart-tests.tsx index afd8e8b3ac..56b05453a9 100644 --- a/types/emoji-mart/emoji-mart-tests.tsx +++ b/types/emoji-mart/emoji-mart-tests.tsx @@ -1,6 +1,6 @@ -// Port of https://missive.github.io/emoji-mart/ +// Port of https://github.com/missive/emoji-mart/blob/v2.8.0/stories/index.js -import * as React from 'react'; +import React = require('react'); import { Picker, Emoji, EmojiProps, CustomEmoji } from 'emoji-mart'; From e3612e282716e8740dafa96cabedde5ddea115ef Mon Sep 17 00:00:00 2001 From: Nicholas Pappagalo Date: Mon, 13 Aug 2018 19:24:19 -0700 Subject: [PATCH 057/109] rmv self from definitions by section of package header --- types/styled-system/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index 38cda70448..d9c386242c 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -7,7 +7,6 @@ // Eloy Durán // Matthieu Vachon // Adam Lavin -// Nicholas Pappagalo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 From 86498ece8f9d43e81205d7327b3f10984c630648 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 21:42:51 -0500 Subject: [PATCH 058/109] Remove unused import --- types/emoji-mart/dist-es/utils/shared-props.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/emoji-mart/dist-es/utils/shared-props.d.ts b/types/emoji-mart/dist-es/utils/shared-props.d.ts index bbd5966610..c091e24556 100644 --- a/types/emoji-mart/dist-es/utils/shared-props.d.ts +++ b/types/emoji-mart/dist-es/utils/shared-props.d.ts @@ -1,6 +1,5 @@ import React = require('react'); -import { Data } from './data'; import { EmojiData, EmojiSkin, CustomEmoji } from './emoji-index/nimble-emoji-index'; export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string; From 6dda1632760e007fd0c0eaeb177e9e32c92bebe4 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 23:42:18 -0500 Subject: [PATCH 059/109] steam-login: add types --- types/steam-login/index.d.ts | 61 ++++++++++++++++++++++++++ types/steam-login/steam-login-tests.ts | 35 +++++++++++++++ types/steam-login/tsconfig.json | 23 ++++++++++ types/steam-login/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 types/steam-login/index.d.ts create mode 100644 types/steam-login/steam-login-tests.ts create mode 100644 types/steam-login/tsconfig.json create mode 100644 types/steam-login/tslint.json diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts new file mode 100644 index 0000000000..13fc21c691 --- /dev/null +++ b/types/steam-login/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for steam-login 0.1 +// Project: http://github.com/cpancake/steam-login +// Definitions by: Nick Winans +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Request, Response, NextFunction } from 'express'; + +export interface MiddlewareOptions { + verify: string; + realm: string; + apiKey: string; + useSession?: boolean; +} + +export interface SteamUser { + _json: { + steamid: string; + personaname: string; + profileurl: string; + avatar: string; + avatarmedium: string; + avatarfull: string; + personastate: number; + communityvisibilitystate: number; + profilestate?: number; + lastlogoff: number; + commentpermission?: number; + realname?: string; + primaryclanid?: string; + timecreated?: number; + gameid?: string; + gameserverip?: string; + gameextrainfo?: string; + loccountrycode?: string; + locstatecode?: string; + loccityid?: number; + }; + steamid: string; + username: string; + name: string; + profile: string; + avatar: { + small: string; + medium: string; + large: string; + }; +} + +export interface SteamRequest extends Request { + logout(): (req: Request) => () => void; + user: SteamUser; +} + +export function middleware(opts: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; + +export function enforceLogin(redirect: string): (req: Request, res: Response, next: NextFunction) => NextFunction; + +export function verify(): (req: Request, res: Response, next: NextFunction) => NextFunction; + +export function authenticate(): (req: Request, res: Response, next: NextFunction) => NextFunction; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts new file mode 100644 index 0000000000..e741a0f5de --- /dev/null +++ b/types/steam-login/steam-login-tests.ts @@ -0,0 +1,35 @@ +// Port of https://github.com/cpancake/steam-login/blob/master/example.js + +import * as express from 'express'; +import * as steam from 'steam-login'; +import * as session from 'express-session'; + +const app = express(); + +app.use(session({ resave: false, saveUninitialized: false, secret: 'a secret' })); +app.use(steam.middleware({ + realm: 'http://localhost:3000/', + verify: 'http://localhost:3000/verify', + apiKey: process.argv[2] +} +)); + +app.get('/', (req: steam.SteamRequest, res) => { + res.send(req.user == null ? 'not logged in' : 'hello ' + req.user.username).end(); +}); + +app.get('/authenticate', steam.authenticate(), (req, res) => { + res.redirect('/'); +}); + +app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => { + res.send(req.user).end(); +}); + +app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => { + req.logout(); + res.redirect('/'); +}); + +app.listen(3000); +console.log('listening'); diff --git a/types/steam-login/tsconfig.json b/types/steam-login/tsconfig.json new file mode 100644 index 0000000000..a1d49993f6 --- /dev/null +++ b/types/steam-login/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "steam-login-tests.ts" + ] +} diff --git a/types/steam-login/tslint.json b/types/steam-login/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/steam-login/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5cae8a991523293a42411a38644c639c4a74e2c9 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 23:56:17 -0500 Subject: [PATCH 060/109] Update to support tsconfig "strictFunctionTypes": true --- types/steam-login/index.d.ts | 4 ++-- types/steam-login/steam-login-tests.ts | 2 +- types/steam-login/tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts index 13fc21c691..a765f8e7e0 100644 --- a/types/steam-login/index.d.ts +++ b/types/steam-login/index.d.ts @@ -48,8 +48,8 @@ export interface SteamUser { } export interface SteamRequest extends Request { - logout(): (req: Request) => () => void; - user: SteamUser; + logout?(): (req: Request) => () => void; + user?: SteamUser; } export function middleware(opts: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts index e741a0f5de..84eae31a01 100644 --- a/types/steam-login/steam-login-tests.ts +++ b/types/steam-login/steam-login-tests.ts @@ -27,7 +27,7 @@ app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => { }); app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => { - req.logout(); + req.logout ? req.logout() : null; res.redirect('/'); }); diff --git a/types/steam-login/tsconfig.json b/types/steam-login/tsconfig.json index a1d49993f6..8548e16277 100644 --- a/types/steam-login/tsconfig.json +++ b/types/steam-login/tsconfig.json @@ -7,7 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From c9244569c6aeb3a7149b71e15547b259fd783a81 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 14 Aug 2018 00:07:15 -0500 Subject: [PATCH 061/109] Simplify exported function returns --- types/steam-login/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts index a765f8e7e0..849a45b920 100644 --- a/types/steam-login/index.d.ts +++ b/types/steam-login/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import { Request, Response, NextFunction } from 'express'; +import { Request, RequestHandler } from 'express'; export interface MiddlewareOptions { verify: string; @@ -52,10 +52,10 @@ export interface SteamRequest extends Request { user?: SteamUser; } -export function middleware(opts: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; +export function middleware(opts: MiddlewareOptions): RequestHandler; -export function enforceLogin(redirect: string): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function enforceLogin(redirect: string): RequestHandler; -export function verify(): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function verify(): RequestHandler; -export function authenticate(): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function authenticate(): RequestHandler; From 9c9cacbae6518912ecb24e378cf98f43413cf551 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Tue, 14 Aug 2018 14:12:33 +0800 Subject: [PATCH 062/109] [echarts]: add jsdoc comments and update to ec4.0.4 - Added functions descriptions, parameter descriptions and etc. in the form of JSDoc to better support code impletion. - Changed a few interfaces according to https://echarts.apache.org/api.html . --- types/echarts/index.d.ts | 461 ++++++++++++++++++++++++++++++++++----- 1 file changed, 404 insertions(+), 57 deletions(-) diff --git a/types/echarts/index.d.ts b/types/echarts/index.d.ts index 15892864e5..08e87cab09 100644 --- a/types/echarts/index.d.ts +++ b/types/echarts/index.d.ts @@ -3,120 +3,412 @@ // Definitions by: Xie Jingyang // AntiMoron // Liveangela +// Ovilia // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 declare namespace echarts { - function init(dom: HTMLDivElement | HTMLCanvasElement, theme?: object | string, opts?: { - devicePixelRatio?: number - renderer?: string - width?: number | string - height?: number | string - }): ECharts; + /** + * Creates an ECharts instance, and returns an echartsInstance. You shall + * not initialize multiple ECharts instances on a single container. + * + * @param {HTMLDivElement | HTMLCanvasElement} dom Instance container, + * usually is a `div` element with height and width defined. + * @param {object | string} [theme] Theme to be applied. + * This can be a configuring object of a theme, or a theme name + * registered through [echarts.registerTheme](https://echarts.apache.org/api.html#echarts.registerTheme). + * @param {object} [opts] Chart configurations. + * @param {number} [opts.devicePixelRatio] Ratio of one physical pixel to + * the size of one device independent pixels. Browser's + * `window.devicePixelRatio` is used by default. + * @param {string} [opts.renderer] Supports `'canvas'` or `'svg'`. + * See [Render by Canvas or SVG](https://echarts.apache.org/tutorial.html#Render%20by%20Canvas%20or%20SVG). + * @param {number} [opts.width] Specify width explicitly, in pixel. + * If setting to `null`/`undefined`/`'auto'`, width of `dom` + * (instance container) will be used. + * @param {number} [opts.height] Specify height explicitly, in pixel. + * If setting to `null`/`undefined`/`'auto'`, height of `dom` + * (instance container) will be used. + */ + function init( + dom: HTMLDivElement | HTMLCanvasElement, + theme?: object | string, + opts?: { + devicePixelRatio?: number + renderer?: string + width?: number | string + height?: number | string + } + ): ECharts - const graphic: Graphic; + /** + * Connects interaction of multiple chart series. For example: + * + ```js + // set group id of each instance respectively. + chart1.group = 'group1'; + chart2.group = 'group1'; + echarts.connect('group1'); + // or incoming instance array that need to be linked. + echarts.connect([chart1, chart2]); + ``` + * + * @param group Group id in string, or array of chart instance. + */ + function connect(group: string | ECharts[]): void - interface Graphic { - clipPointsByRect(points: number[][], rect: ERectangle): number[][]; - clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle; - LinearGradient: { new(x: number, y: number, x2: number, y2: number, colorStops: object[], globalCoord?: boolean): LinearGradient } - } + /** + * Disconnects interaction of multiple chart series. To have one single + * instance to be removed, you can set `group` of chart instance to be null. + * + * @param {string} group Group id in string. + */ + function disConnect(group: string): void - function connect(group: string | string[]): void; + /** + * Destroys chart instance, after which the instance cannot be used any + * more. + * + * @param target Chart instance or container. + */ + function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement) + : void - function disConnect(group: string): void; + /** + * Returns chart instance of dom container. + * + * @param target Chart container. + */ + function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement) + : ECharts - function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement): void; + /** + * Registers available maps. This can only be used after including + * [geo](https://echarts.apache.org/option.html#geo) + * component or chart series of + * [map](https://echarts.apache.org/option.html#series-map). + * + * @param {string} mapName Map name, referring to `map` value set in + * [geo](https://echarts.apache.org/option.html#geo) + * component or + * [map](https://echarts.apache.org/option.html#series-map). + * @param {object} geoJson Data in GeoJson format. See + * [http://geojson.org/](http://geojson.org/) for more format information. + * @param {object} [specialAreas] Zoomed part of a specific area in the map + * for better visual effect. + * See [USA Population Estimates example](https://ecomfe.github.io/echarts-examples/public/editor.html?c=map-usa). + */ + function registerMap( + mapName: string, + geoJson: object, + specialAreas?: object + ): void - function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement): ECharts; - - function registerMap(mapName: string, geoJson: object, specialAreas?: object): void; - - function registerTheme(themeName: string, theme: object): void; + /** + * Registers a theme, should be specified when + * [initialize the chart instance](https://echarts.apache.org/api.html#echarts.init). + * + * @param {string} themeName Theme name. + * @param {object} theme Theme configurations. + */ + function registerTheme(themeName: string, theme: object): void interface MapObj { - /** geoJson data for map */ + /** + * geoJson data for map + */ geoJson: object, - /** special areas fro map */ + /** + * special areas fro map + */ specialAreas: object } - function getMap(mapName: string): MapObj; + /** + * Get a registed map. + * + * @param {string} mapName Map name. + * @return {MapObj} Map data. + */ + function getMap(mapName: string): MapObj - interface LinearGradient { - colorStops: object[]; - global: boolean; - type: string; - x: number - x2: number - y: number - y2: number + /** + * Util methods about graphics. + */ + const graphic: Graphic; + + interface Graphic { + /** + * Clip the given points by the given rectangular. + * + * @param {number[][]} points The points to be clipped, + * like [[23, 44], [12, 15], ...]. + * @param {ERectangle} rect The rectangular that is used to clip points. + */ + clipPointsByRect(points: number[][], rect: ERectangle): number[][]; + + /** + * Clip the first input rectangular by the second input rectangular. + * + * @param {ERectangle} targetRect The rectangular to be clipped. + * @param {ERectangle} rect The rectangular that is used to clip + * targetRect. + */ + clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle; } interface ECharts { + /** + * Group name to be used in chart connection + */ group: string - setOption(option: EChartOption, notMerge?: boolean, notRefreshImmediately?: boolean): void + /** + * Configuration item, data, universal interface, all parameters and + * data can all be modified through `setOption`. ECharts will merge + * new parameters and data, and then refresh chart. + * + * @param {EChartOption} option Configuration item and data. Please + * refer to [configuration item manual](https://echarts.apache.org/option.html) + * for more information. + * @param {boolean} [notMerge=false] Whether not to merge with previous + * `option` + * @param {boolean} [lazyUpdate=false] Whether not to update chart + * immediately + */ + setOption( + option: EChartOption, + notMerge?: boolean, + lazyUpdate?: boolean + ) : void + /** + * Configuration item, data, universal interface, all parameters and + * data can all be modified through `setOption`. ECharts will merge + * new parameters and data, and then refresh chart. + * + * @param {EChartOption} option Configuration item and data. Please + * refer to [configuration item manual](https://echarts.apache.org/option.html) + * for more information. + * @param {EChartsOptionConfig} [opts] Options about how to setOption + */ + setOption(option: EChartOption, opts?: EChartsOptionConfig): void + + /** + * Gets width of ECharts instance container. + * + * @return {number} Width. + */ getWidth(): number + /** + * Gets height of ECharts instance container. + * + * @return {number} Height. + */ getHeight(): number + /** + * Gets DOM element of ECharts instance container. + * + * @return {HTMLCanvasElement|HTMLDivElement} DOM container. + */ getDom(): HTMLCanvasElement | HTMLDivElement - getOption(): object + /** + * Gets `option` object maintained in current instance, which contains + * configuration item and data merged from previous `setOption` + * operations by users, along with user interaction states. + * For example, switching of legend, zooming area of data zoom, + * and so on. Therefore, a new instance that is exactly the same + * can be recovered from this option. + */ + getOption(): EChartOption - resize(): void + /** + * Resizes chart, which should be called manually when container size + * changes. When `opts` is not provided, DOM size is used. + * + * @param {EChartsResizeOption} opts Specify parameters explicitly. + */ + resize(opts?: EChartsResizeOption): void + /** + * Triggers chart action, like chart switch `legendToggleSelect`, + * zoom data area `dataZoom`, show tooltip `showTip` and so on. + * See [action](https://echarts.apache.org/api.html#action) and + * [events](https://echarts.apache.org/api.html#events) + * for more information. + * + * @param payload Trigger multiple actions through `batch` attribute. + */ dispatchAction(payload: object): void + /** + * Binds event-handling function. + * There are two kinds of events in ECharts, one of which is mouse + * events, which will be triggered when the mouse clicks certain + * element in the chart, the other kind will be triggered after + * `dispatchAction` is called. Every action has a corresponding + * event. + * If event is triggered externally by `dispatchAction`, and there + * is batch attribute in action to trigger batch action, then the + * corresponding response event parameters be in batch. + * + * @param {string} eventName Event names are all in lower-cases, + * for example, `'click'`, `'mousemove'`, `'legendselected'` + * @param {Function} handler Event-handling function, whose format + * is as following: + ```js + (event: object) + ``` + * @param {object} [context] context of callback function, what + * `this` refers to. + */ on(eventName: string, handler: Function, context?: object): void + /** + * Unbind event-handler function. + * + * @param {string} eventName Event names are all in lower-cases, + * for example, `'click'`, `'mousemove'`, `'legendselected'` + * @param {Function} [handler] The function to be unbound could be + * passed. Otherwise, all event functions of this type will be + * unbound. + */ off(eventName: string, handler?: Function): void - showLoading(type?: string, opts?: object): void + /** + * Convert a point from logical coordinate (e.g., in geo, cartesian, + * graph, ...) to pixel coordinate. + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be converted. + */ + convertToPixel(finder: EChartsConvertFinder, value: string | any[]) + : string | any[] + /** + * Convert a point from pixel coordinate to logical coordinate + * (e.g., in geo, cartesian, graph, ...). + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be converted. + */ + convertFromPixel(finder: EChartsConvertFinder, value: any[] | string) + : any[] | string + + /** + * Determine whether the given point is in the given coordinate systems or series. + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be judged, in pixel + * coordinate system. + */ + containPixel(finder: EChartsConvertFinder, value: any[]): boolean + + /** + * Shows loading animation. You can call this interface manually before + * data is loaded, and call `hideLoading` to hide loading animation + * after data is loaded. + * + * @param {string} [type='default'] + * @param {EChartsLoadingOption} [opts] + */ + showLoading(type?: string, opts?: EChartsLoadingOption): void + + /** + * Hides animation loading effect. + */ hideLoading(): void + /** + * Exports chart image; returns a base64 URL; can be set to `src` of + * `Image`. + * + * @param opts Options. + */ getDataURL(opts: { - /** 导出的格式,可选 png, jpeg */ + // Exporting format, can be either png, or jpeg type?: string, - /** 导出的图片分辨率比例,默认为 1。*/ + // Resolution ratio of exporting image, 1 by default. pixelRatio?: number, - /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ - backgroundColor?: string + // Background color of exporting image, use backgroundColor in + // option by default. + backgroundColor?: string, + // Excluded components list. e.g. ['toolbox'] + excludeComponents?: string[] }): string + /** + * Exports connected chart image; returns a base64 url; can be set to + * `src` of `Image`. Position of charts in exported image are + * related to that of the container. + * + * @param opts Options. + */ getConnectedDataURL(opts: { - /** 导出的格式,可选 png, jpeg */ + // Exporting format, can be either png, or jpeg type: string, - /** 导出的图片分辨率比例,默认为 1。 */ + // Resolution ratio of exporting image, 1 by default. pixelRatio: number, - /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ - backgroundColor: string + // Background color of exporting image, use backgroundColor in + // option by default. + backgroundColor: string, + // Excluded components list. e.g. ['toolbox'] + excludeComponents?: string[] }): string + /** + * The method is used in rendering millions of data + * (e.g. rendering geo data). In these scenario, the entire size of + * data is probably up to 10 or 100 MB, even using binary format. + * So chunked load data and rendering is required. When using + * `appendData`, the graphic elements that have been rendered will + * not be cleared, but keep rendering new graphic elements. + * + * @param opts Data options. + */ + appendData(opts: { + // Specify which series the data will be appended to. + seriesIndex?: string, + // The data to be appended. + data?: any[]|TypedArray, + }): void + + /** + * Clears current instance; removes all components and charts in + * current instance. + */ clear(): void + /** + * Returns whether current instance has been disposed. + * + * @return {boolean} Whether has been disposed. + */ isDisposed(): boolean + /** + * Disposes instance. Once disposed, the instance can not be used again. + */ dispose(): void - - /** 转换逻辑点到像素 */ - convertToPixel(finder: ConvertFinder | string, value: string | any[]): string | any[] - - convertFromPixel(finder: ConvertFinder | string, value: any[] | string): any[] | string - - containPixel(finder: ConvertFinder | string, - /** 要被判断的点,为像素坐标值,以 echarts 实例的 dom 节点的左上角为坐标 [0, 0] 点。*/ - value: any[]): boolean - - getModel(): { - getComponent(finder: string): any; - } } - interface ConvertFinder { + type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array + | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array + | Float64Array; + + interface EChartsConvertFinder { seriesIndex?: number, seriesId?: string, seriesName?: string, @@ -193,6 +485,29 @@ declare namespace echarts { zAxis3D?: object } + interface EChartsOptionConfig { + notMerge?: boolean, + lazyUpdate?: boolean, + silent?: boolean + } + + interface EChartsResizeOption { + /** + * Chart width. + */ + width?: number | string, + + /** + * Chart height. + */ + heiight?: number | string, + + /** + * Specify whether or not to prevent triggering events. + */ + silent?: boolean + } + interface EChartTitleOption { show?: boolean; text?: string; @@ -219,6 +534,38 @@ declare namespace echarts { shadowOffsetX?: number, shadowOffsetY?: number, } + + interface EChartsLoadingOption { + /** + * Loading text. + * @default 'loading' + */ + text?: string, + + /** + * Loading circle color. + * @default '#c23531' + */ + color?: string, + + /** + * Loading text color. + * @default '#000' + */ + textColor?: string, + + /** + * Mask background color. + * @default 'rgba(255, 255, 255, 0.8)' + */ + maskColor?: string, + + /** + * Zlevel of loading. If not 0, it creates a new canvas for loading. + * @default 0 + */ + zlevel?: 0 + } } declare module 'echarts' { From fcaa13327f9d8a828c5ab1a0ed82b3f8dfcb8885 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Tue, 14 Aug 2018 14:22:01 +0800 Subject: [PATCH 063/109] [echarts] add echarts version --- types/echarts/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/echarts/index.d.ts b/types/echarts/index.d.ts index 08e87cab09..bfbd7af809 100644 --- a/types/echarts/index.d.ts +++ b/types/echarts/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for echarts +// Type definitions for echarts 4.1.0 // Project: http://echarts.baidu.com/ // Definitions by: Xie Jingyang // AntiMoron From e2761ccf91a7dc3f9f5bfd065b2b459815561810 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Tue, 14 Aug 2018 09:08:16 +0200 Subject: [PATCH 064/109] Removed typings for unexposed internals Both `playerMap` and `readyMap` are internal weakmaps in Vimeo's player.js and are never exposed, so there is no need to export their types. --- types/vimeo__player/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index 6fac1db7d9..cf7475f246 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -111,6 +111,4 @@ export interface VimeoPromise extends Promise { } /*~ You can declare properties of the module using const, let, or var */ -export const playerMap: WeakMap; -export const readyMap: WeakMap; export default Player; From 4a8f29c946b9e4b9e839ba29a58bf436c337c87f Mon Sep 17 00:00:00 2001 From: Igor Schelkonogov Date: Tue, 14 Aug 2018 17:09:11 +0500 Subject: [PATCH 065/109] Include support for contextual rewrite --- types/webpack-dev-server/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/webpack-dev-server/index.d.ts b/types/webpack-dev-server/index.d.ts index dab8ae5467..435d2547d9 100644 --- a/types/webpack-dev-server/index.d.ts +++ b/types/webpack-dev-server/index.d.ts @@ -14,6 +14,7 @@ import * as express from 'express'; import * as serveStatic from 'serve-static'; import * as https from 'https'; import * as http from 'http'; +import { Url } from "url"; declare namespace WebpackDevServer { interface ListeningApp { @@ -31,9 +32,16 @@ declare namespace WebpackDevServer { type ProxyConfigArray = ProxyConfigArrayItem[]; + interface Context { + match: RegExpMatchArray; + parsedUrl: Url; + } + + type RewriteTo = (context: Context) => string; + interface Rewrite { from: RegExp; - to: string; + to: string | RegExp | RewriteTo; } interface HistoryApiFallbackConfig { From c589c779849c61bfd53e56b49777fcb95f40d418 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Tue, 14 Aug 2018 13:25:00 +0100 Subject: [PATCH 066/109] Remove comment about styled-components --- types/styled-system/styled-system-tests.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index e16b90665d..c0f9ba9ded 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -1,4 +1,3 @@ -// Example uses styled-components, but styled-system works with most other css-in-js libraries as well import * as React from "react"; import { themeGet, From 0d0dec2df11ef2ed026f6785c92becaf602290dc Mon Sep 17 00:00:00 2001 From: Stian Jensen Date: Tue, 14 Aug 2018 15:21:07 +0200 Subject: [PATCH 067/109] Add Moment to react-native-datepicker types --- types/react-native-datepicker/index.d.ts | 3 ++- types/react-native-datepicker/package.json | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 types/react-native-datepicker/package.json diff --git a/types/react-native-datepicker/index.d.ts b/types/react-native-datepicker/index.d.ts index 929acdc375..365fb6ced6 100644 --- a/types/react-native-datepicker/index.d.ts +++ b/types/react-native-datepicker/index.d.ts @@ -6,11 +6,12 @@ import * as React from 'react'; import { ImageURISource } from 'react-native'; +import * as moment from 'moment'; export interface DatePickerProps { mode?: 'date' | 'datetime' | 'time'; androidMode?: 'default' | 'calendar' | 'spinner'; - date?: string | Date; + date?: string | Date | moment.Moment; format?: string; iconSource?: ImageURISource; iconComponent?: JSX.Element; diff --git a/types/react-native-datepicker/package.json b/types/react-native-datepicker/package.json new file mode 100644 index 0000000000..19e5fb0d14 --- /dev/null +++ b/types/react-native-datepicker/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.14.0" + } +} From b7887d9d6614a37ef7f7cbe9815625102ba28c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 14 Aug 2018 14:27:18 +0100 Subject: [PATCH 068/109] [react-navigation] Remove robertohuertasm from authors --- types/react-navigation/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 6e286c2217..46918c6762 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -11,7 +11,6 @@ // Qibang Sun // Sergei Butko: // Veit Lehmann: -// Roberto Huertas: // Steven Miller // Armando Assuncao // Ciaran Liedeman From fe3c19d8bbac3c8e381e2d1e9cab5f7281cba6ce Mon Sep 17 00:00:00 2001 From: Alex Brick Date: Mon, 13 Aug 2018 09:45:12 +0200 Subject: [PATCH 069/109] [superagent-bunyan] Adding types for superagent-bunyan --- types/superagent-bunyan/index.d.ts | 12 ++++++++++ .../superagent-bunyan-tests.ts | 16 +++++++++++++ types/superagent-bunyan/tsconfig.json | 23 +++++++++++++++++++ types/superagent-bunyan/tslint.json | 1 + 4 files changed, 52 insertions(+) create mode 100644 types/superagent-bunyan/index.d.ts create mode 100644 types/superagent-bunyan/superagent-bunyan-tests.ts create mode 100644 types/superagent-bunyan/tsconfig.json create mode 100644 types/superagent-bunyan/tslint.json diff --git a/types/superagent-bunyan/index.d.ts b/types/superagent-bunyan/index.d.ts new file mode 100644 index 0000000000..1dfec979e4 --- /dev/null +++ b/types/superagent-bunyan/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for superagent-bunyan 5.2 +// Project: https://github.com/joaquimserafim/superagent-bunyan#readme +// Definitions by: Alex Brick +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as Logger from 'bunyan'; +import { Plugin } from 'superagent'; + +declare function superagentLogger(logger: Logger, requestId?: string, extra?: object): Plugin; + +export = superagentLogger; diff --git a/types/superagent-bunyan/superagent-bunyan-tests.ts b/types/superagent-bunyan/superagent-bunyan-tests.ts new file mode 100644 index 0000000000..3a6f973e91 --- /dev/null +++ b/types/superagent-bunyan/superagent-bunyan-tests.ts @@ -0,0 +1,16 @@ +import * as request from 'superagent'; +import * as bunyan from 'bunyan'; + +import superagentLogger = require('superagent-bunyan'); + +const logger = bunyan.createLogger({name: 'my_log'}); + +logger.info('Hey!'); + +request + .get('http://localhost:3000') + .use(superagentLogger(logger)) + .use(superagentLogger(logger, 'requestId')) + .use(superagentLogger(logger, 'requestId', { foo: 'bar' })) + .use(superagentLogger(logger, undefined, { foo: 'bar' })) + .end((err, res) => {}); diff --git a/types/superagent-bunyan/tsconfig.json b/types/superagent-bunyan/tsconfig.json new file mode 100644 index 0000000000..0118838dcd --- /dev/null +++ b/types/superagent-bunyan/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", + "superagent-bunyan-tests.ts" + ] +} diff --git a/types/superagent-bunyan/tslint.json b/types/superagent-bunyan/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/superagent-bunyan/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a54ae6fc5f4bc08ab4228dbe3d97ba87454b784c Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Tue, 14 Aug 2018 23:49:28 +0900 Subject: [PATCH 070/109] react-native-vector-icons: fontawesome5, 5pro --- .../FontAwesome5.d.ts | 43 +++++++++++++++++++ .../FontAwesome5Pro.d.ts | 6 +++ 2 files changed, 49 insertions(+) create mode 100644 types/react-native-vector-icons/FontAwesome5.d.ts create mode 100644 types/react-native-vector-icons/FontAwesome5Pro.d.ts diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts new file mode 100644 index 0000000000..7d40fe2c5d --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -0,0 +1,43 @@ +import { Component } from "../../../../../Library/Caches/typescript/2.9/node_modules/@types/react"; +import { Icon, IconProps, ImageSource } from "./Icon"; + +export const FA5Style: { + regular: 0; + light: 1; + solid: 2; + brand: 3; +}; + +type ValueOf = T[keyof T]; + +// borrowed from +// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html +type Omit = Pick>; + +export type FontAwesome5IconVariants = keyof Omit; + +// borrowed from https://stackoverflow.com/a/49725198/1105281 +type RequireOnlyOne = Omit & + { + [K in Keys]-?: Required> & + Partial, undefined>> + }[Keys]; + +export type FontAwesome5IconProps = RequireOnlyOne< + { [K in FontAwesome5IconVariants]?: boolean } & IconProps, + FontAwesome5IconVariants +>; + +export default class FontAwesome5Icon extends Component< + FontAwesome5IconProps, + any +> { + static getImageSource( + name: string, + size?: number, + color?: string, + fa5Style?: ValueOf + ): Promise; + static loadFont(file?: string): Promise; + static hasIcon(name: string): boolean; +} diff --git a/types/react-native-vector-icons/FontAwesome5Pro.d.ts b/types/react-native-vector-icons/FontAwesome5Pro.d.ts new file mode 100644 index 0000000000..f8233abce5 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5Pro.d.ts @@ -0,0 +1,6 @@ +import { Component } from "react"; +import FontAwesome5Icon, { FontAwesome5IconProps } from "./FontAwesome5"; + +export type FontAwesome5ProIconProps = FontAwesome5IconProps; +export { FA5Style } from "./FontAwesome5"; +export default FontAwesome5Icon; From 18f5c760696dbe4a3c13c9dc518210b0695275b0 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Tue, 14 Aug 2018 23:50:41 +0900 Subject: [PATCH 071/109] react-native-vector-icons: fontawesome5 test --- .../react-native-vector-icons-tests.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 51cb1eee81..e0dcaeb9b6 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -3,6 +3,8 @@ import { View, Text, TabBarIOS } from 'react-native'; import { createIconSet } from 'react-native-vector-icons'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; +import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5'; +import FontAwesome5ProIcon from 'react-native-vector-icons/FontAwesome5Pro'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { @@ -27,6 +29,8 @@ class Example extends React.Component { {/* Normal Icon */} + + {/* Icon button */} Date: Wed, 15 Aug 2018 00:02:12 +0900 Subject: [PATCH 072/109] react-native-vector-icons: allow omitting variant --- types/react-native-vector-icons/FontAwesome5.d.ts | 8 ++++---- .../react-native-vector-icons-tests.tsx | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts index 7d40fe2c5d..18df444e79 100644 --- a/types/react-native-vector-icons/FontAwesome5.d.ts +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -16,14 +16,14 @@ type Omit = Pick>; export type FontAwesome5IconVariants = keyof Omit; -// borrowed from https://stackoverflow.com/a/49725198/1105281 -type RequireOnlyOne = Omit & +// modified from https://stackoverflow.com/a/49725198/1105281 +type AllowOnlyOne = Omit & { - [K in Keys]-?: Required> & + [K in Keys]-?: Partial> & Partial, undefined>> }[Keys]; -export type FontAwesome5IconProps = RequireOnlyOne< +export type FontAwesome5IconProps = AllowOnlyOne< { [K in FontAwesome5IconVariants]?: boolean } & IconProps, FontAwesome5IconVariants >; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index e0dcaeb9b6..18b03edcaa 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -29,6 +29,7 @@ class Example extends React.Component { {/* Normal Icon */} + From dd09c5bced412294d13432e4b736717fc38bdc45 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Wed, 15 Aug 2018 00:03:39 +0900 Subject: [PATCH 073/109] fix messed up react import --- types/react-native-vector-icons/FontAwesome5.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts index 18df444e79..44fca921cc 100644 --- a/types/react-native-vector-icons/FontAwesome5.d.ts +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -1,4 +1,4 @@ -import { Component } from "../../../../../Library/Caches/typescript/2.9/node_modules/@types/react"; +import { Component } from "react"; import { Icon, IconProps, ImageSource } from "./Icon"; export const FA5Style: { From 300ac3256322cc0280c6d3abfe129440f8d39c62 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Wed, 15 Aug 2018 00:05:41 +0900 Subject: [PATCH 074/109] react-native-vector-icons: FA5 definitions > tsconfig --- types/react-native-vector-icons/tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/react-native-vector-icons/tsconfig.json b/types/react-native-vector-icons/tsconfig.json index f66f39ed95..993aae3195 100644 --- a/types/react-native-vector-icons/tsconfig.json +++ b/types/react-native-vector-icons/tsconfig.json @@ -25,6 +25,8 @@ "EvilIcons.d.ts", "Feather.d.ts", "FontAwesome.d.ts", + "FontAwesome5.d.ts", + "FontAwesome5Pro.d.ts", "Foundation.d.ts", "Ionicons.d.ts", "MaterialCommunityIcons.d.ts", From bd0f04155cfc0b8e70bb01a415be4f7a9cd19313 Mon Sep 17 00:00:00 2001 From: ikokostya Date: Tue, 14 Aug 2018 18:08:48 +0300 Subject: [PATCH 075/109] [node] Add dns.Resolver declaration (#28102) * [node] Add dns.Resolver declaration * Add test cases * Improve test cases --- types/node/index.d.ts | 20 ++++++++++++++++++++ types/node/node-tests.ts | 8 ++++++++ types/node/v8/index.d.ts | 20 ++++++++++++++++++++ types/node/v8/node-tests.ts | 8 ++++++++ types/node/v9/index.d.ts | 20 ++++++++++++++++++++ types/node/v9/node-tests.ts | 8 ++++++++ 6 files changed, 84 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 7745372a21..b702085203 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2770,6 +2770,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2796,6 +2797,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index ce46e31654..46154ce254 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3388,6 +3388,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index d8a1cb431c..dc44245c59 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -2646,6 +2646,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2672,6 +2673,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/v8/node-tests.ts b/types/node/v8/node-tests.ts index 9cec14a88e..d89e6faacc 100644 --- a/types/node/v8/node-tests.ts +++ b/types/node/v8/node-tests.ts @@ -3127,6 +3127,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 8150a68294..fd89e18e16 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -2728,6 +2728,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2754,6 +2755,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/v9/node-tests.ts b/types/node/v9/node-tests.ts index 3d7861f532..ace737fa3b 100644 --- a/types/node/v9/node-tests.ts +++ b/types/node/v9/node-tests.ts @@ -3160,6 +3160,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** From ecba929771c1743300f30be1e7e21ef5eb25ddc9 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Tue, 14 Aug 2018 17:47:27 +0200 Subject: [PATCH 076/109] Fixed definitions for react-native/BatchedBridge. BatchedBridge (and MessageQueue) must be imported like this: import BatchedBridge from "react-native/Libraries/BatchedBridge/BatchedBridge"; So we must use default export. --- types/react-native/BatchedBridge.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native/BatchedBridge.d.ts b/types/react-native/BatchedBridge.d.ts index dd63f73087..0f1b02a0f4 100644 --- a/types/react-native/BatchedBridge.d.ts +++ b/types/react-native/BatchedBridge.d.ts @@ -15,9 +15,9 @@ declare class MessageQueue { declare module "react-native/Libraries/BatchedBridge/BatchedBridge" { const BatchedBridge: MessageQueue; - export = BatchedBridge; + export default BatchedBridge; } declare module "react-native/Libraries/BatchedBridge/MessageQueue" { - export = MessageQueue; + export default MessageQueue; } From a0466280f37ee00cf532610f94a13d1220b25fd5 Mon Sep 17 00:00:00 2001 From: Sefa Ilkimen Date: Tue, 14 Aug 2018 17:47:29 +0200 Subject: [PATCH 077/109] [express-fileupload]: add promised `.mv()` signature `.mv()` returns a Promise when callback argument is not provided --- types/express-fileupload/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/express-fileupload/index.d.ts b/types/express-fileupload/index.d.ts index 89331c066a..752581d612 100644 --- a/types/express-fileupload/index.d.ts +++ b/types/express-fileupload/index.d.ts @@ -29,6 +29,7 @@ declare namespace fileUpload { mimetype: string; data: Buffer; mv(path: string, callback: (err: any) => void): void; + mv(path: string): Promise; } interface Options { From 67c528c7e37440e77a71a984c7e36f05b9888c50 Mon Sep 17 00:00:00 2001 From: Sefa Ilkimen Date: Tue, 14 Aug 2018 18:10:55 +0200 Subject: [PATCH 078/109] [express-fileupload]: add missing options and properties add missing `abortOnLimit` option and `truncated` property --- types/express-fileupload/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/express-fileupload/index.d.ts b/types/express-fileupload/index.d.ts index 752581d612..060476b109 100644 --- a/types/express-fileupload/index.d.ts +++ b/types/express-fileupload/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for express-fileupload 0.1 +// Type definitions for express-fileupload 0.4 // Project: https://github.com/richardgirges/express-fileupload#readme // Definitions by: Gintautas Miselis +// Sefa Ilkimen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -28,6 +29,7 @@ declare namespace fileUpload { encoding: string; mimetype: string; data: Buffer; + truncated: boolean; mv(path: string, callback: (err: any) => void): void; mv(path: string): Promise; } @@ -36,6 +38,7 @@ declare namespace fileUpload { debug?: boolean; safeFileNames?: boolean; preserveExtension?: boolean | string | number; + abortOnLimit?: boolean; [property: string]: any; } } From be37428451f1ee300efcdde260c7064391211566 Mon Sep 17 00:00:00 2001 From: Colin Bradley Date: Tue, 14 Aug 2018 18:53:54 +0100 Subject: [PATCH 079/109] dd-trace - compatability with opentracing --- types/dd-trace/package.json | 6 ++ types/dd-trace/src/opentracing/reference.d.ts | 29 ------- types/dd-trace/src/opentracing/span.d.ts | 5 +- .../src/opentracing/span_context.d.ts | 6 +- .../src/opentracing/span_options.d.ts | 37 -------- types/dd-trace/src/opentracing/tracer.d.ts | 86 +------------------ 6 files changed, 16 insertions(+), 153 deletions(-) create mode 100644 types/dd-trace/package.json delete mode 100644 types/dd-trace/src/opentracing/reference.d.ts delete mode 100644 types/dd-trace/src/opentracing/span_options.d.ts diff --git a/types/dd-trace/package.json b/types/dd-trace/package.json new file mode 100644 index 0000000000..90deb3c97b --- /dev/null +++ b/types/dd-trace/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "opentracing": ">=0.14.1" + } +} diff --git a/types/dd-trace/src/opentracing/reference.d.ts b/types/dd-trace/src/opentracing/reference.d.ts deleted file mode 100644 index 57def49166..0000000000 --- a/types/dd-trace/src/opentracing/reference.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Span = require('./span'); -import SpanContext = require('./span_context'); - -declare class Reference { - /** - * @return The Reference type (e.g., REFERENCE_CHILD_OF or - * REFERENCE_FOLLOWS_FROM). - */ - type(): string; - - /** - * @return The SpanContext being referred to (e.g., the - * parent in a REFERENCE_CHILD_OF Reference). - */ - referencedContext(): SpanContext; - - /** - * Initialize a new Reference instance. - * - * @param type - the Reference type constant (e.g., - * REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM). - * @param referencedContext - the SpanContext being referred - * to. As a convenience, a Span instance may be passed in instead - * (in which case its .context() is used here). - */ - constructor(type: string, referencedContext: SpanContext | Span); -} - -export = Reference; \ No newline at end of file diff --git a/types/dd-trace/src/opentracing/span.d.ts b/types/dd-trace/src/opentracing/span.d.ts index e61a611efd..cf9286210b 100644 --- a/types/dd-trace/src/opentracing/span.d.ts +++ b/types/dd-trace/src/opentracing/span.d.ts @@ -1,7 +1,8 @@ import Tracer = require('./tracer'); import SpanContext = require('./span_context'); +import { Span } from 'opentracing'; -declare class Span { +declare class DatadogSpan extends Span { /** * Returns the SpanContext object associated with this Span. */ @@ -117,4 +118,4 @@ declare class Span { finish(finishTime?: number): void; } -export = Span; +export = DatadogSpan; diff --git a/types/dd-trace/src/opentracing/span_context.d.ts b/types/dd-trace/src/opentracing/span_context.d.ts index 4e3b532649..cf9565d5a5 100644 --- a/types/dd-trace/src/opentracing/span_context.d.ts +++ b/types/dd-trace/src/opentracing/span_context.d.ts @@ -1,3 +1,5 @@ +import { SpanContext } from 'opentracing'; + /** * SpanContext represents Span state that must propagate to descendant Spans * and across process boundaries. @@ -8,7 +10,7 @@ * identify or otherwise contextualize the associated Span instance (e.g., a * tuple). */ -declare class SpanContext { +declare class DatadogSpanContext extends SpanContext { /** * Use to create references to parent spans. */ @@ -35,4 +37,4 @@ interface SpanContextLike { spanId: number; } -export = SpanContext; +export = DatadogSpanContext; diff --git a/types/dd-trace/src/opentracing/span_options.d.ts b/types/dd-trace/src/opentracing/span_options.d.ts deleted file mode 100644 index 054d9024d1..0000000000 --- a/types/dd-trace/src/opentracing/span_options.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Span = require('./span'); -import Reference = require('./reference'); -import SpanContext = require('./span_context'); - -interface SpanOptions { - /** - * a parent SpanContext (or Span, for convenience) that the newly-started - * span will be the child of (per REFERENCE_CHILD_OF). If specified, - * `references` must be unspecified. - */ - childOf?: Span | SpanContext; - - /** - * an array of Reference instances, each pointing to a causal parent - * SpanContext. If specified, `fields.childOf` must be unspecified. - */ - references?: Reference[]; - - /** - * set of key-value pairs which will be set as tags on the newly created - * Span. Ownership of the object is passed to the created span for - * efficiency reasons (the caller should not modify this object after - * calling startSpan). - */ - tags?: { - [key: string]: any; - }; - - /** - * a manually specified start time for the created Span object. The time - * should be specified in milliseconds as Unix timestamp. Decimal value are - * supported to represent time values with sub-millisecond accuracy. - */ - startTime?: number; -} - -export = SpanOptions; diff --git a/types/dd-trace/src/opentracing/tracer.d.ts b/types/dd-trace/src/opentracing/tracer.d.ts index a40559dbcd..252a0d558c 100644 --- a/types/dd-trace/src/opentracing/tracer.d.ts +++ b/types/dd-trace/src/opentracing/tracer.d.ts @@ -1,91 +1,11 @@ -import SpanOptions = require('./span_options'); -import Span = require('./span'); -import SpanContext = require('./span_context'); +import { Tracer } from 'opentracing'; /** * Tracer is the entry-point between the instrumentation API and the tracing * implementation. */ -declare class Tracer { - /** - * Starts and returns a new Span representing a logical unit of work. - * - * For example: - * - * // Start a new (parentless) root Span: - * var parent = Tracer.startSpan('DoWork'); - * - * // Start a new (child) Span: - * var child = Tracer.startSpan('load-from-db', { - * childOf: parent.context(), - * }); - * - * // Start a new async (FollowsFrom) Span: - * var child = Tracer.startSpan('async-cache-write', { - * references: [ - * opentracing.followsFrom(parent.context()) - * ], - * }); - * - * @param name - the name of the operation (REQUIRED). - * @param options - options for the newly created span. - * @return A new Span object. - */ - startSpan(name: string, options?: SpanOptions): Span; +declare class DatadogTracer extends Tracer { - /** - * Injects the given SpanContext instance for cross-process propagation - * within `carrier`. The expected type of `carrier` depends on the value of - * `format. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * var clientSpan = ...; - * ... - * // Inject clientSpan into a text carrier. - * var headersCarrier = {}; - * Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * // Incorporate the textCarrier into the outbound HTTP request header - * // map. - * Object.assign(outboundHTTPReq.headers, headersCarrier); - * // ... send the httpReq - * - * @param spanContext - the SpanContext to inject into the - * carrier object. As a convenience, a Span instance may be passed - * in instead (in which case its .context() is used for the - * inject()). - * @param format - the format of the carrier. - * @param carrier - see the documentation for the chosen `format` - * for a description of the carrier object. - */ - inject(spanContext: SpanContext | Span, format: string, carrier: any): void; - - /** - * Returns a SpanContext instance extracted from `carrier` in the given - * `format`. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * // Use the inbound HTTP request's headers as a text map carrier. - * var headersCarrier = inboundHTTPReq.headers; - * var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * var serverSpan = Tracer.startSpan('...', { childOf : wireCtx }); - * - * @param format - the format of the carrier. - * @param carrier - the type of the carrier object is determined by - * the format. - * @return The extracted SpanContext, or null if no such SpanContext could - * be found in `carrier` - */ - extract(format: string, carrier: any): SpanContext | null; } -export = Tracer; +export = DatadogTracer; From 887a2752a3622d147f501ab7f2689fa47969263a Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen Date: Tue, 14 Aug 2018 22:26:18 +0300 Subject: [PATCH 080/109] Add typings for universal-cookie --- types/universal-cookie/index.d.ts | 102 ++++++++++++++++++ types/universal-cookie/tsconfig.json | 16 +++ types/universal-cookie/tslint.json | 1 + .../universal-cookie-tests.ts | 20 ++++ 4 files changed, 139 insertions(+) create mode 100644 types/universal-cookie/index.d.ts create mode 100644 types/universal-cookie/tsconfig.json create mode 100644 types/universal-cookie/tslint.json create mode 100644 types/universal-cookie/universal-cookie-tests.ts diff --git a/types/universal-cookie/index.d.ts b/types/universal-cookie/index.d.ts new file mode 100644 index 0000000000..4bba4adee6 --- /dev/null +++ b/types/universal-cookie/index.d.ts @@ -0,0 +1,102 @@ +// Type definitions for universal-cookie 2.2 +// Project: https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie#readme +// Definitions by: Tomi Turtiainen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export interface CookiesByName { + [cookieName: string]: string; +} + +export interface GetOpts { + /** + * do not convert the cookie into an object no matter what + */ + doNotParse: boolean; +} + +export interface CookieOpts { + /** + * cookie path, use / as the path if you want your cookie to be accessible on all pages + */ + path?: string; + + /** + * absolute expiration date for the cookie + */ + expires?: Date; + + /** + * relative max age of the cookie from when the client receives it in second + */ + maxAge?: number; + + /** + * domain for the cookie (sub.domain.com or .allsubdomains.com) + */ + domain?: string; + + /** + * Is only accessible through HTTPS? + */ + secure?: boolean; + + /** + * Is only the server can access the cookie? + */ + httpOnly?: boolean; +} + +export type ChangeListenerCallback = ( + name: string, + value: string | object, + options: CookieOpts +) => void; + +export default class Cookies { + constructor(cookieHeader?: string | CookiesByName); + + /** + * Get a cookie value + * + * @param name cookie name + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + get(name: string, options?: GetOpts): string; + + /** + * Get all cookies + * + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + getAll(options?: GetOpts): CookiesByName; + + /** + * Set a cookie value + * + * @param name cookie name + * @param value save the value and stringify the object if needed + * @param options Support all the cookie options from RFC 6265 + */ + set(name: string, value: string | object, options?: CookieOpts): void; + + /** + * Set a cookie value + * + * @param name cookie name + * @param options Support all the cookie options from RFC 6265 + */ + remove(name: string, options?: CookieOpts): void; + + /** + * Add a listener to when a cookie is set or removed. + * + * @param callback Call that will be called with the first argument containing name, value and options of the changed cookie. + */ + addChangeListener(callback: ChangeListenerCallback): void; + + /** + * Remove a listener from the change callback. + */ + removeChangeListener(callback: ChangeListenerCallback): void; +} diff --git a/types/universal-cookie/tsconfig.json b/types/universal-cookie/tsconfig.json new file mode 100644 index 0000000000..1c324ed8c6 --- /dev/null +++ b/types/universal-cookie/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "universal-cookie-tests.ts"] +} diff --git a/types/universal-cookie/tslint.json b/types/universal-cookie/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/universal-cookie/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/universal-cookie/universal-cookie-tests.ts b/types/universal-cookie/universal-cookie-tests.ts new file mode 100644 index 0000000000..9591fa3c5b --- /dev/null +++ b/types/universal-cookie/universal-cookie-tests.ts @@ -0,0 +1,20 @@ +import Cookies from "universal-cookie"; + +const cookies = new Cookies(); +new Cookies("My=Cookie"); +new Cookies({}); + +cookies.set("my", "cookie"); +cookies.set("object", { some: "value" }); +cookies.set("with", "options", { + path: "/" +}); + +cookies.get("my"); +cookies.getAll(); + +cookies.remove("object"); +cookies.remove("object", { path: "/" }); + +cookies.addChangeListener((name, value) => {}); +cookies.removeChangeListener((name, value) => {}); From ae7488c42654616e3d7997866d058f09aa6dc899 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Tue, 14 Aug 2018 17:13:06 -0700 Subject: [PATCH 081/109] Remove codeowner; add back lint rule; fix types --- .github/CODEOWNERS | 1 - types/shallow-equals/index.d.ts | 4 +--- types/shallow-equals/tsconfig.json | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d15d79bc9d..8c7f823a07 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3968,7 +3968,6 @@ /types/set-value/ @DanielRosenwasser /types/settings/ @shreyjain1994 /types/sha1/ @arcdev1 -/types/shallow-equals/ @rsolomon /types/shallowequal/ @seansfkelley /types/shapefile/ @DenisCarriere /types/sharedworker/ @nakakura diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 69e1a6c552..7d91b03923 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -8,7 +8,5 @@ export = shallow_equals; declare function shallow_equals( a?: A, b?: B, - compare?: (objA?: A, objB?: B) => boolean, + compare?: (objA: A, objB: B) => boolean, ): boolean; - -declare namespace shallow_equals {} diff --git a/types/shallow-equals/tsconfig.json b/types/shallow-equals/tsconfig.json index 74f59acd72..83137182f4 100644 --- a/types/shallow-equals/tsconfig.json +++ b/types/shallow-equals/tsconfig.json @@ -4,7 +4,7 @@ "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": ["../"], From 39ad4eadfcdd6dddf07744a688064ff727824f3f Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Wed, 15 Aug 2018 11:56:08 +0900 Subject: [PATCH 082/109] guess it wants me to export everything --- types/react-native-vector-icons/FontAwesome5.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts index 44fca921cc..79c77ff0e2 100644 --- a/types/react-native-vector-icons/FontAwesome5.d.ts +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -8,16 +8,16 @@ export const FA5Style: { brand: 3; }; -type ValueOf = T[keyof T]; +export type ValueOf = T[keyof T]; // borrowed from // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html -type Omit = Pick>; +export type Omit = Pick>; export type FontAwesome5IconVariants = keyof Omit; // modified from https://stackoverflow.com/a/49725198/1105281 -type AllowOnlyOne = Omit & +export type AllowOnlyOne = Omit & { [K in Keys]-?: Partial> & Partial, undefined>> From a2fe5554f7700458284d4a53bcf4b0be6b253659 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Tue, 14 Aug 2018 23:21:10 -0400 Subject: [PATCH 083/109] [react-native] Add hardwareAccelerated to Modal --- types/react-native/index.d.ts | 45 ++++++++++++++++++------------- types/react-native/test/index.tsx | 5 ++++ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 5a49af5685..184fc39724 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -4754,7 +4754,7 @@ declare class MaskedViewComponent extends React.Component {} declare const MaskedViewBase: Constructor & typeof MaskedViewComponent; export class MaskedViewIOS extends MaskedViewBase {} -export interface ModalProps { +export interface ModalBaseProps { // Only `animated` is documented. The JS code says `animated` is // deprecated and `animationType` is preferred. animated?: boolean; @@ -4784,35 +4784,42 @@ export interface ModalProps { * The `onShow` prop allows passing a function that will be called once the modal has been shown. */ onShow?: (event: NativeSyntheticEvent) => void; +} + +export interface ModalPropsIOS { + /** + * The `presentationStyle` determines the style of modal to show + */ + presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; + /** * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field. - * @platform ios */ - supportedOrientations?: ( - | "portrait" - | "portrait-upside-down" - | "landscape" - | "landscape-left" - | "landscape-right")[]; + supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">; + + /** + * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. + */ + onDismiss?: () => void; + /** * The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed. * The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation. - * @platform ios */ onOrientationChange?: (event?: NativeSyntheticEvent) => void; - /** - * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. - * @platform ios - */ - onDismiss?: () => void; - /** - * The `presentationStyle` determines the style of modal to show - * @platform ios - */ - presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; } +export interface ModalPropsAndroid { + /** + * Controls whether to force hardware acceleration for the underlying window. + */ + hardwareAccelerated?: boolean; +} + + +export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid; + export class Modal extends React.Component {} /** diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 0399d41321..60c4d89302 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -71,6 +71,7 @@ import { TextInputSubmitEditingEventData, WebView, KeyboardAvoidingView, + Modal, } from "react-native"; declare module "react-native" { @@ -754,3 +755,7 @@ const AlertIOSTest = () => { 'email-address' ); } + +const ModalTest = () => ( + +) From 78d9f40cf499277c1da6606c39622695c886be54 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 18:25:56 +0800 Subject: [PATCH 084/109] EntryFunc may return Entry --- types/webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index a228afc242..664439523b 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -117,7 +117,7 @@ declare namespace webpack { [name: string]: string | string[]; } - type EntryFunc = () => (string | string[] | Promise); + type EntryFunc = () => (string | string[] | Entry | Promise); interface DevtoolModuleFilenameTemplateInfo { identifier: string; From 9bd8c2e8840c7fb9a35718f26e57ec7e967f8ec7 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 18:30:19 +0800 Subject: [PATCH 085/109] Add test cases --- types/webpack/webpack-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 2f75d11b31..d8a36fd6db 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -55,6 +55,14 @@ configuration = { entry: () => ['./demo', './demo2'] }; +configuration = { + entry: () => { + p1: "./page1", + p2: "./page2", + p3: "./page3" + } +}; + configuration = { entry: () => new Promise((resolve) => resolve('./demo')) }; @@ -63,6 +71,14 @@ configuration = { entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) }; +configuration = { + entry: () => new Promise((resolve) => resolve({ + p1: "./page1", + p2: "./page2", + p3: "./page3" + })) +}; + // // https://webpack.github.io/docs/optimization.html // From 73095f3f18378bd49c311652cbc7af7d889fddba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dra=C5=BEen=20Ten=C5=BEera?= Date: Wed, 15 Aug 2018 14:16:09 +0200 Subject: [PATCH 086/109] [yup] Add ValidationError as a valid return type for the test function --- types/yup/index.d.ts | 4 ++-- types/yup/yup-tests.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index b4c8ea797e..2dcf110a9e 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -55,7 +55,7 @@ export interface Schema { oneOf(arrayOfValues: any[], message?: string): this; notOneOf(arrayOfValues: any[], message?: string): this; when(keys: string | any[], builder: WhenOptions): this; - test(name: string, message: string, test: (this: TestContext, value?: any) => boolean | Promise, callbackStyleAsync?: boolean): this; + test(name: string, message: string, test: (this: TestContext, value?: any) => boolean | ValidationError | Promise, callbackStyleAsync?: boolean): this; test(options: TestOptions): this; transform(fn: TransformFunction): this; } @@ -202,7 +202,7 @@ export interface TestOptions { /** * Test function, determines schema validity */ - test: (this: TestContext, value: any) => boolean | Promise; + test: (this: TestContext, value: any) => boolean | ValidationError | Promise; /** * The validation error message diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index 2d5b509b37..c6f367a043 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -141,6 +141,26 @@ mixed.test({ test: testContext }); +// Async ValidationError +const asyncValidationErrorTest = function(this: TestContext): Promise { + return new Promise(resolve => resolve(this.createError({ path: "testPath", message: "testMessage" }))); +}; + +mixed.test('async-validation-error', 'Returns async ValidationError', asyncValidationErrorTest); +mixed.test({ + test: asyncValidationErrorTest, +}); + +// Sync ValidationError +const syncValidationErrorTest = function(this: TestContext): ValidationError { + return this.createError({ path: "testPath", message: "testMessage" }); +}; + +mixed.test('sync-validation-error', 'Returns sync ValidationError', syncValidationErrorTest); +mixed.test({ + test: syncValidationErrorTest, +}); + yup.string().transform(function(this, value: any, originalvalue: any) { return this.isType(value) && value !== null ? value.toUpperCase() : value; }); From 764767d1a4c74ac49527416451debca1f6d9190d Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 15 Aug 2018 09:48:39 -0400 Subject: [PATCH 087/109] [moment-duration-format] Add initialization function. --- types/moment-duration-format/index.d.ts | 4 ++++ types/moment-duration-format/test/module-tests.ts | 4 ++++ types/moment-duration-format/tsconfig.json | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 types/moment-duration-format/test/module-tests.ts diff --git a/types/moment-duration-format/index.d.ts b/types/moment-duration-format/index.d.ts index 1716d55d83..760b7b8263 100644 --- a/types/moment-duration-format/index.d.ts +++ b/types/moment-duration-format/index.d.ts @@ -90,3 +90,7 @@ declare module "moment" { type TemplateFunction = ((this: DurationFormatSettings) => string); } + +declare function momentDurationFormatSetup(_moment: typeof moment): void; + +export = momentDurationFormatSetup; diff --git a/types/moment-duration-format/test/module-tests.ts b/types/moment-duration-format/test/module-tests.ts new file mode 100644 index 0000000000..9178e9c414 --- /dev/null +++ b/types/moment-duration-format/test/module-tests.ts @@ -0,0 +1,4 @@ +import moment = require("moment"); +import momentDurationFormatSetup = require("moment-duration-format"); + +momentDurationFormatSetup(moment); diff --git a/types/moment-duration-format/tsconfig.json b/types/moment-duration-format/tsconfig.json index 997b0f907e..b41c97ed28 100644 --- a/types/moment-duration-format/tsconfig.json +++ b/types/moment-duration-format/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", - "moment-duration-format-tests.ts" + "moment-duration-format-tests.ts", + "test/module-tests.ts" ] } \ No newline at end of file From b5097f8c646d19d3de2b8d7a4981472ee8c10736 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 21:54:36 +0800 Subject: [PATCH 088/109] Fix test case --- types/webpack/webpack-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index d8a36fd6db..16234d422a 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -56,11 +56,11 @@ configuration = { }; configuration = { - entry: () => { + entry: () => ({ p1: "./page1", p2: "./page2", p3: "./page3" - } + }) }; configuration = { From 1cf6df0035f30887fa6ab4333a1b460b3ab4ae94 Mon Sep 17 00:00:00 2001 From: Aaron Ryden Date: Wed, 15 Aug 2018 10:40:01 -0400 Subject: [PATCH 089/109] add asyncStackTraces for latest knex version --- types/knex/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index c1fb224fa0..54dece1068 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -536,6 +536,7 @@ declare namespace Knex { acquireConnectionTimeout?: number; useNullAsDefault?: boolean; searchPath?: string | string[]; + asyncStackTraces?: boolean; } interface ConnectionConfig { From d42a3e4e16e57ff1fe5a18c300f568b6be4eb608 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Wed, 15 Aug 2018 17:25:20 +0200 Subject: [PATCH 090/109] [node] Allow SharedArrayBuffer in Buffer.from (#27933) * Move from namespace to static attributes * Allow SharedArrayBuffer in Buffer.from * Address comments * Add SharedArrayBuffer to byteLength * Fix tests --- types/node/index.d.ts | 14 +++++++++----- types/node/node-tests.ts | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index b702085203..63b06965f6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -26,6 +26,7 @@ // Lishude // Andrew Makarov // Zane Hannan AU +// Thomas den Hollander // Eugene Y. Q. Shen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -172,6 +173,10 @@ interface SymbolConstructor { readonly asyncIterator: symbol; } declare var Symbol: SymbolConstructor; +interface SharedArrayBuffer { + readonly byteLength: number; + slice(begin?: number, end?: number): SharedArrayBuffer; +} // Node.js ESNEXT support interface String { @@ -349,13 +354,13 @@ declare var Buffer: { new(array: Uint8Array): Buffer; /** * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. + * the given {ArrayBuffer}/{SharedArrayBuffer}. * * * @param arrayBuffer The ArrayBuffer with which to share memory. * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. */ - new(arrayBuffer: ArrayBuffer): Buffer; + new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer; /** * Allocates a new buffer containing the given {array} of octets. * @@ -379,8 +384,7 @@ declare var Buffer: { * * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer() */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - // from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; + from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer @@ -418,7 +422,7 @@ declare var Buffer: { * @param string string to test. * @param encoding encoding used to evaluate (defaults to 'utf8') */ - byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number; + byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: string): number; /** * Returns a buffer which is the result of concatenating all the buffers in the list together. * diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 46154ce254..a7fcd4d44a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -446,6 +446,11 @@ function bufferTests() { const arrUint8: Uint8Array = new Uint8Array(2); const buf5: Buffer = Buffer.from(arrUint8); const buf6: Buffer = Buffer.from(buf1); + const sharedArrayBuffer: SharedArrayBuffer = { + byteLength: 10, + slice: (begin?: number, end?: number) => sharedArrayBuffer + }; + const buf7: Buffer = Buffer.from(sharedArrayBuffer); } // Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) From 24973f21e7035ab79b6a11435c2d1b5267069534 Mon Sep 17 00:00:00 2001 From: denisname Date: Wed, 15 Aug 2018 17:48:04 +0200 Subject: [PATCH 091/109] JQuery: HTMLSelectElement and arrays (#27810) * Change to work better with arrays and HTMLSelectElement See pull request description * document.body and document.documentElement are possibly null in TypeScript@next * Select2 fix test * Change according to review comments * Fix JQuery in TS 2.3 * CI failed, force to run again * document.body is not null anymore * Rename params * Add a comment above the `tslint:disable`s * Wrong line :/ I went too fast --- types/jquery/index.d.ts | 18 +++++++++++++++--- types/jquery/jquery-tests.ts | 6 ++++++ types/select2/select2-tests.ts | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 821e7ec162..b03a48dc6f 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -146,12 +146,24 @@ interface JQueryStatic { * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. * - * @param element_elementArray A DOM element to wrap in a jQuery object. - * An array containing a set of DOM elements to wrap in a jQuery object. + * @param element A DOM element to wrap in a jQuery object. * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ - (element_elementArray: T | ArrayLike): JQuery; + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (element: T): JQuery; + /** + * Return a collection of matched elements either found in the DOM based on passed argument(s) or created + * by passing an HTML string. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + * @see \`{@link https://api.jquery.com/jQuery/ }\` + * @since 1.0 + */ + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (elementArray: T[]): JQuery; /** * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 309b1e2f89..417d2e7941 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -69,6 +69,12 @@ function JQueryStatic() { // $ExpectType JQuery $(); + // $ExpectType JQuery + $(new HTMLSelectElement()); + + // $ExpectType JQuery + $([new HTMLSelectElement()]); + // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432 function issue_19597_378218432() { const myDiv = $(document.createElement('div')); diff --git a/types/select2/select2-tests.ts b/types/select2/select2-tests.ts index b3ce0d5896..a351dcc178 100644 --- a/types/select2/select2-tests.ts +++ b/types/select2/select2-tests.ts @@ -774,7 +774,7 @@ const selectedData: Select2.OptionData[] = $("#mySelect2").select2("data"); // jQuery Generic declare let select: HTMLSelectElement; -const $select: JQuery = $(select) as JQuery; +const $select: JQuery = $(select); select = $select.select2().get(0); select = $select.select2({tags: true}).get(0); From f7c353d66fd8466e715fbb6204634491aaf946cf Mon Sep 17 00:00:00 2001 From: Paleo Date: Wed, 15 Aug 2018 18:37:03 +0100 Subject: [PATCH 092/109] All members in UpdateStatement returns the UpdateStatement --- types/sql-bricks/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/sql-bricks/index.d.ts b/types/sql-bricks/index.d.ts index ccc7e523a7..41cc6b9146 100644 --- a/types/sql-bricks/index.d.ts +++ b/types/sql-bricks/index.d.ts @@ -230,10 +230,10 @@ declare namespace SqlBricks { interface UpdateStatement extends Statement { values(...values: any[]): UpdateStatement set(...values: any[]): UpdateStatement - where(column?: string | null, value?: any): SelectStatement - where(...whereExpr: WhereExpression[]): SelectStatement - and(column?: string | null, value?: any): SelectStatement - and(...whereExpr: WhereExpression[]): SelectStatement + where(column?: string | null, value?: any): UpdateStatement + where(...whereExpr: WhereExpression[]): UpdateStatement + and(column?: string | null, value?: any): UpdateStatement + and(...whereExpr: WhereExpression[]): UpdateStatement } /** From f4982fb3fcd46ed0a9ddd111559650da84461cbc Mon Sep 17 00:00:00 2001 From: Luke Ivanchenko-Cooney Date: Thu, 16 Aug 2018 03:46:54 +1000 Subject: [PATCH 093/109] Add decoding attribute to img tag (#28126) --- types/react/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index ce586b0869..e8de06ef62 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1459,6 +1459,7 @@ declare namespace React { interface ImgHTMLAttributes extends HTMLAttributes { alt?: string; crossOrigin?: "anonymous" | "use-credentials" | ""; + decoding?: "async" | "auto" | "sync"; height?: number | string; sizes?: string; src?: string; From 6d32c2cc520b7e74499dafd49a4a0f03efdacc60 Mon Sep 17 00:00:00 2001 From: Andrew Palugniok Date: Wed, 15 Aug 2018 18:50:25 +0100 Subject: [PATCH 094/109] [recharts] Add optional stroke prop to X and Y axes --- types/recharts/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index dc96bdbe46..0cf9898638 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -10,6 +10,7 @@ // Jamie Saunders // Paul Melnikow // Harry Cruse +// Andrew Palugniok // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -917,6 +918,7 @@ export interface XAxisProps extends EventAttributes { // see label section at http://recharts.org/#/en-US/api/XAxis label?: string | number | Label | LabelProps; allowDuplicatedCategory?: boolean; + stroke?: string; } export class XAxis extends React.Component { } @@ -968,6 +970,7 @@ export interface YAxisProps extends EventAttributes { reversed?: boolean; // see label section at http://recharts.org/#/en-US/api/YAxis label?: string | number | Label | LabelProps; + stroke?: string; } export class YAxis extends React.Component { } From 91dbdc35edcff195e5a8860f7c9a5509cca015e6 Mon Sep 17 00:00:00 2001 From: Andrew Palugniok Date: Wed, 15 Aug 2018 19:04:21 +0100 Subject: [PATCH 095/109] [recharts] Add stroke prop to an axis in tests --- types/recharts/recharts-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/recharts/recharts-tests.tsx b/types/recharts/recharts-tests.tsx index 855a5c9e75..665c0a13de 100644 --- a/types/recharts/recharts-tests.tsx +++ b/types/recharts/recharts-tests.tsx @@ -90,7 +90,7 @@ class Component extends React.Component<{}, ComponentState> { - + From f439d9c79794cb791f7322c1381305efd3d841e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Borntr=C3=A4ger?= Date: Wed, 15 Aug 2018 20:17:37 +0200 Subject: [PATCH 096/109] Removing myself as contributer --- types/hapi/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 23aaf3608c..57641d67d3 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger -// Rafael Souza Fijalkowski +// Definitions by: Rafael Souza Fijalkowski // Justin Simms // Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 1d0e817f1f92a78d97f57207d3c3891c1db9d775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Borntr=C3=A4ger?= Date: Wed, 15 Aug 2018 20:18:14 +0200 Subject: [PATCH 097/109] Removing myself as contributer --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8c7f823a07..e377cd02ab 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1567,7 +1567,7 @@ /types/hapi/v12/ @jasonswearingen /types/hapi/v15/ @jasonswearingen /types/hapi/v16/ @jasonswearingen @AJamesPhillips -/types/hapi/ @BorntraegerMarc @rafaelsouzaf @jhsimms @SimonSchick +/types/hapi/ @rafaelsouzaf @jhsimms @SimonSchick /types/hapi-auth-basic/ @AJamesPhillips @saboya /types/hapi-auth-jwt2/v7/ @warrenseymour /types/hapi-auth-jwt2/ @warrenseymour @SimonSchick From c06a096270b3528bfb4f80532dde14a362e9e39a Mon Sep 17 00:00:00 2001 From: Saqib Rokadia Date: Wed, 15 Aug 2018 13:40:35 -0700 Subject: [PATCH 098/109] Adding the fullCircle property on to the gauge field. --- types/c3/c3-tests.ts | 1 + types/c3/index.d.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/types/c3/c3-tests.ts b/types/c3/c3-tests.ts index f2e630cd09..6d7ea67287 100644 --- a/types/c3/c3-tests.ts +++ b/types/c3/c3-tests.ts @@ -452,6 +452,7 @@ function gauge_examples() { max: 100, units: " %", width: 10, + fullCircle: true, } }); } diff --git a/types/c3/index.d.ts b/types/c3/index.d.ts index 6c466458e3..0d94347ca3 100644 --- a/types/c3/index.d.ts +++ b/types/c3/index.d.ts @@ -276,6 +276,12 @@ export interface ChartConfiguration { * Set width of gauge chart. */ width?: number; + /** + * Whether this should be displayed + * as a full circle instead of a + * half circle. + */ + fullCircle?: boolean; }; spline?: { From 7c108482f443f8139ae0c19d0862c0342fb933d1 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Aug 2018 13:45:34 -0700 Subject: [PATCH 099/109] Puppeteer: Fix tests (#28147) --- types/puppeteer/puppeteer-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 96cb4fd361..e883157fec 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer"; // Get the "viewport" of the page, as reported by the page. const dimensions = await page.evaluate(() => { return { - width: document.documentElement.clientWidth, - height: document.documentElement.clientHeight, + width: document.documentElement!.clientWidth, + height: document.documentElement!.clientHeight, deviceScaleFactor: window.devicePixelRatio }; }); @@ -300,7 +300,7 @@ puppeteer.launch().then(async browser => { someElement; // $ExpectType ElementHandle // If one passes an ElementHandle, puppeteer will unwrap its DOM reference instead - await page.$eval('.hello-world', (e, x1: HTMLDivElement) => x1.noWrap, someElement); + await page.$eval('.hello-world', (e, x1) => (x1 as any).noWrap, someElement); browser.close(); })(); From a3491e13daaeceec0116fa2186f9a2d13f8770c4 Mon Sep 17 00:00:00 2001 From: Alex Jerabek Date: Wed, 15 Aug 2018 14:25:42 -0700 Subject: [PATCH 100/109] Adding property access to the description of Context --- types/office-js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index f9eb56c8f5..316198dc8c 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -600,6 +600,7 @@ declare namespace Office { } /** * Represents the runtime environment of the add-in and provides access to key objects of the API. + * The current context exists as a property of Office. It is accessed using `Office.context`. * * @remarks *
HostsAccess, Excel, Outlook, PowerPoint, Project, Word
From 9f9978b45c9a667dbf8a9c8d62f2555cc7ad9472 Mon Sep 17 00:00:00 2001 From: Serhii Nanovskyi Date: Thu, 16 Aug 2018 00:14:29 +0300 Subject: [PATCH 101/109] [passport-strategy] update typings --- types/passport-strategy/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/passport-strategy/index.d.ts b/types/passport-strategy/index.d.ts index 1a0b2dd4f5..33b35ddbaf 100644 --- a/types/passport-strategy/index.d.ts +++ b/types/passport-strategy/index.d.ts @@ -45,7 +45,7 @@ declare class Strategy implements passport.Strategy { * @param {Object} info * @api public */ - success(user: any, info: any): void; + success(user: any, info?: any): void; /** * Fail authentication, with optional `challenge` and `status`, defaulting From 5e86b01489998c3e1470f4007f45227657e92089 Mon Sep 17 00:00:00 2001 From: Serhii Nanovskyi Date: Thu, 16 Aug 2018 00:26:15 +0300 Subject: [PATCH 102/109] [passport-strategy] update tests --- types/passport-strategy/passport-strategy-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/passport-strategy/passport-strategy-tests.ts b/types/passport-strategy/passport-strategy-tests.ts index e9c6fd604f..4b8090d241 100644 --- a/types/passport-strategy/passport-strategy-tests.ts +++ b/types/passport-strategy/passport-strategy-tests.ts @@ -33,7 +33,7 @@ export class Strategy extends passport.Strategy { var self = this; - function verified(err: Error, user: any, info: any) { + function verified(err: Error, user: any, info?: any) { if (err) { return self.error(err); } @@ -43,6 +43,6 @@ export class Strategy extends passport.Strategy { self.success(user, info); } - verified(null, {}, {}); + verified(null, {}); } } From b22bf252438e64a79a61b827e2f05ec2b3ffeb7e Mon Sep 17 00:00:00 2001 From: Warrick FitzGerald Date: Wed, 15 Aug 2018 18:45:22 -0400 Subject: [PATCH 103/109] Added includeTlsChannelId?: boolean; to ConnectInfo interface as per https://developer.chrome.com/extensions/runtime#method-connect --- types/chrome/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 6dbf118947..49f079e159 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4959,6 +4959,7 @@ declare namespace chrome.runtime { export interface ConnectInfo { name?: string; + includeTlsChannelId?: boolean; } export interface InstalledDetails { From ec98bf9b57a03247837a8db5169c970f15ba7ff9 Mon Sep 17 00:00:00 2001 From: d-ph Date: Wed, 15 Aug 2018 23:47:31 +0100 Subject: [PATCH 104/109] [bluebird-global] Change how instance method are pulled from Bluebird. Fixes the issue where the generic type of the Promise is lost (actually: set to "any") on instance methods. More info in ticket #28081 --- .../bluebird-global/bluebird-global-tests.ts | 4 + types/bluebird-global/index.d.ts | 92 +++++++++---------- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/types/bluebird-global/bluebird-global-tests.ts b/types/bluebird-global/bluebird-global-tests.ts index 0464b188cd..b6bbb915e2 100644 --- a/types/bluebird-global/bluebird-global-tests.ts +++ b/types/bluebird-global/bluebird-global-tests.ts @@ -40,3 +40,7 @@ function testPromiseRejection() { return value.toUpperCase(); }); } + +function testGithubTicket28081Regression() { + Promise.resolve([3]).map((n: number) => true); +} diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index 0d8ac4eeb3..7f38f981f1 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -67,52 +67,52 @@ declare global { * Patch all instance method */ interface Promise { - all: typeof Bluebird.prototype.all; - any: typeof Bluebird.prototype.any; - asCallback: typeof Bluebird.prototype.asCallback; - bind: typeof Bluebird.prototype.bind; - call: typeof Bluebird.prototype.call; - cancel: typeof Bluebird.prototype.cancel; - // catch: typeof Bluebird.prototype.catch; - caught: typeof Bluebird.prototype.caught; - delay: typeof Bluebird.prototype.delay; - disposer: typeof Bluebird.prototype.disposer; - done: typeof Bluebird.prototype.done; - each: typeof Bluebird.prototype.each; - error: typeof Bluebird.prototype.error; - filter: typeof Bluebird.prototype.filter; - // finally: typeof Bluebird.prototype.finally; - get: typeof Bluebird.prototype.get; - isCancelled: typeof Bluebird.prototype.isCancelled; - isFulfilled: typeof Bluebird.prototype.isFulfilled; - isPending: typeof Bluebird.prototype.isPending; - isRejected: typeof Bluebird.prototype.isRejected; - isResolved: typeof Bluebird.prototype.isResolved; - lastly: typeof Bluebird.prototype.lastly; - map: typeof Bluebird.prototype.map; - mapSeries: typeof Bluebird.prototype.mapSeries; - nodeify: typeof Bluebird.prototype.nodeify; - props: typeof Bluebird.prototype.props; - race: typeof Bluebird.prototype.race; - reason: typeof Bluebird.prototype.reason; - reduce: typeof Bluebird.prototype.reduce; - reflect: typeof Bluebird.prototype.reflect; - return: typeof Bluebird.prototype.return; - some: typeof Bluebird.prototype.some; - spread: typeof Bluebird.prototype.spread; - suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections; - tap: typeof Bluebird.prototype.tap; - tapCatch: typeof Bluebird.prototype.tapCatch; - // then: typeof Bluebird.prototype.then; - thenReturn: typeof Bluebird.prototype.thenReturn; - thenThrow: typeof Bluebird.prototype.thenThrow; - catchReturn: typeof Bluebird.prototype.catchReturn; - catchThrow: typeof Bluebird.prototype.catchThrow; - throw: typeof Bluebird.prototype.throw; - timeout: typeof Bluebird.prototype.timeout; - toJSON: typeof Bluebird.prototype.toJSON; - toString: typeof Bluebird.prototype.toString; - value: typeof Bluebird.prototype.value; + all: Bluebird["all"]; + any: Bluebird["any"]; + asCallback: Bluebird["asCallback"]; + bind: Bluebird["bind"]; + call: Bluebird["call"]; + cancel: Bluebird["cancel"]; + // catch: Bluebird["catch"]; + caught: Bluebird["caught"]; + delay: Bluebird["delay"]; + disposer: Bluebird["disposer"]; + done: Bluebird["done"]; + each: Bluebird["each"]; + error: Bluebird["error"]; + filter: Bluebird["filter"]; + // finally: Bluebird["finally"]; + get: Bluebird["get"]; + isCancelled: Bluebird["isCancelled"]; + isFulfilled: Bluebird["isFulfilled"]; + isPending: Bluebird["isPending"]; + isRejected: Bluebird["isRejected"]; + isResolved: Bluebird["isResolved"]; + lastly: Bluebird["lastly"]; + map: Bluebird["map"]; + mapSeries: Bluebird["mapSeries"]; + nodeify: Bluebird["nodeify"]; + props: Bluebird["props"]; + race: Bluebird["race"]; + reason: Bluebird["reason"]; + reduce: Bluebird["reduce"]; + reflect: Bluebird["reflect"]; + return: Bluebird["return"]; + some: Bluebird["some"]; + spread: Bluebird["spread"]; + suppressUnhandledRejections: Bluebird["suppressUnhandledRejections"]; + tap: Bluebird["tap"]; + tapCatch: Bluebird["tapCatch"]; + // then: Bluebird["then"]; + thenReturn: Bluebird["thenReturn"]; + thenThrow: Bluebird["thenThrow"]; + catchReturn: Bluebird["catchReturn"]; + catchThrow: Bluebird["catchThrow"]; + throw: Bluebird["throw"]; + timeout: Bluebird["timeout"]; + toJSON: Bluebird["toJSON"]; + toString: Bluebird["toString"]; + value: Bluebird["value"]; /* * Copy&paste ::then and ::catch from lib.es2015.promise.d.ts, because Bluebird's typings are not From 446c9030785a819d33e77d825e6e17f4c6339573 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Mon, 13 Aug 2018 13:27:19 +0200 Subject: [PATCH 105/109] [reconnect-core] new package --- types/reconnect-core/index.d.ts | 47 ++++++++++++++++++++ types/reconnect-core/reconnect-core-tests.ts | 41 +++++++++++++++++ types/reconnect-core/tsconfig.json | 24 ++++++++++ types/reconnect-core/tslint.json | 9 ++++ 4 files changed, 121 insertions(+) create mode 100644 types/reconnect-core/index.d.ts create mode 100644 types/reconnect-core/reconnect-core-tests.ts create mode 100644 types/reconnect-core/tsconfig.json create mode 100644 types/reconnect-core/tslint.json diff --git a/types/reconnect-core/index.d.ts b/types/reconnect-core/index.d.ts new file mode 100644 index 0000000000..49f77276d4 --- /dev/null +++ b/types/reconnect-core/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for reconnect-core 1.3 +// Project: https://www.npmjs.com/package/reconnect-core +// Definitions by: James Bromwell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Backoff, ExponentialOptions } from "backoff"; +import { EventEmitter } from "events"; +import { Stream } from "stream"; + +export namespace reconnect { + // TODO: Once DT supports TS 3.0, use new Generic Rest Parameter feature for + // ArgType. Current definitions only support one parameter passed to + // connect() but the library actually allows any number of args. + type CustomModule = + (opts?: ModuleOptions, cb?: (con: ConnectionType) => void) => Instance; + + interface ModuleOptions extends ExponentialOptions { + immediate?: boolean; + failAfter?: number; + onConnect?: (con: ConnectionType) => void; + strategy?: "fibonacci" | "exponential" | Backoff; + } + + interface Instance extends EventEmitter { + connect(opts: ArgType): this; + listen(opts: ArgType): this; + disconnect(): this; + reset(): void; + + readonly connected: boolean; + reconnect: boolean; + + on(event: "backoff", cb: (n: number, delay: number, err?: any) => void): this; + on(event: "connect" | "connection", cb: (con: ConnectionType) => void): this; + on(event: "disconnect", cb: (err?: any) => void): this; + on(event: "error" | "fail", cb: (err: any) => void): this; + on(event: "reconnect", cb: (n: number, delay: number) => void): this; + } +} + +type ConnectFunction = + (this: reconnect.Instance, opts: ArgType) => ConnectionType; +export function reconnect( + cf: ConnectFunction): reconnect.CustomModule; + +export default reconnect; diff --git a/types/reconnect-core/reconnect-core-tests.ts b/types/reconnect-core/reconnect-core-tests.ts new file mode 100644 index 0000000000..4677386fa5 --- /dev/null +++ b/types/reconnect-core/reconnect-core-tests.ts @@ -0,0 +1,41 @@ +import reconnect from "reconnect-core"; +import { NetConnectOpts, Socket, connect } from "net"; + +// Approximation of example from docs +const module = reconnect(arg => { + // TS can't resolve passing even the simplest union types to function overloads :-/ + // (see TS issue #14107) + if (typeof arg === "string") { + return connect(arg); + } else if (typeof arg === "number") { + return connect(arg); + } else { + return connect(arg); + } +}); + +const conn = module({ + initialDelay: 1e3, + maxDelay: 30e3, + strategy: "fibonacci", + failAfter: Infinity, + randomisationFactor: 0, + immediate: false +}, sock => { + sock.on("data", console.log); +}); + +conn.on("connect", con => con.address()) + .on("reconnect", (n, delay) => { + n.toExponential(); + delay.toFixed(); + }) + .on("disconnect", console.log) + .on("error", console.log) + .connect(12345); + +conn.disconnect(); + +conn.reconnect = false; + +conn.reset(); diff --git a/types/reconnect-core/tsconfig.json b/types/reconnect-core/tsconfig.json new file mode 100644 index 0000000000..fd7721cde3 --- /dev/null +++ b/types/reconnect-core/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "forceConsistentCasingInFileNames": true, + "lib": [ + "es2016" + ], + "module": "commonjs", + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "target": "es6", + "types": [], + "typeRoots": [ + "../" + ] + }, + "files": [ + "index.d.ts", + "reconnect-core-tests.ts" + ] +} diff --git a/types/reconnect-core/tslint.json b/types/reconnect-core/tslint.json new file mode 100644 index 0000000000..188c29af25 --- /dev/null +++ b/types/reconnect-core/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // I don't understand why turning this on breaks the linter, would welcome feedback + "strict-export-declare-modifiers": false, + // Flags exported interface member as invalid when returning void, see dtslint issue #110 + "void-return": false + } +} From 5ff04209a7a69c6c1f89a318a06a0872d438d0c5 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Thu, 16 Aug 2018 11:13:03 +0200 Subject: [PATCH 106/109] [reconnect-core] fixes from review feedback --- types/reconnect-core/index.d.ts | 6 +++--- types/reconnect-core/reconnect-core-tests.ts | 21 +++++++++++--------- types/reconnect-core/tslint.json | 8 +------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/types/reconnect-core/index.d.ts b/types/reconnect-core/index.d.ts index 49f77276d4..0a447e7571 100644 --- a/types/reconnect-core/index.d.ts +++ b/types/reconnect-core/index.d.ts @@ -8,7 +8,7 @@ import { Backoff, ExponentialOptions } from "backoff"; import { EventEmitter } from "events"; import { Stream } from "stream"; -export namespace reconnect { +declare namespace reconnect { // TODO: Once DT supports TS 3.0, use new Generic Rest Parameter feature for // ArgType. Current definitions only support one parameter passed to // connect() but the library actually allows any number of args. @@ -41,7 +41,7 @@ export namespace reconnect { type ConnectFunction = (this: reconnect.Instance, opts: ArgType) => ConnectionType; -export function reconnect( +declare function reconnect( cf: ConnectFunction): reconnect.CustomModule; -export default reconnect; +export = reconnect; diff --git a/types/reconnect-core/reconnect-core-tests.ts b/types/reconnect-core/reconnect-core-tests.ts index 4677386fa5..f809224d2f 100644 --- a/types/reconnect-core/reconnect-core-tests.ts +++ b/types/reconnect-core/reconnect-core-tests.ts @@ -1,8 +1,8 @@ -import reconnect from "reconnect-core"; +import reconnect = require("reconnect-core"); import { NetConnectOpts, Socket, connect } from "net"; // Approximation of example from docs -const module = reconnect(arg => { +const module: reconnect.CustomModule = reconnect(arg => { // TS can't resolve passing even the simplest union types to function overloads :-/ // (see TS issue #14107) if (typeof arg === "string") { @@ -14,16 +14,19 @@ const module = reconnect(arg => { } }); -const conn = module({ +const opts: reconnect.ModuleOptions = { + failAfter: Infinity, + immediate: false, initialDelay: 1e3, maxDelay: 30e3, - strategy: "fibonacci", - failAfter: Infinity, randomisationFactor: 0, - immediate: false -}, sock => { - sock.on("data", console.log); -}); + strategy: "fibonacci", + onConnect: sock => { + sock.on("data", console.log); + }, +}; + +const conn = module(opts); conn.on("connect", con => con.address()) .on("reconnect", (n, delay) => { diff --git a/types/reconnect-core/tslint.json b/types/reconnect-core/tslint.json index 188c29af25..f93cf8562a 100644 --- a/types/reconnect-core/tslint.json +++ b/types/reconnect-core/tslint.json @@ -1,9 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - // I don't understand why turning this on breaks the linter, would welcome feedback - "strict-export-declare-modifiers": false, - // Flags exported interface member as invalid when returning void, see dtslint issue #110 - "void-return": false - } + "extends": "dtslint/dt.json" } From be003858ba5694698a4f52399354778ab8ee8df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Thu, 16 Aug 2018 11:21:38 +0200 Subject: [PATCH 107/109] MouseEvent extends SyntheticEvent --- types/react-virtualized/dist/es/Table.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-virtualized/dist/es/Table.d.ts b/types/react-virtualized/dist/es/Table.d.ts index 09e3c2b37e..b66fac389b 100644 --- a/types/react-virtualized/dist/es/Table.d.ts +++ b/types/react-virtualized/dist/es/Table.d.ts @@ -189,13 +189,13 @@ export type RowMouseEventHandlerParams = { index: number; }; index: number; - event: React.SyntheticEvent>; + event: React.MouseEvent; }; export type HeaderMouseEventHandlerParams = { dataKey: string; columnData: any; - event: React.SyntheticEvent>; + event: React.MouseEvent; }; // ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md From 5ee37c8c2fccb6444eb0c6578f7b53f62a8efeef Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 16 Aug 2018 12:47:25 +0200 Subject: [PATCH 108/109] Simplify n3 tslint --- types/n3/tslint.json | 78 +------------------------------------------- 1 file changed, 1 insertion(+), 77 deletions(-) diff --git a/types/n3/tslint.json b/types/n3/tslint.json index 886f1a8b6c..d88586e5bd 100644 --- a/types/n3/tslint.json +++ b/types/n3/tslint.json @@ -1,79 +1,3 @@ { - "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 - } + "extends": "dtslint/dt.json" } From bf8bf814a6cdd87cbd9a4d6176ce19509d8e595c Mon Sep 17 00:00:00 2001 From: Ricky Kirkham Date: Thu, 16 Aug 2018 11:10:29 -0700 Subject: [PATCH 109/109] add internal only warning and req set to openBrowserWindow --- types/office-js/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index f9eb56c8f5..98b42e10ed 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -1021,7 +1021,11 @@ declare namespace Office { */ closeContainer(): void; /** - * Opens a browser window and loads the specified URL. + * For internal Microsoft use only. Do not call from your code. Opens a browser window and loads the specified URL. + * + * @remarks + *
Requirement setsOpenBrowserWindowAPI 1.1
+ * * @param url The full URL to be opened including protocol (e.g., https), and port number, if any. */ openBrowserWindow(url: string): void;