Skip to content

Instantly share code, notes, and snippets.

@LeeDDHH
Created January 29, 2022 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeDDHH/ec59b2d60b966a1de6abad9f66adc64b to your computer and use it in GitHub Desktop.
Save LeeDDHH/ec59b2d60b966a1de6abad9f66adc64b to your computer and use it in GitHub Desktop.
TypeScriptでCSSの参照の型定義をする

型定義

  • styleのオブジェクトをインデックスシグネチャで参照するように型定義をする
// cssModule.d.ts のようなファイルとして生成
declare module '*.css' {
  interface IClassNames {
    [className: string]: string
  }
  const classNames: IClassNames;
  export = classNames;
}

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment