atularen / ngx-monaco-editor

Monaco Editor component for Angular 2 and Above
https://www.npmjs.com/package/ngx-monaco-editor
MIT License
428 stars 155 forks source link

intellisense become invalidated #228

Open chenqiangkobe opened 3 years ago

chenqiangkobe commented 3 years ago

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { MonacoEditorModule, NgxMonacoEditorConfig } from 'ngx-monaco-editor';

export function onMonacoLoad() { const monaco = (window as any).monaco;

monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({ noSemanticValidation: true, noSyntaxValidation: false }); // compiler options monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2015, allowNonTsExtensions: true, allowJS: true, }); // extra libraries const libSource = [ 'declare class Facts {', ' /*', ' Returns the next fact', ' */', ' static next():string', ' middle():string', ' static prev():string', '}', ].join('\n'); monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource); // When resolving definitions and references, the editor will try to use created models. // Creating a model for the library allows "peek definition/references" commands to work with the library. monaco.editor.createModel(libSource, 'typescript');

} const monacoConfig: NgxMonacoEditorConfig = { baseUrl: 'assets', defaultOptions: { scrollBeyondLastLine: false }, onMonacoLoad }; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, MonacoEditorModule.forRoot(monacoConfig) // use forRoot() in main app module only. ], providers: [], bootstrap: [AppComponent] })

in editor, intellisense will work(Facts.next()) but soon be invalidated why?