mohux / react-brackets

Reusable and customizable react brackets component, you can use it to build components such as single elimination, or double elimination brackets
105 stars 47 forks source link

Type 'keyof T' does not satisfy the constraint 'string'. #24

Closed rupalchawla closed 1 year ago

rupalchawla commented 1 year ago

Found this issue below with demo and fixed it, I'll see if I can fork the repo and checkin, but in the meantime I have also mentioned the fix below

Issue -

/BracketGenerator.d.ts
(22,63): Type 'keyof T' does not satisfy the constraint 'string'.
  Type 'string | number | symbol' is not assignable to type 'string'.
    Type 'number' is not assignable to type 'string'.

Fixed BracketGenerator.d.ts

export declare type Diff<T extends string | number | symbol, U extends string> = ({
    [P in T]: P;
} & {
    [P in U]: never;
} & {
    [x: string]: never;
})[T];
export declare type Omit<T, K extends string> = Pick<T, Diff<keyof T, K>>;
rupalchawla commented 1 year ago

Fixed demo/../BracketGenerator.d.ts

export declare type Diff<T extends string | number | symbol, U extends string> = ({
    [P in T]: P;
} & {
    [P in U]: never;
} & {
    [x: string]: never;
})[T];
export declare type Omit<T, K extends string> = Pick<T, Diff<keyof T, K>>;