posit-dev / posit-dev/positron

Language Runtime enums must exist in too many places

Open
#12 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: api
Dominant language
TypeScript
Stars
4.3k
Forks
183
Avg merge
1d 11h
Merged PRs (30d)
206

Description

The enums associated with the Language Runtime API need to exist in the vscode.d.ts type definitions, so extension authors can build on them.

https://github.com/rstudio/myriac/blob/87d043fa70b8734129f733865d420d9f31fca04d/src/vscode-dts/vscode.d.ts#L16447-L16457

Hygiene rules ensure that types that exist on the external API must also exist on the extension host, so we have to copy this to extHostTypes.

https://github.com/rstudio/myriac/blob/87d043fa70b8734129f733865d420d9f31fca04d/src/vs/workbench/api/common/extHostTypes.ts#L3899-L3909

Other rules forbid the importing of any types from vscode API or extHost (which represent the extension host process) into the core/contrib code. So we have to define the enum a third time there for use inside the core.

https://github.com/rstudio/myriac/blob/87d043fa70b8734129f733865d420d9f31fca04d/src/vs/workbench/contrib/languageRuntime/common/languageRuntimeService.ts#L33-L42

It feels like there ought to be a way for us to reduce this to two type declarations, or even one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the three enum declarations in src/vscode-dts/vscode.d.ts, src/vs/workbench/api/common/extHostTypes.ts, and src/vs/workbench/contrib/languageRuntime/common/languageRuntimeService.ts. Trace the import restrictions described in the issue and determine whether a shared declaration can satisfy the external API, extension host, and core users. Done means reducing duplication without importing vscode or extHost types into core/contrib code.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.