From 99c613546ef61bf96da779198497c7aede2ac4c1 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 4 Dec 2020 14:44:20 +0200 Subject: [PATCH] removed occasional changes related to typescript 4.1 Signed-off-by: Roman --- package.json | 2 +- src/extensions/cluster-feature.ts | 26 +++++++++---------- .../__tests__/page-registry.test.ts | 2 +- src/main/kubectl.ts | 2 +- src/main/lens-binary.ts | 2 +- src/renderer/components/select/select.tsx | 4 +-- src/renderer/components/table/table.tsx | 6 ++--- src/renderer/navigation/url-param.ts | 4 +-- yarn.lock | 7 ++++- 9 files changed, 30 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index b2c1619f95..5042ff2be9 100644 --- a/package.json +++ b/package.json @@ -383,7 +383,7 @@ "typedoc": "0.17.0-3", "typedoc-plugin-markdown": "^2.4.0", "typeface-roboto": "^0.0.75", - "typescript": "^4.0.2", + "typescript": "4.0.2", "url-loader": "^4.1.0", "webpack": "^4.44.2", "webpack-cli": "^3.3.11", diff --git a/src/extensions/cluster-feature.ts b/src/extensions/cluster-feature.ts index 3736e7b1f7..36a2f0bfb8 100644 --- a/src/extensions/cluster-feature.ts +++ b/src/extensions/cluster-feature.ts @@ -41,42 +41,42 @@ export abstract class ClusterFeature { /** * to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be installed. The implementation * of this method should install kubernetes resources using the applyResources() method, or by directly accessing the kubernetes api (K8sApi) - * + * * @param cluster the cluster that the feature is to be installed on */ - abstract install(cluster: Cluster): Promise; + abstract async install(cluster: Cluster): Promise; /** * to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be upgraded. The implementation * of this method should upgrade the kubernetes resources already installed, if relevant to the feature - * + * * @param cluster the cluster that the feature is to be upgraded on */ - abstract upgrade(cluster: Cluster): Promise; + abstract async upgrade(cluster: Cluster): Promise; /** * to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be uninstalled. The implementation * of this method should uninstall kubernetes resources using the kubernetes api (K8sApi) - * + * * @param cluster the cluster that the feature is to be uninstalled from */ - abstract uninstall(cluster: Cluster): Promise; + abstract async uninstall(cluster: Cluster): Promise; /** * to be implemented in the derived class, this method is called periodically by Lens to determine details about the feature's current status. The implementation - * of this method should provide the current status information. The currentVersion and latestVersion fields may be displayed by Lens in describing the feature. + * of this method should provide the current status information. The currentVersion and latestVersion fields may be displayed by Lens in describing the feature. * The installed field should be set to true if the feature has been installed, otherwise false. Also, Lens relies on the canUpgrade field to determine if the feature * can be upgraded so the implementation should set the canUpgrade field according to specific rules for the feature, if relevant. - * + * * @param cluster the cluster that the feature may be installed on - * + * * @return a promise, resolved with the updated ClusterFeatureStatus */ - abstract updateStatus(cluster: Cluster): Promise; + abstract async updateStatus(cluster: Cluster): Promise; /** * this is a helper method that conveniently applies kubernetes resources to the cluster. - * + * * @param cluster the cluster that the resources are to be applied to * @param resourceSpec as a string type this is a folder path that is searched for files specifying kubernetes resources. The files are read and if any of the resource * files are templated, the template parameters are filled using the templateContext field (See renderTemplate() method). Finally the resources are applied to the @@ -101,9 +101,9 @@ export abstract class ClusterFeature { /** * this is a helper method that conveniently reads kubernetes resource files into a string array. It also fills templated resource files with the template parameter values * specified by the templateContext field. Templated files must end with the extension '.hb' and the template syntax must be compatible with handlebars.js - * + * * @param folderPath this is a folder path that is searched for files defining kubernetes resources. - * + * * @return an array of strings, each string being the contents of a resource file found in the folder path. This can be passed directly to applyResources() */ protected renderTemplates(folderPath: string): string[] { diff --git a/src/extensions/registries/__tests__/page-registry.test.ts b/src/extensions/registries/__tests__/page-registry.test.ts index 9b07eb439f..2910c874c9 100644 --- a/src/extensions/registries/__tests__/page-registry.test.ts +++ b/src/extensions/registries/__tests__/page-registry.test.ts @@ -70,7 +70,7 @@ describe("globalPageRegistry", () => { ], ext); }); - describe("getByPageMenuTarget", () => { + describe("getByPageTarget", () => { it("matching to first registered page without id", () => { const page = globalPageRegistry.getByPageTarget({ extensionId: ext.name }); diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index 0001e1a283..0a96ee354b 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -272,7 +272,7 @@ export class Kubectl { logger.info(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const stream = customRequest({ url: this.url, gzip: true, diff --git a/src/main/lens-binary.ts b/src/main/lens-binary.ts index a992d8c460..3cf5a5fce7 100644 --- a/src/main/lens-binary.ts +++ b/src/main/lens-binary.ts @@ -183,7 +183,7 @@ export class LensBinary { throw(error); }); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { file.on("close", () => { this.logger.debug(`${this.originalBinaryName} binary download closed`); if (!this.tarPath) fs.chmod(binaryPath, 0o755, (err) => { diff --git a/src/renderer/components/select/select.tsx b/src/renderer/components/select/select.tsx index 6864c80c6b..ddbecef8c6 100644 --- a/src/renderer/components/select/select.tsx +++ b/src/renderer/components/select/select.tsx @@ -50,7 +50,7 @@ export class Select extends React.Component { }), }; - protected isValidOption(opt: SelectOption | any): opt is SelectOption { + protected isValidOption(opt: SelectOption | any) { return typeof opt === "object" && opt.value !== undefined; } @@ -72,7 +72,7 @@ export class Select extends React.Component { const { autoConvertOptions, options } = this.props; if (autoConvertOptions && Array.isArray(options)) { - return (options as any[]).map(opt => { + return options.map(opt => { return this.isValidOption(opt) ? opt : { value: opt, label: String(opt) }; }); } diff --git a/src/renderer/components/table/table.tsx b/src/renderer/components/table/table.tsx index 53b5752d3c..92bb142060 100644 --- a/src/renderer/components/table/table.tsx +++ b/src/renderer/components/table/table.tsx @@ -1,7 +1,7 @@ import "./table.scss"; import React from "react"; -import lodash from "lodash"; +import { orderBy } from "lodash"; import { observer } from "mobx-react"; import { observable } from "mobx"; import { autobind, cssNames, noop } from "../../utils"; @@ -104,10 +104,10 @@ export class Table extends React.Component { } getSorted(items: any[]) { - const { sortBy, orderBy } = this.sortParams; + const { sortBy, orderBy: order } = this.sortParams; const sortingCallback = this.props.sortable[sortBy] || noop; - return lodash.orderBy(items, sortingCallback, orderBy as any); + return orderBy(items, sortingCallback, order as any); } @autobind() diff --git a/src/renderer/navigation/url-param.ts b/src/renderer/navigation/url-param.ts index a601d25ddc..9cdaa98502 100644 --- a/src/renderer/navigation/url-param.ts +++ b/src/renderer/navigation/url-param.ts @@ -15,8 +15,8 @@ export interface UrlParamInit { export class UrlParam { static SYSTEM_PREFIX = "lens-"; - public name: string; - public urlName: string; + readonly name: string; + readonly urlName: string; constructor(private init: UrlParamInit, private history: IObservableHistory) { const { isSystem, name, skipEmpty = true } = init; diff --git a/yarn.lock b/yarn.lock index 32c1a8284d..3e85e11d5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14545,7 +14545,12 @@ typeface-roboto@^0.0.75: resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-0.0.75.tgz#98d5ba35ec234bbc7172374c8297277099cc712b" integrity sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg== -typescript@^4.0.2, typescript@^4.0.3: +typescript@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" + integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== + +typescript@^4.0.3: version "4.1.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9" integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==