Add typing
This commit is contained in:
parent
da7e692f3e
commit
b68b8b3aab
|
@ -15,7 +15,7 @@ describe("AttachmentView", () => {
|
|||
size: "1000",
|
||||
sizeName: "kb",
|
||||
fileName: "my filename",
|
||||
key: "encKey",
|
||||
key: "encKey" as any,
|
||||
};
|
||||
|
||||
jest
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("CipherView", () => {
|
|||
});
|
||||
|
||||
it("fromJSON hydrates new view object", () => {
|
||||
const mockFromJson = (key: string) => (key + "fromJSON") as any;
|
||||
const mockFromJson = (key: any) => (key + "fromJSON") as any;
|
||||
jest.spyOn(LoginView, "fromJSON").mockImplementation(mockFromJson);
|
||||
jest.spyOn(AttachmentView, "fromJSON").mockImplementation(mockFromJson);
|
||||
jest.spyOn(FieldView, "fromJSON").mockImplementation(mockFromJson);
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("LoginView", () => {
|
|||
|
||||
jest
|
||||
.spyOn(LoginUriView, "fromJSON")
|
||||
.mockImplementation((key: string) => (key + "fromJSON") as any);
|
||||
.mockImplementation((key: any) => (key + "fromJSON") as any);
|
||||
|
||||
const login = LoginView.fromJSON(parsed);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ export class AttachmentView implements View {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): AttachmentView {
|
||||
static fromJSON(obj: Partial<AttachmentView>): AttachmentView {
|
||||
const view = new AttachmentView();
|
||||
view.id = obj.id;
|
||||
view.url = obj.url;
|
||||
|
|
|
@ -80,7 +80,7 @@ export class CardView extends ItemView {
|
|||
return year.length === 2 ? "20" + year : year;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
toJSON(): Partial<CardView> {
|
||||
// Needed to serialize getters which are not included by JSON.stringify
|
||||
return {
|
||||
cardholderName: this.cardholderName,
|
||||
|
@ -92,7 +92,7 @@ export class CardView extends ItemView {
|
|||
};
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): CardView {
|
||||
static fromJSON(obj: Partial<CardView>): CardView {
|
||||
const view = new CardView();
|
||||
view.cardholderName = obj.cardholderName;
|
||||
view.brand = obj.brand;
|
||||
|
|
|
@ -132,8 +132,8 @@ export class CipherView implements View {
|
|||
return this.linkedFieldOptions.get(id)?.i18nKey;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
const result: any = {
|
||||
toJSON(): Partial<CipherView> {
|
||||
const result: Partial<CipherView> = {
|
||||
id: this.id,
|
||||
organizationId: this.organizationId,
|
||||
folderId: this.folderId,
|
||||
|
@ -176,7 +176,7 @@ export class CipherView implements View {
|
|||
return result;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): CipherView {
|
||||
static fromJSON(obj: Partial<CipherView>): CipherView {
|
||||
const view = new CipherView();
|
||||
view.id = obj.id;
|
||||
view.organizationId = obj.organizationId;
|
||||
|
|
|
@ -26,7 +26,7 @@ export class FieldView implements View {
|
|||
return this.value != null ? "••••••••" : null;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): FieldView {
|
||||
static fromJSON(obj: Partial<FieldView>): FieldView {
|
||||
const view = new FieldView();
|
||||
view.name = obj.name;
|
||||
view.value = obj.value;
|
||||
|
|
|
@ -140,7 +140,7 @@ export class IdentityView extends ItemView {
|
|||
return addressPart2;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
toJSON(): Partial<IdentityView> {
|
||||
// Needed to serialize getters which are not included by JSON.stringify
|
||||
return {
|
||||
title: this.title,
|
||||
|
@ -164,7 +164,7 @@ export class IdentityView extends ItemView {
|
|||
};
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): IdentityView {
|
||||
static fromJSON(obj: Partial<IdentityView>): IdentityView {
|
||||
const view = new IdentityView();
|
||||
view.title = obj.title;
|
||||
view.firstName = obj.firstName;
|
||||
|
|
|
@ -125,7 +125,7 @@ export class LoginUriView implements View {
|
|||
: this.uri;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
toJSON(): Partial<LoginUriView> {
|
||||
// Needed to serialize getters which are not included by JSON.stringify
|
||||
return {
|
||||
match: this.match,
|
||||
|
@ -133,7 +133,7 @@ export class LoginUriView implements View {
|
|||
};
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): LoginUriView {
|
||||
static fromJSON(obj: Partial<LoginUriView>): LoginUriView {
|
||||
const view = new LoginUriView();
|
||||
view.match = obj.match;
|
||||
view.uri = obj.uri;
|
||||
|
|
|
@ -61,7 +61,7 @@ export class LoginView extends ItemView {
|
|||
return this.uris != null && this.uris.length > 0;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): LoginView {
|
||||
static fromJSON(obj: Partial<LoginView>): LoginView {
|
||||
const view = new LoginView();
|
||||
|
||||
view.username = obj.username;
|
||||
|
|
|
@ -14,7 +14,7 @@ export class PasswordHistoryView implements View {
|
|||
this.lastUsedDate = ph.lastUsedDate;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): PasswordHistoryView {
|
||||
static fromJSON(obj: Partial<PasswordHistoryView>): PasswordHistoryView {
|
||||
const view = new PasswordHistoryView();
|
||||
view.password = obj.password;
|
||||
view.lastUsedDate = obj.lastUsedDate == null ? null : new Date(obj.lastUsedDate);
|
||||
|
|
|
@ -19,7 +19,7 @@ export class SecureNoteView extends ItemView {
|
|||
return null;
|
||||
}
|
||||
|
||||
static fromJSON(obj: any): SecureNoteView {
|
||||
static fromJSON(obj: Partial<SecureNoteView>): SecureNoteView {
|
||||
const view = new SecureNoteView();
|
||||
view.type = obj.type;
|
||||
return view;
|
||||
|
|
Loading…
Reference in New Issue