-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
implemented treat warning as errors commandline option. #966
Conversation
@@ -1092,6 +1092,7 @@ module ts { | |||
sourceRoot?: string; | |||
target?: ScriptTarget; | |||
version?: boolean; | |||
warnaserror?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please camelCase this
I"m not sure what the purpose of this is. Do we have any actual warnings in typescript today? |
@CyrusNajmabadi Not real warnings but when would type this:
It would still create a file with output with valid JavaScript. I added this piece of code because the issue I linked to is having the label "Accepting PR". |
5623f77
to
417555c
Compare
I think we need that for some scenarios. Incremental build with errors for instance does not work wiper simthing like this. I do not like the name of the flag; users will have the same reaction as @CyrusNajmabadi. I can not find a good name though, may be suppressEmitWithErrors or early.. |
I'm also not big on the name, but I'm at a loss for significantly better ones.
|
I like (or at least tolerate better) |
yeah I think |
@@ -364,6 +364,7 @@ module ts { | |||
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, | |||
Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, | |||
Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, | |||
Do_not_emit_JavaScript_on_error: { code: 6007, category: DiagnosticCategory.Message, key: "Do not emit JavaScript on error." }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to: "Do not emit outputs if any type checking errors were reported"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“type checking” is a very compiler-team specific term. Really, all we’re trying to say is “Do not emit any outputs if any errors were reported.”
-- Cyrus
From: Mohamed Hegazy [mailto:notifications@github.com]
Sent: Monday, October 27, 2014 3:38 PM
To: Microsoft/TypeScript
Cc: Cyrus Najmabadi
Subject: Re: [TypeScript] implemented treat warning as errors commandline option. (#966)
In src/compiler/diagnosticInformationMap.generated.ts:
@@ -364,6 +364,7 @@ module ts {
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." },
Do_not_emit_JavaScript_on_error: { code: 6007, category: DiagnosticCategory.Message, key: "Do not emit JavaScript on error." },
I would change this to: "Do not emit outputs if any type checking errors were reported"
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/966/files#r19442813.
The logic on whether to emit or not is used in three places, 1. tsc.ts (batch compiler), and you got that, 2. emitter.ts (used by compile on save), and 3. harness.ts (used by the tests to mimic the batch compiler behavior). we need to ensure that all 3 do the same thing. something like this: function isEmitBlocked(sourceFile?: SourceFile): boolean {
return program.getDiagnostics(sourceFile).length !== 0 ||
hasEarlyErrors(sourceFile) ||
(compilerOptions.noEmitOnError && getDiagnostics(sourceFile));
} Note: sourceFile is needed here, but it is optional. in case of batch compiler, sourceFile is not specified, as we want to do the check globally. but for compile on save, we want to do the check on one file only. One more thing, we will need a unit test for this. Unit tests use reads "// @: value" from the beginning of the file, and uses them to set compilation settings. look at the switch statement in: https://github.com/Microsoft/TypeScript/blob/master/src/harness/harness.ts#L672 Then add a test that has "// @noEmitOnErrors: true" and ensure that there are no outputs. i would also add a @sourcemap and @declaration |
Added some new commits. For future reference the link to harness with SHA in the url harness.ts. (You can create this url by clicking on a line number and press 'y' and it will always be the right one) |
@@ -175,7 +175,11 @@ class CompilerBaselineRunner extends RunnerBase { | |||
it('Correct sourcemap content for ' + fileName, () => { | |||
if (options.sourceMap) { | |||
Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { | |||
return result.getSourceMapRecord(); | |||
var record = result.getSourceMapRecord(); | |||
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a situation in which record
can be undefined
but the condition options.noEmitOnError && result.errors.length !== 0
evaluates to false? Perhaps a ||
is more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if || is more appropriate here, when for example noEmitOnError is true and there are errors and record is not undefined (because getSourceMapRecord returned a sourcemap).. then it should actually try to compare them right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, do you actually get an empty sourcemap file if you don't perform this check?
Sorry, I'm personally not familiar enough with the harness code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it did, runBaseline calls generateActual: https://github.com/Microsoft/TypeScript/blob/5ce3baf339e0424263069c70f0ea239bc3cea96a/src/harness/harness.ts#L1307 which creates the file when it is something different than null. It throws an error when it is undefined.
Comments for |
Thanks for feedback everyone. Will add some comments in compilerRunner.ts |
e9df900
to
4c1397b
Compare
For some reasons I can't see where you defined |
|
👍 |
@DickvdBrink extremely sorry for the delay. This totally fell off my radar. The PR is ready to go, can you refresh the PR by merging from main. |
12eb5c0
to
4c1397b
Compare
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/types.ts src/harness/harness.ts
@mhegazy no problem, better late than never right ;) |
implemented treat warning as errors commandline option.
thanks, and sorry again for the delay. |
Same name as csc.exe uses: msdn
Issue #828
Feedback appreciated but feel free to close when you don't want this functionality at this point :)