Skip to content

/// <reference>s and single file output: emit order too easy to break #955

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

Closed
sparecycles opened this issue Oct 24, 2014 · 1 comment
Closed
Labels
Duplicate An existing issue was already created Suggestion An idea for TypeScript

Comments

@sparecycles
Copy link
Contributor

It appears that the order in which the output is emitted into a single file is determined by the references. In general, if a file references another, the other file is emitted first.

As a matter of preference, I want to have every file which requires the symbols of another file to reference that other file. In other words I want (at least) that if the services is run on any of my files individually, there would be no missing symbols.

Unfortunately this breaks on the simplest case of having a class which makes references its subclasses when these are in different files. I need the parent class to be emitted first, and the subclasses need to follow, but since the parent class file references the subclasses, they get emitted first and we get the error __.prototype = b.prototype; b is undefined (in __extends() of course).

A correct emit order ought to be determined by use of symbols at the module and class-static level. But the compile time cost of scanning for symbols and determining their source locations may be prohibitive.

Or there could be an extension to /// <reference ...> to indicate either that the referenced file is needed at load-time and/or not. (In the case of the "I need this loaded first" annotation, we could detect cycles and flag errors).

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Oct 24, 2014
@RyanCavanaugh
Copy link
Member

See #21 - feel free to add comments there on scenarios we should be looking at.

@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Oct 24, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants