Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Mar 7, 2023
1 parent 8f3ce83 commit f14cc2b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {

const showChatEffects = SettingsStore.getValue("showChatEffects");

let mainSplitBody: React.ReactFragment;
let mainSplitBody: JSX.Element;
let mainSplitContentClassName: string;
// Decide what to show in the main split
switch (this.state.mainSplitContentType) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/UploadBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class UploadBar extends React.PureComponent<IProps, IState> {
count: this.state.countFiles - 1,
});

const uploadSize = filesize(this.state.currentTotal!);
const uploadSize = filesize(this.state.currentTotal!) as string;
return (
<div className="mx_UploadBar">
<div className="mx_UploadBar_filename">
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/ChangelogDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class ChangelogDialog extends React.Component<IProps, State> {
content = <Spinner key={repo} />;
} else if (typeof this.state[repo] === "string") {
content = _t("Unable to load commit detail: %(msg)s", {
msg: this.state[repo],
msg: this.state[repo] as string,
});
} else {
content = (this.state[repo] as Commit[]).map(this.elementsForCommit);
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/UploadConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
{preview && <div>{preview}</div>}
<div id={fileId}>
{placeholder}
{this.props.file.name} ({filesize(this.props.file.size)})
{this.props.file.name} ({filesize(this.props.file.size) as string})
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/views/dialogs/UploadFailureDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default class UploadFailureDialog extends React.Component<IProps> {
"This file is <b>too large</b> to upload. " +
"The file size limit is %(limit)s but this file is %(sizeOfThisFile)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
sizeOfThisFile: filesize(this.props.badFiles[0].size),
limit: filesize(this.props.contentMessages.getUploadLimit()) as string,
sizeOfThisFile: filesize(this.props.badFiles[0].size) as string,
},
{
b: (sub) => <b>{sub}</b>,
Expand All @@ -71,7 +71,7 @@ export default class UploadFailureDialog extends React.Component<IProps> {
message = _t(
"These files are <b>too large</b> to upload. " + "The file size limit is %(limit)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
limit: filesize(this.props.contentMessages.getUploadLimit()) as string,
},
{
b: (sub) => <b>{sub}</b>,
Expand All @@ -89,7 +89,7 @@ export default class UploadFailureDialog extends React.Component<IProps> {
message = _t(
"Some files are <b>too large</b> to be uploaded. " + "The file size limit is %(limit)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
limit: filesize(this.props.contentMessages.getUploadLimit()) as string,
},
{
b: (sub) => <b>{sub}</b>,
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/MFileBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export default class MFileBody extends React.Component<IProps, IState> {
</a>
{this.context.timelineRenderingType === TimelineRenderingType.File && (
<div className="mx_MImageBody_size">
{this.content.info?.size ? filesize(this.content.info.size) : ""}
{this.content.info?.size ? (filesize(this.content.info.size) as string) : ""}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/languageHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export function replaceByRegexes(text: string, mapping: IVariables | Tags): stri
}

if (shouldWrapInSpan) {
return React.createElement("span", null, ...output);
return React.createElement("span", null, ...(output as Array<number | string | React.ReactNode>));
} else {
return output.join("");
}
Expand Down
4 changes: 3 additions & 1 deletion test/i18n-test/languageHandler-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
setLanguage,
setMissingEntryGenerator,
substitute,
IVariables,
Tags,
} from "../../src/languageHandler";
import { stubClient } from "../test-utils";

Expand All @@ -34,7 +36,7 @@ describe("languageHandler", function () {
const plurals = "and %(count)s others...";
const variableSub = "You are now ignoring %(userId)s";

type TestCase = [string, string, Record<string, unknown>, Record<string, unknown> | undefined, TranslatedString];
type TestCase = [string, string, IVariables, Tags | undefined, TranslatedString];
const testCasesEn: TestCase[] = [
// description of the test case, translationString, variables, tags, expected result
["translates a basic string", basicString, {}, undefined, "Rooms"],
Expand Down

0 comments on commit f14cc2b

Please sign in to comment.