chore(NA): moving @kbn/utility-types to babel transpiler (#107159)

* chore(NA): moving @kbn/utility-types to babel transpiler

* chore(NA): fix type imports

* chore(NA): fix type imports

* chore(NA): fix type imports

* chore(NA): fix rootdir of tsd tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2021-07-30 18:43:50 +01:00 committed by GitHub
parent e0ea3233d9
commit 561b89889f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 46 additions and 37 deletions

View file

@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}

View file

@ -1,12 +1,13 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
PKG_BASE_NAME = "kbn-utility-types"
PKG_REQUIRE_NAME = "@kbn/utility-types"
SOURCE_FILES = glob([
"jest/index.ts",
"index.ts"
"src/jest/index.ts",
"src/index.ts"
])
SRCS = SOURCE_FILES
@ -22,16 +23,21 @@ NPM_MODULE_EXTRA_FILES = [
"README.md",
]
SRC_DEPS = [
RUNTIME_DEPS = [
"@npm//utility-types",
]
TYPES_DEPS = [
"@npm//utility-types",
"@npm//@types/node",
"@npm//@types/jest",
]
DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
@ -42,23 +48,24 @@ ts_config(
)
ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
emit_declaration_only = True,
incremental = False,
out_dir = "target_types",
source_map = True,
root_dir = ".",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = "@kbn/utility-types",
visibility = ["//visibility:public"],
)

View file

@ -1,3 +1,3 @@
{
"types": "../target/jest/index.d.ts"
"types": "../target_types/jest/index.d.ts"
}

View file

@ -3,12 +3,12 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "target/index.js",
"types": "target/index.d.ts",
"main": "target_node/index.js",
"types": "target_types/index.d.ts",
"kibana": {
"devOnly": false
},
"scripts": {
"test": "../../node_modules/.bin/tsd tsd_tests"
"test": "../../node_modules/.bin/tsd src/tsd_tests"
}
}

View file

@ -3,7 +3,7 @@
"tsd": {
"directory": "test_d",
"compilerOptions": {
"rootDir": "../"
"rootDir": ".."
}
}
}

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { MethodKeysOf } from '../../index';
import { MethodKeysOf } from '../..';
class Test {
public name: string = '';

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicContract } from '../../index';
import { PublicContract } from '../..';
class Test {
public str: string = '';

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicKeys } from '../../index';
import { PublicKeys } from '../..';
class Test {
public str: string = '';

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable, expectNotAssignable } from 'tsd';
import { PublicMethodsOf } from '../../index';
import { PublicMethodsOf } from '../..';
class Test {
public name: string = '';

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { ShallowPromise } from '../../index';
import { ShallowPromise } from '../..';
type P1 = ShallowPromise<string>;
type P2 = ShallowPromise<ShallowPromise<string>>;

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnionToIntersection } from '../../index';
import { UnionToIntersection } from '../..';
type INTERSECTED = UnionToIntersection<{ foo: 'bar' } | { baz: 'qux' }>;

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnwrapObservable, ObservableLike } from '../../index';
import { UnwrapObservable, ObservableLike } from '../..';
type STRING = UnwrapObservable<ObservableLike<string>>;

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnwrapPromise } from '../../index';
import { UnwrapPromise } from '../..';
type STRING = UnwrapPromise<Promise<string>>;
type TUPLE = UnwrapPromise<Promise<[number, number]>>;

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Values } from '../../index';
import { Values } from '../..';
// Arrays
type STRING = Values<string[]>;

View file

@ -8,7 +8,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Writable } from '../../index';
import { Writable } from '../..';
type WritableArray = Writable<readonly string[]>;
expectAssignable<WritableArray>(['1']);

View file

@ -1,22 +1,21 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"outDir": "./target",
"stripInternal": true,
"declaration": true,
"declarationMap": true,
"rootDir": "./",
"emitDeclarationOnly": true,
"incremental": false,
"outDir": "./target_types",
"rootDir": "./src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-utility-types",
"stripInternal": true,
"types": [
"jest",
"node"
]
},
"include": [
"index.ts",
"jest/**/*",
"tsd_tests/**/*"
"src/**/*",
]
}

View file

@ -8,7 +8,7 @@
import { mockRawDocExistsInNamespace } from './collect_multi_namespace_references.test.mock';
import type { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { ElasticsearchClient } from 'src/core/server/elasticsearch';
import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks';

View file

@ -12,7 +12,7 @@ import {
mockRawDocExistsInNamespace,
} from './update_objects_spaces.test.mock';
import type { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { ElasticsearchClient } from 'src/core/server/elasticsearch';
import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks';

View file

@ -7,7 +7,7 @@
*/
import { getEsdsl } from './esdsl';
import { MockedKeys } from '@kbn/utility-types/target/jest';
import { MockedKeys } from '@kbn/utility-types/jest';
import { EsdslExpressionFunctionDefinition } from '../../../common/search/expressions';
import { StartServicesAccessor } from 'kibana/public';
import { DataPublicPluginStart, DataStartDependencies } from '../../types';

View file

@ -19,7 +19,7 @@ jest.mock('./common', () => {
});
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
import type { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { ElasticsearchClient, SavedObject, SavedObjectsClientContract } from 'kibana/server';
import { ElasticsearchAssetType } from '../../../../types';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import type { DeeplyMockedKeys } from '@kbn/utility-types/target/jest';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { RequestHandler, RouteConfig } from 'src/core/server';
import { kibanaResponseFactory } from 'src/core/server';
import { httpServerMock } from 'src/core/server/mocks';