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

How can I debug compilation? #3318

Closed
urbanhop opened this issue May 31, 2015 · 2 comments
Closed

How can I debug compilation? #3318

urbanhop opened this issue May 31, 2015 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@urbanhop
Copy link

This is less an issue but a request for advice. I try to change the way code for namespaces is emitted.

Currently the typescript code

namespace A{
    var x = 42;
}

is emitted as

var A;
(function (A) {
    var x = 42;
})(A || (A = {}));

which I want to change to be emitted as

    var A_x = 42;

Obviously, all references to x also need to become A_x .

I walkted through emitter.ts and declarationEmitter.ts but without being able to stepping through the compilation with a debugger it is hard to fully understand the pieces. So my question:

How can I debug compilation ?
Hints on my namespace hack are also appreciated.

@DanielRosenwasser
Copy link
Member

If you're on Windows with a program that can use the script debugging interface (e.g. Visual Studio), you can use cscript with with /X flag to signal that it should stop on the first statement.

If you want to make it faster, use the Chakra engine using something like the flag /E:{16d51579-a30b-4c8b-a276-0ff4dc41e755}.

If you don't have that privilege, you can use node-inspector and run the compiler with node --debug-brk build/local/tsc.js.

As a word of caution, if you're intending on sending this out as a PR, I don't think we're inclined to accept something like that (or at least, we'd need a proposal to consider first). If it's for your own personal purposes, I fully encourage you to learn about the compiler and experiment. I'd look into emitIdentifier in emitter.ts.

@DanielRosenwasser DanielRosenwasser added the Question An issue which isn't directly actionable in code label Jun 1, 2015
@urbanhop
Copy link
Author

urbanhop commented Jun 1, 2015

Thank you so much Daniel, this was very helpful.

No PR indended, pure private hack for some very specific reasons.

@urbanhop urbanhop closed this as completed Jun 1, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants