[@typescript/api] Batch of Checker and Type APIs#2831
Merged
andrewbranch merged 5 commits intomicrosoft:mainfrom Feb 19, 2026
Merged
[@typescript/api] Batch of Checker and Type APIs#2831andrewbranch merged 5 commits intomicrosoft:mainfrom
andrewbranch merged 5 commits intomicrosoft:mainfrom
Conversation
- Add Symbol methods: getParent, getMembers, getExports - Add Type method: getSymbol - Add Signature type with flags, declaration, parameters, target - Add Checker methods: getSignaturesOfType, getTypeAtLocation, getTypeAtPosition - Add SignatureKind and SignatureFlags enums (.enum.ts pattern) - Fix RemoteSourceFile.id to use node handle format (pos.end.kind.path) - Remove unused base64 node id from binary encoder - Fix GetSymbolAtLocation to handle SourceFile nodes (remove early parent check) - Add comprehensive sync and async client tests
- Add 11 type sub-property endpoints (getTargetOfType, getTypesOfType, getTypeParametersOfType, etc.) to Go server and TS client - Add getDeclaredTypeOfSymbol endpoint for retrieving declared types of type alias symbols (vs getTypeOfSymbol which returns value types) - Add fetchType/fetchTypes helpers to TypeObject for lazy resolution of type handles with local cache support via ObjectRegistry.tryGetType - Remove handle-typed properties from public type interfaces, keeping handles as wire-format fields for client-side cache optimization - Rename tupleReadonly to readonly across Go JSON tags and TS interfaces - Add comprehensive tests for all type sub-property fetchers
…ypeOfLiteralType, getShorthandAssignmentValueSymbol, getTypeOfSymbolAtLocation Add new checker API endpoints: - getContextualType: returns the contextual type for an expression node - getBaseTypeOfLiteralType: widens literal types to their base (e.g. 42 -> number) - getShorthandAssignmentValueSymbol: resolves value symbol of shorthand property assignments - getTypeOfSymbolAtLocation: returns narrowed type of a symbol at a specific location - 11 intrinsic type getters: getAnyType, getStringType, getNumberType, getBooleanType, getVoidType, getUndefinedType, getNullType, getNeverType, getUnknownType, getBigIntType, getESSymbolType Includes Go checker exports, server handlers, TS sync/async client implementations, base interface definitions, and tests for all new endpoints.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive batch of Checker and Type APIs to expose TypeScript's type system through the Go language server API. The changes enable programmatic access to type information, signatures, and symbol relationships.
Changes:
- Exposes checker query methods for types, symbols, and signatures (getDeclaredTypeOfSymbol, getTypeAtLocation, getSignaturesOfType, getContextualType, etc.)
- Adds intrinsic type getters (getAnyType, getStringType, getNumberType, etc.) for accessing built-in types
- Implements symbol relationship methods (getMembers, getExports, getParent) for traversing symbol hierarchies
- Introduces type hierarchy interfaces with sub-property accessors for complex types (UnionType, ConditionalType, IndexedAccessType, etc.)
- Adds new enum types (ObjectFlags, ElementFlags, SignatureFlags, SignatureKind) for type discrimination
- Includes comprehensive test coverage for both sync and async API variants
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSwitchCase6.baseline.jsonc* | Fixed baseline for go-to-definition on switch case - diff removed |
| internal/checker/types.go | Added getter methods for type sub-properties (Target, Types, IsReadonly, CheckType, ExtendsType, etc.) |
| internal/checker/exports.go | Exposed intrinsic type getters and getBaseTypeOfLiteralType |
| internal/checker/checker.go | Removed redundant nil check in GetSymbolAtLocation |
| internal/api/session.go | Implemented API handlers for new methods, added signature registry, refactored with setupChecker helper |
| internal/api/proto.go | Extended TypeResponse with detailed type structure data, added SignatureResponse and new method definitions |
| internal/api/encoder/encoder.go | Removed node ID encoding from source files |
| _packages/api/src/signatureKind.* | New enum for call vs construct signatures |
| _packages/api/src/signatureFlags.* | New enum for signature flags (HasRestParameter, Construct, Abstract) |
| _packages/api/src/objectFlags.* | New enum for object type flags (Class, Interface, Reference, Tuple, etc.) |
| _packages/api/src/elementFlags.* | New enum for tuple element flags (Required, Optional, Rest, Variadic) |
| _packages/api/src/base/objectRegistry.ts | Extended to support signature registration alongside symbols and types |
| _packages/api/src/base/api.ts | Added comprehensive type hierarchy interfaces and checker methods |
| _packages/api/src/sync/api.ts | Implemented sync API with TypeObject class, Symbol/Type sub-property methods, Signature class |
| _packages/api/src/async/api.ts | Parallel async implementation with Promise-based methods |
| _packages/api/src/proto.ts | Extended TypeResponse and SignatureResponse interfaces |
| _packages/api/src/node.ts | Removed source file ID encoding |
| _packages/api/package.json | Added imports for new enum modules |
| _packages/api/test/api.sync.test.ts | Comprehensive test suite for new checker, symbol, and type APIs |
| _packages/api/test/api.async.test.ts | Async variant of test suite |
jakebailey
approved these changes
Feb 19, 2026
This was referenced Feb 20, 2026
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.
Checker query methods:
getDeclaredTypeOfSymbolgetTypeAtLocation/getTypeAtLocationsgetTypeAtPosition/getTypesAtPositionsgetSignaturesOfTypegetContextualTypegetBaseTypeOfLiteralTypegetShorthandAssignmentValueSymbolgetTypeOfSymbolAtLocationIntrinsic type getters:
getAnyType,getStringType,getNumberType,getBooleanType,getVoidType,getUndefinedType,getNullType,getNeverType,getUnknownType,getBigIntType,getESSymbolTypeSymbol property fetchers:
getMembers,getExports,getParentType hierarchy:
Type— base type (id,flags,getSymbol())LiteralType— string/number/bigint/boolean literals (value)ObjectType— object types (objectFlags)TypeReference— e.g.Array<string>(getTarget())InterfaceType— classes and interfaces (getTypeParameters(),getOuterTypeParameters(),getLocalTypeParameters())TupleType— tuple types (elementFlags,fixedLength,readonly)UnionOrIntersectionType— (getTypes())UnionTypeIntersectionTypeTypeParameterIndexType—keyof T(getTarget())IndexedAccessType—T[K](getObjectType(),getIndexType())ConditionalType—T extends U ? X : Y(getCheckType(),getExtendsType())SubstitutionType— (getBaseType(),getConstraint())TemplateLiteralType— template literals (texts,getTypes())StringMappingType—Uppercase<T>etc. (getTarget())New enums/flags exposed:
ObjectFlags,ElementFlags,SignatureFlags,SignatureKind