Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript declaration preview from extra lib results in error #1444

Closed
foxable opened this issue May 17, 2019 · 2 comments
Closed

TypeScript declaration preview from extra lib results in error #1444

foxable opened this issue May 17, 2019 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug documentation typescript
Milestone

Comments

@foxable
Copy link

foxable commented May 17, 2019

monaco-editor version: 0.17.0
Browser: IE, Chrome, Firefox
OS: Windows 10

The TypeScript declaration preview does not work for declarations added through monaco.languages.typescript.javascriptDefaults.addExtraLib() and causes an error.

Steps or JS usage snippet reproducing the issue:

  1. Go to the Configure JavaScript defaults playground example
  2. Trigger the declaration preview on Facts (hover while pressing Ctrl)

This results in the following error:

Error: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "filename/facts.d.ts", query: "", fragment: ""}
    at editor.main.js:209
    at t.e (editor.main.js:210)
    at new t (editor.main.js:211)
    at Function.e.parse (editor.main.js:211)
    at tsMode.js:7
    at async Promise.all (index 0)
    at editor.main.js:38
@blutorange
Copy link
Contributor

Not sure if this is intentional or not, but this can be fixed by adding a scheme (eg. inmemory) to the file path given to addExtraLib. In the example above from the playground on lines 19-26, it should read:

monaco.languages.typescript.javascriptDefaults.addExtraLib([
	'declare class Facts {',
	'    /**',
	'     * Returns the next fact',
	'     */',
	'    static next():string',
	'}',
].join('\n'), 'inmemory:filename/facts.d.ts');

(inmemory:filename/facts.d.ts instead of filename/facts.d.ts)

@foxable
Copy link
Author

foxable commented May 20, 2019

Thank you for your hint, this solved the issue for me. I would still be interested if this is intentional or not, since the scheme was even missing in the playground example.

@alexdima alexdima added this to the On Deck milestone Dec 11, 2019
@alexdima alexdima self-assigned this Dec 11, 2019
@alexdima alexdima modified the milestones: On Deck, December 2019 Dec 11, 2019
@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug typescript and removed typescript labels Dec 11, 2019
sthagen added a commit to sthagen/microsoft-monaco-editor that referenced this issue Dec 18, 2019
Fixes microsoft#1444: Add a schema to extra lib paths
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug documentation typescript
Projects
None yet
Development

No branches or pull requests

3 participants