-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Suggestion: Allow type and value parameters for modules #2625
Comments
It's kind of confusing -- what is the type of the value expression |
|
Sorry, I meant in the case where you hadn't written an |
so answering your questions, can you currently refer a generic function in TS? yes, but it doesn't make much sense in most cases (unless for calling it once resolved) i hope the analogy with generic functions can be used in this case |
basically i wish we had OCAML's first class modules in TypeScript: |
I think if we fully supported local types and class expressions you could probably get what you want by making |
@danquirk I am afraid I am not following how it could work.
|
@Aleksey-Bykov I certainly imagine considering making something like that work. Obviously I don't want to promise anything at this point though :) It doesn't seem all that different from this kind of thing that we allow today: function aConstructor<T>() {
return function anotherConstructor() {
var data: T;
return { value: data }
}
}
var a = aConstructor<Date>(); // we don't allow 'new' here since this isn't void returning
var b = a();
var r = b.value; // Date Those are essentially the static sides of your 2 classes. Each function could return an interface type describing the instance side, but of course the problem today is you can't define an interface inside |
With ES6 modules in place, we have shied away from any changes to the module system. it is already complicated enough, and there is not an implementation yet. |
Consider a situation when each class and function in the module depends on the same type/value parameters:
It would be awesome if such parameters went to the module level and were resolved at importing
The text was updated successfully, but these errors were encountered: