From 198a13755faa915fe2f87825709cb0c89a016235 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 8 Dec 2024 17:24:47 -0800 Subject: [PATCH] Upgrade TypeScript and core-js (cherry picked from commit 148480909917f69ff3b2ca547ccb4716dd56606e) Closes #5306 --- .../Selectors/createArtistAlbumsSelector.ts | 3 ++- .../createArtistMetadataProfileSelector.ts | 3 ++- .../createArtistQualityProfileSelector.ts | 3 ++- ...{getRelativeDate.js => getRelativeDate.ts} | 24 ++++++++++++++++--- package.json | 4 ++-- yarn.lock | 16 ++++++------- 6 files changed, 37 insertions(+), 16 deletions(-) rename frontend/src/Utilities/Date/{getRelativeDate.js => getRelativeDate.ts} (65%) diff --git a/frontend/src/Store/Selectors/createArtistAlbumsSelector.ts b/frontend/src/Store/Selectors/createArtistAlbumsSelector.ts index baffd87ec..414a451f5 100644 --- a/frontend/src/Store/Selectors/createArtistAlbumsSelector.ts +++ b/frontend/src/Store/Selectors/createArtistAlbumsSelector.ts @@ -1,4 +1,5 @@ import { createSelector } from 'reselect'; +import AlbumAppState from 'App/State/AlbumAppState'; import AppState from 'App/State/AppState'; import Artist from 'Artist/Artist'; import { createArtistSelectorForHook } from './createArtistSelector'; @@ -7,7 +8,7 @@ function createArtistAlbumsSelector(artistId: number) { return createSelector( (state: AppState) => state.albums, createArtistSelectorForHook(artistId), - (albums, artist = {} as Artist) => { + (albums: AlbumAppState, artist = {} as Artist) => { const { isFetching, isPopulated, error, items } = albums; const filteredAlbums = items.filter( diff --git a/frontend/src/Store/Selectors/createArtistMetadataProfileSelector.ts b/frontend/src/Store/Selectors/createArtistMetadataProfileSelector.ts index 0acbd3997..fa60d936d 100644 --- a/frontend/src/Store/Selectors/createArtistMetadataProfileSelector.ts +++ b/frontend/src/Store/Selectors/createArtistMetadataProfileSelector.ts @@ -1,13 +1,14 @@ import { createSelector } from 'reselect'; import AppState from 'App/State/AppState'; import Artist from 'Artist/Artist'; +import MetadataProfile from 'typings/MetadataProfile'; import { createArtistSelectorForHook } from './createArtistSelector'; function createArtistMetadataProfileSelector(artistId: number) { return createSelector( (state: AppState) => state.settings.metadataProfiles.items, createArtistSelectorForHook(artistId), - (metadataProfiles, artist = {} as Artist) => { + (metadataProfiles: MetadataProfile[], artist = {} as Artist) => { return metadataProfiles.find((profile) => { return profile.id === artist.metadataProfileId; }); diff --git a/frontend/src/Store/Selectors/createArtistQualityProfileSelector.ts b/frontend/src/Store/Selectors/createArtistQualityProfileSelector.ts index 99325276f..67639919b 100644 --- a/frontend/src/Store/Selectors/createArtistQualityProfileSelector.ts +++ b/frontend/src/Store/Selectors/createArtistQualityProfileSelector.ts @@ -1,13 +1,14 @@ import { createSelector } from 'reselect'; import AppState from 'App/State/AppState'; import Artist from 'Artist/Artist'; +import QualityProfile from 'typings/QualityProfile'; import { createArtistSelectorForHook } from './createArtistSelector'; function createArtistQualityProfileSelector(artistId: number) { return createSelector( (state: AppState) => state.settings.qualityProfiles.items, createArtistSelectorForHook(artistId), - (qualityProfiles, artist = {} as Artist) => { + (qualityProfiles: QualityProfile[], artist = {} as Artist) => { return qualityProfiles.find( (profile) => profile.id === artist.qualityProfileId ); diff --git a/frontend/src/Utilities/Date/getRelativeDate.js b/frontend/src/Utilities/Date/getRelativeDate.ts similarity index 65% rename from frontend/src/Utilities/Date/getRelativeDate.js rename to frontend/src/Utilities/Date/getRelativeDate.ts index 812064272..178d14fb7 100644 --- a/frontend/src/Utilities/Date/getRelativeDate.js +++ b/frontend/src/Utilities/Date/getRelativeDate.ts @@ -6,15 +6,33 @@ import isTomorrow from 'Utilities/Date/isTomorrow'; import isYesterday from 'Utilities/Date/isYesterday'; import translate from 'Utilities/String/translate'; -function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds = false, timeForToday = false } = {}) { +interface GetRelativeDateOptions { + timeFormat?: string; + includeSeconds?: boolean; + timeForToday?: boolean; +} + +function getRelativeDate( + date: string | undefined, + shortDateFormat: string, + showRelativeDates: boolean, + { + timeFormat, + includeSeconds = false, + timeForToday = false, + }: GetRelativeDateOptions = {} +) { if (!date) { - return null; + return ''; } const isTodayDate = isToday(date); if (isTodayDate && timeForToday && timeFormat) { - return formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds }); + return formatTime(date, timeFormat, { + includeMinuteZero: true, + includeSeconds, + }); } if (!showRelativeDates) { diff --git a/package.json b/package.json index 15cdbaf46..541ac96c2 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "redux-thunk": "2.4.2", "reselect": "4.1.8", "stacktrace-js": "2.0.2", - "typescript": "5.1.6" + "typescript": "5.7.2" }, "devDependencies": { "@babel/core": "7.26.0", @@ -109,7 +109,7 @@ "babel-loader": "9.2.1", "babel-plugin-inline-classnames": "2.0.1", "babel-plugin-transform-react-remove-prop-types": "0.4.24", - "core-js": "3.38.1", + "core-js": "3.39.0", "css-loader": "6.7.3", "css-modules-typescript-loader": "4.0.1", "eslint": "8.57.1", diff --git a/yarn.lock b/yarn.lock index 52f0191bc..f795a84db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2541,10 +2541,10 @@ core-js-compat@^3.38.0, core-js-compat@^3.38.1: dependencies: browserslist "^4.23.3" -core-js@3.38.1: - version "3.38.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.38.1.tgz#aa375b79a286a670388a1a363363d53677c0383e" - integrity sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw== +core-js@3.39.0: + version "3.39.0" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.39.0.tgz#57f7647f4d2d030c32a72ea23a0555b2eaa30f83" + integrity sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g== core-js@^2.4.0: version "2.6.12" @@ -6900,10 +6900,10 @@ typescript-plugin-css-modules@5.0.1: stylus "^0.59.0" tsconfig-paths "^4.1.2" -typescript@5.1.6: - version "5.1.6" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274" - integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA== +typescript@5.7.2: + version "5.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6" + integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg== unbox-primitive@^1.0.2: version "1.0.2"