Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Kiyotoshi Ichikawa
2018-04-18 11:11:48 -04:00
43 changed files with 21441 additions and 4898 deletions
+1
View File
@@ -1858,6 +1858,7 @@
/types/jsonstream/ @Bartvds
/types/jsontoxml/ @benstevens48
/types/jsonwebtoken/ @SomaticIT @danielheim @brikou
/types/jsonwebtoken-promisified @aneilbaboo
/types/jspdf/ @amberjs
/types/jsqrcode/ @lordazzi
/types/jsrender/ @zakki
+5 -4
View File
@@ -7236,6 +7236,9 @@ declare namespace chrome.webNavigation {
* @since Chrome 17.
*/
declare namespace chrome.webRequest {
/** How the requested resource will be used. */
export type ResourceType = "main_frame" | "sub_frame" | "stylesheet" | "script" | "image" | "font" | "object" | "xmlhttprequest" | "ping" | "csp_report" | "media" | "websocket" | "other";
export interface AuthCredentials {
username: string;
password: string;
@@ -7277,9 +7280,8 @@ declare namespace chrome.webRequest {
tabId?: number;
/**
* A list of request types. Requests that cannot match any of the types will be filtered out.
* Each element one of: "main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", or "other"
*/
types?: string[];
types?: ResourceType[];
/** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */
urls: string[];
@@ -7330,9 +7332,8 @@ declare namespace chrome.webRequest {
tabId: number;
/**
* How the requested resource will be used.
* One of: "main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", or "other"
*/
type: string;
type: ResourceType;
/** The time when this signal is triggered, in milliseconds since the epoch. */
timeStamp: number;
}
+7 -7
View File
@@ -312,19 +312,19 @@ declare namespace cropperjs {
/**
* the offset left of the crop box
*/
left?: number;
left: number;
/**
* the offset top of the crop box
*/
top?: number;
top: number;
/**
* the width of the crop box
*/
width?: number;
width: number;
/**
* the height of the crop box
*/
height?: number;
height: number;
}
interface CanvasData {
/**
@@ -516,7 +516,7 @@ declare class cropperjs {
/**
* Change the cropped area position and size with new data (base on the original image).
*/
setData(data: cropperjs.Data): void;
setData(data: Partial<cropperjs.Data>): void;
/**
* Output the container size data.
@@ -545,7 +545,7 @@ declare class cropperjs {
/**
* Change the canvas (image wrapper) position and size with new data.
*/
setCanvasData(data: cropperjs.CanvasData): void;
setCanvasData(data: Partial<cropperjs.CanvasData>): void;
/**
* Output the crop box position and size data.
@@ -555,7 +555,7 @@ declare class cropperjs {
/**
* Change the crop box position and size with new data.
*/
setCropBoxData(data: cropperjs.CropBoxData): void;
setCropBoxData(data: Partial<cropperjs.CropBoxData>): void;
/**
* Get a canvas drawn the cropped image.
+22 -1
View File
@@ -4,6 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from 'events';
/** Declaration file generated by dts-gen */
@@ -17,7 +18,27 @@ export class Advertisement {
updateTXT(txtObj: any): void;
}
export class Browser {
/**
* A service entry as returned by serviceUp
*/
export class Service {
fullname: string; // 'InstanceName._googlecast._tcp.local.'
name: string; // 'InstanceName'
type: SType; // { name: 'googlecast'; protocol: 'tcp' }
domain: string; // 'local'
host: string; // 'Hostname.local.'
port: number; // 8009
addresses: string[]; // ['192.168.1.15']
txt: any; // { id: 'strings' }
txtRaw: any;
}
export class SType {
name: string;
protocol: string;
}
export class Browser extends EventEmitter {
constructor(type: any, ...args: any[]);
list(): any;
+2 -2
View File
@@ -521,11 +521,11 @@ declare module 'ember-data' {
/**
* Get the reference for the specified belongsTo relationship.
*/
belongsTo(name: keyof ModelRegistry): BelongsToReference;
belongsTo(name: RelationshipsFor<this>): BelongsToReference;
/**
* Get the reference for the specified hasMany relationship.
*/
hasMany(name: keyof ModelRegistry): HasManyReference<any>;
hasMany(name: RelationshipsFor<this>): HasManyReference<any>;
/**
* Given a callback, iterates over each of the relationships in the model,
* invoking the callback with the name of each relationship and its relationship
+9
View File
@@ -16,17 +16,23 @@ class Comment extends DS.Model {
author = DS.attr('string');
}
class Series extends DS.Model {
title = DS.attr('string');
}
class RelationalPost extends DS.Model {
title = DS.attr('string');
tag = DS.attr('string');
comments = DS.hasMany('comment', { async: true });
relatedPosts = DS.hasMany('post');
series = DS.belongsTo('series');
}
declare module 'ember-data' {
interface ModelRegistry {
'relational-post': RelationalPost;
comment: Comment;
series: Series;
}
}
@@ -35,3 +41,6 @@ blogPost!.get('comments').then((comments) => {
// now we can work with the comments
let author: string = comments.get('firstObject')!.get('author');
});
blogPost!.hasMany('relatedPosts');
blogPost!.belongsTo('series');
+2 -2
View File
@@ -325,7 +325,7 @@ declare module 'ember' {
* `inject`) or for service lookup. Each factory is registered with
* a full name including two parts: `type:name`.
*/
register(fullName: string, factory: Function, options: {}): any;
register(fullName: string, factory: Function, options?: { singleton?: boolean, instantiate?: boolean }): any;
/**
* Unregister a factory.
*/
@@ -1243,7 +1243,7 @@ declare module 'ember' {
* Returns a new enumerable that contains only items containing a unique property value.
* The default implementation returns an array regardless of the receiver type.
*/
uniqBy(): NativeArray<T>;
uniqBy(property: string): NativeArray<T>;
/**
* Returns `true` if the passed object can be found in the enumerable.
*/
+17
View File
@@ -0,0 +1,17 @@
import ApplicationInstance from '@ember/application/instance';
const appInstance = ApplicationInstance.create();
appInstance.register('some:injection', class Foo {});
appInstance.register('some:injection', class Foo {}, {
singleton: true,
});
appInstance.register('some:injection', class Foo {}, {
instantiate: false,
});
appInstance.register('some:injection', class Foo {}, {
singleton: false,
instantiate: true,
});
+3
View File
@@ -16,3 +16,6 @@ assertType<number>(array.get('length'));
assertType<Person | undefined>(array.get('firstObject'));
assertType<string[]>(array.mapBy('name'));
assertType<string[]>(array.map(p => p.get('name')));
assertType<Person[]>(array.sortBy('name'));
assertType<Person[]>(array.uniq());
assertType<Person[]>(array.uniqBy('name'));
+1
View File
@@ -22,6 +22,7 @@
"index.d.ts",
"test/lib/assert.ts",
"test/application.ts",
"test/application-instance.ts",
"test/ember-tests.ts",
"test/error.ts",
"test/event.ts",
+6 -1
View File
@@ -223,7 +223,8 @@ boolean = memberExpression.computed;
// Declarations
var functionDeclaration: ESTree.FunctionDeclaration;
identifier = functionDeclaration.id;
var identifierOrNull: ESTree.Identifier | null = functionDeclaration.id;
functionDeclaration.id = null;
var params: Array<ESTree.Pattern> = functionDeclaration.params;
blockStatement = functionDeclaration.body;
booleanMaybe = functionDeclaration.generator;
@@ -237,6 +238,10 @@ var variableDeclarator: ESTree.VariableDeclarator;
pattern = variableDeclarator.id; // Pattern
expressionMaybe = variableDeclarator.init;
var classDeclaration: ESTree.ClassDeclaration;
identifierOrNull = classDeclaration.id;
classDeclaration.id = null;
// Clauses
// SwitchCase
string = switchCase.type;
+4 -2
View File
@@ -196,7 +196,8 @@ interface BaseDeclaration extends BaseStatement { }
export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
type: "FunctionDeclaration";
id: Identifier;
/** It is null when a function declaration is a part of the `export default function` statement */
id: Identifier | null;
body: BlockStatement;
}
@@ -473,7 +474,8 @@ export interface MethodDefinition extends BaseNode {
export interface ClassDeclaration extends BaseClass, BaseDeclaration {
type: "ClassDeclaration";
id: Identifier;
/** It is null when a class declaration is a part of the `export default class` statement */
id: Identifier | null;
}
export interface ClassExpression extends BaseClass, BaseExpression {
@@ -6,7 +6,7 @@ const app = express();
// Logger with all options
app.use(expressWinston.logger({
baseMeta: { foo: 'foo' },
baseMeta: { foo: 'foo', nested: { bar: 'baz' } },
bodyBlacklist: ['foo'],
bodyWhitelist: ['bar'],
colorize: true,
@@ -47,7 +47,7 @@ app.use(expressWinston.logger({
// Error Logger with all options
app.use(expressWinston.errorLogger({
baseMeta: { foo: 'foo' },
baseMeta: { foo: 'foo', nested: { bar: 'baz' } },
dynamicMeta: (req, res, err) => ({ foo: 'bar' }),
level: (req, res) => 'level',
metaField: 'metaField',
+3 -7
View File
@@ -7,18 +7,14 @@
import { ErrorRequestHandler, Handler, Request, Response } from 'express';
import { TransportInstance, Winston } from 'winston';
export interface MetaObject {
[field: string]: string;
}
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => MetaObject | undefined;
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => object;
export type DynamicLevelFunction = (req: Request, res: Response, err: Error) => string;
export type RequestFilter = (req: Request, propName: string) => boolean;
export type ResponseFilter = (res: Response, propName: string) => boolean;
export type RouteFilter = (req: Request, res: Response) => boolean;
export interface BaseLoggerOptions {
baseMeta?: MetaObject;
baseMeta?: object;
bodyBlacklist?: string[];
bodyWhitelist?: string[];
colorize?: boolean;
@@ -55,7 +51,7 @@ export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinst
export function logger(options: LoggerOptions): Handler;
export interface BaseErrorLoggerOptions {
baseMeta?: MetaObject;
baseMeta?: object;
dynamicMeta?: DynamicMetaFunction;
level?: string | DynamicLevelFunction;
metaField?: string;
+20729 -4813
View File
File diff suppressed because it is too large Load Diff
+188
View File
@@ -0,0 +1,188 @@
// Type definitions for jsonwebtoken-promisified 1.0
// Project: https://github.com/joepie91/node-jsonwebtoken-promisified
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>,
// Daniel Heim <https://github.com/danielheim>,
// Brice BERNARD <https://github.com/brikou>
// Aneil Mallavarapu <https://github.com/aneilbaboo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
export class JsonWebTokenError extends Error {
inner: Error;
constructor(message: string, error?: Error);
}
export class TokenExpiredError extends JsonWebTokenError {
expiredAt: number;
constructor(message: string, expiredAt: number);
}
export class NotBeforeError extends JsonWebTokenError {
date: Date;
constructor(message: string, date: Date);
}
export interface SignOptions {
/**
* Signature algorithm. Could be one of these values :
* - HS256: HMAC using SHA-256 hash algorithm (default)
* - HS384: HMAC using SHA-384 hash algorithm
* - HS512: HMAC using SHA-512 hash algorithm
* - RS256: RSASSA using SHA-256 hash algorithm
* - RS384: RSASSA using SHA-384 hash algorithm
* - RS512: RSASSA using SHA-512 hash algorithm
* - ES256: ECDSA using P-256 curve and SHA-256 hash algorithm
* - ES384: ECDSA using P-384 curve and SHA-384 hash algorithm
* - ES512: ECDSA using P-521 curve and SHA-512 hash algorithm
* - none: No digital signature or MAC value included
*/
algorithm?: string;
keyid?: string;
/** {string} - expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms.js). Eg: 60, "2 days", "10h", "7d" */
expiresIn?: string | number;
/** {string} - expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms.js). Eg: 60, "2 days", "10h", "7d" */
notBefore?: string | number;
audience?: string | string[];
subject?: string;
issuer?: string;
jwtid?: string;
noTimestamp?: boolean;
header?: object;
encoding?: string;
}
export interface VerifyOptions {
algorithms?: string[];
audience?: string | string[];
clockTimestamp?: number;
clockTolerance?: number;
issuer?: string | string[];
ignoreExpiration?: boolean;
ignoreNotBefore?: boolean;
jwtid?: string;
subject?: string;
/**
* @deprecated
* {string} - Max age of token
*/
maxAge?: string;
}
export interface DecodeOptions {
complete?: boolean;
json?: boolean;
}
export type VerifyCallback = (
err: JsonWebTokenError | NotBeforeError | TokenExpiredError,
decoded: object | string
) => void;
export type SignCallback = (err: Error, encoded: string) => void;
export type Secret = string | Buffer | { key: string; passphrase: string };
/**
* Synchronously sign the given payload into a JSON Web Token string
* @param payload - Payload to sign, could be an literal, buffer or string
* @param secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
* @param [options] - Options for the signature
* @returns The JSON Web Token string
*/
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options?: SignOptions,
): string;
/**
* Sign the given payload into a JSON Web Token string
* @param payload - Payload to sign, could be an literal, buffer or string
* @param secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
* @param options - Options for the signature
* @param callback - Callback to get the encoded token on
*/
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
callback: SignCallback,
): void;
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options: SignOptions,
callback: SignCallback,
): void;
/**
* Sign the given payload asynchronously into a JSON Web Token String
* @param payload - Payload to sign, could be an literal, buffer or string
* @param secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
* @param [options] - Options for the signature
* @returns A promise providing JSON Web Token string
*/
export function signAsync(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options?: SignOptions
): Promise<string>;
/**
* Synchronously verify given token using a secret or a public key to get a decoded token
* @param token - JWT string to verify
* @param secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
* @param [options] - Options for the verification
* @returns The decoded token.
*/
export function verify(
token: string,
secretOrPublicKey: string | Buffer,
options?: VerifyOptions,
): object | string;
/**
* Asynchronously verify given token using a secret or a public key to get a decoded token
* @param token - JWT string to verify
* @param secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
* @param options - Options for the verification
* @param callback - Callback to get the decoded token on
*/
export function verify(
token: string,
secretOrPublicKey: string | Buffer,
callback?: VerifyCallback
): void;
export function verify(
token: string,
secretOrPublicKey: string | Buffer,
options: VerifyOptions,
callback?: VerifyCallback
): void;
/**
* Asynchronously verify given token using a secret or a public key to get a decoded token
* @param token - the JWT string to verify
* @param secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
* @returns - Promise returning the decoded token
*/
export function verifyAsync(
token: string,
secretOrPublicKey: string | Buffer,
options?: VerifyOptions
): Promise<object|string>;
/**
* Returns the decoded payload without verifying if the signature is valid.
* @param token - JWT string to decode
* @param [options] - Options for decoding
* @returns The decoded Token
*/
export function decode(
token: string,
options?: DecodeOptions,
): null | { [key: string]: any } | string;
@@ -0,0 +1,148 @@
/**
* Test suite created by Maxime LUCE <https://github.com/SomaticIT>
*
* Created by using code samples from https://github.com/auth0/node-jsonwebtoken.
*/
import jwt = require("jsonwebtoken-promisified");
import fs = require("fs");
let token: string;
let cert: Buffer;
interface TestObject {
foo: string;
}
const testObject = { foo: "bar" };
/**
* jwt.sign
* https://github.com/auth0/node-jsonwebtoken#usage
*/
// sign with default (HMAC SHA256)
token = jwt.sign(testObject, "shhhhh");
// sign with default (HMAC SHA256) and single audience
token = jwt.sign(testObject, "shhhhh", { audience: "theAudience" });
// sign with default (HMAC SHA256) and multiple audiences
token = jwt.sign(testObject, "shhhhh", {
audience: ["audience1", "audience2"],
});
// sign with default (HMAC SHA256) and a keyid
token = jwt.sign(testObject, "shhhhh", { keyid: "theKeyId" });
// sign with RSA SHA256
cert = fs.readFileSync("private.key"); // get private key
token = jwt.sign(testObject, cert, { algorithm: "RS256" });
// sign with encrypted RSA SHA256 private key (only PEM encoding is supported)
const privKey: Buffer = fs.readFileSync("encrypted_private.key"); // get private key
const secret = { key: privKey.toString(), passphrase: "keypwd" };
token = jwt.sign(testObject, secret, { algorithm: "RS256" }); // the algorithm option is mandatory in this case
// sign asynchronously
jwt.sign(testObject, cert, { algorithm: "RS256" }, (
err: Error,
token: string,
) => {
console.log(token);
});
jwt.signAsync(testObject, cert, { algorithm: "RS256" }).then(
(token: string) => console.log(token)
);
/**
* jwt.verify
* https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback
*/
// verify a token symmetric
jwt.verify(token, "shhhhh", (
err: jwt.JsonWebTokenError | jwt.NotBeforeError | jwt.TokenExpiredError,
decoded: object | string
) => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
jwt.verifyAsync(token, "shhhhh").then(decoded => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
// use external time for verifying
jwt.verify(token, 'shhhhh', { clockTimestamp: 1 }, (err, decoded) => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
jwt.verifyAsync(token, 'shhhhh', { clockTimestamp: 1 }).then(decoded => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
// invalid token
jwt.verify(token, "wrong-secret", (err, decoded) => {
// err
// decoded undefined
});
// verify a token asymmetric
cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, (err, decoded) => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
jwt.verifyAsync(token, cert).then(decoded => {
const result = decoded as TestObject;
console.log(result.foo); // bar
});
// verify audience
cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, { audience: "urn:foo" }, (err, decoded) => {
// if audience mismatch, err == invalid audience
});
// verify issuer
cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, { audience: "urn:foo", issuer: "urn:issuer" }, (
err,
decoded,
) => {
// if issuer mismatch, err == invalid issuer
});
// verify algorithm
cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, { algorithms: ["RS256"] }, (err, decoded) => {
// if algorithm mismatch, err == invalid algorithm
});
// verify without expiration check
cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, { ignoreExpiration: true }, (err, decoded) => {
// if ignoreExpration == false and token is expired, err == expired token
});
/**
* jwt.decode
* https://github.com/auth0/node-jsonwebtoken#jwtdecodetoken
*/
let decoded = jwt.decode(token);
decoded = jwt.decode(token, { complete: false });
if (decoded !== null && typeof decoded === "object") {
console.log(decoded.foo);
}
decoded = jwt.decode(token, { json: false });
decoded = jwt.decode(token, { complete: false, json: false });
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsonwebtoken-promisified-tests.ts"
]
}
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+2 -2
View File
@@ -107,7 +107,7 @@ export class Pool extends events.EventEmitter {
query(queryStream: QueryConfig & stream.Readable): stream.Readable;
query(queryConfig: QueryArrayConfig): Promise<QueryArrayResult>;
query(queryConfig: QueryConfig): Promise<QueryResult>;
query(queryText: string, values?: any[]): Promise<QueryResult>;
query(queryTextOrConfig: string | QueryConfig, values?: any[]): Promise<QueryResult>;
query(queryConfig: QueryArrayConfig, callback: (err: Error, result: QueryArrayResult) => void): Query;
query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query;
query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query;
@@ -125,7 +125,7 @@ export class ClientBase extends events.EventEmitter {
query(queryStream: QueryConfig & stream.Readable): stream.Readable;
query(queryConfig: QueryArrayConfig): Promise<QueryArrayResult>;
query(queryConfig: QueryConfig): Promise<QueryResult>;
query(queryText: string, values?: any[]): Promise<QueryResult>;
query(queryTextOrConfig: string | QueryConfig, values?: any[]): Promise<QueryResult>;
query(queryConfig: QueryArrayConfig, callback: (err: Error, result: QueryArrayResult) => void): Query;
query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query;
query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query;
+11
View File
@@ -66,6 +66,14 @@ client.query(query)
.catch(e => {
console.error(e.stack);
});
client.query(query, ['brianc'])
.then(res => {
console.log(res.rows);
console.log(res.fields.map(f => f.name));
})
.catch(e => {
console.error(e.stack);
});
const queryArrMode: QueryArrayConfig = {
name: 'get-name-array',
@@ -156,6 +164,9 @@ pool.query('SELECT $1::text as name', ['brianc'], (err, result) => {
pool.query('SELECT $1::text as name', ['brianc'])
.then((res) => console.log(res.rows[0].name))
.catch(err => console.error('Error executing query', err.stack));
pool.query({ text: 'SELECT $1::text as name' }, ['brianc'])
.then((res) => console.log(res.rows[0].name))
.catch(err => console.error('Error executing query', err.stack));
pool.end(() => {
console.log('pool has ended');
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for promise-timeout 1.3
// Project: https://github.com/building5/promise-timeout#readme
// Definitions by: Aankhen <https://github.com/Aankhen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function timeout<T>(promise: Promise<T>, timeoutMillis: number): Promise<T>;
export class TimeoutError extends Error { }
@@ -0,0 +1,10 @@
import { timeout, TimeoutError } from "promise-timeout";
function acceptError(e: Error) { }
acceptError(new TimeoutError());
timeout(); // $ExpectError
timeout(new Promise(() => { })); // $ExpectError
timeout(new Promise(() => { }), 1000); // $ExpectType Promise<{}>
+23
View File
@@ -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",
"promise-timeout-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+7 -4
View File
@@ -23,6 +23,9 @@
declare let R: R.Static;
declare namespace R {
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends string> = Pick<T, Diff<keyof T, K>>;
type Ord = number | string | boolean;
type Path = ReadonlyArray<(number | string)>;
@@ -1174,8 +1177,8 @@ declare namespace R {
/**
* Returns a partial copy of an object omitting the keys specified.
*/
omit<T>(names: ReadonlyArray<string>, obj: T): T;
omit(names: ReadonlyArray<string>): <T>(obj: T) => T;
omit<T, K extends string>(names: ReadonlyArray<K>, obj: T): Omit<T, K>;
omit<K extends string>(names: ReadonlyArray<K>): <T>(obj: T) => Omit<T, K>;
/**
* Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be
@@ -1285,8 +1288,8 @@ declare namespace R {
* Returns a partial copy of an object containing only the keys specified. If the key does not exist, the
* property is ignored.
*/
pick<T, K extends keyof T>(names: ReadonlyArray<K | string>, obj: T): Pick<T, K>;
pick(names: ReadonlyArray<string>): <T, U>(obj: T) => U;
pick<T, K extends string>(names: ReadonlyArray<K>, obj: T): Pick<T, Diff<keyof T, keyof Omit<T, K>>>;
pick<K extends string>(names: ReadonlyArray<K>): <T>(obj: T) => Pick<T, Diff<keyof T, keyof Omit<T, K>>>;
/**
* Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
+1 -1
View File
@@ -142,7 +142,7 @@ declare namespace ReactIntl {
interface Props extends MessageDescriptor {
values?: {[key: string]: MessageValue | JSX.Element};
tagName?: string;
children?: (formattedMessage: string[]) => React.ReactNode;
children?: (...formattedMessage: string[]) => React.ReactNode;
}
}
class FormattedMessage extends React.Component<FormattedMessage.Props> { }
+14
View File
@@ -150,6 +150,20 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
{(text) => <div className="messageDiv">{text}</div>}
</FormattedMessage>
<FormattedMessage
id="test"
description="Test"
>
{(text) => <input placeholder={text} />}
</FormattedMessage>
<FormattedMessage
id="test"
description="Test"
>
{(...text) => <ul>{text.map(t => <li>{t}</li>)}</ul>}
</FormattedMessage>
<FormattedHTMLMessage
id="test"
description="Test"
+15
View File
@@ -3736,6 +3736,14 @@ export interface SectionListData<ItemT> extends SectionBase<ItemT> {
[key: string]: any;
}
export interface SectionListScrollParams {
animated?: boolean;
itemIndex: number;
sectionIndex: number;
viewOffset?: number;
viewPosition?: number;
}
export interface SectionListProperties<ItemT> extends ScrollViewProperties {
/**
* Rendered in between adjacent Items within each section.
@@ -3844,6 +3852,13 @@ export interface SectionListProperties<ItemT> extends ScrollViewProperties {
* Only enabled by default on iOS because that is the platform standard there.
*/
stickySectionHeadersEnabled?: boolean;
/**
* Scrolls to the item at the specified sectionIndex and itemIndex (within the section)
* positioned in the viewable area such that viewPosition 0 places it at the top
* (and may be covered by a sticky header), 1 at the bottom, and 0.5 centered in the middle.
*/
scrollToLocation?(params: SectionListScrollParams): void;
}
export interface SectionListStatic<SectionT> extends React.ComponentClass<SectionListProperties<SectionT>> {}
+10 -9
View File
@@ -158,9 +158,7 @@ export interface NavigationScreenDetails<T> {
navigation: NavigationScreenProp<NavigationRoute>;
}
export interface NavigationScreenOptions {
title?: string;
}
export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions;
export interface NavigationScreenConfigProps {
navigation: NavigationScreenProp<NavigationRoute>;
@@ -289,7 +287,8 @@ export interface NavigationStackViewConfig {
onTransitionEnd?: () => void;
}
export type NavigationStackScreenOptions = NavigationScreenOptions & {
export interface NavigationStackScreenOptions {
title?: string;
header?: (React.ReactElement<any> | ((headerProps: HeaderProps) => React.ReactElement<any>)) | null;
headerTransparent?: boolean;
headerTitle?: string | React.ReactElement<any>;
@@ -305,14 +304,14 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & {
headerBackground?: React.ReactNode | React.ReactType;
gesturesEnabled?: boolean;
gestureResponseDistance?: { vertical?: number; horizontal?: number };
};
}
export interface NavigationStackRouterConfig {
headerTransitionPreset?: 'fade-in-place' | 'uikit';
initialRouteName?: string;
initialRouteParams?: NavigationParams;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationStackScreenOptions>;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
}
export type NavigationStackAction =
@@ -352,7 +351,7 @@ export interface NavigationPathsConfig {
export interface NavigationTabRouterConfig {
initialRouteName?: string;
paths?: NavigationPathsConfig;
navigationOptions?: NavigationScreenConfig<NavigationTabScreenOptions>;
navigationOptions?: NavigationScreenConfig<NavigationScreenOptions>;
order?: string[]; // todo: type these as the real route names rather than 'string'
// Does the back button cause the router to switch to the initial tab
@@ -364,7 +363,8 @@ export interface TabScene {
index: number;
tintColor?: string;
}
export interface NavigationTabScreenOptions extends NavigationScreenOptions {
export interface NavigationTabScreenOptions {
title?: string;
tabBarIcon?:
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
@@ -384,7 +384,8 @@ export interface NavigationTabScreenOptions extends NavigationScreenOptions {
}) => void;
}
export interface NavigationDrawerScreenOptions extends NavigationScreenOptions {
export interface NavigationDrawerScreenOptions {
title?: string;
drawerIcon?:
React.ReactElement<any>
| ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement<
@@ -193,7 +193,10 @@ const tabNavigatorConfigWithNavigationOptions: TabNavigatorConfig = {
navigationOptions: {
tabBarOnPress: ({scene, jumpToIndex}) => {
jumpToIndex(scene.index);
}
},
headerStyle: {
backgroundColor: 'red',
},
},
};
+10
View File
@@ -54,6 +54,11 @@ export type ScrollParams = {
scrollTop: number;
scrollWidth: number;
};
export type ScrollbarPresenceParams = {
horizontal: boolean;
size: number;
vertical: boolean;
};
export type SectionRenderedParams = RenderedSection;
export type SCROLL_DIRECTION_HORIZONTAL = "horizontal";
export type SCROLL_DIRECTION_VERTICAL = "vertical";
@@ -237,6 +242,11 @@ export type GridCoreProps = {
* ({ clientHeight, clientWidth, scrollHeight, scrollLeft, scrollTop, scrollWidth }): void
*/
onScroll?: (params: ScrollParams) => any;
/**
* Called whenever a horizontal or vertical scrollbar is added or removed.
* ({ horizontal: boolean, size: number, vertical: boolean }): void
*/
onScrollbarPresenceChange?: (params: ScrollbarPresenceParams) => any;
/**
* Callback invoked with information about the section of the Grid that was just rendered.
* ({ columnStartIndex, columnStopIndex, rowStartIndex, rowStopIndex }): void
+40 -38
View File
@@ -1,8 +1,10 @@
// Type definitions for snekfetch 3.1
// Type definitions for snekfetch 3.6
// Project: https://github.com/GusCaplan/snekfetch
// Definitions by: Iker Pérez Brunelli <https://github.com/DarkerTV>
// Shayne Hartford <https://github.com/ShayBox>
// Yukine <https://github.com/Dev-Yukine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.4
/// <reference types="node" />
@@ -71,48 +73,48 @@ declare class Snekfetch extends Readable {
constructor(method: Snekfetch.methods, url: string, opts?: Snekfetch.SnekfetchOptions);
static acl(url: string): Snekfetch;
static bind(url: string): Snekfetch;
static checkout(url: string): Snekfetch;
static connect(url: string): Snekfetch;
static copy(url: string): Snekfetch;
static delete(url: string): Snekfetch;
static get(url: string): Snekfetch;
static head(url: string): Snekfetch;
static link(url: string): Snekfetch;
static lock(url: string): Snekfetch;
static msearch(url: string): Snekfetch;
static merge(url: string): Snekfetch;
static mkactivity(url: string): Snekfetch;
static mkcalendar(url: string): Snekfetch;
static mkcol(url: string): Snekfetch;
static move(url: string): Snekfetch;
static notify(url: string): Snekfetch;
static options(url: string): Snekfetch;
static patch(url: string): Snekfetch;
static post(url: string): Snekfetch;
static propfind(url: string): Snekfetch;
static proppatch(url: string): Snekfetch;
static purge(url: string): Snekfetch;
static put(url: string): Snekfetch;
static rebind(url: string): Snekfetch;
static report(url: string): Snekfetch;
static search(url: string): Snekfetch;
static subscribe(url: string): Snekfetch;
static trace(url: string): Snekfetch;
static unbind(url: string): Snekfetch;
static unlink(url: string): Snekfetch;
static unlock(url: string): Snekfetch;
static unsubscribe(url: string): Snekfetch;
static brew(url: string): Snekfetch;
static acl(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static bind(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static checkout(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static connect(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static copy(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static delete(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static get(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static head(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static link(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static lock(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static msearch(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static merge(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static mkactivity(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static mkcalendar(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static mkcol(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static move(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static notify(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static options(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static patch(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static post(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static propfind(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static proppatch(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static purge(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static put(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static rebind(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static report(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static search(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static subscribe(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static trace(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static unbind(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static unlink(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static unlock(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static unsubscribe(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
static brew(url: string, opts?: Snekfetch.SnekfetchOptions): Snekfetch;
query(name: string, value: string): Snekfetch;
query(name: string | { [key: string]: string | string[] }, value?: string): Snekfetch;
set(name: string | { [key: string]: string | string[] }, value?: string | string[]): Snekfetch;
attach(name: string, data: string | object | Buffer, filename?: string): Snekfetch;
send(data?: any): Snekfetch;
send(data?: string|Buffer|object): Snekfetch;
then(): Promise<Snekfetch.Result>;
then<T>(resolver: (res: Snekfetch.Result) => T, rejector?: (err: Error) => any): Promise<T>;
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for toobusy-js 0.5
// Project: https://github.com/STRML/node-toobusy
// Definitions by: Arne Schubert <https://github.com/atd-schubert>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = toobusy_js;
declare function toobusy_js(): boolean;
declare namespace toobusy_js {
function interval(newInterval: number): number;
function lag(): number;
function maxLag(newLag: number): number;
function smmothingFactor(newFactor: number): number;
function shutdown(): void;
function onLag(fn: (lag: number) => void, threshold?: number): void;
function started(): boolean;
}
+17
View File
@@ -0,0 +1,17 @@
import toobusy = require("toobusy-js");
let numberValue = 1;
let booleanValue = true;
booleanValue = toobusy();
booleanValue = toobusy.started();
numberValue = toobusy.interval(numberValue);
numberValue = toobusy.lag();
numberValue = toobusy.maxLag(numberValue);
numberValue = toobusy.smmothingFactor(numberValue);
toobusy.onLag((duration: number) => {});
toobusy.onLag((duration: number) => {}, numberValue);
toobusy.shutdown();
+23
View File
@@ -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",
"toobusy-js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -12,7 +12,7 @@ declare namespace tv4 {
description?: string; // used for humans only, and not used for computation
id?: string;
$schema?: string;
type?: string;
type?: string | string[];
items?: any;
properties?: any;
patternProperties?: any;
+1 -1
View File
@@ -129,7 +129,7 @@ schema = {
alert("data 2 error: " + JSON.stringify(validator.error, null, 4));
schema = {
"type": "array",
"type": ["array"],
"items": {"$ref": "#"}
};
}
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for write-file-atomically 2.0
// Project: https://github.com/shinnn/write-file-atomically#readme
// Definitions by: Aankhen <https://github.com/Aankhen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import writeFileAtomic = require("write-file-atomic");
export = WriteFileAtomically;
declare function WriteFileAtomically(path: string, data: WriteFileAtomically.Data, options?: writeFileAtomic.Options): Promise<void>;
declare namespace WriteFileAtomically {
type Data = string | Buffer | Uint8Array;
}
+23
View File
@@ -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",
"write-file-atomically-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,10 @@
import writeFileAtomically = require('write-file-atomically');
writeFileAtomically(1, '_'); // $ExpectError
import { readFileSync } from 'fs';
(() => {
writeFileAtomically('file.txt', 'Hi!');
readFileSync('file.txt', 'utf8');
})();