Skip to content

/// <reference path="..." /> ignored, resulting in invalid --outFile order of files #12395

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
Janne252 opened this issue Nov 20, 2016 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@Janne252
Copy link

TypeScript Version: 2.2.0-dev.20161120

Code
Full source code can be found at Janne252/jannengine

Expected behavior:
/// <reference path="./baseRenderable.ts" /> defined in polygon.ts should make sure that baseRenderable.ts is appended to the output file BEFORE polygon.ts.

Actual behavior:
polygon.ts is appended to the output file before baseRenderable.ts, which results in the ever so annoying Uncaught TypeError: Cannot read property 'prototype' of undefined error.

Here is a part of the tsc output generated by the tsconfig.json entry "listFiles" set to true:

.../jannengine/src/system/engine/inputProvider.ts
.../jannengine/src/system/component/event/eventHandlerCallbackBind.ts
.../jannengine/src/system/component/event/eventHandler.ts
.../jannengine/src/system/helpers/math.ts
.../jannengine/src/system/component/vector2d.ts
.../jannengine/src/system/component/size.ts
.../jannengine/src/system/component/random.ts
.../jannengine/src/system/component/color.ts
.../jannengine/src/system/component/padding.ts
.../jannengine/src/system/component/range/range.ts
.../jannengine/src/system/component/range/xyRange.ts
.../jannengine/src/system/drawing/polygon.ts
.../jannengine/src/system/drawing/line/lineCap.ts
.../jannengine/src/system/drawing/line/lineJoin.ts
.../jannengine/src/system/drawing/line/line.ts
.../jannengine/src/system/drawing/baseRenderable.ts

As you can see, polygon.ts is added before baseRenderable.ts even though polygon.ts defines baseRenderable.ts as its dependency.

An example of the generated .js file can be found in janne252/jannengine/js/combined_sample

I'm aware that this issue is related to #5207. However to my understanding my code should work, according to the documentation about How do I control file ordering in combined output. To me it seems that the /// <reference path="..." /> entries in my code are completely ignored because the resulting output file is identical with and without the /// <reference path="..." /> entries in the code files.

@Janne252
Copy link
Author

Well, is there anything that can be done to fix this? Unless I'm mistaken, the Triple-Slash Directives are not working at all.

@Janne252
Copy link
Author

F*** me, there was a circle reference in my source code. BaseRenderable requires Line and Line requires BaseRenderable. Whoops.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 22, 2016

I would not use /// <reference path="..." /> for this specific reason. i would instead use files or include in your tsconfig.json. a flat list is much easier to debug than a graph of links between files.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Nov 22, 2016
@Janne252
Copy link
Author

@mhegazy Fortunately that wasn't the issue after all, I had accidentally created a situation where A requires B and B requires A. Unfortunately it too way too long to notice.

Thanks for the reply though!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants