提交 f5850c95 编写于 作者: M Matt Bierner

Try using @types for typings instead of our custom versions in src/typings

上级 0fb32449
......@@ -63,10 +63,12 @@ function createCompile(src, build, emitError) {
};
}
var libDtsGlob = 'node_modules/typescript/lib/*.d.ts';
var atTypesDts = 'node_modules/@types/**/*.d.ts';
var excludedTypesFilter = util.filter(function (data) { return !/node_modules(\/|\\)@types(\/|\\)(node|webpack|uglify-js)(\/|\\)/.test(data.path); });
function compileTask(src, out, build) {
return function () {
var compile = createCompile(src, build, true);
var srcPipe = es.merge(gulp.src(src + "/**", { base: "" + src }), gulp.src(libDtsGlob));
var srcPipe = es.merge(gulp.src(src + "/**", { base: "" + src }), gulp.src(libDtsGlob), gulp.src(atTypesDts).pipe(excludedTypesFilter));
// Do not write .d.ts files to disk, as they are not needed there.
var dtsFilter = util.filter(function (data) { return !/\.d\.ts$/.test(data.path); });
return srcPipe
......@@ -81,7 +83,7 @@ exports.compileTask = compileTask;
function watchTask(out, build) {
return function () {
var compile = createCompile('src', build);
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src(libDtsGlob));
var src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src(libDtsGlob), gulp.src(atTypesDts).pipe(excludedTypesFilter));
var watchSrc = watch('src/**', { base: 'src' });
// Do not write .d.ts files to disk, as they are not needed there.
var dtsFilter = util.filter(function (data) { return !/\.d\.ts$/.test(data.path); });
......
......@@ -73,6 +73,8 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
}
const libDtsGlob = 'node_modules/typescript/lib/*.d.ts';
const atTypesDts = 'node_modules/@types/**/*.d.ts';
const excludedTypesFilter = util.filter(data => !/node_modules(\/|\\)@types(\/|\\)(node|webpack|uglify-js)(\/|\\)/.test(data.path));
export function compileTask(src: string, out: string, build: boolean): () => NodeJS.ReadWriteStream {
......@@ -82,6 +84,7 @@ export function compileTask(src: string, out: string, build: boolean): () => Nod
const srcPipe = es.merge(
gulp.src(`${src}/**`, { base: `${src}` }),
gulp.src(libDtsGlob),
gulp.src(atTypesDts).pipe(excludedTypesFilter),
);
// Do not write .d.ts files to disk, as they are not needed there.
......@@ -104,6 +107,7 @@ export function watchTask(out: string, build: boolean): () => NodeJS.ReadWriteSt
const src = es.merge(
gulp.src('src/**', { base: 'src' }),
gulp.src(libDtsGlob),
gulp.src(atTypesDts).pipe(excludedTypesFilter),
);
const watchSrc = watch('src/**', { base: 'src' });
......
......@@ -56,10 +56,7 @@
},
"devDependencies": {
"7zip": "0.0.6",
"@types/keytar": "4.0.1",
"@types/minimist": "1.2.0",
"@types/mocha": "2.2.39",
"@types/sinon": "1.16.34",
"@types/webpack": "^4.4.10",
"asar": "^0.14.0",
"chromium-pickle-js": "^0.2.0",
......
// Type definitions for mocha 2.2.5
// Project: http://mochajs.org/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MochaSetupOptions {
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: any[];
// reporter instance (function or string), defaults to `mocha.reporters.Spec`
reporter?: any;
// bail on the first test failure
bail?: boolean;
// ignore global leaks
ignoreLeaks?: boolean;
// grep string or regexp to filter tests with
grep?: any;
}
declare var mocha: Mocha;
declare var describe: Mocha.IContextDefinition;
declare var xdescribe: Mocha.IContextDefinition;
// alias for `describe`
declare var context: Mocha.IContextDefinition;
// alias for `describe`
declare var suite: Mocha.IContextDefinition;
declare var it: Mocha.ITestDefinition;
declare var xit: Mocha.ITestDefinition;
// alias for `it`
declare var test: Mocha.ITestDefinition;
declare var specify: Mocha.ITestDefinition;
// Used with the --delay flag; see https://mochajs.org/#hooks
declare function run(): void;
interface MochaDone {
(error?: any): any;
}
declare function setup(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare function teardown(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare function suiteSetup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function suiteTeardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function before(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function before(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function after(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function after(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
declare class Mocha {
currentTest: Mocha.ITestDefinition;
constructor(options?: {
grep?: RegExp;
ui?: string;
reporter?: string;
timeout?: number;
reporterOptions?: any;
slow?: number;
bail?: boolean;
});
/** Setup mocha with the given options. */
setup(options: MochaSetupOptions): Mocha;
bail(value?: boolean): Mocha;
addFile(file: string): Mocha;
/** Sets reporter by name, defaults to "spec". */
reporter(name: string): Mocha;
/** Sets reporter constructor, defaults to mocha.reporters.Spec. */
reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha;
ui(value: string): Mocha;
grep(value: string): Mocha;
grep(value: RegExp): Mocha;
invert(): Mocha;
ignoreLeaks(value: boolean): Mocha;
checkLeaks(): Mocha;
/**
* Function to allow assertion libraries to throw errors directly into mocha.
* This is useful when running tests in a browser because window.onerror will
* only receive the 'message' attribute of the Error.
*/
throwError(error: Error): void;
/** Enables growl support. */
growl(): Mocha;
globals(value: string): Mocha;
globals(values: string[]): Mocha;
useColors(value: boolean): Mocha;
useInlineDiffs(value: boolean): Mocha;
timeout(value: number): Mocha;
slow(value: number): Mocha;
enableTimeouts(value: boolean): Mocha;
asyncOnly(value: boolean): Mocha;
noHighlighting(value: boolean): Mocha;
/** Runs tests and invokes `onComplete()` when finished. */
run(onComplete?: (failures: number) => void): Mocha.IRunner;
}
// merge the Mocha class declaration with a module
declare namespace Mocha {
interface ISuiteCallbackContext {
timeout(ms: number): this;
retries(n: number): this;
slow(ms: number): this;
}
interface IHookCallbackContext {
skip(): this;
timeout(ms: number): this;
[index: string]: any;
}
interface ITestCallbackContext {
skip(): this;
timeout(ms: number): this;
retries(n: number): this;
slow(ms: number): this;
[index: string]: any;
}
/** Partial interface for Mocha's `Runnable` class. */
interface IRunnable {
title: string;
fn: Function;
async: boolean;
sync: boolean;
timedOut: boolean;
timeout(n: number): this;
}
/** Partial interface for Mocha's `Suite` class. */
interface ISuite {
parent: ISuite;
title: string;
fullTitle(): string;
}
/** Partial interface for Mocha's `Test` class. */
interface ITest extends IRunnable {
parent: ISuite;
pending: boolean;
state: 'failed' | 'passed' | undefined;
fullTitle(): string;
}
interface IBeforeAndAfterContext extends IHookCallbackContext {
currentTest: ITest;
}
/** Partial interface for Mocha's `Runner` class. */
interface IRunner { }
interface IContextDefinition {
(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
only(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
skip(description: string, callback: (this: ISuiteCallbackContext) => void): void;
timeout(ms: number): void;
}
interface ITestDefinition {
(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): ITest;
// only(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): ITest;
skip(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): void;
timeout(ms: number): void;
state: "failed" | "passed";
}
export module reporters {
export class Base {
stats: {
suites: number;
tests: number;
passes: number;
pending: number;
failures: number;
};
constructor(runner: IRunner);
}
export class Doc extends Base { }
export class Dot extends Base { }
export class HTML extends Base { }
export class HTMLCov extends Base { }
export class JSON extends Base { }
export class JSONCov extends Base { }
export class JSONStream extends Base { }
export class Landing extends Base { }
export class List extends Base { }
export class Markdown extends Base { }
export class Min extends Base { }
export class Nyan extends Base { }
export class Progress extends Base {
/**
* @param options.open String used to indicate the start of the progress bar.
* @param options.complete String used to indicate a complete test on the progress bar.
* @param options.incomplete String used to indicate an incomplete test on the progress bar.
* @param options.close String used to indicate the end of the progress bar.
*/
constructor(runner: IRunner, options?: {
open?: string;
complete?: string;
incomplete?: string;
close?: string;
});
}
export class Spec extends Base { }
export class TAP extends Base { }
export class XUnit extends Base {
constructor(runner: IRunner, options?: any);
}
}
}
declare module "mocha" {
export = Mocha;
}
\ No newline at end of file
......@@ -22,16 +22,6 @@
dependencies:
commander "*"
"@types/keytar@4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/keytar/-/keytar-4.0.1.tgz#e2cf6405dc33861424e59b67516c66d2cf7bc21b"
integrity sha512-loKBID6UL4QjhD2scuvv6oAPlQ/WAY7aYTDyKlKo7fIgriLS8EZExqT567cHL5CY6si51MRoX1+r3mitD3eYrA==
"@types/minimist@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
"@types/mocha@2.2.39":
version "2.2.39"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.39.tgz#f68d63db8b69c38e9558b4073525cf96c4f7a829"
......@@ -47,11 +37,6 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
integrity sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==
"@types/sinon@1.16.34":
version "1.16.34"
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-1.16.34.tgz#a9761fff33d0f7b3fe61875b577778a2576a9a03"
integrity sha1-qXYf/zPQ97P+YYdbV3d4oldqmgM=
"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册