Sha256: 1285ddb279c6d0bc5fe46162a893855078ae5b708d804cd93bfc4a23d1e903d9

Contents?: true

Size: 1.18 KB

Versions: 24

Compression:

Stored size: 1.18 KB

Contents

import type {DelimiterCase} from './delimiter-case';

/**
Convert object properties to delimiter case recursively.

This can be useful when, for example, converting some API types from a different style.

@see DelimiterCase
@see DelimiterCasedProperties

@example
```
import type {DelimiterCasedPropertiesDeep} from 'type-fest';

interface User {
	userId: number;
	userName: string;
}

interface UserWithFriends {
	userInfo: User;
	userFriends: User[];
}

const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = {
	'user-info': {
	'user-id': 1,
		'user-name': 'Tom',
	},
	'user-friends': [
		{
			'user-id': 2,
			'user-name': 'Jerry',
		},
		{
			'user-id': 3,
			'user-name': 'Spike',
		},
	],
};
```

@category Change case
@category Template literal
@category Object
*/
export type DelimiterCasedPropertiesDeep<
	Value,
	Delimiter extends string,
> = Value extends Function | Date | RegExp
	? Value
	: Value extends Array<infer U>
	? Array<DelimiterCasedPropertiesDeep<U, Delimiter>>
	: Value extends Set<infer U>
	? Set<DelimiterCasedPropertiesDeep<U, Delimiter>> : {
			[K in keyof Value as DelimiterCase<
				K,
				Delimiter
			>]: DelimiterCasedPropertiesDeep<Value[K], Delimiter>;
	};

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.50 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.49 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.48 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.47 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.46 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.45 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.44 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.43 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.42 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.41 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.40 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.39 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.38 node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.32 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.31 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.30 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.29 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.28 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts
immosquare-cleaner-0.1.27 node_modules/boxen/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts