From af3a57e16aa35e809b4b23ff21c507d8b040c749 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Fri, 16 Sep 2016 11:36:37 -0700 Subject: [PATCH 1/3] Fix Types-2.0 CI --- ...bowser-tests.ts => bowser-tests-global.ts} | 13 +- bowser/bowser-tests-module.ts | 9 + bowser/tsconfig.json | 3 +- electron/index.d.ts | 2 +- esprima/index.d.ts | 2 +- gulp/index.d.ts | 2 + mongoose-promise/index.d.ts | 231 +++++++++--------- mongoose-promise/tsconfig.json | 2 +- whatwg-fetch/whatwg-fetch-tests.ts | 41 +--- 9 files changed, 134 insertions(+), 171 deletions(-) rename bowser/{bowser-tests.ts => bowser-tests-global.ts} (55%) create mode 100644 bowser/bowser-tests-module.ts diff --git a/bowser/bowser-tests.ts b/bowser/bowser-tests-global.ts similarity index 55% rename from bowser/bowser-tests.ts rename to bowser/bowser-tests-global.ts index 910b716e0f..490d02a254 100644 --- a/bowser/bowser-tests.ts +++ b/bowser/bowser-tests-global.ts @@ -1,19 +1,10 @@ - - -import Bowser = require('bowser'); - -Bowser.msedge === true; -Bowser.test(['msie']) === true; -Bowser.a === Bowser.c; -Bowser.osversion > 10; -Bowser.osversion === '10.1A'; - bowser.msedge === true; bowser.test(['msie']) === true; bowser.a === bowser.c; bowser.osversion > 10; bowser.osversion === '10.1A'; bowser.compareVersions(['9.0', '10']); -bowser() === {android: true, x: true}; + +bowser() === {android: true, x: true}; bowser.check({msie: "11"}, window.navigator.userAgent); bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent); \ No newline at end of file diff --git a/bowser/bowser-tests-module.ts b/bowser/bowser-tests-module.ts new file mode 100644 index 0000000000..7d662b2f2b --- /dev/null +++ b/bowser/bowser-tests-module.ts @@ -0,0 +1,9 @@ + + +import Bowser = require('bowser'); + +Bowser.msedge === true; +Bowser.test(['msie']) === true; +Bowser.a === Bowser.c; +Bowser.osversion > 10; +Bowser.osversion === '10.1A'; \ No newline at end of file diff --git a/bowser/tsconfig.json b/bowser/tsconfig.json index 7716ba9fcc..5261c0e68b 100644 --- a/bowser/tsconfig.json +++ b/bowser/tsconfig.json @@ -14,6 +14,7 @@ }, "files": [ "index.d.ts", - "bowser-tests.ts" + "bowser-tests-module.ts", + "bowser-tests-global.ts" ] } \ No newline at end of file diff --git a/electron/index.d.ts b/electron/index.d.ts index 7d10fce465..cac4bab9b2 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// declare namespace Electron { diff --git a/esprima/index.d.ts b/esprima/index.d.ts index 312392e4b5..920257abd3 100644 --- a/esprima/index.d.ts +++ b/esprima/index.d.ts @@ -21,7 +21,7 @@ declare namespace esprima { value: string; } - interface Comment extends ESTree.Node { + interface Comment extends ESTree.BaseNode { value: string; } diff --git a/gulp/index.d.ts b/gulp/index.d.ts index 0387e0962f..89b1a5dfa5 100644 --- a/gulp/index.d.ts +++ b/gulp/index.d.ts @@ -5,9 +5,11 @@ /// /// +/// import Orchestrator = require("orchestrator"); +import VinylFile = require("vinyl"); declare namespace gulp { interface Gulp extends Orchestrator { diff --git a/mongoose-promise/index.d.ts b/mongoose-promise/index.d.ts index d2622bb6f9..fe60fe73c3 100644 --- a/mongoose-promise/index.d.ts +++ b/mongoose-promise/index.d.ts @@ -3,126 +3,125 @@ // Definitions by: simonxca // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/* - * These are the default promises included in the Mongoose v4.x - * definitions. They will be deprecated beginning Mongoose V5.x - * in favor of native ES6 Promises. - * - * You can switch the promise library that mongoose uses by: - * - * 1. Including this somewhere in your code: - * mongoose.Promise = YOUR_PROMISE; - * - * 2. Including this somewhere in your main .d.ts file: - * type MongoosePromise = YOUR_PROMISE; - */ +/// +/// /* * http://mongoosejs.com/docs/api.html#promise-js * - * Callback signatures are from the mPromise type definitions. + * mongoose.d.ts uses global.Promise by default. This is the MongooseJS + * mpromise implementation (which are deprecated). If you still want to + * use it, install these definitions in your project. */ -interface MongoosePromise { - /** - * Promise constructor. - * Promises are returned from executed queries. - * @param fn a function which will be called when the promise - * is resolved that accepts fn(err, ...){} as signature - * @event err Emits when the promise is rejected - * @event complete Emits when the promise is fulfilled - * @deprecated Mongoose 5.0 will use native promises by default (or bluebird, if native - * promises are not present) but still support plugging in your own ES6-compatible - * promises library. Mongoose 5.0 will not support mpromise. +import mpromise = require('mpromise'); +declare module 'mongoose' { + + type Promise = MongoosePromise; + + /* + * mpromise definitions. + * Callback signatures are from the mPromise type definitions. */ - new(fn?: (err: any, arg: T) => void): MongoosePromise; - new(fn?: (err: any, ...args: T[]) => void): MongoosePromise; + class MongoosePromise extends mpromise { + /** + * Promise constructor. + * Promises are returned from executed queries. + * @param fn a function which will be called when the promise + * is resolved that accepts fn(err, ...){} as signature + * @event err Emits when the promise is rejected + * @event complete Emits when the promise is fulfilled + * @deprecated Mongoose 5.0 will use native promises by default (or bluebird, if native + * promises are not present) but still support plugging in your own ES6-compatible + * promises library. Mongoose 5.0 will not support mpromise. + */ + constructor(fn?: (err: any, arg: T) => void); + constructor(fn?: (err: any, ...args: T[]) => void); + + /** + * Adds a single function as a listener to both err and complete. + * It will be executed with traditional node.js argument position when the promise is resolved. + * @deprecated Use onResolve instead. + */ + addBack(listener: (err: any, arg: T) => void): this; + addBack(listener: (err: any, ...args: T[]) => void): this; + + /** + * Adds a listener to the complete (success) event. + * @deprecated Adds a listener to the complete (success) event. + */ + addCallback(listener: (arg: T) => void): this; + addCallback(listener: (...args: T[]) => void): this; + + /** + * Adds a listener to the err (rejected) event. + * @deprecated Use onReject instead. + */ + addErrback(listener: (err: any) => void): this; + + /** ES6-style .catch() shorthand */ + catch(onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; + + /** + * Signifies that this promise was the last in a chain of then()s: if a handler passed + * to the call to then which produced this promise throws, the exception will go uncaught. + */ + end(): void; + + /** + * Rejects this promise with err. + * If the promise has already been fulfilled or rejected, not action is taken. + * Differs from #reject by first casting err to an Error if it is not instanceof Error. + */ + error(err: any): this; + + /** + * Adds listener to the event. + * If event is either the success or failure event and the event has already been emitted, + * thelistener is called immediately and passed the results of the original emitted event. + */ + on(event: string, listener: Function): this; + + /** + * Rejects this promise with reason. + * If the promise has already been fulfilled or rejected, not action is taken. + */ + reject(reason: Object | string | Error): this; + + /** + * Resolves this promise to a rejected state if err is passed or a fulfilled state if no err is passed. + * If the promise has already been fulfilled or rejected, not action is taken. + * err will be cast to an Error if not already instanceof Error. + * NOTE: overrides mpromise#resolve to provide error casting. + * @param err error or null + * @param val value to fulfill the promise with + */ + resolve(err?: any, val?: Object): this; + + /** + * Creates a new promise and returns it. If onFulfill or onReject are passed, they are added as + * SUCCESS/ERROR callbacks to this promise after the nextTick. + * Conforms to promises/A+ specification. + */ + then(onFulFill: (arg: T) => void | TRes | PromiseLike, + onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; + then(onFulfill: (...args: T[]) => void | TRes | PromiseLike, + onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; + + /** + * Fulfills this promise with passed arguments. Alias of mpromise#fulfill. + * @deprecated Use fulfill instead. + */ + complete(args: T): this; + complete(...args: T[]): this; + + /** Fulfills this promise with passed arguments. */ + fulfill(...args: T[]): this; + fulfill(arg: T): this; + + /** ES6-style promise constructor wrapper around mpromise. */ + static ES6(resolver: ( + complete: (...args: TRes[]) => void | TRes | PromiseLike, + error: (e: any) => void | TRes | PromiseLike + ) => void): MongoosePromise; + } } - -declare class MongoosePromise { - /** - * Adds a single function as a listener to both err and complete. - * It will be executed with traditional node.js argument position when the promise is resolved. - * @deprecated Use onResolve instead. - */ - addBack(listener: (err: any, arg: T) => void): this; - addBack(listener: (err: any, ...args: T[]) => void): this; - - /** - * Adds a listener to the complete (success) event. - * @deprecated Adds a listener to the complete (success) event. - */ - addCallback(listener: (arg: T) => void): this; - addCallback(listener: (...args: T[]) => void): this; - - /** - * Adds a listener to the err (rejected) event. - * @deprecated Use onReject instead. - */ - addErrback(listener: (err: any) => void): this; - - /** ES6-style .catch() shorthand */ - catch(onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; - - /** - * Signifies that this promise was the last in a chain of then()s: if a handler passed - * to the call to then which produced this promise throws, the exception will go uncaught. - */ - end(): void; - - /** - * Rejects this promise with err. - * If the promise has already been fulfilled or rejected, not action is taken. - * Differs from #reject by first casting err to an Error if it is not instanceof Error. - */ - error(err: any): this; - - /** - * Adds listener to the event. - * If event is either the success or failure event and the event has already been emitted, - * thelistener is called immediately and passed the results of the original emitted event. - */ - on(event: string, listener: Function): this; - - /** - * Rejects this promise with reason. - * If the promise has already been fulfilled or rejected, not action is taken. - */ - reject(reason: Object | string | Error): this; - - /** - * Resolves this promise to a rejected state if err is passed or a fulfilled state if no err is passed. - * If the promise has already been fulfilled or rejected, not action is taken. - * err will be cast to an Error if not already instanceof Error. - * NOTE: overrides mpromise#resolve to provide error casting. - * @param err error or null - * @param val value to fulfill the promise with - */ - resolve(err?: any, val?: Object): this; - - /** - * Creates a new promise and returns it. If onFulfill or onReject are passed, they are added as - * SUCCESS/ERROR callbacks to this promise after the nextTick. - * Conforms to promises/A+ specification. - */ - then(onFulFill: (arg: T) => void | TRes | PromiseLike, - onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; - then(onFulfill: (...args: T[]) => void | TRes | PromiseLike, - onReject?: (err: any) => void | TRes | PromiseLike): MongoosePromise; - - /** - * Fulfills this promise with passed arguments. Alias of mpromise#fulfill. - * @deprecated Use fulfill instead. - */ - complete(args: T): this; - complete(...args: T[]): this; - - /** Fulfills this promise with passed arguments. */ - fulfill(...args: T[]): this; - fulfill(arg: T): this; - - /** ES6-style promise constructor wrapper around mpromise. */ - static ES6(resolver: ( - complete: (...args: TRes[]) => void | TRes | PromiseLike, - error: (e: any) => void | TRes | PromiseLike - ) => void): MongoosePromise; -} \ No newline at end of file diff --git a/mongoose-promise/tsconfig.json b/mongoose-promise/tsconfig.json index 45378dfc67..ea8993399c 100644 --- a/mongoose-promise/tsconfig.json +++ b/mongoose-promise/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index 7434c8372b..aa6b90b8c8 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -1,44 +1,5 @@  -function test_HeadersCopiedFromHeaders1() { - var source = new Headers(); - source.append('Content-Type', 'application/json'); - return new Headers(source); -} - -function test_HeadersCopiedFromHash1() { - var source:HeadersMap = { - 'Content-Type': 'application/json' - }; - return new Headers(source); -} - -function test_HeadersCopiedFromHeaders2() { - var source = new Headers(); - source.append('Content-Type', 'application/json'); - return new Headers(source); -} - -function test_HeadersCopiedFromHash2() { - var source:HeadersMap = { - 'Content-Type': 'application/json' - }; - return new Headers(source); -} - -function test_HeadersCopiedFromHeaders3() { - var source = new Headers(); - source.append('Content-Type', 'application/json'); - return new Headers(source); -} - -function test_HeadersCopiedFromHash3() { - var source:HeadersMap = { - 'Content-Type': 'application/json' - }; - return new Headers(source); -} - function test_HeadersCopiedFromHeaders() { var source = new Headers(); source.append('Content-Type', 'application/json'); @@ -107,4 +68,4 @@ function handlePromise(promise: Promise) { }).then((text) => { console.log(text); }); -} +} \ No newline at end of file From 27541f076b2e20514cb60456ccaeabf8c9958c88 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Sep 2016 13:16:58 -0700 Subject: [PATCH 2/3] Fix header error: don't need periods at end of name --- cordova-plugin-contacts/index.d.ts | 6 +++--- cordova-plugin-file/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cordova-plugin-contacts/index.d.ts b/cordova-plugin-contacts/index.d.ts index 90b21ae2bb..6728b991d6 100644 --- a/cordova-plugin-contacts/index.d.ts +++ b/cordova-plugin-contacts/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for Apache Cordova Contacts plugin. +// Type definitions for Apache Cordova Contacts plugin // Project: https://github.com/apache/cordova-plugin-contacts // Definitions by: Microsoft Open Technologies, Inc. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +// // Copyright (c) Microsoft Open Technologies, Inc. // Licensed under the MIT license. @@ -204,7 +204,7 @@ declare var ContactName: { * The ContactField object is a reusable component that represents contact fields generically. * Each ContactField object contains a value, type, and pref property. A Contact object stores * several properties in ContactField[] arrays, such as phone numbers and email addresses. - * + * * In most instances, there are no pre-determined values for a ContactField object's type attribute. * For example, a phone number can specify type values of home, work, mobile, iPhone, * or any other value that is supported by a particular device platform's contact database. diff --git a/cordova-plugin-file/index.d.ts b/cordova-plugin-file/index.d.ts index f9471eda72..3243632714 100644 --- a/cordova-plugin-file/index.d.ts +++ b/cordova-plugin-file/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Apache Cordova File System plugin. +// Type definitions for Apache Cordova File System plugin // Project: https://github.com/apache/cordova-plugin-file // Definitions by: Microsoft Open Technologies, Inc. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 915fd561991a100071ce072acb445344ba4001b8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 16 Sep 2016 15:48:23 -0700 Subject: [PATCH 3/3] Fix more header punctuation --- cordova-plugin-contacts/index.d.ts | 2 +- cordova-plugin-file/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cordova-plugin-contacts/index.d.ts b/cordova-plugin-contacts/index.d.ts index 6728b991d6..f0979ba6c2 100644 --- a/cordova-plugin-contacts/index.d.ts +++ b/cordova-plugin-contacts/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Apache Cordova Contacts plugin // Project: https://github.com/apache/cordova-plugin-contacts -// Definitions by: Microsoft Open Technologies, Inc. +// Definitions by: Microsoft Open Technologies Inc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Copyright (c) Microsoft Open Technologies, Inc. diff --git a/cordova-plugin-file/index.d.ts b/cordova-plugin-file/index.d.ts index 3243632714..6aadbf6fad 100644 --- a/cordova-plugin-file/index.d.ts +++ b/cordova-plugin-file/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Apache Cordova File System plugin // Project: https://github.com/apache/cordova-plugin-file -// Definitions by: Microsoft Open Technologies, Inc. +// Definitions by: Microsoft Open Technologies Inc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Copyright (c) Microsoft Open Technologies, Inc.