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

[ts][ftr] improve types for ftr and expect.js, cleanup changes to tsconfig files #31948

Merged
merged 24 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3ca5ba1
[ts] improve ftr/expect.js types
Feb 25, 2019
c6fd398
[ftr] remove --require cli option
Feb 25, 2019
770edbf
[ts] remove extra tsconfig options
Feb 25, 2019
0c93afc
remove require: mocha opt
Feb 25, 2019
a8a90a7
Merge branch 'master' of github.com:elastic/kibana into fixup/31234
Feb 27, 2019
c513f6c
add readme to kbn-test/types
Feb 27, 2019
3ee8511
[esArchiver/Stats] typescript-ify
Feb 27, 2019
3ac25eb
[esArchiver] fix return types
Feb 27, 2019
ae12e78
[@kbn/test] add generic ftr types
Feb 27, 2019
1f2ae48
[ftr] add types for base services
Feb 27, 2019
233181f
[ftr/common] add types for services
Feb 27, 2019
a0787dc
[ftr/functional] add service/pageObject types
Feb 27, 2019
a8c1373
[ts] remove trailing comma from config
Feb 27, 2019
4d71962
[ftr/types] use Pick helper
Feb 27, 2019
a4ebece
[ftr/types] add docs to provider functions
Feb 27, 2019
21e3826
[ftr/types] finish doc block
Feb 27, 2019
441876e
[ftr/functional/appMenu] add docs
Feb 27, 2019
2d71144
[ts] fixup some type errors I missed
Feb 27, 2019
1a3a5ed
Merge branch 'master' of github.com:elastic/kibana into fixup/31234
Feb 27, 2019
156874c
[ftr/types] remove unused import
Feb 27, 2019
bfd92a4
[ftr/types] make hasService() a typeguard
Feb 27, 2019
be45eab
Merge branch 'master' of github.com:elastic/kibana into fixup/31234
Feb 28, 2019
c4d1565
Merge branch 'master' of github.com:elastic/kibana into fixup/31234
Feb 28, 2019
a3b9900
fix dep type issues previously hidden by skipLibCheck
Feb 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@
"ts-jest": "^23.1.4",
"ts-loader": "^5.2.2",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-microsoft-contrib": "^6.0.0",
Expand Down
42 changes: 21 additions & 21 deletions packages/kbn-config-schema/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./target/types",
"outDir": "./target/out",
"stripInternal": true,
"declarationMap": true,
"types": [
"jest",
"node"
]
},
"include": [
"./types/joi.d.ts",
"./src/**/*.ts"
],
"exclude": [
"target"
]
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./target/types",
"outDir": "./target/out",
"stripInternal": true,
"declarationMap": true,
"types": [
"jest",
"node"
]
},
"include": [
"./types/joi.d.ts",
"./src/**/*.ts"
],
"exclude": [
"target"
]
}
32 changes: 16 additions & 16 deletions packages/kbn-pm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"extends": "../../tsconfig.json",
"exclude": [
"dist"
],
"include": [
"./src/**/*.ts",
"./types/index.d.ts"
],
"compilerOptions": {
"types": [
"jest",
"node"
]
}
}
{
"extends": "../../tsconfig.json",
"exclude": [
"dist"
],
"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 @@
{
spalger marked this conversation as resolved.
Show resolved Hide resolved
"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;
}
2 changes: 1 addition & 1 deletion src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ 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'),
new Project(resolve(REPO_ROOT, 'test/tsconfig.json')),

// NOTE: using glob.sync rather than glob-all or globby
// because it takes less than 10 ms, while the other modules
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>;
spalger marked this conversation as resolved.
Show resolved Hide resolved
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>;
}
5 changes: 1 addition & 4 deletions test/typings/wrapper.ts → src/es_archiver/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
* under the License.
*/

export interface TestWrapper {
getService(service: string): any;
getPageObjects(pages: string[]): { [name: string]: any };
}
export { EsArchiver } from './es_archiver';
1 change: 0 additions & 1 deletion src/functional_test_runner/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const functionalTestRunner = createFunctionalTestRunner({
bail: cmd.bail,
grep: cmd.grep,
invert: cmd.invert,
require: `ts-node/register --project tests/tsconfig.json -r tsconfig-paths/register -T "test/**/*.{ts,js}"`
vitalics marked this conversation as resolved.
Show resolved Hide resolved
},
suiteTags: {
include: cmd.includeTag,
Expand Down
1 change: 0 additions & 1 deletion src/functional_test_runner/lib/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const schema = Joi.object().keys({
slow: Joi.number().default(30000),
timeout: Joi.number().default(INSPECTING ? Infinity : 360000),
ui: Joi.string().default('bdd'),
require: Joi.string().default('')
}).default(),

updateBaselines: Joi.boolean().default(false),
Expand Down
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