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

CONSOLE-2501: Upgrade to Typescript v4 #10432

Closed
wants to merge 1 commit into from
Closed

Conversation

glekner
Copy link
Contributor

@glekner glekner commented Nov 10, 2021

  • Updated Major typescript version to match the dynamic plugin sdk version 4.2.4
  • Updated ts-loader and ForkTsCheckerWebpackPlugin versions. cli logs about ts errors are now a lot clearer.
  • Updated i18n-parser to support ts4
  • Updated @typescript-eslint/eslint-plugin and @typescript-eslint/parser from v2 to v5
  • Updated eslint-plugin-react-hooks to v4 - Added lots of missing useMemos
  • Added globals like React JSX
  • Fixed breaking changes and rules
  • Changed Chainable<Subject> to Chainable (cypress). eslint would shout about unused vars, and since updating versions Subject is the default type interface Cypress.Chainable<Subject = any>

CLI Errors:
Before
Screen Shot 2021-11-10 at 19 42 18

After
Screen Shot 2021-11-10 at 19 35 50

@glekner
Copy link
Contributor Author

glekner commented Nov 10, 2021

please review @spadgett @vojtechszocs @rawagner @christianvogt

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 10, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glekner
To complete the pull request process, please assign invinciblejai after the PR has been reviewed.
You can assign the PR to them by writing /assign @invinciblejai in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added component/ceph Related to ceph-storage-plugin component/core Related to console core functionality labels Nov 10, 2021
@openshift-ci openshift-ci bot added component/dashboard Related to dashboard component/dev-console Related to dev-console component/git-service Related to git-service component/gitops Related to gitops-plugin component/helm Related to helm-plugin component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/monitoring Related to monitoring component/olm Related to OLM component/pipelines Related to pipelines-plugin component/sdk Related to console-plugin-sdk component/shared Related to console-shared component/topology Related to topology kind/cypress Related to Cypress e2e integration testing labels Nov 10, 2021
@glekner glekner force-pushed the ts4 branch 2 times, most recently from e415e7f to 3f993e3 Compare November 10, 2021 17:30
frontend/package.json Show resolved Hide resolved
frontend/package.json Outdated Show resolved Hide resolved
@@ -166,7 +166,6 @@ export const createFlashSystemPayload: CreatePayload<FlashSystemState> = (
const storageSecretTemplate: SecretKind = {
apiVersion: apiVersionForModel(SecretModel),
stringData: {
// eslint-disable-next-line @typescript-eslint/camelcase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't see why this comment could be removed. We want the camelcase rule active for most of the code. Did the defaults change?

@@ -79,6 +79,7 @@ const ClusterInventoryItem = withDashboardResources<ClusterInventoryItemProps>(
});
}, [mapperLoader]);

// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolves
The 'additionalResourcesData' object makes the dependencies of useCallback Hook (at line 105) change on every render. To fix this, wrap the initialization of 'additionalResourcesData' in its own useMemo()

no need for useMemo here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a legitimate problem that shouldn't be ignored?

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid adding this at the top of the file. It's better to apply only where it's needed.

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here.

@@ -101,6 +101,7 @@ export const FilterToolbar: React.FC<FilterToolbarProps> = ({
const labelFilterQueryArgumentKey = uniqueFilterName
? `${uniqueFilterName}-${labelFilter}`
: labelFilter;
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

@@ -11,6 +11,7 @@ export const useIsVisible = (ref) => {
}
};

// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

@spadgett
Copy link
Member

We'll need to solve this error:

error @typescript-eslint/[email protected]: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >=16.0.0". Got "14.16.0"

@glekner
Copy link
Contributor Author

glekner commented Nov 10, 2021

@spadgett

@spadgett spadgett changed the title Upgrade to Typescript v4 CONSOLE-2501: Upgrade to Typescript v4 Nov 11, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 14, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 14, 2021
@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 21, 2021
@rebeccaalpert
Copy link
Contributor

/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:750
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
scripts/generate-pkg-assets.ts(20,10): error TS2550: Property 'entries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2017' or later.
    at createTSError (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:750:12)
    at reportTSError (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:754:19)
    at getOutput (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:941:36)
    at Object.compile (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:1243:30)
    at Module.m._compile (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:1370:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.require.extensions.<computed> [as .ts] (/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:1374:12)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  diagnosticText: "scripts/generate-pkg-assets.ts(20,10): error TS2550: Property 'entries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2017' or later.\n",
  diagnosticCodes: [ 2550 ]

@rebeccaalpert
Copy link
Contributor

I spoke to Kim and she suggested creating a branch based on glekner:ts4/a new PR and then close this. I'll take a look at the GH comments before I do that to make sure they have been addressed first.

@glekner
Copy link
Contributor Author

glekner commented Nov 25, 2021

@rebeccaalpert I fixed the TS compilation error.

The only remaining issue AFAIK is jest. I assume the current version of ts-jest doesn't support TS4.
and upgrading it means upgrading the rest of the jest pkgs.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 25, 2021

@glekner: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/frontend 778c1da link true /test frontend
ci/prow/e2e-gcp-console 778c1da link true /test e2e-gcp-console
ci/prow/ceph-storage-plugin 778c1da link true /test ceph-storage-plugin
ci/prow/kubevirt-plugin 778c1da link true /test kubevirt-plugin

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 29, 2021

@glekner: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 29, 2021
@rebeccaalpert
Copy link
Contributor

Closing this per Kim. I will work on fixing tests and resolving open comments in this PR in the new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/dev-console Related to dev-console component/git-service Related to git-service component/gitops Related to gitops-plugin component/helm Related to helm-plugin component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/monitoring Related to monitoring component/olm Related to OLM component/pipelines Related to pipelines-plugin component/sdk Related to console-plugin-sdk component/shared Related to console-shared component/topology Related to topology kind/cypress Related to Cypress e2e integration testing needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants