backstage / backstage

Backstage is an open framework for building developer portals
https://backstage.io/
Apache License 2.0
28.61k stars 6.08k forks source link

πŸ› Bug Report: mismatched TaskRunner types after TypeScript version upgrade #16592

Closed planeiii-te closed 1 year ago

planeiii-te commented 1 year ago

πŸ“œ Description

Dependabot attempted to bump TypeScript from 4.6.4 to 4.9.5. This resulted in type errors from Backstage code when running tsc.

πŸ‘ Expected behavior

No errors. All types are correctly setup.

πŸ‘Ž Actual Behavior with Screenshots

+ yarn tsc
yarn run v1.22.19
$ tsc
packages/backend/src/plugins/search.ts:71:5 - error TS2322: Type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-tasks/dist/index").TaskRunner' is not assignable to type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-plugin-api/node_modules/@backstage/backend-tasks/dist/index").TaskRunner'.
  Types of property 'run' are incompatible.
    Type '(task: import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-tasks/dist/index").TaskInvocationDefinition) => Promise<void>' is not assignable to type '(task: import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-plugin-api/node_modules/@backstage/backend-tasks/dist/index").TaskInvocationDefinition) => Promise<...>'.
      Types of parameters 'task' and 'task' are incompatible.
        Type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-plugin-api/node_modules/@backstage/backend-tasks/dist/index").TaskInvocationDefinition' is not assignable to type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-tasks/dist/index").TaskInvocationDefinition'.
          Types of property 'fn' are incompatible.
            Type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-plugin-api/node_modules/@backstage/backend-tasks/dist/index").TaskFunction' is not assignable to type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-tasks/dist/index").TaskFunction'.
              Type '(abortSignal: AbortSignal) => void | Promise<void>' is not assignable to type 'TaskFunction'.
                Type '(abortSignal: AbortSignal) => void | Promise<void>' is not assignable to type '(abortSignal: import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/node-abort-controller/index").AbortSignal) => void | Promise<void>'.
                  Types of parameters 'abortSignal' and 'abortSignal' are incompatible.
                    Type 'AbortSignal' is missing the following properties from type 'AbortSignal': reason, throwIfAborted

71     schedule,
       ~~~~~~~~

  node_modules/@backstage/plugin-search-backend-node/dist/index.d.ts:65:5
    65     schedule: TaskRunner;
           ~~~~~~~~
    The expected type comes from property 'schedule' which is declared here on type 'RegisterCollatorParameters'

packages/backend/src/plugins/search.ts:79:5 - error TS2322: Type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-tasks/dist/index").TaskRunner' is not assignable to type 'import("/home/jenkins/agent/workspace/thousandeyes_backstage_PR-181/node_modules/@backstage/backend-plugin-api/node_modules/@backstage/backend-tasks/dist/index").TaskRunner'.

79     schedule,
       ~~~~~~~~

  node_modules/@backstage/plugin-search-backend-node/dist/index.d.ts:65:5
    65     schedule: TaskRunner;
           ~~~~~~~~
    The expected type comes from property 'schedule' which is declared here on type 'RegisterCollatorParameters'

Found 2 errors in the same file, starting at: packages/backend/src/plugins/search.ts:71

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
script returned exit code 2

πŸ‘Ÿ Reproduction steps

  1. yarn upgrade typescript@latest
  2. yarn tsc

πŸ“ƒ Provide the context for the Bug.

This is the only thing preventing the upgrade of the TypeScript library.

πŸ–₯️ Your Environment

OS:   Darwin 22.3.0 - darwin/x64
node: v16.13.1
yarn: 1.22.19
cli:  0.18.1 (installed)
backstage:  1.5.1

Dependencies:
  @backstage/app-defaults                               1.2.0
  @backstage/backend-common                             0.16.0
  @backstage/backend-plugin-api                         0.1.4, 0.2.0
  @backstage/backend-tasks                              0.3.7, 0.4.3
  @backstage/catalog-client                             1.3.1
  @backstage/catalog-model                              1.2.0
  @backstage/cli-common                                 0.1.11
  @backstage/cli                                        0.18.1
  @backstage/config-loader                              1.1.8
  @backstage/config                                     1.0.6
  @backstage/core-app-api                               1.5.0
  @backstage/core-components                            0.12.4
  @backstage/core-plugin-api                            1.4.0
  @backstage/dev-utils                                  1.0.12
  @backstage/errors                                     1.1.4
  @backstage/integration-aws-node                       0.1.0
  @backstage/integration-react                          1.1.10
  @backstage/integration                                1.4.2
  @backstage/plugin-analytics-module-ga                 0.1.24
  @backstage/plugin-api-docs                            0.8.13
  @backstage/plugin-app-backend                         0.3.39
  @backstage/plugin-auth-backend                        0.15.1
  @backstage/plugin-auth-node                           0.2.11
  @backstage/plugin-catalog-backend-module-github       0.1.8
  @backstage/plugin-catalog-backend                     1.6.0
  @backstage/plugin-catalog-common                      1.0.11
  @backstage/plugin-catalog-graph                       0.2.25
  @backstage/plugin-catalog-import                      0.8.12
  @backstage/plugin-catalog-node                        1.3.0
  @backstage/plugin-catalog-react                       1.3.0
  @backstage/plugin-catalog                             1.7.1
  @backstage/plugin-github-actions                      0.5.13
  @backstage/plugin-home                                0.4.30
  @backstage/plugin-jenkins-backend                     0.1.29
  @backstage/plugin-jenkins-common                      0.1.11
  @backstage/plugin-jenkins                             0.7.12
  @backstage/plugin-org                                 0.5.10
  @backstage/plugin-permission-common                   0.7.3
  @backstage/plugin-permission-node                     0.7.5
  @backstage/plugin-permission-react                    0.4.10
  @backstage/plugin-proxy-backend                       0.2.33
  @backstage/plugin-scaffolder-backend                  1.9.0
  @backstage/plugin-scaffolder-common                   1.2.3
  @backstage/plugin-scaffolder                          1.9.1
  @backstage/plugin-search-backend-module-elasticsearch 1.1.0
  @backstage/plugin-search-backend-module-pg            0.3.6
  @backstage/plugin-search-backend-node                 1.1.0
  @backstage/plugin-search-backend                      1.2.0
  @backstage/plugin-search-common                       1.2.1
  @backstage/plugin-search-react                        1.4.0
  @backstage/plugin-search                              1.0.6
  @backstage/plugin-sonarqube-backend                   0.1.4
  @backstage/plugin-sonarqube                           0.4.2
  @backstage/plugin-stack-overflow                      0.1.10
  @backstage/plugin-tech-radar                          0.5.20
  @backstage/plugin-techdocs-backend                    1.5.0
  @backstage/plugin-techdocs-module-addons-contrib      1.0.8
  @backstage/plugin-techdocs-node                       1.4.3
  @backstage/plugin-techdocs-react                      1.1.1
  @backstage/plugin-techdocs                            1.4.2
  @backstage/plugin-user-settings                       0.4.8
  @backstage/release-manifests                          0.0.5
  @backstage/test-utils                                 1.2.5
  @backstage/theme                                      0.2.17
  @backstage/types                                      1.0.2
  @backstage/version-bridge                             1.0.3
Done in 0.68s.

πŸ‘€ Have you spent some time to check if this bug has been raised before?

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

None

freben commented 1 year ago

As you can see under your "Environment" section, you have duplicate installations of the @backstage/backend-tasks package, of incompatible versions. You may want to do yarn why @backstage/backend-tasks and see why that is. Make sure to use yarn backstage-cli versions:bump when you perform upgrades, to try to avoid those situations.

planeiii-te commented 1 year ago

It was the result of installing plugins that referenced other versions. Thank you.

yarn why @backstage/backend-tasks

➜  backstage git:(main) yarn why @backstage/backend-tasks
yarn why v1.22.19
[1/4] πŸ€”  Why do we have the module "@backstage/backend-tasks"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] πŸ”  Finding dependency...
[4/4] 🚑  Calculating file sizes...
=> Found "@backstage/backend-tasks@0.3.7"
info Has been hoisted to "@backstage/backend-tasks"
info Reasons this module exists
   - "workspace-aggregator-e57afcdc-90bc-458f-92cc-2edede20285c" depends on it
   - Hoisted from "_project_#backend#@backstage#backend-tasks"
   - Hoisted from "_project_#backend#@backstage#plugin-catalog-backend-module-github#@backstage#backend-tasks"
   - Hoisted from "_project_#backend#@backstage#plugin-catalog-backend-module-github#@backstage#backend-plugin-api#@backstage#backend-tasks"
info Disk size without dependencies: "836KB"
info Disk size with unique dependencies: "17.12MB"
info Disk size with transitive dependencies: "836KB"
info Number of shared dependencies: 309
=> Found "@backstage/backend-plugin-api#@backstage/backend-tasks@0.4.3"
info This module exists because "_project_#@backstage#backend-plugin-api" depends on it.
info Disk size without dependencies: "160KB"
info Disk size with unique dependencies: "16.4MB"
info Disk size with transitive dependencies: "160KB"
info Number of shared dependencies: 309
=> Found "@backstage/plugin-scaffolder-backend#@backstage/backend-tasks@0.4.3"
info This module exists because "_project_#backend#@backstage#plugin-scaffolder-backend" depends on it.
info Disk size without dependencies: "160KB"
info Disk size with unique dependencies: "16.4MB"
info Disk size with transitive dependencies: "160KB"
info Number of shared dependencies: 309
=> Found "@backstage/plugin-search-backend-node#@backstage/backend-tasks@0.4.3"
info This module exists because "_project_#backend#@backstage#plugin-search-backend-node" depends on it.
info Disk size without dependencies: "160KB"
info Disk size with unique dependencies: "16.4MB"
info Disk size with transitive dependencies: "160KB"
info Number of shared dependencies: 309
✨  Done in 3.92s.