我正在尝试从https://github.com/borisyankov/DefinitelyTyped/tree/master/googlemaps输入 googlemaps以在 MapOptions 上强制执行类型。所以给出以下错误代码:
/// <reference path="google.maps.d.ts" />
var map;
function initialize() {
var mapOptions = {
zoom: "no, not really",
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
我希望 google.maps.d.ts 中的 MapOptions 类型会将缩放属性标记为不正确。为什么不tsc
将此标记为类型错误?
更新:尝试了以下版本以包含更多包含更多类型信息以供编译器咀嚼,但仍然没有骰子:
/// <reference path="google.maps.d.ts" />
var map;
function initialize() {
var mapOptions : google.maps.MapOptions = {
zoom: "no, not really",
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}