Skip to content

Update storybook to enable noImplicitAny use #4206

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

Merged
merged 12 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "none",
"area": "improvement",
"workstream": "noImplicitAny",
"comment": "Storybook snippets noImplicitAny",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "none",
"area": "improvement",
"workstream": "noImplicitAny",
"comment": "Storybook snippets noImplicitAny",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,18 @@ export const _TagsSurvey = (props: _TagsSurveyProps): JSX.Element => {
if (issue) {
setSelectedTags((prevState) => {
if (prevState[issueCategory]?.issues) {
(prevState[issueCategory]!.issues as unknown[]) = prevState[issueCategory]!.issues!.filter(function (
value
) {
return value !== issue;
});
// 'prevState[issueCategory]!.issues as ...' typing is required here to avoid a typescript limitation
// "This expression is not callable" caused by filter().
// More information can be found here: https://github.com/microsoft/TypeScript/issues/44373
(prevState[issueCategory]!.issues as (_AudioIssue | _OverallIssue | _ScreenshareIssue | _VideoIssue)[]) =
(prevState[issueCategory]!.issues as (
| _AudioIssue
| _OverallIssue
| _ScreenshareIssue
| _VideoIssue
)[])!.filter(function (value: _AudioIssue | _OverallIssue | _ScreenshareIssue | _VideoIssue) {
return value !== issue;
});
if (prevState[issueCategory]!.issues!.length === 0) {
delete prevState[issueCategory];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export class CallWithChatBackedCallAdapter implements CallAdapter {
public leaveCall = async (forEveryone?: boolean): Promise<void> =>
await this.callWithChatAdapter.leaveCall(forEveryone);

public startCall = (participants: string[] | StartCallIdentifier[], options: StartCallOptions): Call | undefined => {
if (participants.every((participant) => typeof participant === 'string')) {
public startCall = (participants: (string | StartCallIdentifier)[], options: StartCallOptions): Call | undefined => {
if (participants.every((participant: string | StartCallIdentifier) => typeof participant === 'string')) {
return this.callWithChatAdapter.startCall(participants as string[], options);
} else {
return this.callWithChatAdapter.startCall(participants as StartCallIdentifier[], options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const CustomDataModelExampleContainer = (props: CustomDataModelExampleCon
// It is recommended that Contoso memoize the `onFetchAvatarPersonaData` callback
// to avoid costly re-fetching of data.
// A 3rd Party utility such as Lodash (_.memoize) can be used to memoize the callback.
const onFetchAvatarPersonaData = (userId): Promise<AvatarPersonaData> =>
const onFetchAvatarPersonaData = (userId: string): Promise<AvatarPersonaData> =>
new Promise((resolve) => {
if (userId === props.botUserId) {
return resolve({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
CallParticipantListParticipant,
ControlBarButtonStyles,
CustomAvatarOptions,
FluentThemeProvider,
ParticipantsButton
} from '@azure/communication-react';
Expand Down Expand Up @@ -42,7 +43,7 @@ const mockParticipants: CallParticipantListParticipant[] = [
}
];

const customOnRenderAvatar = (userId?: string, options?): JSX.Element => {
const customOnRenderAvatar = (userId?: string, options?: CustomAvatarOptions): JSX.Element => {
if (userId === 'user2') {
return (
<img
Expand All @@ -63,12 +64,7 @@ const customOnRenderAvatar = (userId?: string, options?): JSX.Element => {
}

return (
<Persona
text={options.displayName}
hidePersonaDetails={true}
size={PersonaSize.size32}
showOverflowTooltip={false}
/>
<Persona text={options?.text} hidePersonaDetails={true} size={PersonaSize.size32} showOverflowTooltip={false} />
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const MessageWithCustomMentionRenderer: () => JSX.Element = () => {
}
];

const onUpdateMessageCallback = (messageId, content): Promise<void> => {
const onUpdateMessageCallback = (messageId: string, content: string): Promise<void> => {
const msgIdx = messages.findIndex((m) => m.messageId === messageId);
const message = messages[msgIdx];
message.content = content;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ParticipantItem } from '@azure/communication-react';
import { CustomAvatarOptions, ParticipantItem } from '@azure/communication-react';
import { Persona, PersonaPresence, PersonaSize } from '@fluentui/react';
import React from 'react';

export const CustomAvatarExample: () => JSX.Element = () => {
const onRenderAvatar = (userId, options): JSX.Element => {
const onRenderAvatar = (userId?: string, options?: CustomAvatarOptions): JSX.Element => {
return (
<Persona
size={PersonaSize.size32}
text={options.text}
text={options?.text}
imageUrl="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-react-assets/persona-female.png"
showOverflowTooltip={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const CustomUserRenderSnippet: () => JSX.Element = () => {
const onRenderUser = (user: CommunicationParticipant): JSX.Element => {
return (
<>
<img src={imageMap[user.userId]} style={avatarStyle} /> {user.displayName}
<img src={imageMap[user.userId as keyof typeof imageMap]} style={avatarStyle} /> {user.displayName}
</>
);
};
Expand Down
1 change: 0 additions & 1 deletion packages/storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../common/config/tsc/tsconfig.json",
"compilerOptions": {
"noImplicitAny": false, // disable for now for storybook
"outDir": "./dist",
"paths": {
"@azure/communication-react": ["../communication-react/src"],
Expand Down