Skip to content

Commit

Permalink
Fix type error in mergeStyles.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
louischan-oursky committed Dec 11, 2024
1 parent 117fb00 commit 89459fe
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions portal/src/util/mergeStyles.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { useCallback, useMemo } from "react";
import { IStyleFunctionOrObject, IStyleSet } from "@fluentui/react";
import { IStyleFunctionOrObject } from "@fluentui/react";
import {
concatStyleSetsWithProps,
concatStyleSets,
IConcatenatedStyleSet,
IStyleSetBase,
} from "@fluentui/merge-styles";

export function useMergedStyles<TStylesProps, IStyleSet>(
...styless: (IStyleFunctionOrObject<TStylesProps, IStyleSet> | undefined)[]
): IStyleFunctionOrObject<TStylesProps, IStyleSet> {
export function useMergedStyles<TStylesProps, TStyleSet extends IStyleSetBase>(
...styless: (IStyleFunctionOrObject<TStylesProps, TStyleSet> | undefined)[]
): (
props: TStylesProps
) => ReturnType<typeof concatStyleSetsWithProps<TStylesProps, TStyleSet>> {
return useCallback(
(props) => {
return concatStyleSetsWithProps(props, ...styless);
},
// eslint-disable-next-line
// eslint-disable-next-line react-hooks/exhaustive-deps
[...styless]
);
}

export function useMergedStylesPlain(
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
...styless: (IStyleSet | undefined)[]
): IConcatenatedStyleSet<IStyleSet> {
export function useMergedStylesPlain<TStyleSet extends IStyleSetBase>(
...styless: (TStyleSet | undefined)[]
): IConcatenatedStyleSet<TStyleSet> {
return useMemo(
() => concatStyleSets(...styless),
// eslint-disable-next-line
// eslint-disable-next-line react-hooks/exhaustive-deps
[...styless]
) as IConcatenatedStyleSet<IStyleSet>;
) as IConcatenatedStyleSet<TStyleSet>;
}

0 comments on commit 89459fe

Please sign in to comment.