From 31731b0a805b86452b2ec0b6fdef9ba5256087a7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 7 Mar 2025 14:31:44 +0100 Subject: [PATCH] bump to typescript 5.6 Signed-off-by: Patrik Oldsberg --- .changeset/brave-wasps-fry.md | 5 ++ .changeset/thin-books-rest.md | 5 ++ .../ast-types-npm-0.14.2-43c4ac4b0d.patch | 15 ++++ package.json | 6 +- .../templates/default-app/package.json.hbs | 2 +- plugins/catalog/package.json | 1 - .../DefaultEntityPresentationApi.ts | 40 +++++++++- yarn.lock | 79 ++++++++----------- 8 files changed, 100 insertions(+), 53 deletions(-) create mode 100644 .changeset/brave-wasps-fry.md create mode 100644 .changeset/thin-books-rest.md create mode 100644 .yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch diff --git a/.changeset/brave-wasps-fry.md b/.changeset/brave-wasps-fry.md new file mode 100644 index 0000000000..9703e3b5b5 --- /dev/null +++ b/.changeset/brave-wasps-fry.md @@ -0,0 +1,5 @@ +--- +'@backstage/create-app': minor +--- + +Upgraded the TypeScript version in the template to `5.8`. diff --git a/.changeset/thin-books-rest.md b/.changeset/thin-books-rest.md new file mode 100644 index 0000000000..3a9134443e --- /dev/null +++ b/.changeset/thin-books-rest.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Internal refactor to avoid `expiry-map` dependency. diff --git a/.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch b/.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch new file mode 100644 index 0000000000..add3e4c556 --- /dev/null +++ b/.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch @@ -0,0 +1,15 @@ +diff --git a/main.d.ts b/main.d.ts +index 6b9a8d05d61821a7e7dc831a52a9f7b505bfee42..1010bb5352d975a171a4019768ff6f6f2967c301 100644 +--- a/main.d.ts ++++ b/main.d.ts +@@ -1,7 +1,7 @@ +-import { ASTNode, Type, AnyType, Field } from "./lib/types"; +-import { NodePath } from "./lib/node-path"; ++import { ASTNode, type Type, AnyType, Field } from "./lib/types"; ++import { type NodePath } from "./lib/node-path"; + import { namedTypes } from "./gen/namedTypes"; +-import { builders } from "./gen/builders"; ++import { type builders } from "./gen/builders"; + import { Visitor } from "./gen/visitor"; + declare const astNodesAreEquivalent: { + (a: any, b: any, problemPath?: any): boolean; diff --git a/package.json b/package.json index 4c92b778ce..79bdd06002 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,9 @@ "@material-ui/pickers@^3.3.10": "patch:@material-ui/pickers@npm%3A3.3.11#./.yarn/patches/@material-ui-pickers-npm-3.3.11-1c8f68ea20.patch", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", - "jest-haste-map@^29.7.0": "patch:jest-haste-map@npm%3A29.7.0#./.yarn/patches/jest-haste-map-npm-29.7.0-e3be419eff.patch" + "jest-haste-map@^29.7.0": "patch:jest-haste-map@npm%3A29.7.0#./.yarn/patches/jest-haste-map-npm-29.7.0-e3be419eff.patch", + "ast-types@^0.14.1": "patch:ast-types@npm%3A0.14.2#./.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch", + "ast-types@0.14.2": "patch:ast-types@npm%3A0.14.2#./.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch" }, "dependencies": { "@backstage/errors": "workspace:^", @@ -145,7 +147,7 @@ "sloc": "^0.3.1", "sort-package-json": "^2.8.0", "typedoc": "^0.27.6", - "typescript": "~5.2.0" + "typescript": "~5.6.0" }, "packageManager": "yarn@3.8.1", "engines": { diff --git a/packages/create-app/templates/default-app/package.json.hbs b/packages/create-app/templates/default-app/package.json.hbs index af519905e9..83659e2a02 100644 --- a/packages/create-app/templates/default-app/package.json.hbs +++ b/packages/create-app/templates/default-app/package.json.hbs @@ -36,7 +36,7 @@ "@playwright/test": "^1.32.3", "node-gyp": "^10.0.0", "prettier": "^2.3.2", - "typescript": "~5.4.0" + "typescript": "~5.8.0" }, "resolutions": { "@types/react": "^18", diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index cdea19fe1a..2d12ec5367 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -79,7 +79,6 @@ "@mui/utils": "^5.14.15", "classnames": "^2.3.1", "dataloader": "^2.0.0", - "expiry-map": "^2.0.0", "history": "^5.0.0", "lodash": "^4.17.21", "pluralize": "^8.0.0", diff --git a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts index 2832792951..4b80820e77 100644 --- a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts +++ b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts @@ -28,7 +28,6 @@ import { } from '@backstage/plugin-catalog-react'; import { durationToMilliseconds, HumanDuration } from '@backstage/types'; import DataLoader from 'dataloader'; -import ExpiryMap from 'expiry-map'; import ObservableImpl from 'zen-observable'; import { createDefaultRenderer, @@ -149,6 +148,45 @@ interface CacheEntry { entity: Entity | undefined; } +// Simply expory map for the data loader, which only expects a map that implements set, get, and delete and clear +export class ExpiryMap extends Map { + #ttlMs: number; + #timestamps: Map = new Map(); + + constructor(ttlMs: number) { + super(); + this.#ttlMs = ttlMs; + } + + set(key: K, value: V) { + const result = super.set(key, value); + this.#timestamps.set(key, Date.now()); + return result; + } + + get(key: K) { + if (!this.has(key)) { + return undefined; + } + const timestamp = this.#timestamps.get(key)!; + if (Date.now() - timestamp > this.#ttlMs) { + this.delete(key); + return undefined; + } + return super.get(key); + } + + delete(key: K) { + this.#timestamps.delete(key); + return super.delete(key); + } + + clear() { + this.#timestamps.clear(); + return super.clear(); + } +} + /** * Default implementation of the {@link @backstage/plugin-catalog-react#EntityPresentationApi}. * diff --git a/yarn.lock b/yarn.lock index e5260d2a63..87017c2e2d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6437,7 +6437,6 @@ __metadata: "@types/react": ^18.0.0 classnames: ^2.3.1 dataloader: ^2.0.0 - expiry-map: ^2.0.0 history: ^5.0.0 lodash: ^4.17.21 pluralize: ^8.0.0 @@ -23279,7 +23278,7 @@ __metadata: languageName: node linkType: hard -"ast-types@npm:0.14.2, ast-types@npm:^0.14.1": +"ast-types@npm:0.14.2": version: 0.14.2 resolution: "ast-types@npm:0.14.2" dependencies: @@ -23306,6 +23305,15 @@ __metadata: languageName: node linkType: hard +"ast-types@patch:ast-types@npm%3A0.14.2#./.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch::locator=root%40workspace%3A.": + version: 0.14.2 + resolution: "ast-types@patch:ast-types@npm%3A0.14.2#./.yarn/patches/ast-types-npm-0.14.2-43c4ac4b0d.patch::version=0.14.2&hash=f42322&locator=root%40workspace%3A." + dependencies: + tslib: ^2.0.1 + checksum: 6266562e45466c0d79eee8de68ace0ae4d69968638910cfc153f809632b88b6a4ad44ed33ab7b1e9a3b26ee5f5472bb6be834f380ca533db4a6f8ee1675548fa + languageName: node + linkType: hard + "astral-regex@npm:^2.0.0": version: 2.0.0 resolution: "astral-regex@npm:2.0.0" @@ -29134,15 +29142,6 @@ __metadata: languageName: node linkType: hard -"expiry-map@npm:^2.0.0": - version: 2.0.0 - resolution: "expiry-map@npm:2.0.0" - dependencies: - map-age-cleaner: ^0.2.0 - checksum: 9be8662e1a5c1084fb6d0ddc5402658dd06101c330454062b2f5efbf1477259d272e54ec16663d7d12a93d08ed510535781c36acb214696c5bc3a690a02a7a9d - languageName: node - linkType: hard - "exponential-backoff@npm:^3.1.1": version: 3.1.1 resolution: "exponential-backoff@npm:3.1.1" @@ -35739,15 +35738,6 @@ __metadata: languageName: node linkType: hard -"map-age-cleaner@npm:^0.2.0": - version: 0.2.0 - resolution: "map-age-cleaner@npm:0.2.0" - dependencies: - p-defer: ^1.0.0 - checksum: 13a6810b76b0067efa7f4b0f3dc58b58b4a4b5faa4cae5a0e8d5d59eda04d7074724eee426c9b5890a1d7e14d1e2902a090587acc8e2430198e79ab1556a2dad - languageName: node - linkType: hard - "map-or-similar@npm:^1.5.0": version: 1.5.0 resolution: "map-or-similar@npm:1.5.0" @@ -38593,13 +38583,6 @@ __metadata: languageName: node linkType: hard -"p-defer@npm:^1.0.0": - version: 1.0.0 - resolution: "p-defer@npm:1.0.0" - checksum: 4271b935c27987e7b6f229e5de4cdd335d808465604644cb7b4c4c95bef266735859a93b16415af8a41fd663ee9e3b97a1a2023ca9def613dba1bad2a0da0c7b - languageName: node - linkType: hard - "p-filter@npm:^2.1.0": version: 2.1.0 resolution: "p-filter@npm:2.1.0" @@ -42767,7 +42750,7 @@ __metadata: sloc: ^0.3.1 sort-package-json: ^2.8.0 typedoc: ^0.27.6 - typescript: ~5.2.0 + typescript: ~5.6.0 languageName: unknown linkType: soft @@ -46019,16 +46002,6 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.2.0": - version: 5.2.2 - resolution: "typescript@npm:5.2.2" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c - languageName: node - linkType: hard - "typescript@npm:~5.5.0": version: 5.5.4 resolution: "typescript@npm:5.5.4" @@ -46039,6 +46012,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:~5.6.0": + version: 5.6.3 + resolution: "typescript@npm:5.6.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: ba302f8822777ebefb28b554105f3e074466b671e7444ec6b75dadc008a62f46f373d9e57ceced1c433756d06c8b7dc569a7eefdf3a9573122a49205ff99021a + languageName: node + linkType: hard + "typescript@patch:typescript@5.4.2#~builtin": version: 5.4.2 resolution: "typescript@patch:typescript@npm%3A5.4.2#~builtin::version=5.4.2&hash=5adc0c" @@ -46049,16 +46032,6 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@~5.2.0#~builtin": - version: 5.2.2 - resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin::version=5.2.2&hash=f3b441" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 0f4da2f15e6f1245e49db15801dbee52f2bbfb267e1c39225afdab5afee1a72839cd86000e65ee9d7e4dfaff12239d28beaf5ee431357fcced15fb08583d72ca - languageName: node - linkType: hard - "typescript@patch:typescript@~5.5.0#~builtin": version: 5.5.4 resolution: "typescript@patch:typescript@npm%3A5.5.4#~builtin::version=5.5.4&hash=5adc0c" @@ -46069,6 +46042,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@~5.6.0#~builtin": + version: 5.6.3 + resolution: "typescript@patch:typescript@npm%3A5.6.3#~builtin::version=5.6.3&hash=5adc0c" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: ade87bce2363ee963eed0e4ca8a312ea02c81873ebd53609bc3f6dc0a57f6e61ad7e3fb8cbb7f7ab8b5081cbee801b023f7c4823ee70b1c447eae050e6c7622b + languageName: node + linkType: hard + "ua-parser-js@npm:^0.7.30": version: 0.7.33 resolution: "ua-parser-js@npm:0.7.33"