3

devDependency로 @types/jasmine을 (를) 설치했습니다. 내 타이프 라이터를 컴파일gulp-typescipt 및 입력 스크립트의 새로운 @types 입력?

내 꿀꺽의 작업과 같이이다 :

gulp.task('compile:tests', ['compile:typescript', 'clean:tests'], function() { 
    var project = ts.createProject('tsconfig.json', { typescript: typescript }); 

    var tsResult = gulp.src(['spec/**/*spec.ts']) 
     .pipe(ts(project)); 

    return tsResult.js 
     .pipe(gulp.dest('spec/')); 
}); 

내 tsconfig.json

{ 
    "compilerOptions": { 
     "target": "es6", 
     "module": "commonjs", 
     "moduleResolution": "node" 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 

하지만이 오류가 발생합니다

사양 \의 린터를 .spec.ts (7,1) : 오류 TS2304 : '설명'이름을 찾을 수 없습니다.
spec \ linter.spec.ts (8,3) : 오류 TS2304 : 'it'이름을 찾을 수 없습니다.
spec \ linter.spec.ts (17,5) : 오류 TS2304 : 'expect'라는 이름을 찾을 수 없습니다.
spec \ linter.spec.ts (20,3) : 오류 TS2304 : 'it'이름을 찾을 수 없습니다.

타이핑을 인식하기 위해 타이프 스크립트 (gulp-typescript로 사용될 때)를 얻으려면 어떻게해야합니까?

답변

2

업데이트 : 최신 버전은 문제를 해결 모든 @types의 typings을 수동으로 지금까지 내 작품이 주변에있다 포함하는 :

npm install [email protected]

사전 꿀꺽 - 타이프 라이터 3 @로 설치 , 다음과 같이하십시오 :

gulp.src(['spec/**/*spec.ts', "./node_modules/@types/**/*.d.ts"]) 

당신이 타이핑의 충돌 버전을 가지고 있다면 (여기에 당신 @types/[email protected]은) 당신은 중복을 피하기 위해 그들을 건너 뛸 수 있습니다 : 당신은 project.src() 대신 gulp.src(['typings-glob', 'sources-glob']) 사용할 수 있습니다

gulp.src([ 
    paths.source + '**/*.ts', 
    "node_modules/@types/**/index.d.ts", 
    "!node_modules/@types/**/node_modules/**/index.d.ts"]) 
2

.

** 어떤 이유로, 제가 작업하고있는 프로젝트에서 project.src()을 사용할 때 3 초 정도 더 걸릴 수 있으므로 gulp.src 옵션을 사용합니다.

+0

방금 ​​테스트했습니다. node_modules를 제외하면 나에게 적합하지 않습니다. (제외하지 않고 다른 오류가 발생 함) : ( –

+0

) _exclude_ 대신 또는 함께 _include_ 속성을 사용할 수 있습니다. [tsconfig 스키마] (http://json.schemastore.org/tsconfig)를 참조하십시오. –

0

다음 작업은 나를위한 것입니다. , 어느 쪽도 사용하지 않습니다

{ "compilerOptions": { "target": "es6", "module": "commonjs", "moduleResolution": "node" }, "files": [ "node_modules/@types/**/*.d.ts" ], "exclude": [ "node_modules" ] } 

NVM

, 그 실 거예요 작품은 "포함"과 함께 "제외".