Skip to content

Exposing more endpoints#3403

Open
navya9singh wants to merge 1 commit intomicrosoft:mainfrom
navya9singh:navyasingh/updatingExport
Open

Exposing more endpoints#3403
navya9singh wants to merge 1 commit intomicrosoft:mainfrom
navya9singh:navyasingh/updatingExport

Conversation

@navya9singh
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 15, 2026 01:36
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR expands the public API surface by exposing additional checker endpoints (types/signatures utilities) through the Go session layer and the TypeScript client libraries.

Changes:

  • Added new API methods/endpoints: resolved signature, non-nullable type, type-from-type-node, widened type, parameter type, array-like checks, and signature declaration printing.
  • Exposed NodeBuilderFlags in the TypeScript API to support node/signature printing flags.
  • Added Go checker wrappers for newly exposed functionality.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/checker/printer.go Exposes SignatureToSignatureDeclaration via Checker.
internal/checker/exports.go Exposes widened-type functionality via Checker.
internal/api/session.go Routes and implements new API handlers for the added endpoints.
internal/api/proto.go Adds method constants, unmarshalers, and request parameter types for new endpoints.
_packages/api/src/sync/api.ts Adds sync client methods for new endpoints and exports NodeBuilderFlags.
_packages/api/src/async/api.ts Adds async client methods for new endpoints and exports NodeBuilderFlags.
_packages/api/src/enums/nodeBuilderFlags.ts Adds generated runtime NodeBuilderFlags enum values.
_packages/api/src/enums/nodeBuilderFlags.enum.ts Adds generated TypeScript NodeBuilderFlags type enum.

Comment thread internal/api/session.go
Comment on lines +1357 to +1376
// handleGetParameterType returns the type of a parameter at a given index in a signature.
func (s *Session) handleGetParameterType(ctx context.Context, params *GetParameterTypeParams) (*TypeResponse, error) {
setup, err := s.setupChecker(ctx, params.Snapshot, params.Project)
if err != nil {
return nil, err
}
defer setup.done()

sig, err := setup.sd.resolveSignatureHandle(params.Signature)
if err != nil {
return nil, err
}

t := setup.checker.GetTypeParameterAtPosition(sig, int(params.Index))
if t == nil {
return nil, nil
}

return setup.sd.registerType(t), nil
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This handler is documented and named to return a parameter type, but it calls GetTypeParameterAtPosition, which typically refers to a generic type parameter (e.g., T) rather than a function parameter’s type. Either switch to the checker API that returns the parameter type at position (commonly GetTypeAtPosition(signature, index)), or rename the endpoint/params/method to getTypeParameterAtPosition to match the implemented behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Name is same as that in Strada. The function returns the type of parameter as an index and not a generic type parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, Copilot is right about this. The function you wrote here returns the type of a generic type parameter. The checker function you need to use is called getTypeAtPosition and isn't exported yet.

Comment thread internal/api/session.go
Comment thread internal/api/session.go
sig, err := setup.sd.resolveSignatureHandle(params.Signature)
if err != nil {
return nil, err
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

params.Index is int32 and is directly cast to int without validation. Negative values (or out-of-range values) should be rejected with a clear error to avoid undefined behavior or downstream panics inside the checker. Consider validating params.Index >= 0 (and, if feasible, bounds-checking against the signature’s parameter count) and returning an error like invalid parameter index.

Suggested change
}
}
if params.Index < 0 {
return nil, fmt.Errorf("invalid parameter index")
}

Copilot uses AI. Check for mistakes.
Comment on lines +743 to +751
signatureToSignatureDeclaration(signature: Signature, kind: number, enclosingDeclaration?: Node, flags?: number): Node | undefined {
const binaryData = this.client.apiRequestBinary("signatureToSignatureDeclaration", {
snapshot: this.snapshotId,
project: this.projectId,
signature: signature.id,
kind,
location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
flags,
});
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The TS client method is typed with kind: number and flags?: number, but this endpoint is semantically tied to specific enums (AST Kind/SyntaxKind for kind, and NodeBuilderFlags for flags). Since NodeBuilderFlags is already added to exports, update the method signature to use flags?: NodeBuilderFlags (and a stronger type for kind if available) to prevent accidental invalid values and improve IntelliSense.

Copilot uses AI. Check for mistakes.
Comment on lines +735 to +743
async signatureToSignatureDeclaration(signature: Signature, kind: number, enclosingDeclaration?: Node, flags?: number): Promise<Node | undefined> {
const binaryData = await this.client.apiRequestBinary("signatureToSignatureDeclaration", {
snapshot: this.snapshotId,
project: this.projectId,
signature: signature.id,
kind,
location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
flags,
});
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Same typing issue as the sync client: kind/flags are exposed as plain numbers. Prefer flags?: NodeBuilderFlags (and a stronger enum type for kind if available) so callers don’t accidentally pass unrelated constants.

Copilot uses AI. Check for mistakes.
Comment thread internal/api/proto.go
Comment on lines +721 to +735
// GetNonNullableTypeParams returns the type with null and undefined removed.
type GetNonNullableTypeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Type Handle[checker.Type] `json:"type"`
}

// GetTypeFromTypeNodeParams returns the type for a type node.
type GetTypeFromTypeNodeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Location Handle[ast.Node] `json:"location"`
}

// GetWidenedTypeParams returns the widened type of a type.
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

These doc comments describe the result of the operation rather than what the params struct represents (e.g., “returns …”). For clarity and consistency, reword to something like: // GetNonNullableTypeParams are the parameters for the getNonNullableType method. (Similarly for GetTypeFromTypeNodeParams, GetWidenedTypeParams, and GetParameterTypeParams.)

Suggested change
// GetNonNullableTypeParams returns the type with null and undefined removed.
type GetNonNullableTypeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Type Handle[checker.Type] `json:"type"`
}
// GetTypeFromTypeNodeParams returns the type for a type node.
type GetTypeFromTypeNodeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Location Handle[ast.Node] `json:"location"`
}
// GetWidenedTypeParams returns the widened type of a type.
// GetNonNullableTypeParams are the parameters for the getNonNullableType method.
type GetNonNullableTypeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Type Handle[checker.Type] `json:"type"`
}
// GetTypeFromTypeNodeParams are the parameters for the getTypeFromTypeNode method.
type GetTypeFromTypeNodeParams struct {
Snapshot Handle[project.Snapshot] `json:"snapshot"`
Project Handle[project.Project] `json:"project"`
Location Handle[ast.Node] `json:"location"`
}
// GetWidenedTypeParams are the parameters for the getWidenedType method.

Copilot uses AI. Check for mistakes.
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.

4 participants