Skip to content

Consider referencing xterm.d.ts from internal types to reduce doc repetition #4663

@Tyriar

Description

@Tyriar

From @PerBothner's suggestion in #4519 (comment)

Right now we often either don't have docs linked to internal types (making development harder, especially for new contributors) or duplicate the docs which of course can easily suffer bitrot.

One solution is to reference xterm and then extend Pick<Terminal, 'apis'> like this:

image

If we do this we would want some rules around the usage, here are some ideas using Terminal.selectAll()/ISelectionService.selectAll() as an example.

1: Pull in any types referenced to a special types file

Example:

ApiTypes.ts

import { Terminal } from 'xterm';

// Each function used internally would have it's own type
export type IApiSelectAll = Pick<Terminal, 'selectAll'>;

Services.ts

export interface ISelectionService extends IApiSelectAll {
}

2: Pull in directly from the API

Services.ts

import { Terminal as IApiTerminal } from 'xterm';

export interface ISelectionService extends Pick<IApiTerminal, 'selectAll'> {
}

I think 1 is probably the nicest unless there are other ideas because:

  • It's obvious across the codebase what IApi* types are
  • It hides the type complexity inside the ApiTypes file
  • Extending multiple is cleaner as a result
  • No need to rename the Terminal as IApiTerminal import manually when a file hasn't referenced it yet
export interface ISelectionService extends IApiSelectAll,
                                           IApiSelectLines {
}

vs

export interface ISelectionService
  extends Pick<IApiTerminal, 'selectAll' | 'selectLines'> {
}

Metadata

Metadata

Assignees

Labels

type/debtTechnical debt that could slow us down in the long run

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions