Skip to content

Commit 16115ab

Browse files
author
lukas
committed
Improve type of editor
1 parent 1be5c5d commit 16115ab

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

projects/editor/src/lib/base-editor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
} from '@angular/core';
1212
import { Subscription } from 'rxjs';
1313
import { MonacoOpts, NGX_MONACO_EDITOR_CONFIG, NgxMonacoEditorConfig } from './config';
14+
import type MonacoNamespace from 'monaco-editor';
15+
16+
type IEditor = MonacoNamespace.editor.IEditor;
1417

1518
let loadedMonaco = false;
1619
let loadPromise: Promise<void>;
@@ -37,7 +40,7 @@ export abstract class BaseEditor implements AfterViewInit, OnDestroy {
3740

3841
@ViewChild('editorContainer', { static: true }) _editorContainer: ElementRef;
3942
@Output() onInit = new EventEmitter<any>();
40-
protected _editor: any;
43+
protected _editor: IEditor;
4144
protected _options: MonacoOpts;
4245
protected _windowResizeSubscription: Subscription;
4346
private _insideNg: boolean = false;

projects/editor/src/lib/diff-editor.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import { fromEvent } from 'rxjs';
44
import { BaseEditor } from './base-editor';
55
import { DiffEditorModel } from './types';
66
import { MonacoOpts } from './config';
7+
import type MonacoNamespace from 'monaco-editor';
78

8-
declare var monaco: any;
9+
type IDiffEditor = MonacoNamespace.editor.IDiffEditor;
10+
11+
type Monaco = typeof MonacoNamespace;
12+
declare var monaco: Monaco;
913

1014
@Component({
1115
standalone: true,
@@ -27,6 +31,8 @@ declare var monaco: any;
2731
export class DiffEditorComponent extends BaseEditor {
2832
private zone = inject(NgZone);
2933

34+
_editor: IDiffEditor;
35+
3036
_originalModel: DiffEditorModel;
3137
_modifiedModel: DiffEditorModel;
3238

projects/editor/src/lib/editor.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ import { fromEvent } from 'rxjs';
55
import { BaseEditor } from './base-editor';
66
import { NgxEditorModel } from './types';
77
import { MonacoOpts } from './config';
8+
import type MonacoNamespace from 'monaco-editor';
89

9-
declare var monaco: any;
10+
type Monaco = typeof MonacoNamespace;
11+
declare var monaco: Monaco;
12+
13+
type ICodeEditor = MonacoNamespace.editor.ICodeEditor;
1014

1115
@Component({
1216
standalone: true,
@@ -34,6 +38,8 @@ export class EditorComponent extends BaseEditor implements ControlValueAccessor
3438
private zone = inject(NgZone);
3539
private _value: string = '';
3640

41+
_editor: ICodeEditor;
42+
3743
propagateChange = (_: any) => {};
3844
onTouched = () => {};
3945

0 commit comments

Comments
 (0)