Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ts migrate #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Empty file.
3 changes: 3 additions & 0 deletions components/toast_wrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {});
},
Expand Down
3 changes: 1 addition & 2 deletions components/toast_wrapper/toast_wrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,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';
Expand Down
26 changes: 10 additions & 16 deletions components/toast_wrapper/toast_wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,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';

Expand All @@ -47,7 +46,7 @@ type OwnProps = {
isCollapsedThreadsEnabled?: boolean;
rootPosts?: $TSFixMe;
atLatestPost?: boolean;
postListIds?: $TSFixMe[];
postListIds?: string[];
latestPostTimeStamp?: number;
atBottom?: boolean;
lastViewedBottom?: number;
Expand All @@ -56,20 +55,15 @@ 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?: (lastViewedBottom?: number) => void;

// @ts-expect-error TS(2552): Cannot find name '$TSFixMeFunction'. 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
Expand Down Expand Up @@ -105,14 +99,14 @@ class ToastWrapper extends React.PureComponent<Props, State> {
};
}

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;
}
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;
}
Expand Down
2 changes: 1 addition & 1 deletion components/toast_wrapper/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
// "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. */
Expand Down