Skip to main content
Module

x/scaffold/src/deps/types.ts>StringKeyOf

scaffold your next project with style and 💗
Latest
type alias StringKeyOf
import { type StringKeyOf } from "https://deno.land/x/scaffold@0.3.0/src/deps/types.ts";

Get keys of the given type as strings.

Number keys are converted to strings.

Use-cases:

  • Get string keys from a type which may have number keys.
  • Makes it possible to index using strings retrieved from template types.

Examples

Example 1

import type {StringKeyOf} from 'type-fest';

type Foo = {
	1: number,
	stringKey: string,
};

type StringKeysOfFoo = StringKeyOf<Foo>;
//=> '1' | 'stringKey'
definition: `${Extract<keyof BaseType, string | number>}`