exporting a Record<K,T> as a named type or interface in ts

1k Views Asked by At

I am pretty new to TypeScript so bear with me. I am aware of using Record<K, T> Utility Type, my question is, Is there any way to export my Record<K, T> as another interface/type or anything that can be used in other files and modules.

1

There are 1 best solutions below

0
omegatrix On BEST ANSWER
// Create and export custom types using Record
export type SomeKeyValue = Record<string, boolean>;

// Use it in another file
// import SomeKeyValue from ...
const something: SomeKeyValue = {
  'first': true,
  'second': false,
};