19

Closed

General problems with<reference> includes

description

Hi,

The reference includes mechanism is somewhat faulty and undermines confidence in the type system - in the sense that one cannot be certain that all compilation errors have been correctly identified when multiple projects are built concurrently.

Here are a some of the issues:

Silent fails

Incorrect syntax in the path fails silently in the following circumstances, instead of displaying the red squiggly line:


Omitting closing slash ("/") in "/// <reference path="file.ts" />" When the quotes (") around the path are missing When the path specifies ".../MyFolder" instead of "../MyFolder" When a ".js" extension is accidentally used instead of ".ts" Space after path: path = "file.ts" does not work (although this doesn't seem to happen consistently)

Build issues


If a referenced file is renamed, then projects containing a reference to that file continue to build successfully in spite of the invalid reference.
Invalid reference paths are sometimes only highlighted when the file containing the invalid reference opened.

General usability issues


The editing of the path is a bit sticky. When an incorrect path is typed in and immediately corrected, the compiler continues to refer to the old path, and in order to force the new path to be recognised it is sometimes necessary to close and reopen the
file. The speed of detection is also rather slow; one finds oneself making an edit and then staring expectantly at the screen waiting to see if something is going to materialise.



The <reference> include mechanism feels like a leftover from the old JavaScript intellisense system, and TypeScript seems to need something shiny and new - and robust.

Please advise.

Thanks.

Noel
Closed Jul 28 at 11:18 PM by jonturner
As part of our move to GitHub, we're closing our CodePlex suggestions and asking that people move them to the GitHub issue tracker for further discussion. Some feature requests may already be active on GitHub, so please make sure to look for an existing issue before filing a new one.

You can find our GitHub issue tracker here:
https://github.com/microsoft/typeScript/issues

comments

pingec wrote Nov 22, 2012 at 8:50 AM

If a referenced file is renamed, then projects containing a reference to that file continue to build successfully in spite of the invalid reference.
Invalid reference paths are sometimes only highlighted when the file containing the invalid reference opened.
Wow, thanks for this. It helped me figure out what was wrong with my project. No errors in IDE, many from the compiler tsc.exe.

kayub wrote Dec 6, 2012 at 11:42 PM

Also, appears no absolute or project path support? I tend to organize my JS into folders... pain to be writing ../ all the time and risking issues.

RupertAvery wrote Jan 29, 2013 at 10:42 AM

How important is spacing in the reference tag?

I've found that this works:

/// <reference path="jquery.d.ts" />

But this doesn’t, and the TypeScript compiler doesn’t even let you know what’s wrong, other than the symbols you try to use from the referred file don’t exist.

/// <reference path= "jquery.d.ts" />

The compiler should at the least let the developer know that something is wrong with the reference itself.

bmantuano wrote Apr 20, 2013 at 1:53 AM

I second kayub's sentiments on project path support.

Absolute paths are supported (e.g. "/Users/blah/source/js/jquery.d.ts") though this isn't really a feasible option when multiple developers are involved.

zijianhuang wrote May 14, 2013 at 6:36 AM

I second RupertAvery. I am now using TS 0.8.3.1

/// <reference path="jquery.d.ts" />
gives me exit error code 1 and 102 warnings.

/// <reference path= "jquery.d.ts" />
works.

The bug mentioned by RupertAvery was fixed, but ended up an opposite bug. Should the space between the equal sign and the path so significant?

zijianhuang wrote May 14, 2013 at 6:49 AM

No. With the extra space, the compiler simply skip without warning. The reason why I did not get compiler error was that I haven't yet written any jQuery statements in ts code.

Apparently 0.8.3.1 is not so friendly to jquery.

zijianhuang wrote May 14, 2013 at 10:46 AM

Removing 0.8.3.1 and installing 0.9 alpha resolved the problem. Now the ts codes with jquery could have intellisense and successful build.