Update example: allow peek definition
parent
2a996151d7
commit
db327beb63
|
@ -53,28 +53,33 @@ monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|||
});
|
||||
|
||||
// extra libraries
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib([
|
||||
var libSource = [
|
||||
'declare class Facts {',
|
||||
' /**',
|
||||
' * Returns the next fact',
|
||||
' */',
|
||||
' static next():string',
|
||||
'}',
|
||||
].join('\n'), 'ts:filename/facts.d.ts');
|
||||
].join('\n');
|
||||
var libUri = 'ts:filename/facts.d.ts';
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||
// When resolving definitions and references, editor will try to use created models.
|
||||
// Following line allows "peek definition/references" commands to work with library.
|
||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||
|
||||
var jsCode = [
|
||||
'"use strict";',
|
||||
'',
|
||||
"class Chuck {",
|
||||
" greet() {",
|
||||
" return Facts.next();",
|
||||
" }",
|
||||
"}"
|
||||
'class Chuck {',
|
||||
' greet() {',
|
||||
' return Facts.next();',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
monaco.editor.create(document.getElementById("container"), {
|
||||
monaco.editor.create(document.getElementById('container'), {
|
||||
value: jsCode,
|
||||
language: "javascript"
|
||||
language: 'javascript'
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -16,26 +16,31 @@ monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|||
});
|
||||
|
||||
// extra libraries
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib([
|
||||
var libSource = [
|
||||
'declare class Facts {',
|
||||
' /**',
|
||||
' * Returns the next fact',
|
||||
' */',
|
||||
' static next():string',
|
||||
'}',
|
||||
].join('\n'), 'ts:filename/facts.d.ts');
|
||||
].join('\n');
|
||||
var libUri = 'ts:filename/facts.d.ts';
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||
// When resolving definitions and references, editor will try to use created models.
|
||||
// Following line allows "peek definition/references" commands to work with library.
|
||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||
|
||||
var jsCode = [
|
||||
'"use strict";',
|
||||
'',
|
||||
"class Chuck {",
|
||||
" greet() {",
|
||||
" return Facts.next();",
|
||||
" }",
|
||||
"}"
|
||||
'class Chuck {',
|
||||
' greet() {',
|
||||
' return Facts.next();',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
monaco.editor.create(document.getElementById("container"), {
|
||||
monaco.editor.create(document.getElementById('container'), {
|
||||
value: jsCode,
|
||||
language: "javascript"
|
||||
language: 'javascript'
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue