Ani*_*esh 3 angularjs typescript visual-studio-code
I have upgraded to Typescript 2.0.3 yesterday and updated the reference path to
/// <reference types="angular" />
Run Code Online (Sandbox Code Playgroud)
after installing the typings for Angular 1.5x using the following command
npm install -s @types/angular
Run Code Online (Sandbox Code Playgroud)
I get the error when I build the project and the error doesn't go away.
Invalid 'reference' directive syntax
How does one fix this?
/// <reference types="angular" />
/// <reference types="d3" />
(function () {
'use strict';
var app = angular.module('charts', []);
app.controller('mainCtrl', function mainCtrl($scope, appService) {
var vm = this;
vm.data1 = [1, 2, 3, 4];
vm.data2 = [4, 5, 7, 11];
vm.update = function (d, i) {
vm.data1 = appService.GetRandomData();
console.log('new data1', vm.data1);
};
vm.update2 = function (d, i) {
vm.data2 = appService.GetRandomData();
console.log('new data2', vm.data2);
};
});
app.directive('barChart', function ($timeout) {
var chart = d3.custom.barChart();
return {
restrict: 'E',
replace: true,
scope: true,
bindToController: {
data: '=',
},
controller: 'mainCtrl',
controllerAs: 'ctrl',
link: function (scope, element, attrs, ctrl) {
var chartEl = d3.select(element[0]);
chartEl.datum(ctrl.data).call(chart)
}
}
});
app.directive('chartForm', function () {
return {
restrict: 'E',
replace: true,
controller: 'mainCtrl',
templateUrl: 'chartform.html'
}
});
app.service('appService', function () {
this.GetRandomData = function () {
var rdata;
rdata = d3.range(~~(Math.random() * 50) + 1).map(function (d, i) {
return ~~(Math.random() * 100);
});
return rdata;
}
});
} ());
Run Code Online (Sandbox Code Playgroud)
小智 6
我在构建服务器 VSTS 中收到此错误。
升级类型脚本版本解决了我的问题。
在包中,json:从
"typescript": "2.8.3"
Run Code Online (Sandbox Code Playgroud)
到
"typescript": "3.5.1"
Run Code Online (Sandbox Code Playgroud)
我已更新工作区设置文件中的打字稿路径.vscode/settings.json以指向最新的打字稿版本。这将使 VS Code 使用最新版本的打字稿。
{
"typescript.tsdk": "C:\\Users\\UserName\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
}
Run Code Online (Sandbox Code Playgroud)
我不认为这是问题,因为当我tsc -v在集成终端中运行时,我得到了2.0.3.
现在我正在修复编译器错误。
有用的网址:
| 归档时间: |
|
| 查看次数: |
21881 次 |
| 最近记录: |