You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
committed by
GitHub
parent
ac7f69216e
commit
61a63e47f4
@ -22,7 +22,7 @@ describe("useDebouncedCallback", () => {
|
||||
beforeAll(() => jest.useFakeTimers());
|
||||
afterAll(() => jest.useRealTimers());
|
||||
|
||||
function render(enabled: boolean, callback: (...params: any) => void, params: any) {
|
||||
function render(enabled: boolean, callback: (...params: any[]) => void, params: any[]) {
|
||||
return renderHook(({ enabled, callback, params }) => useDebouncedCallback(enabled, callback, params), {
|
||||
initialProps: {
|
||||
enabled,
|
||||
@ -34,7 +34,7 @@ describe("useDebouncedCallback", () => {
|
||||
|
||||
it("should be able to handle empty parameters", async () => {
|
||||
// When
|
||||
const params = [];
|
||||
const params: any[] = [];
|
||||
const callback = jest.fn();
|
||||
render(true, callback, params);
|
||||
jest.advanceTimersByTime(1);
|
||||
|
@ -22,12 +22,12 @@ import { act } from "react-dom/test-utils";
|
||||
|
||||
import { useLatestResult } from "../../src/hooks/useLatestResult";
|
||||
|
||||
function LatestResultsComponent({ query, doRequest }) {
|
||||
function LatestResultsComponent({ query, doRequest }: { query: number; doRequest(query: number): Promise<number> }) {
|
||||
const [value, setValueInternal] = useState<number>(0);
|
||||
const [updateQuery, updateResult] = useLatestResult(setValueInternal);
|
||||
useEffect(() => {
|
||||
updateQuery(query);
|
||||
doRequest(query).then((it) => {
|
||||
doRequest(query).then((it: number) => {
|
||||
updateResult(query, it);
|
||||
});
|
||||
}, [doRequest, query, updateQuery, updateResult]);
|
||||
@ -37,7 +37,7 @@ function LatestResultsComponent({ query, doRequest }) {
|
||||
|
||||
describe("useLatestResult", () => {
|
||||
it("should return results", async () => {
|
||||
const doRequest = async (query) => {
|
||||
const doRequest = async (query: number) => {
|
||||
await sleep(180);
|
||||
return query;
|
||||
};
|
||||
@ -63,7 +63,7 @@ describe("useLatestResult", () => {
|
||||
});
|
||||
|
||||
it("should prevent out-of-order results", async () => {
|
||||
const doRequest = async (query) => {
|
||||
const doRequest = async (query: number) => {
|
||||
await sleep(query);
|
||||
return query;
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import React from "react";
|
||||
import { act } from "react-dom/test-utils";
|
||||
@ -24,7 +25,7 @@ import { useProfileInfo } from "../../src/hooks/useProfileInfo";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import { stubClient } from "../test-utils/test-utils";
|
||||
|
||||
function ProfileInfoComponent({ onClick }) {
|
||||
function ProfileInfoComponent({ onClick }: { onClick(hook: ReturnType<typeof useProfileInfo>): void }) {
|
||||
const profileInfo = useProfileInfo();
|
||||
|
||||
const { ready, loading, profile } = profileInfo;
|
||||
@ -38,7 +39,7 @@ function ProfileInfoComponent({ onClick }) {
|
||||
}
|
||||
|
||||
describe("useProfileInfo", () => {
|
||||
let cli;
|
||||
let cli: MatrixClient;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
@ -58,7 +59,6 @@ describe("useProfileInfo", () => {
|
||||
<ProfileInfoComponent
|
||||
onClick={(hook) => {
|
||||
hook.search({
|
||||
limit: 1,
|
||||
query,
|
||||
});
|
||||
}}
|
||||
@ -79,7 +79,6 @@ describe("useProfileInfo", () => {
|
||||
<ProfileInfoComponent
|
||||
onClick={(hook) => {
|
||||
hook.search({
|
||||
limit: 1,
|
||||
query: "",
|
||||
});
|
||||
}}
|
||||
@ -103,7 +102,6 @@ describe("useProfileInfo", () => {
|
||||
<ProfileInfoComponent
|
||||
onClick={(hook) => {
|
||||
hook.search({
|
||||
limit: 1,
|
||||
query,
|
||||
});
|
||||
}}
|
||||
@ -130,7 +128,6 @@ describe("useProfileInfo", () => {
|
||||
<ProfileInfoComponent
|
||||
onClick={(hook) => {
|
||||
hook.search({
|
||||
limit: 1,
|
||||
query,
|
||||
});
|
||||
}}
|
||||
@ -153,7 +150,6 @@ describe("useProfileInfo", () => {
|
||||
<ProfileInfoComponent
|
||||
onClick={(hook) => {
|
||||
hook.search({
|
||||
limit: 1,
|
||||
query,
|
||||
});
|
||||
}}
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import React from "react";
|
||||
import { act } from "react-dom/test-utils";
|
||||
@ -24,7 +25,7 @@ import { usePublicRoomDirectory } from "../../src/hooks/usePublicRoomDirectory";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import { stubClient } from "../test-utils/test-utils";
|
||||
|
||||
function PublicRoomComponent({ onClick }) {
|
||||
function PublicRoomComponent({ onClick }: { onClick(hook: ReturnType<typeof usePublicRoomDirectory>): void }) {
|
||||
const roomDirectory = usePublicRoomDirectory();
|
||||
|
||||
const { ready, loading, publicRooms } = roomDirectory;
|
||||
@ -38,7 +39,7 @@ function PublicRoomComponent({ onClick }) {
|
||||
}
|
||||
|
||||
describe("usePublicRoomDirectory", () => {
|
||||
let cli;
|
||||
let cli: MatrixClient;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import React from "react";
|
||||
import { act } from "react-dom/test-utils";
|
||||
@ -24,7 +25,7 @@ import { useUserDirectory } from "../../src/hooks/useUserDirectory";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import { stubClient } from "../test-utils";
|
||||
|
||||
function UserDirectoryComponent({ onClick }) {
|
||||
function UserDirectoryComponent({ onClick }: { onClick(hook: ReturnType<typeof useUserDirectory>): void }) {
|
||||
const userDirectory = useUserDirectory();
|
||||
|
||||
const { ready, loading, users } = userDirectory;
|
||||
@ -37,7 +38,7 @@ function UserDirectoryComponent({ onClick }) {
|
||||
}
|
||||
|
||||
describe("useUserDirectory", () => {
|
||||
let cli;
|
||||
let cli: MatrixClient;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
@ -53,6 +54,7 @@ describe("useUserDirectory", () => {
|
||||
display_name: query,
|
||||
},
|
||||
],
|
||||
limited: false,
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user