1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

Upgrade TypeScript (#148)

* Update typescript to 3.6.5 along with tslint to latest.

* Upgrade @types/node to 12.12.54 to get rid of compile errors.

* Update tslint.

* Use @types/node 10.17.28 instead
This commit is contained in:
Oscar Hinton
2020-08-12 21:42:42 +02:00
committed by GitHub
parent b32b016f82
commit e516692559
17 changed files with 62 additions and 134 deletions

View File

@@ -14,7 +14,7 @@ export abstract class CollectionService {
get: (id: string) => Promise<Collection>;
getAll: () => Promise<Collection[]>;
getAllDecrypted: () => Promise<CollectionView[]>;
getAllNested: (collections?: CollectionView[]) => Promise<Array<TreeNode<CollectionView>>>;
getAllNested: (collections?: CollectionView[]) => Promise<TreeNode<CollectionView>[]>;
getNested: (id: string) => Promise<TreeNode<CollectionView>>;
upsert: (collection: CollectionData | CollectionData[]) => Promise<any>;
replace: (collections: { [id: string]: CollectionData; }) => Promise<any>;

View File

@@ -14,7 +14,7 @@ export abstract class FolderService {
get: (id: string) => Promise<Folder>;
getAll: () => Promise<Folder[]>;
getAllDecrypted: () => Promise<FolderView[]>;
getAllNested: () => Promise<Array<TreeNode<FolderView>>>;
getAllNested: () => Promise<TreeNode<FolderView>[]>;
getNested: (id: string) => Promise<TreeNode<FolderView>>;
saveWithServer: (folder: Folder) => Promise<any>;
upsert: (folder: FolderData | FolderData[]) => Promise<any>;

View File

@@ -5,7 +5,7 @@ export abstract class SearchService {
isSearchable: (query: string) => boolean;
indexCiphers: () => Promise<void>;
searchCiphers: (query: string,
filter?: ((cipher: CipherView) => boolean) | (Array<(cipher: CipherView) => boolean>),
filter?: ((cipher: CipherView) => boolean) | (((cipher: CipherView) => boolean)[]),
ciphers?: CipherView[]) => Promise<CipherView[]>;
searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[];
}

View File

@@ -34,9 +34,9 @@ export class GroupingsComponent {
@Output() onCollectionClicked = new EventEmitter<CollectionView>();
folders: FolderView[];
nestedFolders: Array<TreeNode<FolderView>>;
nestedFolders: TreeNode<FolderView>[];
collections: CollectionView[];
nestedCollections: Array<TreeNode<CollectionView>>;
nestedCollections: TreeNode<CollectionView>[];
loaded: boolean = false;
cipherType = CipherType;
selectedAll: boolean = false;

View File

@@ -75,11 +75,11 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
return result;
}
private parseDataCategory(data: string): Array<Map<string, string>> {
private parseDataCategory(data: string): Map<string, string>[] {
if (this.isNullOrWhitespace(data) || data.indexOf(Delimiter) === -1) {
return [];
}
const items: Array<Map<string, string>> = [];
const items: Map<string, string>[] = [];
data.split(Delimiter).forEach((p) => {
if (p.indexOf('\n') === -1) {
return;

View File

@@ -4,7 +4,7 @@ import {
} from '../models/domain/treeNode';
export class ServiceUtils {
static nestedTraverse(nodeTree: Array<TreeNode<ITreeNodeObject>>, partIndex: number, parts: string[],
static nestedTraverse(nodeTree: TreeNode<ITreeNodeObject>[], partIndex: number, parts: string[],
obj: ITreeNodeObject, parent: ITreeNodeObject, delimiter: string) {
if (parts.length <= partIndex) {
return;
@@ -38,7 +38,7 @@ export class ServiceUtils {
}
}
static getTreeNodeObject(nodeTree: Array<TreeNode<ITreeNodeObject>>, id: string): TreeNode<ITreeNodeObject> {
static getTreeNodeObject(nodeTree: TreeNode<ITreeNodeObject>[], id: string): TreeNode<ITreeNodeObject> {
for (let i = 0; i < nodeTree.length; i++) {
if (nodeTree[i].node.id === id) {
return nodeTree[i];

View File

@@ -8,14 +8,14 @@ export function throttle(limit: number, throttleKey: (args: any[]) => string) {
return <T>(target: any, propertyKey: string | symbol,
descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<T>>) => {
const originalMethod: () => Promise<T> = descriptor.value;
const allThrottles = new Map<any, Map<string, Array<() => void>>>();
const allThrottles = new Map<any, Map<string, (() => void)[]>>();
const getThrottles = (obj: any) => {
let throttles = allThrottles.get(obj);
if (throttles != null) {
return throttles;
}
throttles = new Map<string, Array<() => void>>();
throttles = new Map<string, (() => void)[]>();
allThrottles.set(obj, throttles);
return throttles;
};

View File

@@ -7,7 +7,7 @@ export class ImportResult {
errorMessage: string;
ciphers: CipherView[] = [];
folders: FolderView[] = [];
folderRelationships: Array<[number, number]> = [];
folderRelationships: [number, number][] = [];
collections: CollectionView[] = [];
collectionRelationships: Array<[number, number]> = [];
collectionRelationships: [number, number][] = [];
}

View File

@@ -1,7 +1,7 @@
export class TreeNode<T extends ITreeNodeObject> {
parent: T;
node: T;
children: Array<TreeNode<T>> = [];
children: TreeNode<T>[] = [];
constructor(node: T, name: string, parent: T) {
this.parent = parent;

View File

@@ -5,5 +5,5 @@ import { KvpRequest } from './kvpRequest';
export class ImportCiphersRequest {
ciphers: CipherRequest[] = [];
folders: FolderRequest[] = [];
folderRelationships: Array<KvpRequest<number, number>> = [];
folderRelationships: KvpRequest<number, number>[] = [];
}

View File

@@ -5,5 +5,5 @@ import { KvpRequest } from './kvpRequest';
export class ImportOrganizationCiphersRequest {
ciphers: CipherRequest[] = [];
collections: CollectionRequest[] = [];
collectionRelationships: Array<KvpRequest<number, number>> = [];
collectionRelationships: KvpRequest<number, number>[] = [];
}

View File

@@ -170,7 +170,7 @@ export class CipherService implements CipherServiceAbstraction {
return null;
}
const promises: Array<Promise<any>> = [];
const promises: Promise<any>[] = [];
const encAttachments: Attachment[] = [];
attachmentsModel.forEach(async (model) => {
const attachment = new Attachment();
@@ -510,7 +510,7 @@ export class CipherService implements CipherServiceAbstraction {
}
async shareWithServer(cipher: CipherView, organizationId: string, collectionIds: string[]): Promise<any> {
const attachmentPromises: Array<Promise<any>> = [];
const attachmentPromises: Promise<any>[] = [];
if (cipher.attachments != null) {
cipher.attachments.forEach((attachment) => {
if (attachment.key == null) {
@@ -531,7 +531,7 @@ export class CipherService implements CipherServiceAbstraction {
}
async shareManyWithServer(ciphers: CipherView[], organizationId: string, collectionIds: string[]): Promise<any> {
const promises: Array<Promise<any>> = [];
const promises: Promise<any>[] = [];
const encCiphers: Cipher[] = [];
for (const cipher of ciphers) {
cipher.organizationId = organizationId;

View File

@@ -51,7 +51,7 @@ export class CollectionService implements CollectionServiceAbstraction {
return [];
}
const decCollections: CollectionView[] = [];
const promises: Array<Promise<any>> = [];
const promises: Promise<any>[] = [];
collections.forEach((collection) => {
promises.push(collection.decrypt().then((c) => decCollections.push(c)));
});
@@ -98,11 +98,11 @@ export class CollectionService implements CollectionServiceAbstraction {
return this.decryptedCollectionCache;
}
async getAllNested(collections: CollectionView[] = null): Promise<Array<TreeNode<CollectionView>>> {
async getAllNested(collections: CollectionView[] = null): Promise<TreeNode<CollectionView>[]> {
if (collections == null) {
collections = await this.getAllDecrypted();
}
const nodes: Array<TreeNode<CollectionView>> = [];
const nodes: TreeNode<CollectionView>[] = [];
collections.forEach((c) => {
const collectionCopy = new CollectionView();
collectionCopy.id = c.id;

View File

@@ -81,7 +81,7 @@ export class FolderService implements FolderServiceAbstraction {
}
const decFolders: FolderView[] = [];
const promises: Array<Promise<any>> = [];
const promises: Promise<any>[] = [];
const folders = await this.getAll();
folders.forEach((folder) => {
promises.push(folder.decrypt().then((f) => decFolders.push(f)));
@@ -98,9 +98,9 @@ export class FolderService implements FolderServiceAbstraction {
return this.decryptedFolderCache;
}
async getAllNested(): Promise<Array<TreeNode<FolderView>>> {
async getAllNested(): Promise<TreeNode<FolderView>[]> {
const folders = await this.getAllDecrypted();
const nodes: Array<TreeNode<FolderView>> = [];
const nodes: TreeNode<FolderView>[] = [];
folders.forEach((f) => {
const folderCopy = new FolderView();
folderCopy.id = f.id;

View File

@@ -72,7 +72,7 @@ export class SearchService implements SearchServiceAbstraction {
}
async searchCiphers(query: string,
filter: (((cipher: CipherView) => boolean) | (Array<(cipher: CipherView) => boolean>)) = null,
filter: (((cipher: CipherView) => boolean) | (((cipher: CipherView) => boolean)[])) = null,
ciphers: CipherView[] = null):
Promise<CipherView[]> {
const results: CipherView[] = [];