Ask questionsTypeScript declaration preview from extra lib results in error

<!-- Do you have a question? Please ask it on --> 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

Answer questions blutorange

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:

	'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)

Github User Rank List