Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add typings for mocha #30190

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
"@types/listr": "^0.13.0",
"@types/lodash": "^3.10.1",
"@types/minimatch": "^2.0.29",
"@types/mocha": "^5.2.5",
spalger marked this conversation as resolved.
Show resolved Hide resolved
"@types/moment-timezone": "^0.5.8",
"@types/mustache": "^0.8.31",
"@types/node": "^10.12.12",
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-config-schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"declarationDir": "./target/types",
"outDir": "./target/out",
"stripInternal": true,
"declarationMap": true
"declarationMap": true,
"types": [
"jest",
"node"
]
},
"include": [
"./types/joi.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-i18n/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"compilerOptions": {
"declaration": true,
"declarationDir": "./target/types",
"types": [
"jest",
"node"
]
}
}
8 changes: 7 additions & 1 deletion packages/kbn-pm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
"include": [
"./src/**/*.ts",
"./types/index.d.ts"
]
],
"compilerOptions": {
"types": [
"jest",
"node"
]
}
}
6 changes: 6 additions & 0 deletions packages/kbn-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": [
"types/**/*"
]
}
225 changes: 225 additions & 0 deletions packages/kbn-test/types/expect.js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// tslint:disable

// Type definitions for expect.js 0.3.1
// Project: https://github.com/Automattic/expect.js
// Definitions by: Teppei Sato <https://github.com/teppeis>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// License: MIT

declare module 'expect.js' {
function expect(target?: any): Root;

interface Assertion {
/**
* Assert typeof / instanceof.
*/
an: An;
/**
* Check if the value is truthy
*/
ok(): void;

/**
* Creates an anonymous function which calls fn with arguments.
*/
withArgs(...args: any[]): Root;

/**
* Assert that the function throws.
*
* @param fn callback to match error string against
*/
throwError(fn?: (exception: any) => void): void;

/**
* Assert that the function throws.
*
* @param fn callback to match error string against
*/
throwException(fn?: (exception: any) => void): void;

/**
* Assert that the function throws.
*
* @param regexp regexp to match error string against
*/
throwError(regexp: RegExp): void;

/**
* Assert that the function throws.
*
* @param fn callback to match error string against
*/
throwException(regexp: RegExp): void;

/**
* Checks if the array is empty.
*/
empty(): Assertion;

/**
* Checks if the obj exactly equals another.
*/
equal(obj: any): Assertion;

/**
* Checks if the obj sortof equals another.
*/
eql(obj: any): Assertion;

/**
* Assert within start to finish (inclusive).
*
* @param start
* @param finish
*/
within(start: number, finish: number): Assertion;

/**
* Assert typeof.
*/
a(type: string): Assertion;

/**
* Assert instanceof.
*/
a(type: Function): Assertion;

/**
* Assert numeric value above n.
*/
greaterThan(n: number): Assertion;

/**
* Assert numeric value above n.
*/
above(n: number): Assertion;

/**
* Assert numeric value below n.
*/
lessThan(n: number): Assertion;

/**
* Assert numeric value below n.
*/
below(n: number): Assertion;

/**
* Assert string value matches regexp.
*
* @param regexp
*/
match(regexp: RegExp): Assertion;

/**
* Assert property "length" exists and has value of n.
*
* @param n
*/
length(n: number): Assertion;

/**
* Assert property name exists, with optional val.
*
* @param name
* @param val
*/
property(name: string, val?: any): Assertion;

/**
* Assert that string contains str.
*/
contain(str: string): Assertion;
string(str: string): Assertion;

/**
* Assert that the array contains obj.
*/
contain(obj: any): Assertion;
string(obj: any): Assertion;

/**
* Assert exact keys or inclusion of keys by using the `.own` modifier.
*/
key(keys: string[]): Assertion;
/**
* Assert exact keys or inclusion of keys by using the `.own` modifier.
*/
key(...keys: string[]): Assertion;
/**
* Assert exact keys or inclusion of keys by using the `.own` modifier.
*/
keys(keys: string[]): Assertion;
/**
* Assert exact keys or inclusion of keys by using the `.own` modifier.
*/
keys(...keys: string[]): Assertion;

/**
* Assert a failure.
*/
fail(message?: string): Assertion;
}

interface Root extends Assertion {
not: Not;
to: To;
only: Only;
have: Have;
be: Be;
}

interface Be extends Assertion {
/**
* Checks if the obj exactly equals another.
*/
(obj: any): Assertion;

an: An;
}

interface An extends Assertion {
/**
* Assert typeof.
*/
(type: string): Assertion;

/**
* Assert instanceof.
*/
(type: Function): Assertion;
}

interface Not extends NotBase {
to: ToBase;
}

interface NotBase extends Assertion {
be: Be;
have: Have;
include: Assertion;
only: Only;
}

interface To extends ToBase {
not: NotBase;
}

interface ToBase extends Assertion {
be: Be;
have: Have;
include: Assertion;
only: Only;
}

interface Only extends Assertion {
have: Have;
}

interface Have extends Assertion {
own: Assertion;
}

export default expect;
}
1 change: 1 addition & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Project } from './project';

export const PROJECTS = [
new Project(resolve(REPO_ROOT, 'tsconfig.json')),
new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), 'kibana/test'),
new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), 'x-pack/test'),

Expand Down
32 changes: 32 additions & 0 deletions src/es_archiver/es_archiver.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ToolingLog } from '@kbn/dev-utils';
import { Client } from 'elasticsearch';

export class EsArchiver {
constructor(options: { client: Client; dataDir: string; log: ToolingLog; kibanaUrl: string });
public save(name: string, indices: string | string[], options?: { raw?: boolean }): Promise<void>;
public load(name: string, options?: { skipExisting?: boolean }): Promise<void>;
public unload(name: string): Promise<void>;
public rebuildAll(): Promise<void>;
public edit(prefix: string, handler: () => Promise<void>): Promise<void>;
public loadIfNeeded(name: string): Promise<void>;
public emptyKibanaIndex(): Promise<void>;
}
20 changes: 20 additions & 0 deletions src/es_archiver/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { EsArchiver } from './es_archiver';
2 changes: 1 addition & 1 deletion src/legacy/ui/public/utils/__tests__/cidr_mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore

import expect from 'expect.js';
import { CidrMask } from '../cidr_mask';

Expand Down
Loading