-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
type/debtTechnical debt that could slow us down in the long runTechnical debt that could slow us down in the long run
Description
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:
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 IApiTerminalimport manually when a file hasn't referenced it yet
export interface ISelectionService extends IApiSelectAll,
IApiSelectLines {
}vs
export interface ISelectionService
extends Pick<IApiTerminal, 'selectAll' | 'selectLines'> {
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/debtTechnical debt that could slow us down in the long runTechnical debt that could slow us down in the long run
