我在 Visual Studio 2015 中使用 TypeScript 智能感知时遇到问题。当我尝试从 Nuget 上的输入切换到使用 npm 安装它们时,问题就开始了。我有我需要的一切,node_modules/@types但智能感知没有找到类型,说它无法解析模块。该项目使用 Visual Studio 的构建和命令行中的 tsc 构建而没有错误。
我目前的猜测是,问题在于我使用的 TypeScript 版本与打字版本的版本不同,因为当我打开打字文件时,打字文件中存在智能感知错误。例如,我已经使用 npm 为 React(v. ^15.4.2) 安装了 Typings(v. ^15.0.21)。当我打开已安装的 index.d.ts 文件时,我收到许多错误:
// Type definitions for React v15.0
// Project: http://facebook.github.io/react/
// Definitions by: ...
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export = React;
export as namespace React;
Run Code Online (Sandbox Code Playgroud)
例如,在前两行中,我得到:
除非提供了“--module”标志,否则无法编译模块...(整个第一行)
预期的声明或声明。(第二行,在出口下)
你明白了,这些将继续通过文件。我尝试了以下方法来解决问题:
我正在尝试获取一个输入类型的选定值,每次都会出现此错误:Uncaught TypeError: Cannot assign to read only property 'highlight' of.它永远不会告诉我它指的是什么对象,它来自TypeAhead.min.js文件,所以我不能确切地说我的代码是什么行引起它.这是我用来设置和捕获输入值的代码:
$(".articles.new").ready ->
engine = new Bloodhound {
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: autocomplete_items
}
engine.initialize()
$('#auto_complete').typeahead { hint: true, highlight: true, minLength: 1 },
{ name: "names", displayKey: "name", source: engine.ttAdapter()}
$('#auto_complete').on 'typeahead:selected', (event, selection) ->
alert selection.name
$('#auto_complete').typeahead 'setQuery', ''
event.stopPropagation()
return
return
Run Code Online (Sandbox Code Playgroud)
对于上下文:auto_complete项是来自我的控制器的具有name属性的对象数组.我在Ruby on Rails 4.1.4上工作.
我该怎么做才能解决这个错误?是什么造成的?