diff --git a/gulp-jshint/gulp-jshint-tests.ts b/gulp-jshint/gulp-jshint-tests.ts new file mode 100644 index 0000000000..fe4d930418 --- /dev/null +++ b/gulp-jshint/gulp-jshint-tests.ts @@ -0,0 +1,16 @@ +/// +/// +import gulp = require("gulp"); +import jshint = require("gulp-jshint"); + + +gulp.task('check1', function() { + gulp.src('lib/*.ts') + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('check2', function() { + gulp.src('lib/*.ts') + .pipe(jshint({ linter: 'jshint', lookup: true })); +}); \ No newline at end of file diff --git a/gulp-jshint/gulp-jshint.d.ts b/gulp-jshint/gulp-jshint.d.ts new file mode 100644 index 0000000000..5e57694e48 --- /dev/null +++ b/gulp-jshint/gulp-jshint.d.ts @@ -0,0 +1,29 @@ +// Type definitions for gulp-jshint +// Project: https://github.com/spalger/gulp-jshint +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-jshint" { + function GulpJSHint(options?: IGulpJSHintOptions): NodeJS.ReadWriteStream; + + interface IGulpJSHintOptions { + /** + * When false do not lookup .jshintrc files. See the JSHint docs for more info. + * Default true. + */ + lookup?: boolean; + + /** + * Either the name of a module to use for linting the code or a linting function itself. This enables using an alternate (but jshint compatible) linter like "jsxhint". + * Default is "jshint" + */ + linter?: string; + } + + namespace GulpJSHint { + declare function reporter(kind: (string | Object)); + } + export = GulpJSHint; +} diff --git a/gulp-notify/gulp-notify-tests.ts b/gulp-notify/gulp-notify-tests.ts new file mode 100644 index 0000000000..0c434b4321 --- /dev/null +++ b/gulp-notify/gulp-notify-tests.ts @@ -0,0 +1,41 @@ +/// +/// +import gulp = require("gulp"); +import notify = require("gulp-notify"); + +var custom = notify.withReporter(function(options, callback) { + console.log("Title:", options.title); + console.log("Message:", options.message); + callback(); +}); + +notify.on('click', (options) => { + console.log('I clicked something!', options); +}); + +notify.on('timeout', (options) => { + console.log('The notification timed out', options); +}); + +gulp.task('notify1', function() { + gulp.src("./src/test.ext") + .pipe(notify("Hello Gulp! From file: <%= file.relative %>")); +}); + +gulp.task('notify2', function() { + gulp.src("./src/test.ext") + .pipe(notify({ + message: "Generated file: <%= file.relative %> @ <%= options.date %>", + templateOptions: { + date: new Date() + } + })); +}); + +gulp.task('notify3', function() { + gulp.src("./src/test.ext") + .pipe(custom("This is a message.")) + .on("error", notify.onError((error: Error) => { + return "Message to the notifier: " + error.message; + }); +}); \ No newline at end of file diff --git a/gulp-notify/gulp-notify.d.ts b/gulp-notify/gulp-notify.d.ts new file mode 100644 index 0000000000..a1e00514fa --- /dev/null +++ b/gulp-notify/gulp-notify.d.ts @@ -0,0 +1,113 @@ +// Type definitions for gulp-jshint +// Project: https://github.com/mikaelbr/gulp-notify +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-notify" { + function GulpNotify(param: string | Function | GulpNotifyOptions): NodeJS.ReadWriteStream; + + interface GulpNotifyOptions { + /** + * Type: Boolean Default: false + * If the notification should only happen on the last file of the stream. Per default a notification is triggered on each file. + */ + onLast?: boolean; + + /** + * Type: Boolean Default: false + * If the returned stream should emit an error or not. If emitError is true, you have to handle .on('error') manually in case the notifier (gulp-notify) fails. If the default false is set, the error will not be emitted but simply printed to the console. + * This means you can run the notifier on a CI system without opting it out but simply letting it fail gracefully. + */ + emitError?: boolean; + + /** + * Type: String Default: File path in stream + * + * The message you wish to attach to file. The string can be a lodash template as it is passed through gulp-util.template. + * + * Example: Created <%= file.relative %>. + * as function + * + * Type: Function(vinylFile) + * + * See notify(Function). + */ + message?: string | Function; + + /** + * Type: String Default: "Gulp Notification" + * + * The title of the notification. The string can be a lodash template as it is passed through gulp-util.template. + * + * Example: Created <%= file.relative %>. + * as function + * + * Type: Function(vinylFile) + * + * See notify(Function). + */ + title?: string | Function; + + /** + * Object passed to the lodash template, for additional properties passed to the template. + */ + templateOptions?: Object; + + /** + * Type: Function(options, callback) Default: node-notifier module + * + * Swap out the notifier by passing in an function. The function expects two arguments: options and callback. + * + * The callback must be called when the notification is finished. Options will contain both title and message. + * + * See notify.withReporter for syntactic sugar. + */ + notifier?: (options, callback) => void; + + /** + * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. + */ + wait?: boolean; + } + + namespace GulpNotify { + + /** + * If the wait option is set to true, the notifier will tigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream. + */ + function on(event: string, callback: (notificationOptions?: Object) => void): void; + + /** + * Wraps options.notifier to return a new notify-function only using the passed in reporter. + */ + function withReporter(reporter: (options: GulpNotifyOptions, callback: () => void) => void): (message: string | Function) => NodeJS.ReadWriteStream; + + + /** + * The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead. + */ + function onError(callback: (string | (error: Error) => string | GulpNotifyOptions)): NodeJS.ReadWriteStream; + + /** + * Type: Integer Default: 2 + * + * Set if logger should be used or not. If log level is set to 0, no logging will be used. If no new log level is passed, the current log level is returned. + * + * 0: No logging + * 1: Log on error + * 2: Log both on error and regular notification. + * + * If logging is set to > 0, the title and message passed to gulp-notify will be logged like so: + * ➜ gulp-notify git:(master) ✗ gulp --gulpfile examples/gulpfile.js one + * [gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js + * [gulp] Working directory changed to /Users/example/repos/gulp-notify/examples + * [gulp] Running 'one'... + * [gulp] Finished 'one' in 4.08 ms + * [gulp] gulp-notify: [Gulp notification] /Users/example/gulp-notify/test/fixtures/1.txt + */ + function logLevel(level: number): void; + } + export = GulpNotify; +} diff --git a/typescript-require/typescript-require-tests.ts b/typescript-require/typescript-require-tests.ts new file mode 100644 index 0000000000..6269a4b9d3 --- /dev/null +++ b/typescript-require/typescript-require-tests.ts @@ -0,0 +1,7 @@ +/// + +require('typescript-require')({ + nodeLib: false, + targetES5: true, + exitOnError: true +}); diff --git a/typescript-require/typescript-require.d.ts b/typescript-require/typescript-require.d.ts new file mode 100644 index 0000000000..68b24ca274 --- /dev/null +++ b/typescript-require/typescript-require.d.ts @@ -0,0 +1,31 @@ +// Type definitions for typescript-require +// Project: https://github.com/theblacksmith/typescript-require +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "typescript-require" { + function TypeScriptRequire(options?: TypeScriptRequireOptions): void; + + interface TypeScriptRequireOptions { + /** + * If true node.d.ts definitions file is loaded before custom ts files. This is disabled by default and you should use. + * Default false. + */ + nodeLib?: boolean; + + /** + * Target ES5 / ES3 output mode. + * Default true. + */ + targetES5?: boolean; + + /** + * Wether execution should stop on compile error. + */ + exitOnError?: boolean; + } + + export = TypeScriptRequire; +}