Skip to content

--emitDeclarationOnly flag to enable declarations only output - #20735

Merged
Mohamed Hegazy (mhegazy) merged 6 commits into
microsoft:masterfrom
nojvek:noEmitJs
Jan 25, 2018
Merged

--emitDeclarationOnly flag to enable declarations only output#20735
Mohamed Hegazy (mhegazy) merged 6 commits into
microsoft:masterfrom
nojvek:noEmitJs

Conversation

@nojvek

@nojvek Noj Vek (nojvek) commented Dec 16, 2017

Copy link
Copy Markdown
Contributor
@nojvek Noj Vek (nojvek) changed the title Adding noEmitJs flag to enable declarations only output Dec 16, 2017
Comment thread src/compiler/program.ts
if (options.noEmitJs && !options.declaration) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "noEmitJs", "declaration"));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would also want to skip verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); down below when noEmitJs is true

@nojvek

Copy link
Copy Markdown
Contributor Author

Kind ping regarding this Sheetal Nandi (@sheetalkamat)

Should I be adding any specific devs from typescript team to this PR? What's the usual process before a PR lands in the repo ?

Comment thread src/compiler/commandLineParser.ts Outdated
description: Diagnostics.Do_not_emit_outputs,
},
{
name: "noEmitJs",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name should be --emitDeclarationsOnly instead.

Comment thread src/compiler/commandLineParser.ts Outdated
name: "noEmitJs",
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would say this belongs into Advanced_Options

@nojvek Noj Vek (nojvek) Jan 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advanced_options don't show up as part of --help or in default tsc --init. Doesn't it make sense that the option showed up there? I plan to enable allowJs + emitDeclarationsOnly in another PR which would help with lots of npm projects to auto-generate jsdoc to .d.ts declarations.

Puppeteer is one good example

Comment thread src/compiler/diagnosticMessages.json Outdated
"category": "Message",
"code": 6013
},
"Do not emit js outputs.": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only emit declaration files.

Comment thread src/server/server.ts Outdated

const ioSession = new IOSession(options);
process.on("uncaughtException", err => {
process.on("uncaughtException", (err: any) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it was failing compilation when doing a “gulp build” with an error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should work now. that was a @types/node issue.

Len Boyette (kevlened) added a commit to kevlened/str2buf that referenced this pull request Jan 6, 2018
@niieani

Bazyli Brzóska (niieani) commented Jan 17, 2018

Copy link
Copy Markdown

Noj Vek (@nojvek) awesome job so far! The Puppeteer community would love some progress on this! ❤️

@nojvek

Noj Vek (nojvek) commented Jan 17, 2018 via email

Copy link
Copy Markdown
Contributor Author
@nojvek Noj Vek (nojvek) changed the title noEmitJs flag to enable declarations only output Jan 23, 2018
@nojvek

Copy link
Copy Markdown
Contributor Author

Mohamed Hegazy (@mhegazy) want to take another pass ?

Bazyli Brzóska (@niieani) - Unfortunately this PR doesn't enable emitting declarations from a JS project. I'll start work on it as soon as this PR lands.

@mhegazy
Mohamed Hegazy (mhegazy) merged commit afc588e into microsoft:master Jan 25, 2018
@niieani

Copy link
Copy Markdown

Thank you Noj Vek (@nojvek)! Looking forward to the next PR 😊!

@nojvek

Copy link
Copy Markdown
Contributor Author

Mohamed Hegazy (@mhegazy) Sheetal Nandi (@sheetalkamat)

// @declaration: true
// @emitDeclarationsOnly: true

For consistency with declaration: true flag, does it make sense to call this new flag emitDeclarationOnly ?

        declaration?: boolean;
        emitDeclarationsOnly?: boolean;
        declarationDir?: string;

It seems the pattern is to use singular *declaration*.

What do you think ?

I can send a rename PR

@mhegazy

Copy link
Copy Markdown
Contributor

humm.. good point.. we can change it to EmitDeclarationOnly

@nojvek

Noj Vek (nojvek) commented Jan 30, 2018 via email

Copy link
Copy Markdown
Contributor Author
@mhegazy

Copy link
Copy Markdown
Contributor

rename PR up in #21651

@mhegazy Mohamed Hegazy (mhegazy) changed the title --emitDeclarationsOnly flag to enable declarations only output Feb 5, 2018
Mohamed Hegazy (mhegazy) pushed a commit that referenced this pull request Feb 5, 2018
* Add emitOnlyDeclarations flag

* Fix name

* verifyOptions checking logic

* Passing tests

* doJsEmitBaseline

* Tests !!!
Mohamed Hegazy (mhegazy) added a commit that referenced this pull request Feb 6, 2018
* --emitDeclarationsOnly flag to enable declarations only output (#20735)

* Add emitOnlyDeclarations flag

* Fix name

* verifyOptions checking logic

* Passing tests

* doJsEmitBaseline

* Tests !!!

* Rename switch `--emitDeclarationsOnly` to `--emitDeclarationOnly` (#21651)

* Rename `--emitDeclarationsOnly` to `--renameDeclarationOnly`

* Rename test files
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants