Skip to content

Commit

Permalink
Update to TS v4 (#73924)
Browse files Browse the repository at this point in the history
* bump ts to v4

* MOAR RAM

* fix type errors for OSS

* first pass on x-pack errors

* second pass on x-pack type errors

* 3rd pass on x-pack type-errors

* mute errors if complex cases

* don't delete if spread suffices

* mute other complex cases

* make User fields optional

* fix optional types

* fix tests

* fix typings for time_range

* fix type errors in x-pack/tests

* rebuild kbn-pm

* remove leftovers from master update

* fix alert tests

* [Telemetry Checker] TS4 Fixes

* bump to 4.0.1-rc

* fix new errors in master

* bump typescript-eslint to version supporting TS v4 syntax

* fix merge commit errors

* update to the stable TS version 4.0.2

* bump ts-eslint to version supporting ts v4

* fix typo

* fix type errors after merge

* update ts in another new package.json

* TEMP: remove me

* Revert "TEMP: remove me"

This reverts commit dc0fc3b.

* [Telemetry] Update snapshot for new TS4 SyntaxKind

* bump prettier to support TS v4 syntax

* fix prettier rules

* last style change

* fix new type errors

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
  • Loading branch information
mshustov and afharo authored Aug 27, 2020
1 parent e488c08 commit 37ec1e1
Show file tree
Hide file tree
Showing 195 changed files with 568 additions and 319 deletions.
3 changes: 2 additions & 1 deletion examples/embeddable_examples/public/book/book_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function getHasMatch(search?: string, savedAttributes?: BookSavedObjectAttribute
);
}

export class BookEmbeddable extends Embeddable<BookEmbeddableInput, BookEmbeddableOutput>
export class BookEmbeddable
extends Embeddable<BookEmbeddableInput, BookEmbeddableOutput>
implements ReferenceOrValueEmbeddable<BookByValueInput, BookByReferenceInput> {
public readonly type = BOOK_EMBEDDABLE;
private subscription: Subscription;
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"**/@types/chai": "^4.2.11",
"**/cypress/@types/lodash": "^4.14.159",
"**/cypress/lodash": "^4.17.20",
"**/typescript": "3.9.5",
"**/typescript": "4.0.2",
"**/graphql-toolkit/lodash": "^4.17.15",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-git/**/base64-js": "^1.2.1",
Expand Down Expand Up @@ -338,8 +338,8 @@
"@types/vinyl": "^2.0.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"angular-aria": "^1.8.0",
"angular-mocks": "^1.7.9",
"angular-recursion": "^1.0.5",
Expand Down Expand Up @@ -381,7 +381,7 @@
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-perf": "^3.2.3",
Expand Down Expand Up @@ -443,7 +443,7 @@
"pkg-up": "^2.0.0",
"pngjs": "^3.4.0",
"postcss": "^7.0.32",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"prop-types": "15.6.0",
"proxyquire": "1.8.0",
"react-grid-layout": "^0.16.2",
Expand All @@ -469,7 +469,7 @@
"tape": "^4.13.0",
"topojson-client": "3.0.0",
"tree-kill": "^1.2.2",
"typescript": "3.9.5",
"typescript": "4.0.2",
"typings-tester": "^0.3.2",
"ui-select": "0.19.8",
"vega": "^5.13.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-kibana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"homepage": "https://github.com/elastic/kibana/tree/master/packages/eslint-config-kibana",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-plugin-babel": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@babel/cli": "^7.10.5",
"@kbn/dev-utils": "1.0.0",
"@kbn/babel-preset": "1.0.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "3.9.5",
"typescript": "4.0.2",
"tsd": "^0.7.4"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"tslib": "^2.0.0"
},
"devDependencies": {
"typescript": "3.9.5",
"typescript": "4.0.2",
"@kbn/expect": "1.0.0",
"chance": "1.0.18"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"del": "^5.1.0",
"getopts": "^2.2.4",
"supports-color": "^7.0.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
},
"dependencies": {
"intl-format-cache": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"del": "^5.1.0",
"raw-loader": "3.1.0",
"supports-color": "^7.0.0",
"typescript": "3.9.5",
"typescript": "4.0.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"execa": "^4.0.2",
"inquirer": "^7.3.3",
"normalize-path": "^3.0.0",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"vinyl": "^2.2.0",
"vinyl-fs": "^3.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/through2": "^2.0.35",
"@types/through2-map": "^3.0.0",
"@types/vinyl": "^2.0.4",
"typescript": "3.9.5"
"typescript": "4.0.2"
},
"peerDependencies": {
"@kbn/babel-preset": "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ module.exports = require("path");
* under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolingLogCollectingWriter = exports.parseLogLevel = exports.pickLevelFromFlags = exports.ToolingLogTextWriter = exports.ToolingLog = void 0;
var tooling_log_1 = __webpack_require__(6);
Object.defineProperty(exports, "ToolingLog", { enumerable: true, get: function () { return tooling_log_1.ToolingLog; } });
var tooling_log_text_writer_1 = __webpack_require__(110);
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
"multimatch": "^4.0.0",
"ncp": "^2.0.0",
"ora": "^1.4.0",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"read-pkg": "^5.2.0",
"rxjs": "^6.5.5",
"spawn-sync": "^1.0.15",
"string-replace-loader": "^2.2.0",
"strip-ansi": "^4.0.0",
"strong-log-transformer": "^2.1.0",
"tempy": "^0.3.0",
"typescript": "3.9.5",
"typescript": "4.0.2",
"unlazy-loader": "^0.1.3",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-release-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
},
"devDependencies": {
"markdown-it": "^10.0.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/kbn-spec-to-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^25.5.4",
"prettier": "^2.0.5"
"prettier": "^2.1.1"
},
"dependencies": {
"commander": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-telemetry-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"normalize-path": "^3.0.0",
"@types/lodash": "^3.10.1",
"moment": "^2.24.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
}

if (ts.isUnionTypeNode(node)) {
const types = node.types.filter((typeNode) => {
return (
typeNode.kind !== ts.SyntaxKind.NullKeyword &&
typeNode.kind !== ts.SyntaxKind.UndefinedKeyword
);
});
const types = node.types.filter(discardNullOrUndefined);

const kinds = types.map((typeNode) => getDescriptor(typeNode, program));
const kinds = types
.map((typeNode) => getDescriptor(typeNode, program))
.filter(discardNullOrUndefined);

const uniqueKinds = uniq(kinds, 'kind');

Expand All @@ -172,3 +169,9 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
throw new Error(`Unknown type ${ts.SyntaxKind[node.kind]}; ${node.getText()}`);
}
}

function discardNullOrUndefined(typeNode: ts.TypeNode | Descriptor | DescriptorValue) {
return (
typeNode.kind !== ts.SyntaxKind.NullKeyword && typeNode.kind !== ts.SyntaxKind.UndefinedKeyword
);
}
2 changes: 1 addition & 1 deletion src/fixtures/agg_resp/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
hits: [],
},
aggregations: {
'1': {
1: {
buckets: [
{
key_as_string: '2015-01-30T01:00:00.000Z',
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/agg_resp/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
hits: [],
},
aggregations: {
'1': {
1: {
buckets: {
'*-1024.0': {
to: 1024,
Expand Down
8 changes: 4 additions & 4 deletions src/legacy/server/status/lib/metrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe('Metrics', function () {
Object.defineProperty(process, 'pid', { get: pidMock }); //

const hapiEvent = {
requests: { '5603': { total: 22, disconnects: 0, statusCodes: { '200': 22 } } },
responseTimes: { '5603': { avg: 1.8636363636363635, max: 4 } },
requests: { 5603: { total: 22, disconnects: 0, statusCodes: { 200: 22 } } },
responseTimes: { 5603: { avg: 1.8636363636363635, max: 4 } },
osload: [2.20751953125, 2.02294921875, 1.89794921875],
osmem: { total: 17179869184, free: 102318080 },
osup: 1008991,
Expand Down Expand Up @@ -150,9 +150,9 @@ describe('Metrics', function () {
it('parses event with missing fields / NaN for responseTimes.avg', async () => {
const hapiEvent = {
requests: {
'5603': { total: 22, disconnects: 0, statusCodes: { '200': 22 } },
5603: { total: 22, disconnects: 0, statusCodes: { 200: 22 } },
},
responseTimes: { '5603': { avg: NaN, max: 4 } },
responseTimes: { 5603: { avg: NaN, max: 4 } },
host: 'blahblah.local',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class AdvancedSettingsComponent extends Component<
}

export const AdvancedSettings = (props: AdvancedSettingsProps) => {
const { query } = useParams();
const { query } = useParams<{ query: string }>();
return (
<AdvancedSettingsComponent
queryText={query || ''}
Expand Down
Loading

0 comments on commit 37ec1e1

Please sign in to comment.