2016-11-18 3 views
3

기본적으로 Typescript (v2.0.10)의 Promise 정의를 Bluebird로 바꾸고 싶습니다. 나는 이것에 대해 많이 읽었지 만 혼란 스러웠습니다. 가능합니까?Typescript에서 전역 가져 오기?

import * as Bluebird from "bluebird"; 
declare var Promise: typeof Bluebird; 
+0

[글로벌 기능 보강] (https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation)을 찾고 있습니다. – poke

답변

2
    :

    import * as Promise from "bluebird"; 
    

    내가 아무 소용이 내 _stubs.d.ts에서이 작업을 수행하려고 :

    정말 모든 상단에이 일을하고 싶지 않아

    파일 TS

  1. npm install --save-dev @types/bluebird-global
  2. tsconfig.json을 편집하여 types 배열에 bluebird-global을 나열하십시오.

    { 
        "compilerOptions": { 
        "types": [ 
         "bluebird-global" 
        ], 
        // the rest of the options 
        } 
    } 
    

편집 : 당신이 당신의 tsconfig.jsoncompilerOptions.types를 사용하지 않는 경우 (2)가 필요하지 않습니다

단계.

관련 문제