【问题标题】:Typescript: Property require does not exist on type 'typeof aceAjax'打字稿:类型'typeof aceAjax'上不存在属性要求
【发布时间】:2018-01-26 16:41:16
【问题描述】:

我正在尝试为 ace 编辑器创建自定义自动完成器。我读过的所有文件都说我需要使用ace.require('ace/ext/language_tools') 来创建一个自动完成程序。但我什至无法让 ace.require() 工作。我不确定我的 package.json 或 .ts 文件本身是否缺少某些内容。

我关注的示例文章: https://github.com/ajaxorg/ace/wiki/How-to-enable-Autocomplete-in-the-Ace-editor

我的 package.json ace 依赖项是这样设置的

"dependencies": {
    "@types/ace": "0.0.36",
    "ace": "^1.3.0",
    "ace-builds": "^1.2.9",
    "brace": "^0.11.0"
},

我的 editor.ts 文件很简单:

import * as ace from 'brace';

class RqlEditor {
    private initAutocompleter(...irrelevant);

    public init(customMetadataProperties: String[]) {
        const langTools = ace.require('ace/ext/language_tools');

        langTools.addCompleter(this.initAutocompleter(customMetadataProperties));
        const editor = ace.edit('container');
        editor.setOptions({
            enableBasicAutocompletion: true,
        });    
    }
}

export default RqlEditor;

【问题讨论】:

    标签: typescript ace-editor


    【解决方案1】:

    当然,经过数小时的搜索,我在提出问题 20 分钟后找到了答案。我正在使用带有 webpack 的大括号,所以我只需要 import 'brace/ext/language_tools。然后我没有使用 ace.require,而是使用了ace.acequire('ace/ext/language_tools')

    【讨论】:

      猜你喜欢
      • 2017-09-29
      • 2020-11-10
      • 2015-01-17
      • 2017-03-02
      • 2021-09-07
      • 2021-01-09
      • 2022-06-22
      • 2016-05-17
      • 2021-08-29
      相关资源
      最近更新 更多