Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular for SQL提示上的Codemirror起作用,但给出类型脚本键入错误_Sql_Angular_Typescript_Typescript Typings_Codemirror - Fatal编程技术网

Angular for SQL提示上的Codemirror起作用,但给出类型脚本键入错误

Angular for SQL提示上的Codemirror起作用,但给出类型脚本键入错误,sql,angular,typescript,typescript-typings,codemirror,Sql,Angular,Typescript,Typescript Typings,Codemirror,突击检查: 我正在尝试在Angular 10中为SQL提示实现CodeMirror,如下所示:。该功能在网页上正常工作,我还可以在控制台日志中看到正确的选项。但是,我也看到此错误无法分配给类型“ShowHintOptions”,因为我错误地设置了hintOptions选项。我还没有找到任何其他的例子,而且我尝试按照正确的输入法进行操作都没有成功。请帮忙 装置 npm安装codemirror@types/codemirror 代码 已找到解决错误的方法 添加任何类型的变量以保存值 const op

突击检查:

我正在尝试在Angular 10中为SQL提示实现CodeMirror,如下所示:。该功能在网页上正常工作,我还可以在控制台日志中看到正确的选项。但是,我也看到此错误
无法分配给类型“ShowHintOptions”
,因为我错误地设置了
hintOptions
选项。我还没有找到任何其他的例子,而且我尝试按照正确的输入法进行操作都没有成功。请帮忙

装置
npm安装codemirror@types/codemirror

代码


已找到解决错误的方法

添加任何类型的变量以保存值

const options: any = {
  tables: {
    users: ["name", "score", "birthDate"],
    countries: ["name", "population", "size"]
  }
};
将变量强制转换为
ShowHintOptions

hintOptions:选项为codemirror.ShowHintOptions,

新代码

ngOnInit(): void {
 const options: any = {
  tables: {
    users: ["name", "score", "birthDate"],
    countries: ["name", "population", "size"]
  }
};
this.editor = codemirror.fromTextArea(this.ref.nativeElement, {
  mode: "text/x-mysql",
  hintOptions: options as codemirror.ShowHintOptions,
  extraKeys: { "Ctrl-Space": "autocomplete" }
});
console.log(this.editor.getOption('hintOptions'));
}

库中的定义显示了可以传递的字段。要么你把未知的东西传递给图书馆,要么它的打字错误wrong@Andrei我已经读过了,但仍然坚持尝试正确的无错误实现。
const options: any = {
  tables: {
    users: ["name", "score", "birthDate"],
    countries: ["name", "population", "size"]
  }
};
ngOnInit(): void {
 const options: any = {
  tables: {
    users: ["name", "score", "birthDate"],
    countries: ["name", "population", "size"]
  }
};
this.editor = codemirror.fromTextArea(this.ref.nativeElement, {
  mode: "text/x-mysql",
  hintOptions: options as codemirror.ShowHintOptions,
  extraKeys: { "Ctrl-Space": "autocomplete" }
});
console.log(this.editor.getOption('hintOptions'));
}