Sha256: 710e09a2711b011cc9681d237da0c1c450d12551b0d21c764826822e548b5464

Contents?: true

Size: 744 Bytes

Versions: 28

Compression:

Stored size: 744 Bytes

Contents

import type {Except} from './except';
import type {Simplify} from './simplify';

/**
Create a type that changes the type of the given keys.

Use-cases:
- Creating variations of a base model.
- Fixing incorrect external types.

@see `Merge` if you need to change multiple properties to different types.

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

type MyModel = {
	id: number;
	createdAt: Date;
	updatedAt: Date;
};

type MyModelApi = SetFieldType<MyModel, 'createdAt' | 'updatedAt', string>;
// {
// 	id: number;
// 	createdAt: string;
// 	updatedAt: string;
// }
```

@category Object
*/
export type SetFieldType<BaseType, Keys extends keyof BaseType, NewType> =
	Simplify<
	Except<BaseType, Keys> &
	Record<Keys, NewType>
	>;

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/type-fest/source/set-field-type.d.ts