From 19c90c8c853a9e3031e9b48125f61a7ebea7f6c2 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 14:43:37 -0700 Subject: [PATCH 01/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/.eslintrc | 0 components/toast_wrapper/index.tsx | 3 +++ 2 files changed, 3 insertions(+) create mode 100644 components/toast_wrapper/.eslintrc diff --git a/components/toast_wrapper/.eslintrc b/components/toast_wrapper/.eslintrc new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/components/toast_wrapper/index.tsx b/components/toast_wrapper/index.tsx index 0cc22f80d038..f402da91950b 100644 --- a/components/toast_wrapper/index.tsx +++ b/components/toast_wrapper/index.tsx @@ -45,6 +45,9 @@ export function makeGetRootPosts() { (post as any).state !== Posts.POST_DELETED); }).reduce((map, obj) => { (map as any)[(obj as any).id] = true; + // line 49 and line 50 added for Diego + // eslint-disable-next-line no-console + console.log(map); return map; }, {}); }, From eeb612e9f95884eb912e27e6a2888e9fd0b984f4 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 15:07:00 -0700 Subject: [PATCH 02/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/components/toast_wrapper/tsconfig.json b/components/toast_wrapper/tsconfig.json index 371850644ba7..68e3c457d980 100644 --- a/components/toast_wrapper/tsconfig.json +++ b/components/toast_wrapper/tsconfig.json @@ -46,6 +46,7 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + "baseUrl": "components/", /* Base directory to resolve non-absolute module names. MICHELLE MADE THE CHANGES 08.08.22*/ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ From 58f5ce519a6c2a0bf922f40ee75d73651a297822 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 16:00:38 -0700 Subject: [PATCH 03/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/toast_wrapper.test.tsx | 2 +- components/toast_wrapper/tsconfig.json | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.test.tsx b/components/toast_wrapper/toast_wrapper.test.tsx index 6e9d8ead1737..e6c11f93c87c 100644 --- a/components/toast_wrapper/toast_wrapper.test.tsx +++ b/components/toast_wrapper/toast_wrapper.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; // @ts-expect-error TS(2307): Cannot find module 'mattermost-redux/constants/pre... Remove this comment to see the full error message -import Preferences from 'mattermost-redux/constants/preferences'; +import Preferences from '@mattermost/constants/preferences'; // @ts-expect-error TS(2307): Cannot find module 'mattermost-redux/utils/post_li... Remove this comment to see the full error message import {DATE_LINE} from 'mattermost-redux/utils/post_list'; diff --git a/components/toast_wrapper/tsconfig.json b/components/toast_wrapper/tsconfig.json index 68e3c457d980..f61fd5418f81 100644 --- a/components/toast_wrapper/tsconfig.json +++ b/components/toast_wrapper/tsconfig.json @@ -46,7 +46,7 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - "baseUrl": "components/", /* Base directory to resolve non-absolute module names. MICHELLE MADE THE CHANGES 08.08.22*/ + // "baseUrl": "./components", /* Base directory to resolve non-absolute module names. MICHELLE MADE THE CHANGES 08.08.22*/ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ @@ -68,6 +68,8 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ + "include": ["./components"] } + } From ab372abf0cf9bdcbd75f4bdb76c3b27de95c54ff Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 16:04:18 -0700 Subject: [PATCH 04/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/tsconfig.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/toast_wrapper/tsconfig.json b/components/toast_wrapper/tsconfig.json index f61fd5418f81..ad1e0c5de92f 100644 --- a/components/toast_wrapper/tsconfig.json +++ b/components/toast_wrapper/tsconfig.json @@ -68,8 +68,9 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ - "include": ["./components"] - } + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + + }, + "include": ["./components"] } From 991fc14aa8863c7b5459367ae7933de95060d904 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 16:31:37 -0700 Subject: [PATCH 05/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/tsconfig.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/toast_wrapper/tsconfig.json b/components/toast_wrapper/tsconfig.json index ad1e0c5de92f..35d6dce3480e 100644 --- a/components/toast_wrapper/tsconfig.json +++ b/components/toast_wrapper/tsconfig.json @@ -46,8 +46,7 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "baseUrl": "./components", /* Base directory to resolve non-absolute module names. MICHELLE MADE THE CHANGES 08.08.22*/ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + "paths": {"components/" : ["./components"]}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ @@ -69,8 +68,5 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - - }, - "include": ["./components"] - + } } From 36e8637caeecefbd3b3956feffc8756fb08a785e Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Mon, 8 Aug 2022 16:33:17 -0700 Subject: [PATCH 06/10] [ts-migrate][toast_wrapper] Init tsconfig.json file Co-authored-by: ts-migrate <> --- components/toast_wrapper/toast_wrapper.test.tsx | 1 - components/toast_wrapper/toast_wrapper.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.test.tsx b/components/toast_wrapper/toast_wrapper.test.tsx index e6c11f93c87c..a866eceb88e4 100644 --- a/components/toast_wrapper/toast_wrapper.test.tsx +++ b/components/toast_wrapper/toast_wrapper.test.tsx @@ -3,7 +3,6 @@ import React from 'react'; -// @ts-expect-error TS(2307): Cannot find module 'mattermost-redux/constants/pre... Remove this comment to see the full error message import Preferences from '@mattermost/constants/preferences'; // @ts-expect-error TS(2307): Cannot find module 'mattermost-redux/utils/post_li... Remove this comment to see the full error message diff --git a/components/toast_wrapper/toast_wrapper.tsx b/components/toast_wrapper/toast_wrapper.tsx index 3cfe3e80f6c1..eb986549fd37 100644 --- a/components/toast_wrapper/toast_wrapper.tsx +++ b/components/toast_wrapper/toast_wrapper.tsx @@ -4,7 +4,6 @@ import React from 'react'; import {FormattedMessage, injectIntl} from 'react-intl'; -// @ts-expect-error TS(2307): Cannot find module 'components/toast/toast' or its... Remove this comment to see the full error message import Toast from 'components/toast/toast'; // @ts-expect-error TS(2307): Cannot find module 'components/timestamp' or its c... Remove this comment to see the full error message From 359fa5a88655dfa40f9704fdbc1ef9e9647fd546 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Tue, 9 Aug 2022 15:37:50 -0700 Subject: [PATCH 07/10] update postListIds type --- components/toast_wrapper/toast_wrapper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.tsx b/components/toast_wrapper/toast_wrapper.tsx index eb986549fd37..ff2e5188e085 100644 --- a/components/toast_wrapper/toast_wrapper.tsx +++ b/components/toast_wrapper/toast_wrapper.tsx @@ -18,9 +18,9 @@ import * as Utils from 'utils/utils'; // @ts-expect-error TS(2307): Cannot find module 'utils/datetime' or its corresp... Remove this comment to see the full error message import {isToday} from 'utils/datetime'; -// @ts-expect-error TS(2307): Cannot find module 'utils/constants' or its corres... Remove this comment to see the full error message import Constants from 'utils/constants'; + // @ts-expect-error TS(2307): Cannot find module 'utils/browser_history' or its ... Remove this comment to see the full error message import {browserHistory} from 'utils/browser_history'; @@ -46,7 +46,7 @@ type OwnProps = { isCollapsedThreadsEnabled?: boolean; rootPosts?: $TSFixMe; atLatestPost?: boolean; - postListIds?: $TSFixMe[]; + postListIds?: string[]; latestPostTimeStamp?: number; atBottom?: boolean; lastViewedBottom?: number; From d127047fcbe0c8088d3edb52e0d516fe3973bca0 Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Tue, 9 Aug 2022 16:20:42 -0700 Subject: [PATCH 08/10] update updateNewMessagesAtInChannel type --- components/toast_wrapper/toast_wrapper.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.tsx b/components/toast_wrapper/toast_wrapper.tsx index ff2e5188e085..2a5323f7a526 100644 --- a/components/toast_wrapper/toast_wrapper.tsx +++ b/components/toast_wrapper/toast_wrapper.tsx @@ -6,6 +6,8 @@ import {FormattedMessage, injectIntl} from 'react-intl'; import Toast from 'components/toast/toast'; +import type {updateNewMessagesAtInChannel} from 'actions/global_actions'; + // @ts-expect-error TS(2307): Cannot find module 'components/timestamp' or its c... Remove this comment to see the full error message import Timestamp, {RelativeRanges} from 'components/timestamp'; @@ -55,10 +57,9 @@ type OwnProps = { focusedPostId?: string; initScrollOffsetFromBottom?: number; - // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message - updateNewMessagesAtInChannel?: $TSFixMeFunction; + updateNewMessagesAtInChannel?: typeof updateNewMessagesAtInChannel; - // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message + // @ts-expect-error TS(2552): Cannot find name '$'. Did you mean ... Remove this comment to see the full error message scrollToNewMessage?: $TSFixMeFunction; // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message From 2fdf1e23e4dceefc625c416c5c913af9a2fa041f Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Wed, 10 Aug 2022 12:57:02 -0700 Subject: [PATCH 09/10] Fixed some of the and --- components/toast_wrapper/toast_wrapper.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.tsx b/components/toast_wrapper/toast_wrapper.tsx index 2a5323f7a526..69c9e6e402ae 100644 --- a/components/toast_wrapper/toast_wrapper.tsx +++ b/components/toast_wrapper/toast_wrapper.tsx @@ -57,19 +57,15 @@ type OwnProps = { focusedPostId?: string; initScrollOffsetFromBottom?: number; - updateNewMessagesAtInChannel?: typeof updateNewMessagesAtInChannel; + updateNewMessagesAtInChannel?: (lastViewedBottom?: number) => void; - // @ts-expect-error TS(2552): Cannot find name '$'. Did you mean ... Remove this comment to see the full error message - scrollToNewMessage?: $TSFixMeFunction; + scrollToNewMessage?: () => void; - // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message - scrollToLatestMessages?: $TSFixMeFunction; + scrollToLatestMessages?: () => void; - // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message - scrollToUnreadMessages?: $TSFixMeFunction; + scrollToUnreadMessages?: () => void; - // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message - updateLastViewedBottomAt?: $TSFixMeFunction; + updateLastViewedBottomAt?: (lastViewedBottom?: number) => void; showSearchHintToast?: boolean; // @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. Did you mean ... Remove this comment to see the full error message @@ -105,7 +101,7 @@ class ToastWrapper extends React.PureComponent { }; } - static countNewMessages = (postListIds: $TSFixMe, rootPosts: $TSFixMe, isCollapsedThreadsEnabled: $TSFixMe) => { + static countNewMessages = (postListIds: string[], rootPosts: $TSFixMe, isCollapsedThreadsEnabled: boolean) => { const mark = getNewMessageIndex(postListIds); if (mark <= 0) { return 0; From 6354c7e8edf5fa8b62e9cb15aa27c066acdd158a Mon Sep 17 00:00:00 2001 From: Michelle Tan Date: Wed, 10 Aug 2022 13:08:02 -0700 Subject: [PATCH 10/10] Fixed some of the TSFixME and TSFixMeFunctionTSFixMeFunction --- components/toast_wrapper/toast_wrapper.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/toast_wrapper/toast_wrapper.tsx b/components/toast_wrapper/toast_wrapper.tsx index 69c9e6e402ae..db6c7d4a47c4 100644 --- a/components/toast_wrapper/toast_wrapper.tsx +++ b/components/toast_wrapper/toast_wrapper.tsx @@ -6,8 +6,6 @@ import {FormattedMessage, injectIntl} from 'react-intl'; import Toast from 'components/toast/toast'; -import type {updateNewMessagesAtInChannel} from 'actions/global_actions'; - // @ts-expect-error TS(2307): Cannot find module 'components/timestamp' or its c... Remove this comment to see the full error message import Timestamp, {RelativeRanges} from 'components/timestamp'; @@ -106,9 +104,9 @@ class ToastWrapper extends React.PureComponent { if (mark <= 0) { return 0; } - let newMessages = postListIds.slice(0, mark).filter((id: $TSFixMe) => !isIdNotPost(id)); + let newMessages = postListIds.slice(0, mark).filter((id: string) => !isIdNotPost(id)); if (isCollapsedThreadsEnabled) { // in collapsed mode we only count root posts - newMessages = newMessages.filter((id: $TSFixMe) => rootPosts[id]); + newMessages = newMessages.filter((id: string) => rootPosts[id]); } return newMessages.length; }