mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Updated gruntjs declaration and tests.
This commit is contained in:
23
express/express.d.ts
vendored
23
express/express.d.ts
vendored
@@ -405,6 +405,12 @@ declare module "express" {
|
||||
//cookies: { string; remember: boolean; };
|
||||
cookies: any;
|
||||
|
||||
/**
|
||||
* Used to generate an anti-CSRF token.
|
||||
* Placed by the CSRF protection middleware.
|
||||
*/
|
||||
csrfToken(): string;
|
||||
|
||||
method: string;
|
||||
|
||||
params: any;
|
||||
@@ -1063,9 +1069,11 @@ declare module "express" {
|
||||
* http.createServer(app).listen(80);
|
||||
* https.createServer({ ... }, app).listen(443);
|
||||
*/
|
||||
listen(port: number, hostname: string, backlog: number, callback: Function): void;
|
||||
listen(port: number, hostname: string, backlog: number, callback?: Function): void;
|
||||
|
||||
listen(port: number, callback: Function): void;
|
||||
listen(port: number, hostname: string, callback?: Function): void;
|
||||
|
||||
listen(port: number, callback?: Function): void;
|
||||
|
||||
listen(path: string, callback?: Function): void;
|
||||
|
||||
@@ -1471,13 +1479,12 @@ declare module "express" {
|
||||
/**
|
||||
* Anti CSRF:
|
||||
*
|
||||
* CRSF protection middleware.
|
||||
* CSRF protection middleware.
|
||||
*
|
||||
* By default this middleware generates a token named "_csrf"
|
||||
* This middleware adds a `req.csrfToken()` function to make a token
|
||||
* which should be added to requests which mutate
|
||||
* state, within a hidden form field, query-string etc. This
|
||||
* token is validated against the visitor's `req.session._csrf`
|
||||
* property.
|
||||
* token is validated against the visitor's session.
|
||||
*
|
||||
* The default `value` function checks `req.body` generated
|
||||
* by the `bodyParser()` middleware, `req.query` generated
|
||||
@@ -1488,11 +1495,11 @@ declare module "express" {
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `value` a function accepting the request, returning the token
|
||||
* - `value` a function accepting the request, returning the token
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
export function csrf(options: any): Handler;
|
||||
export function csrf(options?: {value?: Function}): Handler;
|
||||
|
||||
/**
|
||||
* Directory:
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
// Official code sample from
|
||||
// http://gruntjs.com/getting-started#an-example-gruntfile
|
||||
|
||||
interface MyTaskData {
|
||||
repeat: number;
|
||||
}
|
||||
|
||||
interface MyOptions {
|
||||
sourceRoot: string;
|
||||
}
|
||||
|
||||
// exports should work same as module.exports
|
||||
exports = (grunt: IGrunt) => {
|
||||
|
||||
@@ -26,6 +34,17 @@ exports = (grunt: IGrunt) => {
|
||||
// Default task(s).
|
||||
grunt.registerTask('default', ['uglify']);
|
||||
|
||||
grunt.registerMultiTask('mytask', "short description", function() {
|
||||
var currenttask: grunt.task.IMultiTask<MyTaskData> = this;
|
||||
var options = currenttask.options<MyOptions>({
|
||||
sourceRoot: "default"
|
||||
});
|
||||
var valid = false;
|
||||
valid = valid && options.sourceRoot === "default";
|
||||
valid = valid && currenttask.data.repeat > 0;
|
||||
return valid;
|
||||
});
|
||||
|
||||
|
||||
// util methods
|
||||
var testOneArg = (a: number) => a * 2;
|
||||
|
||||
19
gruntjs/gruntjs.d.ts
vendored
19
gruntjs/gruntjs.d.ts
vendored
@@ -760,10 +760,6 @@ declare module grunt {
|
||||
|
||||
module task {
|
||||
|
||||
interface TaskFunction extends ITask {
|
||||
(...args: any[]): boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link http://gruntjs.com/api/grunt.task}
|
||||
*/
|
||||
@@ -784,9 +780,9 @@ declare module grunt {
|
||||
* Task-specific properties and methods are available inside the task function as properties
|
||||
* of the this object. The task function can return false to indicate that the task has failed.
|
||||
*
|
||||
* @note taskFunction.apply(scope: grunt.task.IMultiTask, args: any[])
|
||||
* @note taskFunction.apply(scope: grunt.task.ITask, args: any[])
|
||||
*/
|
||||
registerTask(taskName: string, description: string, taskFunction: TaskFunction): void
|
||||
registerTask(taskName: string, description: string, taskFunction: Function): void
|
||||
|
||||
/**
|
||||
* Register a "multi task." A multi task is a task that implicitly iterates over all of its
|
||||
@@ -794,10 +790,10 @@ declare module grunt {
|
||||
* In addition to the default properties and methods, extra multi task-specific properties
|
||||
* are available inside the task function as properties of the this object.
|
||||
*
|
||||
* @note taskFunction.apply(scope: grunt.task.IMultiTask, args: any[])
|
||||
* @note taskFunction.apply(scope: grunt.task.IMultiTask<any>, args: any[])
|
||||
*/
|
||||
registerMultiTask(taskName: string, taskFunction: grunt.task.ITask): void
|
||||
registerMultiTask(taskName: string, taskDescription: string, taskFunction: TaskFunction): void
|
||||
registerMultiTask(taskName: string, taskFunction: Function): void
|
||||
registerMultiTask(taskName: string, taskDescription: string, taskFunction: Function): void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -917,9 +913,8 @@ declare module grunt {
|
||||
* object properties, which will be further overridden in multi tasks by any target-level
|
||||
* options object properties.
|
||||
*/
|
||||
// options<T>(defaultsObj: T): ITaskOptions
|
||||
// options<T>(defaultsObj: T): T
|
||||
options(defaultsObj: any): any
|
||||
options(defaultsObj: any): ITaskOptions
|
||||
options<T>(defaultsObj: T): T
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
33
node/node.d.ts
vendored
33
node/node.d.ts
vendored
@@ -15,11 +15,11 @@ declare var global: any;
|
||||
declare var __filename: string;
|
||||
declare var __dirname: string;
|
||||
|
||||
declare function setTimeout(callback: () => void , ms: number): any;
|
||||
declare function clearTimeout(timeoutId: any): void;
|
||||
declare function setInterval(callback: () => void , ms: number): any;
|
||||
declare function clearInterval(intervalId: any): void;
|
||||
declare function setImmediate(callback: () => void ): any;
|
||||
declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer;
|
||||
declare function clearTimeout(timeoutId: Timer): void;
|
||||
declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer;
|
||||
declare function clearInterval(intervalId: Timer): void;
|
||||
declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any;
|
||||
declare function clearImmediate(immediateId: any): void;
|
||||
|
||||
declare var require: {
|
||||
@@ -195,6 +195,11 @@ interface NodeBuffer {
|
||||
INSPECT_MAX_BYTES: number;
|
||||
}
|
||||
|
||||
interface Timer {
|
||||
ref() : void;
|
||||
unref() : void;
|
||||
}
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
* MODULES *
|
||||
@@ -799,8 +804,8 @@ declare module "fs" {
|
||||
export function readSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): any[];
|
||||
export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err: Error, data: any) => void): void;
|
||||
export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void;
|
||||
export function readFileSync(filename: string): NodeBuffer;
|
||||
export function readFileSync(filename: string, options: { encoding?: string; flag?: string; }): any;
|
||||
export function readFileSync(filename: string, options?: { flag?: string; }): NodeBuffer;
|
||||
export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
|
||||
export function writeFile(filename: string, data: any, callback?: (err: Error) => void): void;
|
||||
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: Error) => void): void;
|
||||
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: Error) => void): void;
|
||||
@@ -811,10 +816,11 @@ declare module "fs" {
|
||||
export function appendFile(filename: string, data: any, callback?: (err: Error) => void): void;
|
||||
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
|
||||
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
|
||||
export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void;
|
||||
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void;
|
||||
export function unwatchFile(filename: string, listener?: Stats): void;
|
||||
export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) =>any): FSWatcher;
|
||||
export function watchFile(filename: string, listener: (curr: Stats, prev: Stats)=>void): void;
|
||||
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats)=>void): void;
|
||||
export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats)=>void): void;
|
||||
export function watch(filename: string, listener?: (event: string, filename: string) =>any): FSWatcher;
|
||||
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) =>any): FSWatcher;
|
||||
export function exists(path: string, callback?: (exists: boolean) => void): void;
|
||||
export function existsSync(path: string): boolean;
|
||||
export function createReadStream(path: string, options?: {
|
||||
@@ -1003,7 +1009,10 @@ declare module "crypto" {
|
||||
}
|
||||
export function getDiffieHellman(group_name: string): DiffieHellman;
|
||||
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void;
|
||||
export function randomBytes(size: number, callback?: (err: Error, buf: NodeBuffer) =>void ): void;
|
||||
export function randomBytes(size: number): NodeBuffer;
|
||||
export function randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void;
|
||||
export function pseudoRandomBytes(size: number): NodeBuffer;
|
||||
export function pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void;
|
||||
}
|
||||
|
||||
declare module "stream" {
|
||||
|
||||
Reference in New Issue
Block a user