Sto provando a ottenere la googlemap digitando da https://github.com/borisyankov/DefinitelyTyped/tree/master/googlemaps per imporre tipi su MapOptions. Quindi, dato il seguente codice cattivo:Typescript, google.maps.d.ts e tipo enforcement
/// <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);
Speravo il tipo MapOptions da google.maps.d.ts avrebbe bandiera lo zoom attributo come non corretta. Perché lo tsc
non è contrassegnato come un errore di tipo?
Aggiornamento: ha provato la seguente versione per includere più includere più informazioni sul tipo per il compilatore da masticare, ma ancora niente da fare:
/// <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);
}
Ho provato entrambe le varianti e nessuno dei due sta causando a tsc il lancio di un avviso/errore di tipo. C'è una bandiera che devo lanciare per ottenere 'tsc' per essere più loquace? – Brett
Che strumento stai usando? Vedi l'aggiornamento per quello che ricevo in VS. A volte gli strumenti non funzionano (è alfa, dopotutto) - e devi compilare per ottenere l'errore. – JcFx
Sto usando il 'tsc' [tool.in] open source (http://www.typescriptlang.org/#Download). Spero che il tipo che controlla la metà di TypeScript sia limitato al solo plugin VisualStudio. – Brett