Conversation
import Promise from './Promise'; | ||
|
||
declare var require: Function; | ||
declare var define: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed we've been adding these two declarations in various places (actually, usually when I see us declare define
, it includes the amd
key). Should we centralize them somewhere? (Am I wrong to be concerned about clobbering/conflicts?)
Edit: Actually, I suppose the one place I saw it in core was in request, which this refactors. I saw it in the crypto API PR in that repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And do we need an interface somewhere, or do we need a typings from the loader that we should depend on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need to provide typings for loader internals. The problem with providing those is that the typings for node's require
and AMD's require
are a bit different. Since we're compiling to UMD, most of the need for loader typings is reduced and this module's default function reduce the need for those typings even further.
Test cases? 😉 |
I'll write some test cases tonight. It'll be interesting to test the Node path since Intern runs in an AMD loader... |
I finished up the test cases. There's not a ton to check. One thing to note: the coverage data is off in Node because we're using RequireJS which adds some extra stuff to the interpreted file which throws off istanbul. This is fixed once we switch to the new loader. |
@@ -0,0 +1,54 @@ | |||
import assert = require('intern/chai!assert'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * as assert from 'intern/chai!assert';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assert
module is not an ES6 module, so it (more than likely) shouldn't be imported with ES6 semantics. This may have been fixed in later builds of TS (I've seen instances where import * as ...
isn't callable), but it's still confusing since in ES6, assert
would be a non-callable object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Would it be useful for the tests to also load text resources, instead of just Also, I get the reason why, but it is a shame the API is |
I just pushed a change (and rebased on master) so the With regards to text/JSON loading, this module is meant to be a bridge to the module loader. In Node, that means you can actually pull in JSON objects with it, but in the browser (AMD) you can't and you'd have to use a plugin. |
export type Require = AMDRequire | NodeRequire; | ||
|
||
export interface Load { | ||
(require: Require|string, ...moduleIds: string[]): Promise<any[]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not?
export interface Load {
(require: Require, ...moduleIds: string[]): Promise<any[]>;
(...modulesIds: string[]): Promise<any[]>;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off the top of my head, I don't remember why I did this. Perhaps I was being clever. When I review this over the weekend, I'll see if I can come up with a better defense ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you implementation logic is 100% correct. I just think the exposed API could be a bit cleaner (though it is technically correct). Let's just admit, the availability of union types of blinded us from thinking of overloading things! I have found myself getting wound into knots with union types only to realises that overloading actually makes things cleaner.
Merged in aa982d9. |
Fixes #35.