Skip to content

Latest commit

 

History

History

key-of-base

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

KeyofBase is a keyofStringsOnly-tolerant analogue for PropertyKey

With keyofStringsOnly disabled:

import { KeyofBase } from "ts-essentials";
//      ^? string | number | symbol

type BuiltinKeys = PropertyKey;
//   ^? string | number | symbol

With keyofStringsOnly enabled:

import { KeyofBase } from "ts-essentials";
//      ^? string

type BuiltinKeys = PropertyKey;
//   ^? string | number | symbol

It's recommended to use KeyofBase since TypeScript 2.9.2 – https://devblogs.microsoft.com/typescript/announcing-typescript-2-9-2/#support-for-symbols-and-numeric-literals-in-keyof-and-mapped-object-types

keyofStringsOnly is deprecated since TypeScript 5.0 – https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#deprecations-and-default-changes

TS Playground: