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

working with latest github version - error but no details #140

Closed
bsr203 opened this issue Sep 5, 2014 · 5 comments · Fixed by #141
Closed

working with latest github version - error but no details #140

bsr203 opened this issue Sep 5, 2014 · 5 comments · Fixed by #141

Comments

@bsr203
Copy link

bsr203 commented Sep 5, 2014

Hello,

when using with github version of typescript (https://github.com/Microsoft/TypeScript), there is no detailed error message. I tried installing the compiled file glibally (sudo npm install -g . on the source root) or setting compiler option of grunt-ts. Both results the below output.

grunt ts
Running "ts:dev" (ts) task
Compiling...
Cleared fast compile cache for target: dev
Fast compile will not work when --out is specified. Ignoring fast compilation
Using tsc v1.0.1


>> Error: tsc return code: 1
Warning: Task "ts:dev" failed. Use --force to continue.

Aborted due to warnings.

when switch to https://git01.codeplex.com/typescript branch, it works fine. Tried to look through the debugger, and this what I see. Not sure how the error reporting changed. Is there a way to make grunt-ts work with latest github version? thanks.

screen shot 2014-09-05 at 8 11 29 am

@basarat
Copy link
Member

basarat commented Sep 5, 2014

I have experienced this as well. I assumed they still haven't rewritten this part. But now I suspect they might be using stdout for errors (which is a bad thing). A better place to debug would be here : https://github.com/grunt-ts/grunt-ts/blob/master/tasks/modules/compile.ts#L29-L34 i.e.

                var ret: ICompileResult = {
                    code: code,
                    output: String(result)
                };
                resolve(ret);

to see what grunt.util.spawn returns observe the result variable. I didn't write the String(result) and going back I would refactor it to result.toString (the effect would be the same though, tomayto tomaato). This is what result is (from here):

    var result = {
      stdout: stdout,
      stderr: stderr,
      code: code,
      toString: function() {
        if (code === 0) {
          return stdout;
        } else if ('fallback' in opts) {
          return opts.fallback;
        } else if (opts.grunt) {
          // grunt.log.error uses standard out, to be fixed in 0.5.
          return stderr || stdout;
        }
        return stderr;
      }
    };

Notice stderr is (probably) returned for our case (from toString) and the compiler hasn't set properly (again I suspect). If this is the case it is probably a bug for TypeScript (if you report it I'd like to see a link if so I can follow the bug).

@bsr203
Copy link
Author

bsr203 commented Sep 5, 2014

You are right, it is stdout it sets

screen shot 2014-09-05 at 6 17 20 pm
screen shot 2014-09-05 at 6 25 03 pm

an issue is raised here microsoft/TypeScript#615

@basarat
Copy link
Member

basarat commented Sep 6, 2014

Feature was implemented after the customcompiler I have in this repo:

$ node "node_modules/typescript/bin/tsc" "test/fail/ts/deep/fail.ts" > nul
D:\REPOS\GRUNT\grunt-ts\test\fail\ts\deep\fail.ts(7,1): error TS2095: Could not find symbol 'Simplebad'.

$ node "customcompiler/tsc" "test/fail/ts/deep/fail.ts" > nul
test/fail/ts/deep/fail.ts(7,1): Cannot find name 'Simplebad'.

If I update to latest stdout is used, stderr is empty:

$ node "customcompiler/tsc" "test/fail/ts/deep/fail.ts" > nul

$ node "customcompiler/tsc" "test/fail/ts/deep/fail.ts"
test/fail/ts/deep/fail.ts(7,1): error TS2304: Cannot find name 'Simplebad'.

@basarat
Copy link
Member

basarat commented Sep 6, 2014

Verfied that csharp works the same way the new compiler does:

$ echo %ERRORLEVEL%
0
$ csc bad.cs > nul
$ echo %ERRORLEVEL%
1

i.e. nothing on stderr

@basarat
Copy link
Member

basarat commented Sep 6, 2014

npm : v1.11.9. Thanks @bsr203!

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

Successfully merging a pull request may close this issue.

2 participants