diff --git a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts index 9cf235ab9f..4512070ff7 100644 --- a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts +++ b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts @@ -15,7 +15,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf private iframeMutationObserver: MutationObserver; private iframe: HTMLIFrameElement; private ariaAlertElement: HTMLDivElement; - private ariaAlertTimeout: NodeJS.Timeout; + private ariaAlertTimeout: number | NodeJS.Timeout; private iframeStyles: Partial = { all: "initial", position: "fixed", @@ -41,7 +41,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf }; private foreignMutationsCount = 0; private mutationObserverIterations = 0; - private mutationObserverIterationsResetTimeout: NodeJS.Timeout; + private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout; private readonly windowMessageHandlers: AutofillOverlayIframeWindowMessageHandlers = { updateAutofillOverlayListHeight: (message) => this.updateElementStyles(this.iframe, message.styles), diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts index fa62bc362d..fb6119d816 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts @@ -16,6 +16,21 @@ import { import { AutoFillConstants } from "./autofill-constants"; import AutofillOverlayContentService from "./autofill-overlay-content.service"; +function createMutationRecordMock(customFields = {}): MutationRecord { + return { + addedNodes: mock(), + attributeName: "default-attributeName", + attributeNamespace: "default-attributeNamespace", + nextSibling: null, + oldValue: "default-oldValue", + previousSibling: null, + removedNodes: mock(), + target: null, + type: "attributes", + ...customFields, + }; +} + const defaultWindowReadyState = document.readyState; const defaultDocumentVisibilityState = document.visibilityState; describe("AutofillOverlayContentService", () => { @@ -1304,9 +1319,7 @@ describe("AutofillOverlayContentService", () => { .mockReturnValue(true); autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ - mock({ - target: usernameField, - }), + createMutationRecordMock({ target: usernameField }), ]); expect(usernameField.removeAttribute).not.toHaveBeenCalled(); @@ -1314,10 +1327,7 @@ describe("AutofillOverlayContentService", () => { it("skips handling the mutation if the record type is not for `attributes`", () => { autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ - mock({ - target: usernameField, - type: "childList", - }), + createMutationRecordMock({ target: usernameField, type: "childList" }), ]); expect(usernameField.removeAttribute).not.toHaveBeenCalled(); @@ -1325,7 +1335,7 @@ describe("AutofillOverlayContentService", () => { it("removes all element attributes that are not the style attribute", () => { autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ - mock({ + createMutationRecordMock({ target: usernameField, type: "attributes", attributeName: "placeholder", @@ -1337,7 +1347,7 @@ describe("AutofillOverlayContentService", () => { it("removes all attached style attributes and sets the default styles", () => { autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ - mock({ + createMutationRecordMock({ target: usernameField, type: "attributes", attributeName: "style", diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts index ba70cc0548..7e1f811247 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -42,12 +42,12 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte private overlayListElement: HTMLElement; private mostRecentlyFocusedField: ElementWithOpId; private focusedFieldData: FocusedFieldData; - private userInteractionEventTimeout: NodeJS.Timeout; + private userInteractionEventTimeout: number | NodeJS.Timeout; private overlayElementsMutationObserver: MutationObserver; private bodyElementMutationObserver: MutationObserver; private documentElementMutationObserver: MutationObserver; private mutationObserverIterations = 0; - private mutationObserverIterationsResetTimeout: NodeJS.Timeout; + private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout; private autofillFieldKeywordsMap: WeakMap = new WeakMap(); private eventHandlersMemo: { [key: string]: EventListener } = {}; private readonly customElementDefaultStyles: Partial = { @@ -846,7 +846,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte this.toggleOverlayHidden(true); this.clearUserInteractionEventTimeout(); - this.userInteractionEventTimeout = setTimeout(this.triggerOverlayRepositionUpdates, 750); + this.userInteractionEventTimeout = setTimeout( + this.triggerOverlayRepositionUpdates, + 750, + ) as unknown as number; }; /** diff --git a/package-lock.json b/package-lock.json index b7aff24278..c63c6577c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -178,7 +178,7 @@ "ts-loader": "9.5.1", "tsconfig-paths-webpack-plugin": "4.1.0", "type-fest": "2.19.0", - "typescript": "4.9.5", + "typescript": "5.1.6", "url": "0.11.3", "util": "0.12.5", "wait-on": "7.2.0", @@ -37421,16 +37421,16 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uglify-js": { diff --git a/package.json b/package.json index c33e88c528..231e94192a 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "ts-loader": "9.5.1", "tsconfig-paths-webpack-plugin": "4.1.0", "type-fest": "2.19.0", - "typescript": "4.9.5", + "typescript": "5.1.6", "url": "0.11.3", "util": "0.12.5", "wait-on": "7.2.0", diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 6dd355c8da..c8144b97b9 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -34,5 +34,6 @@ } ] }, - "include": ["apps/**/*", "libs/**/*", "bitwarden_license/**/*"] + "include": ["apps/**/*", "libs/**/*", "bitwarden_license/**/*"], + "exclude": ["**/build"] }