-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Address XS code hygiene tasks #4980
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||
import PropTypes from 'prop-types'; | ||||||
import React, { useCallback, useMemo, useRef } from 'react'; | ||||||
import React, { useCallback, useMemo, useRef, type PropsWithChildren, type ReactNode } from 'react'; | ||||||
|
||||||
import ActivityKeyerContext from './private/Context'; | ||||||
import getActivityId from './private/getActivityId'; | ||||||
|
@@ -8,15 +8,16 @@ import uniqueId from './private/uniqueId'; | |||||
import useActivities from '../../hooks/useActivities'; | ||||||
import useActivityKeyerContext from './private/useContext'; | ||||||
|
||||||
import type { ActivityKeyerContextType } from './private/Context'; | ||||||
import type { FC, PropsWithChildren } from 'react'; | ||||||
import type { WebChatActivity } from 'botframework-webchat-core'; | ||||||
import { type ActivityKeyerContextType } from './private/Context'; | ||||||
import { type WebChatActivity } from 'botframework-webchat-core'; | ||||||
|
||||||
type ActivityIdToKeyMap = Map<string, string>; | ||||||
type ActivityToKeyMap = Map<WebChatActivity, string>; | ||||||
type ClientActivityIdToKeyMap = Map<string, string>; | ||||||
type KeyToActivityMap = Map<string, WebChatActivity>; | ||||||
|
||||||
type ActivityKeyerComposerProps = Readonly<PropsWithChildren<{}>>; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* React context composer component to assign a perma-key to every activity. | ||||||
* This will support both `useGetActivityByKey` and `useGetKeyByActivity` custom hooks. | ||||||
|
@@ -31,7 +32,7 @@ type KeyToActivityMap = Map<string, WebChatActivity>; | |||||
* | ||||||
* Local key are only persisted in memory. On refresh, they will be a new random key. | ||||||
*/ | ||||||
const ActivityKeyerComposer: FC<PropsWithChildren<{}>> = ({ children }) => { | ||||||
const ActivityKeyerComposer = ({ children }: ActivityKeyerComposerProps): ReactNode => { | ||||||
const existingContext = useActivityKeyerContext(false); | ||||||
|
||||||
if (existingContext) { | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
import React, { useEffect, useMemo, useRef } from 'react'; | ||||||
import React, { useEffect, useMemo, useRef, type PropsWithChildren, type ReactNode } from 'react'; | ||||||
|
||||||
import { SENDING, SEND_FAILED, SENT } from '../../types/internal/SendStatus'; | ||||||
import ActivitySendStatusContext from './private/Context'; | ||||||
|
@@ -10,15 +10,16 @@ import useGetKeyByActivity from '../ActivityKeyer/useGetKeyByActivity'; | |||||
import useGetSendTimeoutForActivity from '../../hooks/useGetSendTimeoutForActivity'; | ||||||
import usePonyfill from '../../hooks/usePonyfill'; | ||||||
|
||||||
import type { ActivitySendStatusContextType } from './private/Context'; | ||||||
import type { FC, PropsWithChildren } from 'react'; | ||||||
import type { SendStatus } from '../../types/internal/SendStatus'; | ||||||
import { type ActivitySendStatusContextType } from './private/Context'; | ||||||
import { type SendStatus } from '../../types/internal/SendStatus'; | ||||||
|
||||||
// Magic numbers for `expiryByActivityKey`. | ||||||
const EXPIRY_SEND_FAILED = -Infinity; | ||||||
const EXPIRY_SENT = Infinity; | ||||||
|
||||||
const ActivitySendStatusComposer: FC<PropsWithChildren<{}>> = ({ children }) => { | ||||||
type ActivitySendStatusComposerProps = Readonly<PropsWithChildren<{}>>; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
const ActivitySendStatusComposer = ({ children }: ActivitySendStatusComposerProps): ReactNode => { | ||||||
const [activities] = useActivities(); | ||||||
const [{ clearTimeout, Date, setTimeout }] = usePonyfill(); | ||||||
const forceRender = useForceRender(); | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/bundle/src/adaptiveCards/AdaptiveCardsComposer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/bundle/src/adaptiveCards/Attachment/AdaptiveCardAttachment.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my bad and lack of understanding about TypeScript couple of years ago. Could you help change this line to:
In TypeScript,
{}
meansany
. And it means I can put whatever inside the props. Recently learn abouttype-fest
package for TypeScript helpers. One of the helpers can define an empty object. 😉