utils/tests/type.spec.ts
ztimson fec373ca4c
All checks were successful
Build / Build NPM Project (push) Successful in 1m16s
Build / Tag Version (push) Successful in 14s
Build / Publish Documentation (push) Successful in 53s
Added test suite
2025-05-14 16:30:42 -04:00

19 lines
619 B
TypeScript

import {Writable} from '../src';
describe('Type Utilities', () => {
describe('Writable', () => {
it('should create a writable version of a readonly type', () => {
type ReadonlyPerson = {
readonly name: string;
readonly age: number;
};
type WritablePerson = Writable<ReadonlyPerson>;
// Typescript: WritablePerson's properties should not be readonly
const person: WritablePerson = { name: 'Alice', age: 40 };
person.name = 'Bob'; // Should not error in TypeScript
person.age = 41; // Should not error in TypeScript
expect(person).toEqual({ name: 'Bob', age: 41 });
});
});
});