mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
[PM-22305] Upgrade typescript to 5.8 (#15044)
Upgrade to the latest supported typescript version in Angular. Resolved TS errors by: - adding `: any` which is what the compiler previously implied and now warns about. - adding `toJSON` to satisfy requirement.
This commit is contained in:
@@ -160,7 +160,7 @@ export class AccountSwitcherService {
|
||||
throwError(() => new Error(AccountSwitcherService.incompleteAccountSwitchError)),
|
||||
}),
|
||||
),
|
||||
).catch((err) => {
|
||||
).catch((err): any => {
|
||||
if (
|
||||
err instanceof Error &&
|
||||
err.message === AccountSwitcherService.incompleteAccountSwitchError
|
||||
|
||||
@@ -161,7 +161,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
|
||||
// Create a timeout observable that emits an empty array if pageDetailsFromTab$ hasn't emitted within 1 second.
|
||||
const pageDetailsTimeout$ = timer(1000).pipe(
|
||||
map(() => []),
|
||||
map((): any => []),
|
||||
takeUntil(sharedPageDetailsFromTab$),
|
||||
);
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ export class BrowserRouterService {
|
||||
child = child.firstChild;
|
||||
}
|
||||
|
||||
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
|
||||
// eslint-disable-next-line no-constant-binary-expression
|
||||
const updateUrl = !child?.data?.doNotSaveUrl ?? true;
|
||||
const updateUrl = !child?.data?.doNotSaveUrl;
|
||||
|
||||
if (updateUrl) {
|
||||
this.setPreviousUrl(event.url);
|
||||
|
||||
@@ -62,9 +62,7 @@ export class PopupRouterCacheService {
|
||||
child = child.firstChild;
|
||||
}
|
||||
|
||||
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
|
||||
// eslint-disable-next-line no-constant-binary-expression
|
||||
return !child?.data?.doNotSaveUrl ?? true;
|
||||
return !child?.data?.doNotSaveUrl;
|
||||
}),
|
||||
switchMap((event) => this.push(event.url)),
|
||||
)
|
||||
|
||||
@@ -761,11 +761,13 @@ function createSeededVaultPopupListFiltersService(
|
||||
const collectionServiceMock = {
|
||||
decryptedCollections$: () => seededCollections$,
|
||||
getAllNested: () =>
|
||||
seededCollections$.value.map((c) => ({
|
||||
children: [],
|
||||
node: c,
|
||||
parent: null,
|
||||
})),
|
||||
seededCollections$.value.map(
|
||||
(c): TreeNode<CollectionView> => ({
|
||||
children: [],
|
||||
node: c,
|
||||
parent: null as any,
|
||||
}),
|
||||
),
|
||||
} as any;
|
||||
|
||||
const folderServiceMock = {
|
||||
|
||||
@@ -290,7 +290,7 @@ export class VaultV2Component<C extends CipherViewLike>
|
||||
) {
|
||||
const value = await firstValueFrom(
|
||||
this.totpService.getCode$(this.cipher.login.totp),
|
||||
).catch(() => null);
|
||||
).catch((): any => null);
|
||||
if (value) {
|
||||
this.copyValue(this.cipher, value.code, "verificationCodeTotp", "TOTP");
|
||||
}
|
||||
@@ -329,7 +329,7 @@ export class VaultV2Component<C extends CipherViewLike>
|
||||
|
||||
this.activeUserId = await firstValueFrom(
|
||||
this.accountService.activeAccount$.pipe(getUserId),
|
||||
).catch(() => null);
|
||||
).catch((): any => null);
|
||||
|
||||
if (this.activeUserId) {
|
||||
this.cipherService
|
||||
@@ -448,7 +448,7 @@ export class VaultV2Component<C extends CipherViewLike>
|
||||
const dialogRef = AttachmentsV2Component.open(this.dialogService, {
|
||||
cipherId: this.cipherId as CipherId,
|
||||
});
|
||||
const result = await firstValueFrom(dialogRef.closed).catch(() => null);
|
||||
const result = await firstValueFrom(dialogRef.closed).catch((): any => null);
|
||||
if (
|
||||
result?.action === AttachmentDialogResult.Removed ||
|
||||
result?.action === AttachmentDialogResult.Uploaded
|
||||
@@ -574,7 +574,7 @@ export class VaultV2Component<C extends CipherViewLike>
|
||||
click: async () => {
|
||||
const value = await firstValueFrom(
|
||||
this.totpService.getCode$(cipher.login.totp),
|
||||
).catch(() => null);
|
||||
).catch((): any => null);
|
||||
if (value) {
|
||||
this.copyValue(cipher, value.code, "verificationCodeTotp", "TOTP");
|
||||
}
|
||||
@@ -617,7 +617,7 @@ export class VaultV2Component<C extends CipherViewLike>
|
||||
async buildFormConfig(action: CipherFormMode) {
|
||||
this.config = await this.formConfigService
|
||||
.buildConfig(action, this.cipherId as CipherId, this.addType)
|
||||
.catch(() => null);
|
||||
.catch((): any => null);
|
||||
}
|
||||
|
||||
async editCipher(cipher: CipherView) {
|
||||
|
||||
@@ -110,7 +110,7 @@ export class SubscriptionPricingService {
|
||||
);
|
||||
|
||||
private free$: Observable<BusinessSubscriptionPricingTier> = this.plansResponse$.pipe(
|
||||
map((plans) => {
|
||||
map((plans): BusinessSubscriptionPricingTier => {
|
||||
const freePlan = plans.data.find((plan) => plan.type === PlanType.Free)!;
|
||||
|
||||
return {
|
||||
@@ -215,20 +215,22 @@ export class SubscriptionPricingService {
|
||||
);
|
||||
|
||||
private custom$: Observable<BusinessSubscriptionPricingTier> = this.plansResponse$.pipe(
|
||||
map(() => ({
|
||||
id: BusinessSubscriptionPricingTierIds.Custom,
|
||||
name: this.i18nService.t("planNameCustom"),
|
||||
description: this.i18nService.t("planDescCustom"),
|
||||
availableCadences: [],
|
||||
passwordManager: {
|
||||
type: "custom",
|
||||
features: [
|
||||
this.featureTranslations.strengthenCybersecurity(),
|
||||
this.featureTranslations.boostProductivity(),
|
||||
this.featureTranslations.seamlessIntegration(),
|
||||
],
|
||||
},
|
||||
})),
|
||||
map(
|
||||
(): BusinessSubscriptionPricingTier => ({
|
||||
id: BusinessSubscriptionPricingTierIds.Custom,
|
||||
name: this.i18nService.t("planNameCustom"),
|
||||
description: this.i18nService.t("planDescCustom"),
|
||||
availableCadences: [],
|
||||
passwordManager: {
|
||||
type: "custom",
|
||||
features: [
|
||||
this.featureTranslations.strengthenCybersecurity(),
|
||||
this.featureTranslations.boostProductivity(),
|
||||
this.featureTranslations.seamlessIntegration(),
|
||||
],
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
private showUnexpectedErrorToast() {
|
||||
|
||||
@@ -75,9 +75,7 @@ export class RouterService {
|
||||
const titleId: string = child?.snapshot?.data?.titleId;
|
||||
const rawTitle: string = child?.snapshot?.data?.title;
|
||||
|
||||
// TODO: Eslint upgrade. Please resolve this since the ?? does nothing
|
||||
// eslint-disable-next-line no-constant-binary-expression
|
||||
const updateUrl = !child?.snapshot?.data?.doNotSaveUrl ?? true;
|
||||
const updateUrl = !child?.snapshot?.data?.doNotSaveUrl;
|
||||
|
||||
if (titleId != null || rawTitle != null) {
|
||||
const newTitle = rawTitle != null ? rawTitle : i18nService.t(titleId);
|
||||
|
||||
@@ -87,7 +87,7 @@ export class ProductSwitcherService {
|
||||
startWith(null), // Start with a null event to trigger the initial combineLatest
|
||||
filter((e) => e instanceof NavigationEnd || e instanceof NavigationStart || e === null),
|
||||
),
|
||||
]).pipe(map(() => null));
|
||||
]).pipe(map((): any => null));
|
||||
|
||||
constructor(
|
||||
private organizationService: OrganizationService,
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
CipherViewLikeUtils,
|
||||
} from "@bitwarden/common/vault/utils/cipher-view-like-utils";
|
||||
import { SortDirection, TableDataSource } from "@bitwarden/components";
|
||||
import { OrganizationId } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { GroupView } from "../../../admin-console/organizations/core";
|
||||
|
||||
@@ -579,7 +580,7 @@ export class VaultItemsComponent<C extends CipherViewLike> {
|
||||
.every(({ cipher }) => cipher?.edit && cipher?.viewPassword);
|
||||
}
|
||||
|
||||
private getUniqueOrganizationIds(): Set<string> {
|
||||
private getUniqueOrganizationIds(): Set<string | [] | OrganizationId> {
|
||||
return new Set(this.selection.selected.flatMap((i) => i.cipher?.organizationId ?? []));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
return convertToAccessPolicyItemViews(policies);
|
||||
}),
|
||||
),
|
||||
catchError(async () => {
|
||||
catchError(async (): Promise<any> => {
|
||||
this.logService.info("Error fetching project people access policies.");
|
||||
await this.router.navigate(["/sm", this.organizationId, "projects"]);
|
||||
return undefined;
|
||||
|
||||
@@ -75,7 +75,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
|
||||
// We must do this to make the mocked classes available for all the
|
||||
// assertCredential(...) tests.
|
||||
global.PublicKeyCredential = MockPublicKeyCredential;
|
||||
global.PublicKeyCredential = MockPublicKeyCredential as any;
|
||||
global.AuthenticatorAssertionResponse = MockAuthenticatorAssertionResponse;
|
||||
});
|
||||
|
||||
@@ -397,4 +397,8 @@ export class MockPublicKeyCredential implements PublicKeyCredential {
|
||||
static isUserVerifyingPlatformAuthenticatorAvailable(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ describe("WebAuthnLoginService", () => {
|
||||
|
||||
// We must do this to make the mocked classes available for all the
|
||||
// assertCredential(...) tests.
|
||||
global.PublicKeyCredential = MockPublicKeyCredential;
|
||||
global.PublicKeyCredential = MockPublicKeyCredential as any;
|
||||
global.AuthenticatorAssertionResponse = MockAuthenticatorAssertionResponse;
|
||||
|
||||
// Save the original navigator
|
||||
@@ -316,6 +316,10 @@ class MockPublicKeyCredential implements PublicKeyCredential {
|
||||
static isUserVerifyingPlatformAuthenticatorAvailable(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
function buildCredentialAssertionOptions(): WebAuthnLoginCredentialAssertionOptionsView {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function perUserCache$<TValue>(
|
||||
create(userId),
|
||||
clearBuffer$.pipe(
|
||||
filter((clearId) => clearId === userId || clearId === null),
|
||||
map(() => null),
|
||||
map((): any => null),
|
||||
),
|
||||
).pipe(shareReplay({ bufferSize: 1, refCount: false }));
|
||||
cache.set(userId, observable);
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("AdditionalOptionsSectionComponent", () => {
|
||||
let passwordRepromptService: MockProxy<PasswordRepromptService>;
|
||||
let passwordRepromptEnabled$: BehaviorSubject<boolean>;
|
||||
|
||||
const getInitialCipherView = jest.fn(() => null);
|
||||
const getInitialCipherView = jest.fn((): any => null);
|
||||
const formStatusChange$ = new BehaviorSubject<"enabled" | "disabled">("enabled");
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -34,7 +34,7 @@ describe("AutofillOptionsComponent", () => {
|
||||
let domainSettingsService: MockProxy<DomainSettingsService>;
|
||||
let autofillSettingsService: MockProxy<AutofillSettingsServiceAbstraction>;
|
||||
let platformUtilsService: MockProxy<PlatformUtilsService>;
|
||||
const getInitialCipherView = jest.fn(() => null);
|
||||
const getInitialCipherView = jest.fn((): any => null);
|
||||
const formStatusChange$ = new BehaviorSubject<"enabled" | "disabled">("enabled");
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -20,7 +20,7 @@ describe("CardDetailsSectionComponent", () => {
|
||||
let registerChildFormSpy: jest.SpyInstance;
|
||||
let patchCipherSpy: jest.SpyInstance;
|
||||
|
||||
const getInitialCipherView = jest.fn(() => null);
|
||||
const getInitialCipherView = jest.fn((): any => null);
|
||||
|
||||
beforeEach(async () => {
|
||||
cipherFormProvider = mock<CipherFormContainer>({ getInitialCipherView });
|
||||
|
||||
@@ -37,7 +37,7 @@ describe("CipherFormComponent", () => {
|
||||
provide: CipherFormCacheService,
|
||||
useValue: { init: jest.fn(), getCachedCipherView: jest.fn() },
|
||||
},
|
||||
{ provide: ViewCacheService, useValue: { signal: jest.fn(() => () => null) } },
|
||||
{ provide: ViewCacheService, useValue: { signal: jest.fn(() => (): any => null) } },
|
||||
{ provide: ConfigService, useValue: mock<ConfigService>() },
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("LoginDetailsSectionComponent", () => {
|
||||
let configService: MockProxy<ConfigService>;
|
||||
|
||||
const collect = jest.fn().mockResolvedValue(null);
|
||||
const getInitialCipherView = jest.fn(() => null);
|
||||
const getInitialCipherView = jest.fn((): any => null);
|
||||
|
||||
beforeEach(async () => {
|
||||
getInitialCipherView.mockClear();
|
||||
|
||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -173,7 +173,7 @@
|
||||
"ts-loader": "9.5.2",
|
||||
"tsconfig-paths-webpack-plugin": "4.2.0",
|
||||
"type-fest": "2.19.0",
|
||||
"typescript": "5.5.4",
|
||||
"typescript": "5.8.3",
|
||||
"typescript-eslint": "8.31.0",
|
||||
"typescript-strict-plugin": "2.4.4",
|
||||
"url": "0.11.4",
|
||||
@@ -38542,9 +38542,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz",
|
||||
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
"ts-loader": "9.5.2",
|
||||
"tsconfig-paths-webpack-plugin": "4.2.0",
|
||||
"type-fest": "2.19.0",
|
||||
"typescript": "5.5.4",
|
||||
"typescript": "5.8.3",
|
||||
"typescript-eslint": "8.31.0",
|
||||
"typescript-strict-plugin": "2.4.4",
|
||||
"url": "0.11.4",
|
||||
|
||||
Reference in New Issue
Block a user