GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — implemented treat warning as errors commandline option. by DickvdBrink · Pull Request #966 · microsoft/TypeScript

Conversation

@DickvdBrink

@DickvdBrink Dick van den Brink (DickvdBrink) commented Oct 25, 2014

Copy link
Copy Markdown
Contributor

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 :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
RyanCavanaugh
RyanCavanaugh reviewed Oct 26, 2014
View reviewed changes
Comment thread src/compiler/types.ts Outdated

@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) Oct 26, 2014

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@CyrusNajmabadi

Cyrus Najmabadi (CyrusNajmabadi) commented Oct 26, 2014

Copy link
Copy Markdown
Contributor

I"m not sure what the purpose of this is. Do we have any actual warnings in typescript today?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink

Dick van den Brink (DickvdBrink) commented Oct 26, 2014

Copy link
Copy Markdown
Contributor Author

Cyrus Najmabadi (@CyrusNajmabadi) Not real warnings but when would type this:

var foo: number = "test";

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".
DanQuirk is right about the EmitReturnStatus enum so this code might not be really needed but than I think that issue should be closed as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink
implemented treat warning as errors commandline option (warnaserror).
417555c
@DickvdBrink
Dick van den Brink (DickvdBrink) force-pushed the warnaserror branch from 5623f77 to 417555c Compare October 26, 2014 13:54
@mhegazy

Mohamed Hegazy (mhegazy) commented Oct 26, 2014

Copy link
Copy Markdown
Contributor

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 Cyrus Najmabadi (@CyrusNajmabadi). I can not find a good name though, may be suppressEmitWithErrors or early..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Oct 26, 2014

Copy link
Copy Markdown
Member

I'm also not big on the name, but I'm at a loss for significantly better ones.

  • emitOnCleanBuild
  • emitCleanBuildsOnly
  • noEmitOnAnyErrors
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RyanCavanaugh

Ryan Cavanaugh (RyanCavanaugh) commented Oct 27, 2014

Copy link
Copy Markdown
Member

I like (or at least tolerate better) noEmitOnError[s] or emitCleanOnly. We're consistent in terminology about type errors being "errors" and not "warnings".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink
Changed name to noEmitOnError
bd2c596
@danquirk

Dan Quirk (danquirk) commented Oct 27, 2014

Copy link
Copy Markdown
Member

yeah I think noEmitOnErrors is sufficiently clear and concise

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mhegazy
mhegazy reviewed Oct 27, 2014
View reviewed changes
Comment thread src/compiler/diagnosticInformationMap.generated.ts Outdated

@mhegazy Mohamed Hegazy (mhegazy) Oct 27, 2014

Copy link
Copy Markdown
Contributor

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"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@CyrusNajmabadi Cyrus Najmabadi (CyrusNajmabadi) Oct 29, 2014

Copy link
Copy Markdown
Contributor

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:[email protected]]
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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mhegazy

Mohamed Hegazy (mhegazy) commented Oct 28, 2014

Copy link
Copy Markdown
Contributor

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.
I would change the name of hasEarlyError to isEmitBlocked and add the check for the option and the error as well. i would also check global errors and syntax errors (program.getDiagnostics().length === 0) to be safe.

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 (@sourcemap) and declaration

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink
addressed feedback
e4f5756
@DickvdBrink

Dick van den Brink (DickvdBrink) commented Oct 28, 2014

Copy link
Copy Markdown
Contributor Author

Added some new commits.
Also renamed the hasEarlyErrors method in the interface to is isEmitBlocked (which is what you meant right? or does this break things with VS maybe?)
Changed some things in harness.ts to make it work.

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DanielRosenwasser
DanielRosenwasser reviewed Oct 29, 2014
View reviewed changes
Comment thread src/harness/compilerRunner.ts

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Oct 29, 2014

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DickvdBrink Dick van den Brink (DickvdBrink) Oct 29, 2014

Copy link
Copy Markdown
Contributor Author

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Oct 30, 2014

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DickvdBrink Dick van den Brink (DickvdBrink) Oct 30, 2014

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yuit

Yui (yuit) commented Oct 29, 2014

Copy link
Copy Markdown
Contributor

Comments for isEarly and hasEarlyError will make it clearer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink

Dick van den Brink (DickvdBrink) commented Oct 29, 2014

Copy link
Copy Markdown
Contributor Author

Thanks for feedback everyone. Will add some comments in compilerRunner.ts
Yui (@yuit) Comments for isEarly and hasEarlyError will make it clearer
Sorry, don't know what you mean here (where do you want such comments?)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink
Added test for noEmitOnError
4c1397b
@DickvdBrink
Dick van den Brink (DickvdBrink) force-pushed the warnaserror branch from e9df900 to 4c1397b Compare October 29, 2014 23:11
@yuit

Yui (yuit) commented Oct 29, 2014

Copy link
Copy Markdown
Contributor

For some reasons I can't see where you defined hasEarlyError in the change list. However, what I mean is that could you add comment at the when you declare function hasEarlyError and property isEarly in the Diagnostics. I am not sure what is the property is for

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink

Dick van den Brink (DickvdBrink) commented Oct 30, 2014

Copy link
Copy Markdown
Contributor Author

hasEarlyError was already there, the messages which have isEarly are in diagnosticMessages.json
I'm actually not really sure why those have isEarly so I can't really add a comment for it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Oct 30, 2014

Copy link
Copy Markdown
Contributor

👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Nov 16, 2014

Copy link
Copy Markdown
Contributor

Dick van den Brink (@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DickvdBrink
Dick van den Brink (DickvdBrink) force-pushed the warnaserror branch from 12eb5c0 to 4c1397b Compare November 16, 2014 20:33
Dick van den Brink (DickvdBrink) added 2 commits November 16, 2014 22:02
@DickvdBrink
Merge branch 'master' into warnaserror
e7bb2e0
Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
	src/compiler/types.ts
	src/harness/harness.ts
@DickvdBrink
Update baseline
c90fb4a
@DickvdBrink

Dick van den Brink (DickvdBrink) commented Nov 16, 2014

Copy link
Copy Markdown
Contributor Author

Mohamed Hegazy (@mhegazy) no problem, better late than never right ;)
Updated PR and after the merge I ran the tests again and noticed that my baseline had changed so fixed that in another commit

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mohamed Hegazy (mhegazy) added a commit that referenced this pull request Nov 17, 2014
@mhegazy
Merge pull request #966 from DickvdBrink/warnaserror
d5cfceb
implemented treat warning as errors commandline option.
@mhegazy
Mohamed Hegazy (mhegazy) merged commit d5cfceb into microsoft:master Nov 17, 2014
@mhegazy

Mohamed Hegazy (mhegazy) commented Nov 17, 2014

Copy link
Copy Markdown
Contributor

thanks, and sorry again for the delay.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@DickvdBrink @CyrusNajmabadi @mhegazy @DanielRosenwasser @RyanCavanaugh @danquirk @yuit
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.