Skip to content

Commit

Permalink
docs: enhance docs for @Frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGw committed Apr 26, 2024
1 parent cd39589 commit 610f0df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ test using a testing framework. Here's an example with [`vitest`](https://vitest
import type { Abs, TestType } from 'ts-roids';
import { test, expect , expectTypeOf} from 'vitest';

test('|-54| should be 54'() => {
test('|-54| should be 54',() => {
type ShouldPass = true;
expectTypeOf<TestType<Abs<-54>, 54, ShouldPass>>().toEqualTypeOf<true>();
expectTypeOf<TestType<Abs<-54>, 54, true>>().toEqualTypeOf<ShouldPass>();
});
````

Expand Down
38 changes: 20 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1666,24 +1666,26 @@ const _freeze = (obj: object) => {
*
* @example
* ```ts
* @Frozen
* class Foo<T> {
* foo: T;
* bar: string;
*
* constructor(foo: T) {
* this.foo = foo;
* this.bar = 'bar';
* }
*
* someFoo(): T {
* return this.foo;
* }
* }
*
* const foo = new Foo('foo');
* // The line below will cause a TypeError: Cannot assign to read only property 'bar'
* foo.bar = 'altered bar';
@Frozen
class Foo<T> {
foo: T;
bar?: MaybeUndefined<string>;
constructor(foo: T) {
this.foo = foo;
this.bar = 'bar';
}
someFoo(): T {
return this.foo;
}
}
const foo = new Foo('foo');
// The line below will cause a TypeError: Cannot assign to read only property 'bar'
foo.bar = 'altered bar';
// The line below will cause a TypeError: Cannot delete property 'bar'
delete foo.bar;
* ```
*
*/
Expand Down

0 comments on commit 610f0df

Please sign in to comment.