현재 typescript REST 소비자 용 개발 환경을 설정하려고하고 있는데 다음과 같은 문제가 발생합니다. 컴파일러는 입력에 대한 참조를 염두 해 두는 것처럼 보입니다. .ts 소스 파일은 tsconfig.json의 단일 .d.ts 파일을 통해 내 참조를 관리하려고 할 때 파일을 완전히 무시합니다. 이건 내 tsconfig.json 파일TypeScript 컴파일러가 tsconfig.json의 선언 파일을 무시합니다.
import * as request from 'request';
module HTTPClient {
...
}
입니다 :
다음 코드를 컴파일하는 동안 나는 error TS2307: Cannot find module 'request'.
받고 있어요
{
"compilerOptions": {
"jsx": "react",
"module": "commonjs",
"noImplicitAny": true,
"noEmitOnError": true,
"outDir": "./build/",
"preserveConstEnums": true,
"removeComments": true,
"target": "ES5",
"declarationFiles": true,
"moduleResolution": "classic"
},
"exclude": [
"./node_modules",
"./build",
"./tests"
],
"include": [
"./src/ts/**/*",
"./typings/main.d.ts"
]
}
을 그리고 이것은 내가 사용하고있어 꿀꺽 코드 모든 것을 컴파일하고 묶는 방법 :
var typescriptProject = typescriptCompiler.createProject(project['tsconfig'], { typescript: typescript });
gulp.task(
'compile-ts',
function() {
return gulp
.src([ project['ts'] + '**/*{ts, tsx}' ])
.pipe(typescriptCompiler(typescriptProject))
.js
.pipe(gulp.dest(output['js']));
}
);
gulp.task(
'bundle-js',
function() {
return browserify(output['js'] + 'main.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest(output['web']));
}
);
요청 설치에 대한 주변 정의가 있습니다. 주도하고 typings/main.d.ts
에서 참조. 이 모듈을 해결하기 위해 browserify를 사용하는 방식과 관련이 있습니까? 어떤 도움이라도 대단히 감사 할 것입니다.
먼저, 당신은 몇 가지 옵션 :