Closed mconner closed 8 years ago
Unfortunately I don't know of a way to do this in Eclipse. Even Java code works this way which is why it's possible to have code that works in Eclipse but then breaks during builds. If you have external builds setup like a CI system, it should be able to find bad references across test/src because it can be configured to compile things with the proper references.
Re: "Even Java Code works this way.": Yes, but Java enforces namespace use, whereas JavaScript does not. In Java, I have to statically import a class if I want to access members directly in client code. But JavaScript allows for declaring functions globally, and jasmine.d.ts is doing just that. Because there's no way to separate that in the IDE, if I want them available somewhere, they have to be everywhere. Yes, this is caught in a CI build, or rather, a developer build. However, one of the advantages of TypeScript is fast-fail. I can see immediately that something is not in scope, because the compiler tells me. Jasmine polluting the global namespace coupled with Eclipse only having one build scope results in a situation that is counter-productive to that.
It's still better than the alternative, and I'll have to live with it. I just wish there was a cleaner solution.
Yeah, totally understand this isn't optimal. Getting the sort of one-way dependencies that are desirable isn't trivial - it requires creating separate language service instances for each collection of code (one service would see only src code, one would see src and test code).
You could put the source and test code into separate projects. That does the work of creating a separate language service for each project.
I thought of that, but it seems like more trouble than its worth. As I indicated, this was more of a question. I suspected the answer was, "you can't do it", but was hoping there was something I was missing.
Thanks!
Question: I'm trying to set up testing, using karma and jasmine,with main and test source trees. I can set multiple paths in the Source Folder(s), and include a folder containing jasmine.d.ts. However, it then becomes available to both the test code -- which is what I want --, and the main source -- which I don't want, especially since it declares a bunch of globals. I thought perhaps that I could keep that file outside of all the paths and reference it with a ///
(assume here that the test is at the root of the test source tree), but that results in a file not found error.
Is there any way to do this?