Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Ignore declaration setting in tsconfig.json #45

Closed
jvilk opened this issue Jun 3, 2016 · 9 comments
Closed

Ignore declaration setting in tsconfig.json #45

jvilk opened this issue Jun 3, 2016 · 9 comments

Comments

@jvilk
Copy link

jvilk commented Jun 3, 2016

I have declaration set to true in my tsconfig.json file so I can generate and distribute typings with my library for others consuming the individual modules. (I invoke the TypeScript compiler separately to produce the typings; it wouldn't make sense for rollup-plugin-typescript to generate them for me.)

The TypeScript plugins for Browserify and Webpack seem to ignore this setting, but rollup-plugin-typescript passes it to the TypeScript compiler, resulting in the following error message:

Error loading /Users/jvilk/Code/browserfs/src/browserify_main.ts: Debug Failure. False expression: Unexpected multiple outputs for the file: '/Users/jvilk/Code/browserfs/build/node/browserify_main.d.ts'

After Googling a bit, it appears that this is a limitation of the TypeScript compiler's transpileModule method. Overriding the declaration field to false fixes the problem.

I think it would be great if you chose to do one of the following things:

  • Ignore the declaration setting, as it does not appear to be applicable. (But maybe I'm missing a scenario where it would be?), or...
  • Preemptively throw a more intelligible error when declaration is set to true.
@Victorystick
Copy link
Contributor

@jvilk I'm not familiar enough with declaration to know if and when disabling it could pose a problem. Disabling the option seems like a simple fix. PRs welcome. Otherwise I'll get to myself eventually.

@jvilk
Copy link
Author

jvilk commented Jun 5, 2016

@Victorystick When declaration is true, the compiled produces a typings file for each module. For example, for a module foo.ts, it produces foo.d.js. These typings files make it possible for the compiler to re-consume compiled modules.

These declaration files can only be produced with a normal compilation of the entire program, since they reference each other to import types from other modules. Thus, the transpileModule function, which compiles modules in isolation, throws an error if declaration is set to true.

I think it makes sense to force the option to false before passing it to the compiler, since it is of no use in this context.

@Victorystick
Copy link
Contributor

Released as version 0.7.6.

@austbot
Copy link

austbot commented Oct 14, 2016

This was a terrible Idea. I have a use case where I do want the d.ts file to be spit out.

@jvilk
Copy link
Author

jvilk commented Oct 14, 2016

@austbot but it never worked. It just failed. The fix prevents it from outright failing.

@austbot
Copy link

austbot commented Oct 14, 2016

I see, sorry for the stark comment. Could this be revisited, surly if you can emit a source map we can emit d.ts files? We could even bundle them in this plugin. Was the error with typescript or a problem with rollup not liking multiple outputs for the bundle? @jvilk

@jvilk
Copy link
Author

jvilk commented Oct 14, 2016

@austbot If you are using modules, which you must be in order to use Rollup, TypeScript produces a .d.ts file for each individual module. TypeScript has no feature for combining these into a single file.

To support this use case, Rollup would need to:

  • Not use the transpile API anymore for compilation, which does not produce declaration files.
  • Know where to deposit all of the produced .d.ts files.

It seems cumbersome to support this, especially since this plugin has many serious deficiencies documented in other issues.

I'd recommend not using this plugin. Instead, invoke the TypeScript compiler first to produce individual modules. Then, run rollup on those. That way, you get your declaration files, and sidestep the many other issues documented in this repository.

@austbot
Copy link

austbot commented Oct 15, 2016

I would but type script has an issue with trying to import html and scss
files hence the use of rollup.

@quantuminformation
Copy link

Is there a way to ignore files, ie I don't want d.ts files for my component.spec.ts files?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants