Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaration files not generated with inherited tsconfig.json #520

Closed
yahiko00 opened this issue Jul 4, 2017 · 1 comment
Closed

Declaration files not generated with inherited tsconfig.json #520

yahiko00 opened this issue Jul 4, 2017 · 1 comment

Comments

@yahiko00
Copy link

yahiko00 commented Jul 4, 2017

When the tsconfig.json directly used by the TypeScript project does not explicitly set declaration to true, even if its parent does, then gulp-typescript does not generate declaration files, unlike the inline compiler tsc.

I use gulp-typescript version 3.1.7 and TypeScript 2.4.1.

Here is the gulpfile.js:

const tsProject = ts.createProject(config);
const tsResult = tsProject.src()
    .pipe(sourcemaps.init())
    .pipe(tsProject());

return merge([
    tsResult.js
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(dest)),
    tsResult.dts
        .pipe(rename("index.d.ts"))
        .pipe(gulp.dest(dest))])
    .on("error", gutil.log);

Above, the parameter config in the createProject() method refers to the following tsconfig.debug.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "removeComments": false
  }
}

Here is its parent, tsconfig.json:

{
  "include": [ "./src/**/*.ts" ],
  "compilerOptions": {
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */

    "declaration": true,                      /* Generates corresponding '.d.ts' file. */

    "removeComments": true,                   /* Do not emit comments to output. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "noUnusedLocals": true,                   /* Report errors on unused locals. */
    "noUnusedParameters": true,               /* Report errors on unused parameters. */
    "noImplicitReturns": true,                /* Report error when not all code paths in function return a value. */
    "noFallthroughCasesInSwitch": true        /* Report errors for fallthrough cases in switch statement. */
  }
}

To solve this issue, we need to explicitely set declaration to true in the createProject() method, or repeat "declaration": true in the inherited tsconfig.json (here, tsconfig.debug.json).

This issue refers to this one: #231

@ivogabe
Copy link
Owner

ivogabe commented Jul 6, 2017

Duplicate of #459, will be part of a new release soon

@ivogabe ivogabe closed this as completed Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants