MCPcopy Create free account
hub / github.com/microsoft/typescript-go / handleGetIndexInfosOfType

Method handleGetIndexInfosOfType

internal/api/session.go:2390–2420  ·  view source on GitHub ↗

handleGetIndexInfosOfType returns the index infos of a type.

(ctx context.Context, params *CheckerTypeParams)

Source from the content-addressed store, hash-verified

2388
2389// handleGetIndexInfosOfType returns the index infos of a type.
2390func (s *Session) handleGetIndexInfosOfType(ctx context.Context, params *CheckerTypeParams) ([]*IndexInfoResponse, error) {
2391 setup, err := s.setupChecker(ctx, params.Snapshot, params.Project)
2392 if err != nil {
2393 return nil, err
2394 }
2395 defer setup.done()
2396
2397 t, err := setup.resolveTypeHandle(params.Type)
2398 if err != nil {
2399 return nil, err
2400 }
2401
2402 infos := setup.checker.GetIndexInfosOfType(t)
2403 if len(infos) == 0 {
2404 return nil, nil
2405 }
2406
2407 results := make([]*IndexInfoResponse, len(infos))
2408 for i, info := range infos {
2409 results[i] = &IndexInfoResponse{
2410 KeyType: *setup.newTypeResponse(info.KeyType()),
2411 ValueType: *setup.newTypeResponse(info.ValueType()),
2412 IsReadonly: info.IsReadonly(),
2413 }
2414 if info.Declaration() != nil {
2415 results[i].Declaration = setup.sd.nodeHandleFrom(info.Declaration())
2416 }
2417 }
2418
2419 return results, nil
2420}
2421
2422// handleGetConstraintOfTypeParameter returns the constraint of a type parameter.
2423func (s *Session) handleGetConstraintOfTypeParameter(ctx context.Context, params *CheckerTypeParams) (*TypeResponse, error) {

Callers 1

HandleRequestMethod · 0.95

Calls 12

setupCheckerMethod · 0.95
lenFunction · 0.85
GetIndexInfosOfTypeMethod · 0.80
KeyTypeMethod · 0.80
ValueTypeMethod · 0.80
nodeHandleFromMethod · 0.80
doneMethod · 0.65
makeFunction · 0.50
resolveTypeHandleMethod · 0.45
newTypeResponseMethod · 0.45
IsReadonlyMethod · 0.45
DeclarationMethod · 0.45

Tested by

no test coverage detected