Skip to content

[@typescript/api] Batch of Checker and Type APIs#2831

Merged
andrewbranch merged 5 commits intomicrosoft:mainfrom
andrewbranch:api-surface-area
Feb 19, 2026
Merged

[@typescript/api] Batch of Checker and Type APIs#2831
andrewbranch merged 5 commits intomicrosoft:mainfrom
andrewbranch:api-surface-area

Conversation

@andrewbranch
Copy link
Member

Checker query methods:

  • getDeclaredTypeOfSymbol
  • getTypeAtLocation / getTypeAtLocations
  • getTypeAtPosition / getTypesAtPositions
  • getSignaturesOfType
  • getContextualType
  • getBaseTypeOfLiteralType
  • getShorthandAssignmentValueSymbol
  • getTypeOfSymbolAtLocation

Intrinsic type getters:

  • getAnyType, getStringType, getNumberType, getBooleanType, getVoidType, getUndefinedType, getNullType, getNeverType, getUnknownType, getBigIntType, getESSymbolType

Symbol property fetchers:

  • getMembers, getExports, getParent

Type 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())
      • UnionType
      • IntersectionType
    • TypeParameter
    • IndexTypekeyof T (getTarget())
    • IndexedAccessTypeT[K] (getObjectType(), getIndexType())
    • ConditionalTypeT extends U ? X : Y (getCheckType(), getExtendsType())
    • SubstitutionType — (getBaseType(), getConstraint())
    • TemplateLiteralType — template literals (texts, getTypes())
    • StringMappingTypeUppercase<T> etc. (getTarget())

New enums/flags exposed:

  • ObjectFlags, ElementFlags, SignatureFlags, SignatureKind

- 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.
@andrewbranch andrewbranch marked this pull request as ready for review February 19, 2026 16:53
Copilot AI review requested due to automatic review settings February 19, 2026 16:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@andrewbranch andrewbranch added this pull request to the merge queue Feb 19, 2026
Merged via the queue into microsoft:main with commit e72236e Feb 19, 2026
26 checks passed
@andrewbranch andrewbranch deleted the api-surface-area branch February 19, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants