Repository navigation
Readonly and Required of a class are the class itself - #118
Merged
Merged
Conversation
Mapped over a class, they made an object of its fields, without its methods (Readonly<C> of a class with methods came out empty). A conditional on `abstract new (...args: any) => any`, which a class's own type extends in tslang, keeps the class; object types and interfaces are mapped as before. Partial and Pick are left as they were: kept as the class, they would no longer take an object literal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Readonly<T>andRequired<T>mapped a class into an object of its fields, without its methods.Readonly<C>of a class with methods came out as an empty type, sor.bump()failed withCan't resolve property 'bump' of type [].Both now keep a class as it is:
In tslang a class's own type extends
abstract new (...args: any) => any(MLIRTypeHelper::extendsTypematches a class against a constructor type), while object types, interfaces, arrays and primitives don't. Standard TypeScript would answer no for a class instance, so this relies on tslang's behaviour.extends classdoes not parse.PartialandPickare unchanged: if they kept the class they would no longer accept an object literal (constructor(init: Partial<Point>)called with{ x: 1 }).Not in this change:
readonlyis not enforced by the compiler. A write throughReadonly<{ a: number }>compiles and runs, with or without this change.Testing
tests/readonly_required_class.ts: a class with a method, an optional field, a derived class with a constructor argument, a generic class, plus an object type and an interface. Passes under--emit=jit(release, gc) against a staged copy of the library with this change; fails to compile with the current one.tests.ps1,--emit=exe, debug, and the rc/own/none models.🤖 Generated with Claude Code