microsoft / microsoft/monaco-editor

Add better support for imports suggestion

Open
#1,839 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request typescript
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

When imports that are declared via addExtraLib are explicitly wrapped inside declare module then IntelliSense is actually very nice.
Following setup:

monacoEditor.languages.typescript.typescriptDefaults.addExtraLib("declare module 'test/file1' { export interface Test {} }", 'file:///node_modules/@types/test/file1.d.ts')
monacoEditor.languages.typescript.typescriptDefaults.addExtraLib("declare module 'test/file2' { export interface Test {} }", 'file:///node_modules/@types/test/file2.d.ts')

produces very nice auto-completion:
Screenshot 2020-02-18 at 16 57 04
Screenshot 2020-02-18 at 16 57 12

But if type definitions are missing explicit module wrapping as following:

monacoEditor.languages.typescript.typescriptDefaults.addExtraLib('export interface Test {}', 'file:///node_modules/@types/test/file1.d.ts')
monacoEditor.languages.typescript.typescriptDefaults.addExtraLib('export interface Test {}', 'file:///node_modules/@types/test/file2.d.ts')

then IntelliSense is also completely missing:
Screenshot 2020-02-18 at 16 58 10

It would be nice if the latter use case would also produce the same outcome as the first one without needing to explicitly wrap type definitions.

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 reproducing the two addExtraLib examples and comparing IntelliSense behavior for explicitly wrapped versus unwrapped declarations. Trace the import-suggestion handling used by Monaco's TypeScript integration; done means unwrapped type definitions produce the same import suggestions and completion behavior as wrapped definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.