Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
59,710 changes: 34,224 additions & 25,486 deletions types/office-js-preview/index.d.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions types/react/canary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ declare module "." {
* @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation}
*/
export const Activity: ExoticComponent<ActivityProps>;

/**
* @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation}
*/
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function useEffectEvent<T extends Function>(callback: T): T;
}
3 changes: 0 additions & 3 deletions types/react/experimental.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ declare module "." {
*/
export const unstable_SuspenseList: ExoticComponent<SuspenseListProps>;

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function experimental_useEffectEvent<T extends Function>(event: T): T;

type Reference = object;
type TaintableUniqueValue = string | bigint | ArrayBufferView;
function experimental_taintUniqueValue(
Expand Down
29 changes: 29 additions & 0 deletions types/react/test/canary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,32 @@ function activityTest() {
/>;
<Activity children="peekaboo" name="/" />;
}

function useEffectEventTest() {
// Implicit any
// @ts-expect-error
const anyEvent = React.useEffectEvent(value => {
// $ExpectType any
return value;
});
// $ExpectType any
anyEvent({});
// $ExpectType (value: string) => number
const typedEvent = React.useEffectEvent((value: string) => {
return Number(value);
});
// $ExpectType number
typedEvent("1");
// Argument of type '{}' is not assignable to parameter of type 'string'.
// @ts-expect-error
typedEvent({});

function useContextuallyTypedEvent(fn: (event: Event) => string) {}
useContextuallyTypedEvent(
React.useEffectEvent(event => {
// $ExpectType Event
event;
return String(event);
}),
);
}
29 changes: 0 additions & 29 deletions types/react/test/experimental.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,6 @@ function Page({ children }: { children: NonNullable<React.ReactNode> }) {
);
}

function useEvent() {
// Implicit any
// @ts-expect-error
const anyEvent = React.experimental_useEffectEvent(value => {
// $ExpectType any
return value;
});
// $ExpectType any
anyEvent({});
// $ExpectType (value: string) => number
const typedEvent = React.experimental_useEffectEvent((value: string) => {
return Number(value);
});
// $ExpectType number
typedEvent("1");
// Argument of type '{}' is not assignable to parameter of type 'string'.
// @ts-expect-error
typedEvent({});

function useContextuallyTypedEvent(fn: (event: Event) => string) {}
useContextuallyTypedEvent(
React.experimental_useEffectEvent(event => {
// $ExpectType Event
event;
return String(event);
}),
);
}

function elementTypeTests() {
const ReturnPromise = () => Promise.resolve("React");
const FCPromise: React.FC = ReturnPromise;
Expand Down
6 changes: 6 additions & 0 deletions types/react/ts5.0/canary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ declare module "." {
* @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation}
*/
export const Activity: ExoticComponent<ActivityProps>;

/**
* @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation}
*/
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function useEffectEvent<T extends Function>(callback: T): T;
}
3 changes: 0 additions & 3 deletions types/react/ts5.0/experimental.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ declare module "." {
*/
export const unstable_SuspenseList: ExoticComponent<SuspenseListProps>;

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function experimental_useEffectEvent<T extends Function>(event: T): T;

type Reference = object;
type TaintableUniqueValue = string | bigint | ArrayBufferView;
function experimental_taintUniqueValue(
Expand Down
29 changes: 29 additions & 0 deletions types/react/ts5.0/test/canary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,32 @@ function activityTest() {
/>;
<Activity children="peekaboo" name="/" />;
}

function useEffectEventTest() {
// Implicit any
// @ts-expect-error
const anyEvent = React.useEffectEvent(value => {
// $ExpectType any
return value;
});
// $ExpectType any
anyEvent({});
// $ExpectType (value: string) => number
const typedEvent = React.useEffectEvent((value: string) => {
return Number(value);
});
// $ExpectType number
typedEvent("1");
// Argument of type '{}' is not assignable to parameter of type 'string'.
// @ts-expect-error
typedEvent({});

function useContextuallyTypedEvent(fn: (event: Event) => string) {}
useContextuallyTypedEvent(
React.useEffectEvent(event => {
// $ExpectType Event
event;
return String(event);
}),
);
}
29 changes: 0 additions & 29 deletions types/react/ts5.0/test/experimental.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,6 @@ function Page({ children }: { children: NonNullable<React.ReactNode> }) {
);
}

function useEvent() {
// Implicit any
// @ts-expect-error
const anyEvent = React.experimental_useEffectEvent(value => {
// $ExpectType any
return value;
});
// $ExpectType any
anyEvent({});
// $ExpectType (value: string) => number
const typedEvent = React.experimental_useEffectEvent((value: string) => {
return Number(value);
});
// $ExpectType number
typedEvent("1");
// Argument of type '{}' is not assignable to parameter of type 'string'.
// @ts-expect-error
typedEvent({});

function useContextuallyTypedEvent(fn: (event: Event) => string) {}
useContextuallyTypedEvent(
React.experimental_useEffectEvent(event => {
// $ExpectType Event
event;
return String(event);
}),
);
}

function elementTypeTests() {
const ReturnPromise = () => Promise.resolve("React");
const FCPromise: React.FC = ReturnPromise;
Expand Down