Skip to content

Commit

Permalink
Upgrade typescript to 2.9.2 (#20757)
Browse files Browse the repository at this point in the history
This upgrades TypeScript to version 2.9.2. My main motivation is the support for generic type arguments in JSX elements and tagged templates (e.g. for `styled-components`).

Problems arising from breaking changes in the new TypeScript version have been mitigated by:

* setting the `keyofStringsOnly` option until impacted code has been
  future-proofed
* Restricting some joi-related generics

See the [release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html) for details.

Some follow-up tasks should be:

* Update EUI to support the new `keyof` behaviour
* Update new platform TypeScript code to support new `keyof` behaviour
* Remove `keyofStringsOnly` setting
  • Loading branch information
weltenwort authored Jul 16, 2018
1 parent 4f867a2 commit 4b255e9
Show file tree
Hide file tree
Showing 14 changed files with 1,041 additions and 1,272 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.12.0",
"tslint-plugin-prettier": "^1.3.0",
"typescript": "^2.8.3",
"typescript": "^2.9.2",
"vinyl-fs": "^3.0.2",
"xml2js": "^0.4.19",
"xmlbuilder": "9.0.4",
Expand Down
2,264 changes: 1,013 additions & 1,251 deletions packages/kbn-pm/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"strong-log-transformer": "^1.0.6",
"tempy": "^0.2.1",
"ts-loader": "^3.5.0",
"typescript": "^2.8.1",
"typescript": "^2.9.2",
"webpack": "^3.11.0",
"wrap-ansi": "^3.0.1",
"write-pkg": "^3.1.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-pm/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3592,9 +3592,9 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624"
typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"

uglify-js@^2.8.29:
version "2.8.29"
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-system-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
},
"devDependencies": {
"@types/jest": "^22.2.2",
"typescript": "^2.8.1"
"typescript": "^2.9.2"
}
}
6 changes: 3 additions & 3 deletions packages/kbn-system-loader/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
version "22.2.2"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.2.2.tgz#afe5dacbd00d65325f52da0ed3e76e259629ac9d"

typescript@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624"
typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
3 changes: 2 additions & 1 deletion src/core/server/config/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
ByteSizeOptions,
ByteSizeType,
ConditionalType,
ConditionalTypeValue,
DurationOptions,
DurationType,
LiteralType,
Expand Down Expand Up @@ -146,7 +147,7 @@ function siblingRef<T>(key: string): SiblingReference<T> {
return new SiblingReference(key);
}

function conditional<A, B, C>(
function conditional<A extends ConditionalTypeValue, B, C>(
leftOperand: Reference<A>,
rightOperand: Reference<A> | A,
equalType: Type<B>,
Expand Down
3 changes: 2 additions & 1 deletion src/core/server/config/schema/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
JoiRoot,
Reference,
Rules,
SchemaLike,
State,
ValidationErrorItem,
ValidationOptions,
Expand All @@ -31,7 +32,7 @@ import { isDuration } from 'moment';
import { ByteSizeValue, ensureByteSizeValue } from '../byte_size_value';
import { ensureDuration } from '../duration';

export { AnySchema, Reference, ValidationErrorItem };
export { AnySchema, Reference, SchemaLike, ValidationErrorItem };

function isMap<K, V>(o: any): o is Map<K, V> {
return o instanceof Map;
Expand Down
4 changes: 3 additions & 1 deletion src/core/server/config/schema/types/conditional_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { internals } from '../internals';
import { Reference } from '../references';
import { Type, TypeOptions } from './type';

export class ConditionalType<A, B, C> extends Type<B | C> {
export type ConditionalTypeValue = string | number | boolean | object | null;

export class ConditionalType<A extends ConditionalTypeValue, B, C> extends Type<B | C> {
constructor(
leftOperand: Reference<A>,
rightOperand: Reference<A> | A,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/schema/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { AnyType } from './any_type';
export { ArrayOptions, ArrayType } from './array_type';
export { BooleanType } from './boolean_type';
export { ByteSizeOptions, ByteSizeType } from './byte_size_type';
export { ConditionalType } from './conditional_type';
export { ConditionalType, ConditionalTypeValue } from './conditional_type';
export { DurationOptions, DurationType } from './duration_type';
export { LiteralType } from './literal_type';
export { MaybeType } from './maybe_type';
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"moduleResolution": "node",

// Disallow inconsistently-cased references to the same file.
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,

// Disable the breaking keyof behaviour introduced in TS 2.9.2 until EUI is updated to support that too
"keyofStringsOnly": true
},
"include": [
"src/**/*"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"supertest-as-promised": "4.0.2",
"tmp": "0.0.31",
"tree-kill": "^1.1.0",
"typescript": "^2.8.3",
"typescript": "^2.9.2",
"vinyl-fs": "^3.0.2",
"xml-crypto": "^0.10.1",
"xml2js": "^0.4.19",
Expand Down
6 changes: 3 additions & 3 deletions x-pack/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7753,9 +7753,9 @@ typedarray@^0.0.6, typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^2.8.3:
version "2.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170"
typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"

ua-parser-js@^0.7.9:
version "0.7.17"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13256,9 +13256,9 @@ typedarray@^0.0.6, typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^2.8.3:
version "2.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170"
typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"

ua-parser-js@^0.7.9:
version "0.7.17"
Expand Down

0 comments on commit 4b255e9

Please sign in to comment.