mirror of
https://github.com/sindresorhus/type-fest.git
synced 2026-02-01 15:59:43 +00:00
30 lines
913 B
TypeScript
30 lines
913 B
TypeScript
import {expectType} from 'tsd';
|
|
import type {CamelCasedProperties} from '../index';
|
|
|
|
declare const foo: CamelCasedProperties<{A: number; B: {C: string}}>;
|
|
expectType<{a: number; b: {C: string}}>(foo);
|
|
|
|
declare const bar: CamelCasedProperties<Array<{helloWorld: string}>>;
|
|
expectType<Array<{helloWorld: string}>>(bar);
|
|
|
|
declare const fooBar: CamelCasedProperties<() => {a: string}>;
|
|
expectType<() => {a: string}>(fooBar);
|
|
|
|
declare const baz: CamelCasedProperties<{fooBAR: number; BARFoo: string}>;
|
|
expectType<{fooBAR: number; bARFoo: string}>(baz);
|
|
|
|
declare const biz: CamelCasedProperties<{fooBAR: number; BARFoo: string}, {preserveConsecutiveUppercase: false}>;
|
|
expectType<{fooBar: number; barFoo: string}>(biz);
|
|
|
|
// Verify example
|
|
type User = {
|
|
UserId: number;
|
|
UserName: string;
|
|
};
|
|
|
|
const result: CamelCasedProperties<User> = {
|
|
userId: 1,
|
|
userName: 'Tom',
|
|
};
|
|
expectType<CamelCasedProperties<User>>(result);
|