2016-09-13 12 views
2

この行は何が起こっている`.d.ts`ファイルからどのようにインポートしますか?

import * as mapTypes from '../../../../node_modules/angular2-google-maps/core/services/google-maps-types.d.ts';

angular2 RC4を使用するプロジェクトで動作しますか?

今、私はRC6で新しいシードファイルをしようとしていますし、同じ行が私にこのエラーが発生します

error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing '../../../../node_modules/angular2-google-maps/core/services/google-maps-types' instead.

しかし、私は提案の変更を加えた場合、私は

Cannot find module '../../../../node_modules/angular2-google-maps/core/services/google-maps-types'

を取得します.d.tsファイルは次のようになります。

/** 
* angular2-google-maps - Angular 2 components for Google Maps 
* @version v0.12.0 
* @link https://github.com/SebastianM/angular2-google-maps#readme 
* @license MIT 
*/ 
export declare var google: any; 
export interface GoogleMap { 
    constructor(el: HTMLElement, opts?: MapOptions): void; 
    panTo(latLng: LatLng | LatLngLiteral): void; 
    setZoom(zoom: number): void; 
    addListener(eventName: string, fn: Function): void; 
    getCenter(): LatLng; 
    setCenter(latLng: LatLng | LatLngLiteral): void; 
    getBounds(): LatLngBounds; 
    getZoom(): number; 
    setOptions(options: MapOptions): void; 
} 
... 
そこRC6に一致している、このパッケージの新しいバージョンがあるが、私は、少なくともTS

の中にコンパイルにこれを得ることができる必要があります:10

と一致.tsファイルが

/** 
* angular2-google-maps - Angular 2 components for Google Maps 
* @version v0.12.0 
* @link https://github.com/SebastianM/angular2-google-maps#readme 
* @license MIT 
*/ 
"use strict"; 

//# sourceMappingURL=google-maps-types.js.map 

NOTEのように見えます

/// <reference path="../../../../node_modules/angular2-google-maps/core/services/google-maps-types.d.ts" 

あなたはスタッフTHAをインポートすることができた後:あなたはこのようなファイルあなた.TSの上部にある定義ファイルへの参照を追加します活字体で通常

答えて

1

あなたは活字体の最後のバージョンを使用していて、タイピングの定義は、あなたのNPMパッケージに組み込まれている場合は、あなただけのモジュールからインポートすることができます。

import { GoogleMap } from 'angular2-google-maps/core/services/google-maps-types' 

それはインターフェースだとしても。

実際にcore/services/googles-maps-types.jsから定義をインポートしていますが、このファイルはそのファイル.d.tsに関連付けられた定義を提供するためにのみ存在します。

.tsファイルから直接インポートするかのように動作するようになっていますが、npmモジュールのように、定義ファイルを埋め込み、定義のインポートを許可します。


関連する問題