2017-04-26 15 views
0

私は次のエラーを取得する:TS1219 Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.TypeScript Visual Studio TS1219デコレータの実験的サポートは、将来のリリースで変更される可能性のある機能です。

私はtsconfig.jsonで​​を設定することで、これを抑制することができる知っています。

しかし、私はまだ私は、このコードからエラーを取得する理由を知りたい:

import * as React from "react"; 

import scriptLoader from 'react-async-script-loader' 

@scriptLoader(['https://maps.googleapis.com/maps/api/js?key=your-key']) 
export default class Maps extends React.Component<any, any> { 
    constructor(props: any) { 
     super(props); 
     this.map = null; 
    } 

    refs: { 
     [string: string]: any; 
     map: any; 
    } 
    map: any; 

    componentWillReceiveProps({ isScriptLoaded, isScriptLoadSucceed }) { 
     if (isScriptLoaded && !this.props.isScriptLoaded) { // load finished 
      if (isScriptLoadSucceed) { 
       this.map = new google.maps.Map(this.refs.map, { 
        center: { lat: 10.794234, lng: 106.706541 }, 
        zoom: 20 
       }); 

       if (navigator.geolocation) { 
        navigator.geolocation.getCurrentPosition((position) => { 
         const pos = { 
          lat: position.coords.latitude, 
          lng: position.coords.longitude 
         }; 

         this.map.setCenter(pos); 

         const marker = new google.maps.Marker({ 
          position: pos, 
          map: this.map, 
          title: 'Hello World!' 
         }); 
        },() => { 
         console.log('navigator disabled'); 
        }); 
       } else { 
        // Browser doesn't support Geolocation 
        console.log('navigator disabled'); 
       } 
      } 
      else this.props.onError() 
     } 
    } 

    render() { 
     return (
      <div> 
       <div ref="map" style={{ height: '80%', width: '100%' }}></div> 
       {!this.map && <div className="center-md">Loading...</div>} 
      </div> 
     ) 
    } 
} 
+1

'@scriptLoader(['https://maps.googleapis.com/maps/api/js?key=your-key'])'クラスの上にはデコレータがあります。 –

答えて

1

But I would still like to know why I get the error from this code:

あなたは@scriptLoader(['https://maps.googleapis.com/maps/api/js?key=your-key'])でデコレータを使用しているため。

関連する問題