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

Can compiler only emit declaration file ? #1866

Closed
paztis opened this issue Jan 30, 2015 · 5 comments
Closed

Can compiler only emit declaration file ? #1866

paztis opened this issue Jan 30, 2015 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@paztis
Copy link

paztis commented Jan 30, 2015

Is there a way to only emit the declaration file (.d.ts) with the compiler and not the js file ?

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Jan 30, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jan 30, 2015

There is no supported flags that would do that, only emit all or do not emit at all (--noEmit). Consider using --outDir and picking only the .d.ts files.

@mhegazy mhegazy closed this as completed Apr 21, 2015
@nojvek
Copy link
Contributor

nojvek commented May 17, 2017

I'm thinking of adding a --noEmitJs flag. Would you be willing to entertain that thought?

@mhegazy
Copy link
Contributor

mhegazy commented May 17, 2017

I'm thinking of adding a --noEmitJs flag. Would you be willing to entertain that thought?

if there is a compelling scenario.

@nojvek
Copy link
Contributor

nojvek commented May 17, 2017

Scenario: Auto-Generate typings for a pure js project

Currently typings for js projects are manually hand maintained. A ton of typings are out of date with the actual code. Typings are kind of documentation and if they are separate from code, they will eventually get out of sync.

with --checkJs, JS lib authors get extra benefit of validating code with jsdoc typings. Being able to auto generate just .d.ts from their existing code would make life easier. This can be done as part of the build step.

Basically if declarations:true and noEmitJs:true, only declarations should still be generated

Proposal:

compilerOptions: {
  module: 'amd',
  outFile: 'build/types.d.ts',
  declarations: true,
  allowJs: true,
  checkJs: true, // optional
  noEmitJs: true,
},
include: [
   'src/**.js'
]

This would just generate a single .d.ts file from the project that you can add as part of package.json. No hand maintenance.

@trulysinclair
Copy link

Useful if you only want to generate the declaration files but not compile the js. Current usage for me would be that I'm generating an Electron application. I want the d.ts files in respective directories but the js files don't need to be created because they're made during application compilation and would cause only unnecessary clutter beforehand.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants