Skip to content
This repository has been archived by the owner on Sep 15, 2020. It is now read-only.

Latest commit

 

History

History
36 lines (27 loc) · 903 Bytes

consuming-types-so-question.md

File metadata and controls

36 lines (27 loc) · 903 Bytes

How to consume an existing .d.ts file?

Overview

I am working on an application that uses monaco-editor and would like to understand how I can 'reuse' the original declarations, monaco.d.ts.

Example usage:

import * as monaco from 'monaco-editor'

export const createEditor = (editorParams) => {
  const { domElement, options, override } = editorParams

  // the annotation below to var `editor` should be bound to a local copy
  // of `monaco.d.ts`, located in project root.
  const editor: monaco.editor.IStandaloneCodeEditor = monaco.editor.create(
    domElement,
    { model: null }
  )

  function getEditor() {
    return editor
  }

  function dispose() {
    return editor.dispose()
  }

  return Object.freeze({
    getEditor,
    dispose
  })
}