Merge branch 'types-2.0' into reference_types

This commit is contained in:
Andy Hanson
2016-09-19 06:40:51 -07:00
11 changed files with 416 additions and 161 deletions

View File

@@ -4,6 +4,7 @@ bowser.a === bowser.c;
bowser.osversion > 10;
bowser.osversion === '10.1A';
bowser.compareVersions(['9.0', '10']);
bowser() === <bowser.IBowserDetection>{android: true, x: true};
bowser() === {android: true, x: true};
bowser.check({msie: "11"}, window.navigator.userAgent);
bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);

View File

@@ -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';

View File

@@ -14,6 +14,7 @@
},
"files": [
"index.d.ts",
"bowser-tests.ts"
"bowser-tests-module.ts",
"bowser-tests-global.ts"
]
}

View File

@@ -0,0 +1,20 @@
/// <reference path="canvas-gauges.d.ts" />
import {
LinearGaugeOptions,
RadialGaugeOptions,
LinearGauge,
RadialGauge
} from 'canvas-gauges';
let linearOptions: LinearGaugeOptions = {
renderTo: document.createElement('canvas')
};
let radialOptions: RadialGaugeOptions = {
renderTo: 'gauge-id'
};
new LinearGauge(linearOptions);
new RadialGauge(radialOptions);
console.log(document.gauges.length);

263
canvas-gauges/canvas-gauges.d.ts vendored Normal file
View File

@@ -0,0 +1,263 @@
// Type definitions for canvas-gauges
// Project: https://github.com/Mikhus/canvas-gauges
// Definitions by: Mikhus <https://github.com/Mikhus>
// Definitions: https://github.com/Mikhus/DefinitelyTyped
declare namespace CanvasGauges {
export type RenderTarget = string|HTMLElement;
export interface AnimationRule {
(percent: number): number;
}
export interface Highlight {
from: number,
to: number,
color: string
}
export type MajorTicks = string[]|number[];
export interface GenericOptions {
renderTo: RenderTarget,
width?: number,
height?: number,
minValue?: number,
maxValue?: number,
value?: number,
units?: string|boolean,
majorTicks?: MajorTicks,
minorTicks?: number,
strokeTicks?: boolean,
animatedValue?: boolean,
title?: string|boolean,
borders?: boolean,
valueInt?: number,
valueDec?: number,
majorTicksInt?: number,
majorTicksDec?: number,
animation?: boolean,
animationDuration?: number,
animationRule?: string|AnimationRule,
colorPlate?: string,
colorMajorTicks?: string,
colorMinorTicks?: string,
colorTitle?: string,
colorUnits?: string,
colorNumbers?: string,
colorNeedle?: string,
colorNeedleEnd?: string,
colorValueText?: string,
colorValueTextShadow?: string,
colorBorderShadow?: string,
colorBorderOuter?: string,
colorBorderOuterEnd?: string,
colorBorderMiddle?: string,
colorBorderMiddleEnd?: string,
colorBorderInner?: string,
colorBorderInnerEnd?: string,
colorValueBoxRect?: string,
colorValueBoxRectEnd?: string,
colorValueBoxBackground?: string,
colorValueBoxShadow?: string,
colorNeedleShadowUp?: string,
colorNeedleShadowDown?: string,
needle?: boolean,
needleShadow?: boolean,
needleType?: string,
needleStart?: number,
needleEnd?: number,
needleWidth?: number,
borderOuterWidth?: number,
borderMiddleWidth?: number,
borderInnerWidth?: number,
borderShadowWidth?: number,
valueBox?: boolean,
valueBoxStroke?: number,
valueText?: string,
valueTextShadow?: boolean,
valueBoxBorderRadius?: number,
highlights?: Highlight[],
fontNumbers?: string,
fontTitle?: string,
fontUnits?: string,
fontValue?: string,
fontTitleSize?: number,
fontValueSize?: number,
fontUnitsSize?: number,
fontNumbersSize?: number
}
export interface RadialGaugeOptions extends GenericOptions {
ticksAngle?: number,
startAngle?: number,
colorNeedleCircleOuter?: string,
colorNeedleCircleOuterEnd?: string,
colorNeedleCircleInner?: string,
colorNeedleCircleInnerEnd?: string,
needleCircleSize?: number,
needleCircleInner?: boolean,
needleCircleOuter?: boolean,
animationTarget?: string
}
export interface LinearGaugeOptions extends GenericOptions {
borderRadius?: number,
barBeginCircle?: number,
barWidth?: number,
barStrokeWidth?: number,
barProgress?: boolean,
colorBar?: string,
colorBarEnd?: string,
colorBarStroke?: string,
colorBarProgress?: string,
colorBarProgressEnd?: string,
tickSide?: string,
needleSide?: string,
numberSide?: string,
ticksWidth?: number,
ticksWidthMinor?: number,
ticksPadding?: number,
barLength?: number
}
export interface DrawEventCallback {
(percent: number): any;
}
export interface EndEventCallback {
(): any;
}
export interface rules {
linear: AnimationRule,
quad: AnimationRule,
dequad: AnimationRule,
quint: AnimationRule,
dequint: AnimationRule,
cycle: AnimationRule,
decycle: AnimationRule,
bounce: AnimationRule,
debounce: AnimationRule,
elastic: AnimationRule,
delastic: AnimationRule
}
export class Animation {
public duration: number;
public rule: string|AnimationRule;
public draw: DrawEventCallback;
public end: EndEventCallback;
public static rules: rules;
constructor(rule?: string|AnimationRule, duration?: number,
draw?: DrawEventCallback, end?: EndEventCallback);
public animate(draw?: DrawEventCallback, end?: EndEventCallback): any;
public destroy(): any;
}
export class SmartCanvas {
public element: HTMLCanvasElement;
public elementClone: HTMLCanvasElement;
public context: CanvasRenderingContext2D;
public contextClone: CanvasRenderingContext2D;
public drawWidth: number;
public drawHeight: number;
public drawX: number;
public drawY: number;
public minSide: number;
public width: number;
public height: number;
constructor(element: HTMLCanvasElement,
width?: number,
height?: number);
public init(): any;
public onRedraw(): any;
public destroy(): any;
public commit(): SmartCanvas;
public redraw(): SmartCanvas;
public pixelRatio: number;
public static redraw(): any;
public static collection: Array<SmartCanvas>;
}
export class DomObserver {
public Type: BaseGauge;
public mutationsObserved: boolean;
public isObservable: boolean;
public options: GenericOptions;
public element: string;
public type: string;
constructor(options: GenericOptions,
element: string,
type: string);
public isValidNode(node: Node|HTMLElement): boolean;
public traverse(): any;
public observe(records: MutationRecord[]): any;
public process(node: Node|HTMLElement): BaseGauge;
public static parse(value: any): any;
public static toDashed(camelCase: string): string;
public static toAttributeName(str: string): string;
static domReady(handler: Function): any;
}
export abstract class BaseGauge {
public type: BaseGauge;
public options: GenericOptions;
public canvas: SmartCanvas;
public animation: Animation;
public value: number;
constructor(options: GenericOptions);
public update(options: GenericOptions): BaseGauge;
public destroy(): any;
public abstract draw(): BaseGauge;
public static initialize(type: string, options: GenericOptions): any;
}
export class RadialGauge extends BaseGauge {
public type: RadialGauge;
public options: RadialGaugeOptions;
constructor(options: RadialGaugeOptions);
public draw(): RadialGauge;
}
export class LinearGauge extends BaseGauge {
public type: LinearGauge;
public options: LinearGaugeOptions;
constructor(options: LinearGaugeOptions);
public draw(): LinearGauge;
}
export interface Collection extends Array<BaseGauge> {
get: (id: number | string) => BaseGauge;
}
}
declare module 'canvas-gauges' {
export = CanvasGauges;
}
interface Document {
gauges: CanvasGauges.Collection;
}
interface Window {
BaseGauge: CanvasGauges.BaseGauge;
RadialGauge: CanvasGauges.RadialGauge;
LinearGauge: CanvasGauges.LinearGauge;
}

View File

@@ -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. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.

View File

@@ -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. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.

1
gulp/index.d.ts vendored
View File

@@ -5,6 +5,7 @@
/// <reference types="node" />
/// <reference types="orchestrator" />
/// <reference types="vinyl" />
import Orchestrator = require("orchestrator");

View File

@@ -3,126 +3,125 @@
// Definitions by: simonxca <https://github.com/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<T> = YOUR_PROMISE<T>;
*/
/// <reference types="mongoose" />
/// <reference types="mpromise" />
/*
* 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<T> {
/**
* 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<T> = MongoosePromise<T>;
/*
* mpromise definitions.
* Callback signatures are from the mPromise type definitions.
*/
new(fn?: (err: any, arg: T) => void): MongoosePromise<T>;
new(fn?: (err: any, ...args: T[]) => void): MongoosePromise<T>;
class MongoosePromise<T> extends mpromise<T, any> {
/**
* 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<TRes>(onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
/**
* 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<TRes>(onFulFill: (arg: T) => void | TRes | PromiseLike<TRes>,
onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
then<TRes>(onFulfill: (...args: T[]) => void | TRes | PromiseLike<TRes>,
onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
/**
* 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<TRes>(resolver: (
complete: (...args: TRes[]) => void | TRes | PromiseLike<TRes>,
error: (e: any) => void | TRes | PromiseLike<TRes>
) => void): MongoosePromise<TRes>;
}
}
declare class MongoosePromise<T> {
/**
* 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<TRes>(onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
/**
* 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<TRes>(onFulFill: (arg: T) => void | TRes | PromiseLike<TRes>,
onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
then<TRes>(onFulfill: (...args: T[]) => void | TRes | PromiseLike<TRes>,
onReject?: (err: any) => void | TRes | PromiseLike<TRes>): MongoosePromise<TRes>;
/**
* 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<TRes>(resolver: (
complete: (...args: TRes[]) => void | TRes | PromiseLike<TRes>,
error: (e: any) => void | TRes | PromiseLike<TRes>
) => void): MongoosePromise<TRes>;
}

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",

View File

@@ -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:HeadersInit = {
'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:HeadersInit = {
'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:HeadersInit = {
'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<Response>) {
}).then((text) => {
console.log(text);
});
}
}