Proposal: Type Relationship API
They type checker has no public API for checking type relationships or for looking up types in a given scope. This can make writing semantic-analysis informed lint rules very difficult (either because you need to replicate a lot of logic, or because you simply don't have enough information). Since [tslint enabled semantic checks](https://github.com/palantir/tslint/commit/9248e056c1a652ee13597e68da26cacf0b87e134) we now have a popular consumer who would very much like to be able to perform meaningful semantic comparisons (See [this rule](https://github.com/palantir/tslint/pull/1394#issuecomment-234384650) for instance). # Proposal A small new set of public API methods on the type checker: ``` ts interface TypeChecker { isIdenticalTo(a: Type, b: Type): boolean; // Exposes internal identity relationship isSubtypeOf(a: Type, b: Type): boolean; // Exposes internal structural subtype relationship isAssignableTo(a: Type, b: Type): boolean; // Exposes internal assignable relationship isComparableTo(a: Type, b: Type): boolean; // Exposes internal comparable relationship isInstantiationOf(a: GenericType, b: GenericType): boolean; // While not an internal relationship, it is a straightforward semantic question to ask an answer which requires internal APIs to answer lookupGlobalType(name: string): Type; // Looks up a global symbol named "name" with meaning SymbolFlags.Type (Identical to getGlobalType but without the expected arity based return value) - returns unknownType
Posted by weswigham on Jul 21, 2016, 10:39 PM
Tags
Related issues
- This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
- I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
- the new VSCode UI, looks cute, i don't like it.
- I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
- The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
- Add PR-style review comments in Git Diff UI that feed into the active agent thread
Raise real-world problems, find people facing the same issue, and discuss solutions.5,000 issues0 comments
ux (Software)
This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
the new VSCode UI, looks cute, i don't like it.
I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
Add PR-style review comments in Git Diff UI that feed into the active agent thread
Thanks for indulging me so far, by the way, I really appreciate this discussion, it's very stimulating.
Migrate GDScript to the GDExtension mechanism and overhaul the implementation
Proposal: Type Relationship API
They type checker has no public API for checking type relationships or for looking up types in a given scope. This can make writing semantic-analysis informed lint rules very difficult (either because you need to replicate a lot of logic, or because you simply don't have enough information). Since [tslint enabled semantic checks](https://github.com/palantir/tslint/commit/9248e056c1a652ee13597e68da26cacf0b87e134) we now have a popular consumer who would very much like to be able to perform meaningful semantic comparisons (See [this rule](https://github.com/palantir/tslint/pull/1394#issuecomment-234384650) for instance). # Proposal A small new set of public API methods on the type checker: ``` ts interface TypeChecker { isIdenticalTo(a: Type, b: Type): boolean; // Exposes internal identity relationship isSubtypeOf(a: Type, b: Type): boolean; // Exposes internal structural subtype relationship isAssignableTo(a: Type, b: Type): boolean; // Exposes internal assignable relationship isComparableTo(a: Type, b: Type): boolean; // Exposes internal comparable relationship isInstantiationOf(a: GenericType, b: GenericType): boolean; // While not an internal relationship, it is a straightforward semantic question to ask an answer which requires internal APIs to answer lookupGlobalType(name: string): Type; // Looks up a global symbol named "name" with meaning SymbolFlags.Type (Identical to getGlobalType but without the expected arity based return value) - returns unknownType
Comments (0)
No comments yet. Start the discussion.