Skip to content

Commit

Permalink
refactor: upgrade typescript to 4.9.5 (#4229)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunozoric authored Aug 27, 2024
1 parent f7da215 commit dbcf756
Show file tree
Hide file tree
Showing 185 changed files with 716 additions and 623 deletions.
13 changes: 13 additions & 0 deletions .yarn/patches/@material-base-npm-14.0.0-36e0a55c42.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/observer-foundation.d.ts b/observer-foundation.d.ts
index d546598c6444aae71b00efdba33c20a884058e6f..ea99264896922327a4e5e40e6037edabdd9557c6 100644
--- a/observer-foundation.d.ts
+++ b/observer-foundation.d.ts
@@ -22,7 +22,7 @@
*/
import { MDCFoundation } from './foundation';
import { Observer, ObserverRecord } from './observer';
-export declare class MDCObserverFoundation<Adapter> extends MDCFoundation<Adapter> {
+export declare class MDCObserverFoundation<Adapter extends {} = {}> extends MDCFoundation<Adapter> {
/** A set of cleanup functions to unobserve changes. */
protected unobserves: Set<Function>;
constructor(adapter: Adapter);
13 changes: 13 additions & 0 deletions .yarn/patches/apollo-link-npm-1.2.14-74f0ba01f9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/types.d.ts b/lib/types.d.ts
index 723ae9715022e8ea5d678e9a984b1b5511b230f6..60e30928350db6d718881c45042955aa072a862e 100644
--- a/lib/types.d.ts
+++ b/lib/types.d.ts
@@ -4,7 +4,7 @@ import { ExecutionResult as GraphQLExecutionResult } from 'graphql';
export { DocumentNode };
export interface ExecutionResult<TData = {
[key: string]: any;
-}> extends GraphQLExecutionResult {
+}> extends GraphQLExecutionResult<TData> {
data?: TData | null;
}
export interface GraphQLRequest {
4 changes: 3 additions & 1 deletion cypress-tests/cypress/support/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ type GqlQueryFunction<TReturn, TVariables> = (
options?: GqlQueryOptions
) => Promise<TReturn>;

export const createGqlQuery = <TReturn, TVariables = Record<string, never>>(
export type GqlVariables = Record<string, any>;

export const createGqlQuery = <TReturn, TVariables extends GqlVariables = GqlVariables>(
query: string
): GqlQueryFunction<TReturn, TVariables> => {
return async (variables: TVariables, options?: GqlQueryOptions) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lodash": "^4.17.21",
"nanoid": "^3.3.7",
"node-fetch": "^2.6.1",
"typescript": "4.7.4",
"typescript": "4.9.5",
"uniqid": "^5.2.0"
},
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"glob": "^7.1.3",
"graphql": "^15.7.2",
"husky": "^4.2.5",
"inquirer": "^7.0.0",
"inquirer": "8.2.6",
"inquirer-autocomplete-prompt": "^1.0.1",
"inquirer-checkbox-plus-prompt": "^1.0.1",
"inquirer-maxlength-input-prompt": "^1.0.0",
Expand All @@ -94,7 +94,7 @@
"semver": "^7.5.4",
"ts-expect": "^1.3.0",
"ts-jest": "^29.1.2",
"typescript": "4.7.4",
"typescript": "4.9.5",
"typescript-transform-paths": "^3.4.6",
"verdaccio": "^5.29.1",
"write-json-file": "^4.2.0",
Expand Down Expand Up @@ -223,13 +223,15 @@
"@grpc/grpc-js": "^1.11.1",
"postcss": "^8.4.35",
"semver": "7.5.4",
"typescript": "4.7.4",
"@types/eslint": "8.2.1",
"xml2js": "0.6.2",
"yargs": "^17.3.1",
"lerna@8.1.2": "patch:lerna@npm%3A8.1.2#./.yarn/patches/lerna-npm-8.1.2-be48ad2329.patch",
"react-dnd": "^16.0.0",
"react-dnd-html5-backend": "^16.0.0"
"react-dnd-html5-backend": "^16.0.0",
"apollo-link@^1.2.14": "patch:apollo-link@npm%3A1.2.14#./.yarn/patches/apollo-link-npm-1.2.14-74f0ba01f9.patch",
"apollo-link@^1.0.0": "patch:apollo-link@npm%3A1.2.14#./.yarn/patches/apollo-link-npm-1.2.14-74f0ba01f9.patch",
"@material/base@^14.0.0": "patch:@material/base@npm%3A14.0.0#./.yarn/patches/@material-base-npm-14.0.0-36e0a55c42.patch"
},
"packageManager": "yarn@3.6.4",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-aco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
"prettier": "^2.8.3",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.13",
"typescript": "^4.7.4"
"typescript": "4.9.5"
}
}
27 changes: 18 additions & 9 deletions packages/api-aco/src/apps/AcoApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AcoRequestAction,
AcoSearchRecordCrudBase,
CreateSearchRecordParams,
GenericSearchData,
IAcoApp,
IAcoAppModifyFieldCallableCallback,
IAcoAppOnAnyRequest,
Expand All @@ -12,7 +13,8 @@ import {
IAcoAppParams,
ListSearchRecordsParams,
ListSearchRecordTagsParams,
SearchRecord
SearchRecord,
UpdateSearchRecordParams
} from "~/types";
import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
import lodashUpperFirst from "lodash/upperFirst";
Expand All @@ -34,15 +36,20 @@ export class AcoApp implements IAcoApp {

public get search(): AcoSearchRecordCrudBase {
return {
create: async <TData>(data: CreateSearchRecordParams<TData>) => {
create: async <TData extends GenericSearchData = GenericSearchData>(
data: CreateSearchRecordParams<TData>
) => {
await this.execOnAnyRequest("create");
const result = await this.context.aco.search.create<TData>(this.getModel(), data);
if (!this.onEntry) {
return result;
}
return this.onEntry(result);
return (await this.onEntry(result)) as SearchRecord<TData>;
},
update: async <TData>(id: string, data: SearchRecord<TData>) => {
update: async <TData extends GenericSearchData = GenericSearchData>(
id: string,
data: UpdateSearchRecordParams<TData>
) => {
await this.execOnAnyRequest("update");
const result = await this.context.aco.search.update<TData>(
this.getModel(),
Expand All @@ -52,29 +59,31 @@ export class AcoApp implements IAcoApp {
if (!this.onEntry) {
return result;
}
return this.onEntry(result);
return (await this.onEntry(result)) as SearchRecord<TData>;
},
move: async (id: string, folderId?: string) => {
await this.execOnAnyRequest("move");
return this.context.aco.search.move(this.getModel(), id, folderId);
},
get: async <TData>(id: string) => {
get: async <TData extends GenericSearchData = GenericSearchData>(id: string) => {
await this.execOnAnyRequest("fetch");
const result = await this.context.aco.search.get<TData>(this.getModel(), id);
if (!result || !this.onEntry) {
return result;
}
return this.onEntry(result);
return (await this.onEntry(result)) as SearchRecord<TData>;
},
list: async <TData>(params: ListSearchRecordsParams) => {
list: async <TData extends GenericSearchData = GenericSearchData>(
params: ListSearchRecordsParams
) => {
await this.execOnAnyRequest("fetch");
const result = await this.context.aco.search.list<TData>(this.getModel(), params);
const onEntryList = this.onEntryList;
if (!onEntryList) {
return result;
}
const [entries, meta] = result;
const items = await onEntryList(entries);
const items = (await onEntryList(entries)) as SearchRecord<TData>[];
return [items, meta];
},
delete: async (id: string): Promise<boolean> => {
Expand Down
13 changes: 8 additions & 5 deletions packages/api-aco/src/record/record.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface ListSearchRecordsParams {
after?: string | null;
}

export type CreateSearchRecordParams<TData> = Pick<
export type CreateSearchRecordParams<TData extends GenericSearchData = GenericSearchData> = Pick<
SearchRecord<TData>,
"id" | "title" | "content" | "type" | "location" | "data" | "tags"
>;
Expand Down Expand Up @@ -181,20 +181,23 @@ export interface AcoSearchRecordCrud
AcoSearchRecordCrudBase,
"get" | "list" | "create" | "update" | "delete" | "listTags" | "move"
> {
get<TData>(model: CmsModel, id: string): Promise<SearchRecord<TData>>;
list<TData>(
get<TData extends GenericSearchData = GenericSearchData>(
model: CmsModel,
id: string
): Promise<SearchRecord<TData>>;
list<TData extends GenericSearchData = GenericSearchData>(
model: CmsModel,
params: ListSearchRecordsParams
): Promise<[SearchRecord<TData>[], ListMeta]>;
listTags(
model: CmsModel,
params: ListSearchRecordTagsParams
): Promise<[SearchRecordTag[], ListMeta]>;
create<TData>(
create<TData extends GenericSearchData = GenericSearchData>(
model: CmsModel,
data: CreateSearchRecordParams<TData>
): Promise<SearchRecord<TData>>;
update<TData>(
update<TData extends GenericSearchData = GenericSearchData>(
model: CmsModel,
id: string,
data: UpdateSearchRecordParams<TData>
Expand Down
9 changes: 7 additions & 2 deletions packages/api-aco/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AcoSearchRecordCrud,
AcoSearchRecordCrudBase,
AcoSearchRecordStorageOperations,
GenericSearchData,
SearchRecord
} from "~/record/record.types";
import { AcoFolderCrud, AcoFolderStorageOperations } from "~/folder/folder.types";
Expand Down Expand Up @@ -118,8 +119,12 @@ export interface IAcoApp {
modifyField: IAcoAppModifyFieldCallable;
}
// TODO: determine correct type
export type IAcoAppOnEntry<T = any> = (entry: SearchRecord<T>) => Promise<SearchRecord<T>>;
export type IAcoAppOnEntryList<T = any> = (entry: SearchRecord<T>[]) => Promise<SearchRecord<T>[]>;
export type IAcoAppOnEntry<T extends GenericSearchData = GenericSearchData> = (
entry: SearchRecord<T>
) => Promise<SearchRecord<T>>;
export type IAcoAppOnEntryList<T extends GenericSearchData = GenericSearchData> = (
entry: SearchRecord<T>[]
) => Promise<SearchRecord<T>[]>;
export type AcoRequestAction = "create" | "update" | "delete" | "move" | "fetch";
export type IAcoAppOnAnyRequest = (context: AcoContext, action: AcoRequestAction) => Promise<void>;

Expand Down
2 changes: 1 addition & 1 deletion packages/api-admin-settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"rimraf": "^5.0.5",
"sinon": "^9.0.2",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-admin-users-so-ddb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"jest-dynalite": "^3.2.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-admin-users/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-apw-scheduler-so-ddb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jest-dynalite": "^3.2.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-apw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"rimraf": "^5.0.5",
"sinon": "^9.0.2",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-audit-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@webiny/project-utils": "0.0.0",
"graphql": "^15.8.0",
"ttypescript": "^1.5.13",
"typescript": "^4.7.4"
"typescript": "4.9.5"
},
"dependencies": {
"@webiny/api": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-authentication-cognito/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"jest-dynalite": "^3.2.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-background-tasks-ddb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-background-tasks-es/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-background-tasks-os/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-cognito-authenticator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-dynamodb-to-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@webiny/cli": "0.0.0",
"@webiny/plugins": "0.0.0",
"@webiny/project-utils": "0.0.0",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-elasticsearch-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"rimraf": "^5.0.5",
"ttypescript": "^1.5.13",
"type-fest": "^2.19.0",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-file-manager-ddb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jsonpack": "^1.1.5",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-file-manager-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"rimraf": "^5.0.5",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-file-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"ttypescript": "^1.5.12",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"publishConfig": {
"access": "public",
Expand Down
Loading

0 comments on commit dbcf756

Please sign in to comment.