Closed bennycode closed 5 years ago
Hi Benny, from your configuration, it seems you're not using the tsconfig file and thus cannot use the .src()
function. You must use a tsconfig.json
file to create the tsProject, like so:
const tsProject = ts.createProject('./tsconfig.json');
Can you verify whether that works for you?
Thanks for your super fast reply!
When using ts.createProject('./tsconfig.json')
it works! But now I am getting a little confused because your main.d.ts indicates that settings
can be given as first parameter to ts.createProject
.
I am generating a boilerplate setup for TypeScript and I would like to work with configuration objects rather than file paths. Would it be possible to pass the JSON object of tsconfig.json
to ts.createProject
instead of a file path? Technically it should not make much difference. What do you think?
It would help me a lot if I could do something like:
// Requiring original config
const tsConfig = require('./tsconfig.json');
// Do some modifications on the original config, i.e.:
tsConfig.compilerOptions.declaration = true;
// Use modified config with "gulp-typescript"
const tsProject = ts.createProject(tsConfig);
createProject
indeed also accepts a settings object. However, the .src
method can only be used when you passed it a tsconfig file. We need to have the file path of that tsconfig file to be able to resolve files.
For the use case of modifying some options, you can specify those as the second argument:
const tsProject = ts.createProject('./tsconfig.json', { whatever: true });
Description:
The
gulp-typescript
docs have written that you can replacegulp.src(...)
withtsProject.src()
to load files based on the tsconfig file. I tried to do that but it does not work. My gulp taskworks
usesgulp.src
and works. My gulp taskfails
usestsProject.src
and fails. 😢Tested with:
gulp
v4.0.0gulp-typescript
v5.0.0typescript
v3.2.1Expected behavior:
Compiled output
Actual behavior:
Compilation error:
gulpfile.js:
test.ts