我对package.json文件中的@types依赖项有一个愚蠢的问题:
在以下URL中说明应安装类型
作为运行时依赖npm install --save @types/lodash
TS 2.x d.ts Consumption
但是对我来说安装@types/....
软件包更有意义
as dev dependency npm install --save-dev @types/lodash
对此有何想法?
答案 0 :(得分:4)
在开发模块/库时使用<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="namesCtrl">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">
<select style=" border-bottom: 2px; border-bottom-width: 4px; border-bottom-style: none; z-index: 2; text-align: center; position: absolute; top: 1px; left: 1px; Width: 98px; height: 25px; " ng-model="selected">
<option value="">ALL</option>
<option ng-repeat="option in orderStatus" value="{{option.value}}">{{option.os}}</option>
</select>
</label>
</div>
{{selected}}
<ul>
<li ng-repeat="x in orders | filter : selected">
{{ x.Name }}
</li>
</ul>
<p>All these Order have OrderStatus. {{selected}}</p>
</div>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.orderStatus = [
{ os: 'Open', value: 1 },{ os: 'Completed', value: 2 },{os:'Cancelled',value: 3 }, { os: 'Rejected', value: 4 }
]
$scope.orders = [
{ OrderStatus: 2 , Name: 'order1'},
{ OrderStatus: 3 , Name: 'order2'},
{ OrderStatus: 3, Name: 'order3'},
{ OrderStatus: 1 , Name: 'order4'},
{ OrderStatus: 2 , Name: 'order5'},
{ OrderStatus: 4 , Name: 'order6'},
{ OrderStatus: 2 , Name: 'order7'}
];
});
</script>
</body>
</html>
并希望共享--save
依赖项,否则请使用@types
。
某些背景信息:https://github.com/Microsoft/types-publisher/issues/81