1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-06-26 10:35:48 +02:00

Upgrade typescript to 5.1 (#7917)

Co-authored-by: Cesar Gonzalez <cgonzalez@bitwarden.com>
This commit is contained in:
Oscar Hinton 2024-02-20 12:14:54 +01:00 committed by GitHub
parent e459e30c50
commit 566423925d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 21 deletions

View File

@ -15,7 +15,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
private iframeMutationObserver: MutationObserver; private iframeMutationObserver: MutationObserver;
private iframe: HTMLIFrameElement; private iframe: HTMLIFrameElement;
private ariaAlertElement: HTMLDivElement; private ariaAlertElement: HTMLDivElement;
private ariaAlertTimeout: NodeJS.Timeout; private ariaAlertTimeout: number | NodeJS.Timeout;
private iframeStyles: Partial<CSSStyleDeclaration> = { private iframeStyles: Partial<CSSStyleDeclaration> = {
all: "initial", all: "initial",
position: "fixed", position: "fixed",
@ -41,7 +41,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
}; };
private foreignMutationsCount = 0; private foreignMutationsCount = 0;
private mutationObserverIterations = 0; private mutationObserverIterations = 0;
private mutationObserverIterationsResetTimeout: NodeJS.Timeout; private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout;
private readonly windowMessageHandlers: AutofillOverlayIframeWindowMessageHandlers = { private readonly windowMessageHandlers: AutofillOverlayIframeWindowMessageHandlers = {
updateAutofillOverlayListHeight: (message) => updateAutofillOverlayListHeight: (message) =>
this.updateElementStyles(this.iframe, message.styles), this.updateElementStyles(this.iframe, message.styles),

View File

@ -16,6 +16,21 @@ import {
import { AutoFillConstants } from "./autofill-constants"; import { AutoFillConstants } from "./autofill-constants";
import AutofillOverlayContentService from "./autofill-overlay-content.service"; import AutofillOverlayContentService from "./autofill-overlay-content.service";
function createMutationRecordMock(customFields = {}): MutationRecord {
return {
addedNodes: mock<NodeList>(),
attributeName: "default-attributeName",
attributeNamespace: "default-attributeNamespace",
nextSibling: null,
oldValue: "default-oldValue",
previousSibling: null,
removedNodes: mock<NodeList>(),
target: null,
type: "attributes",
...customFields,
};
}
const defaultWindowReadyState = document.readyState; const defaultWindowReadyState = document.readyState;
const defaultDocumentVisibilityState = document.visibilityState; const defaultDocumentVisibilityState = document.visibilityState;
describe("AutofillOverlayContentService", () => { describe("AutofillOverlayContentService", () => {
@ -1304,9 +1319,7 @@ describe("AutofillOverlayContentService", () => {
.mockReturnValue(true); .mockReturnValue(true);
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
mock<MutationRecord>({ createMutationRecordMock({ target: usernameField }),
target: usernameField,
}),
]); ]);
expect(usernameField.removeAttribute).not.toHaveBeenCalled(); expect(usernameField.removeAttribute).not.toHaveBeenCalled();
@ -1314,10 +1327,7 @@ describe("AutofillOverlayContentService", () => {
it("skips handling the mutation if the record type is not for `attributes`", () => { it("skips handling the mutation if the record type is not for `attributes`", () => {
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
mock<MutationRecord>({ createMutationRecordMock({ target: usernameField, type: "childList" }),
target: usernameField,
type: "childList",
}),
]); ]);
expect(usernameField.removeAttribute).not.toHaveBeenCalled(); expect(usernameField.removeAttribute).not.toHaveBeenCalled();
@ -1325,7 +1335,7 @@ describe("AutofillOverlayContentService", () => {
it("removes all element attributes that are not the style attribute", () => { it("removes all element attributes that are not the style attribute", () => {
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
mock<MutationRecord>({ createMutationRecordMock({
target: usernameField, target: usernameField,
type: "attributes", type: "attributes",
attributeName: "placeholder", attributeName: "placeholder",
@ -1337,7 +1347,7 @@ describe("AutofillOverlayContentService", () => {
it("removes all attached style attributes and sets the default styles", () => { it("removes all attached style attributes and sets the default styles", () => {
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([ autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
mock<MutationRecord>({ createMutationRecordMock({
target: usernameField, target: usernameField,
type: "attributes", type: "attributes",
attributeName: "style", attributeName: "style",

View File

@ -42,12 +42,12 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private overlayListElement: HTMLElement; private overlayListElement: HTMLElement;
private mostRecentlyFocusedField: ElementWithOpId<FormFieldElement>; private mostRecentlyFocusedField: ElementWithOpId<FormFieldElement>;
private focusedFieldData: FocusedFieldData; private focusedFieldData: FocusedFieldData;
private userInteractionEventTimeout: NodeJS.Timeout; private userInteractionEventTimeout: number | NodeJS.Timeout;
private overlayElementsMutationObserver: MutationObserver; private overlayElementsMutationObserver: MutationObserver;
private bodyElementMutationObserver: MutationObserver; private bodyElementMutationObserver: MutationObserver;
private documentElementMutationObserver: MutationObserver; private documentElementMutationObserver: MutationObserver;
private mutationObserverIterations = 0; private mutationObserverIterations = 0;
private mutationObserverIterationsResetTimeout: NodeJS.Timeout; private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout;
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap(); private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
private eventHandlersMemo: { [key: string]: EventListener } = {}; private eventHandlersMemo: { [key: string]: EventListener } = {};
private readonly customElementDefaultStyles: Partial<CSSStyleDeclaration> = { private readonly customElementDefaultStyles: Partial<CSSStyleDeclaration> = {
@ -846,7 +846,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
this.toggleOverlayHidden(true); this.toggleOverlayHidden(true);
this.clearUserInteractionEventTimeout(); this.clearUserInteractionEventTimeout();
this.userInteractionEventTimeout = setTimeout(this.triggerOverlayRepositionUpdates, 750); this.userInteractionEventTimeout = setTimeout(
this.triggerOverlayRepositionUpdates,
750,
) as unknown as number;
}; };
/** /**

10
package-lock.json generated
View File

@ -178,7 +178,7 @@
"ts-loader": "9.5.1", "ts-loader": "9.5.1",
"tsconfig-paths-webpack-plugin": "4.1.0", "tsconfig-paths-webpack-plugin": "4.1.0",
"type-fest": "2.19.0", "type-fest": "2.19.0",
"typescript": "4.9.5", "typescript": "5.1.6",
"url": "0.11.3", "url": "0.11.3",
"util": "0.12.5", "util": "0.12.5",
"wait-on": "7.2.0", "wait-on": "7.2.0",
@ -37421,16 +37421,16 @@
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.9.5", "version": "5.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
}, },
"engines": { "engines": {
"node": ">=4.2.0" "node": ">=14.17"
} }
}, },
"node_modules/uglify-js": { "node_modules/uglify-js": {

View File

@ -139,7 +139,7 @@
"ts-loader": "9.5.1", "ts-loader": "9.5.1",
"tsconfig-paths-webpack-plugin": "4.1.0", "tsconfig-paths-webpack-plugin": "4.1.0",
"type-fest": "2.19.0", "type-fest": "2.19.0",
"typescript": "4.9.5", "typescript": "5.1.6",
"url": "0.11.3", "url": "0.11.3",
"util": "0.12.5", "util": "0.12.5",
"wait-on": "7.2.0", "wait-on": "7.2.0",

View File

@ -34,5 +34,6 @@
} }
] ]
}, },
"include": ["apps/**/*", "libs/**/*", "bitwarden_license/**/*"] "include": ["apps/**/*", "libs/**/*", "bitwarden_license/**/*"],
"exclude": ["**/build"]
} }