typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

Error when use "[key: `data-${string}`]: string;"

Open melodyJie opened this issue 1 year ago • 1 comments

Case:

export interface ComponentProps {
  /**
   * @TJS-ignore
   */
  [key: `data-${string}`]: string;
}

Error:

Error: error: Error: Not supported: IndexSignatureDeclaration with index symbol other than a number or a string

https://github.com/ant-design/ant-design/blob/master/components/button/button.tsx#L46

melodyJie avatar Jan 10 '24 12:01 melodyJie

What worked for me is changing from

interface Config {
  [key: `data-${string}`]: string;
}

to

type Config = Record<`data-${string}`, string>

BrunnerLivio avatar Jan 23 '25 10:01 BrunnerLivio