-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
TypeScript declarations: incorrect Interceptor method signatures #111
Comments
There are a number of issues with us writing Aurelia in TypeScript at present:
Please don't get me wrong, I like TypeScript a lot and think it's probably a good fit for most applications. But I'm not sure it's the best fit for Aurelia's sourcecode base...at least not yet I'm open to moving to TS in the future, but I'm just not sure TS is ready for us yet. @atsu85 Please submit a PR to fix up the interceptor signatures. Or maybe @bryanrsmith can add those? Your'll find that a lot of our types are more filled out in master now. And we're planning to have them completed for the beta in the next week or so. If you find stuff that is missing or incorrect, please help us by submitting PR's. |
Hi @EisenbergEffect, Regarding Your concerns with adopting TypeScript (TS from now on in this comment), I'll use the same numbers for 9 concerns You had:
This doesn't concern me at all - one obvious option would be not to use private and protected modifiers at all, but the other option that seems more reasonable is to deal with this problem when (if at all) it occurs - find&remove all usages of private and protected modifiers is simple enough.
This is wrong assumption - at least with TS 1.6.2 and i think it was the same way with 1.4 as well (if not always). So this is not a problem. If i import interface and class from the same file, then in the compiled output only class is imported from that file. TypeScript compiler understands that Interface doesn't have runtime representation, so it doesn't make sense to emit it as an import (it uses imported interface just for type checking).
This isn't problem either - Java/C# devs know how to resolve circular dependencies and this isn't different for TypeScript either. I hope i haven't misunderstood smth, but if i have, please correct me - I'd love to know. Also it would be nice, if some other TypeScript users could verify my statements (I've seen some activity/interest for TS from @cmichaelgraham, @ctoran, @jdanyow ) |
@bryanrsmith When you get a chance, can you update the interfaces for interceptors to the correct signatures? I'm not as familiar with that part of the codebase or that feature, so I'm not sure I'd get it exactly correct. |
Regarding http-client type declarations:
I can only say the same about myself, so I'd also appreciate help from @bryanrsmith |
@EisenbergEffect, Regarding TypeScript, do you have any comments? Maybe You could ask someone from the Aurelia core team to look into Your concerns and my answers about TypeScript that we listed above? |
I agree with @atsu85 that when compiling TypeScript to ES6 (and not ES5), most of the concerns @EisenbergEffect mentioned above will become non-issues. Remember that TS is only a type checking layer on top of your JavaScript code and will output what you are already writing by hand in ES6. At runtime the browser's engine sees the same thing but what you get is some magical tooling. |
It would be great if someone sent a PR to update the interface definitions we have... |
Are the current type definitions correct? I have an interceptor with Looking at the code, I would assume that the parameter is |
Can you submit a PR to fix that? |
Did my best trying to figure out how the promise chain works in RequestMessageProcessor. Does that look right? |
Generated TypeScript declarations for Interceptor:
http-client/dist/aurelia-http-client.d.ts
Lines 76 to 91 in 6a3f44a
...have neither parameters nor return types.
Official documentation provides some information about parameters and return types, but I think it is not accurate either.
5 months ago i came up with following type declaration for Interceptor (that fulfilled requirements for my code):
...but I haven't investigated the source after that. One thing that should probably be changed is replacing
HttpRequestMessage
withRequestMessage
and smth similar withHttpResponseMessage
.I'm really sad/disappointed that Aurelia team decided in favor to ES6 with type info instead of writing the code in TypeScript. In theory everything should be more-less OK with TypeScript declarations, but in reality almost all Aurelia subprojects have either no TypeScript declaration info or there isn't much to do with automatically generated declarations if You want to use type info in webapp TypeScript source for Aurelia objects (and i'm not even talking about
--noImplicitAny
TypeScript compiler flag).Please, don't get me wrong, i absolutely love Aurelia and very much appreciate the effort from Aurelia team and other contributors, but this approach has many drawbacks (and no significant benefits, if any, that i know about):
a) IDE support for TypeScript helps to understand code much faster
b) IDE support for TypeScript helps to write fixes and new code much faster
c) TypeScript compiler checks trivial errors
...i guess i could continue, but i have to run...
Is there anything missing from TypeScript 1.6 that You'd like to use in Aurelia source code? I can't recall any ES6/ES7 features missing from TypeScript 1.6 (see https://github.com/Microsoft/TypeScript/wiki/Roadmap) that I've seen in aurelia source code. @cmichaelgraham can You think of any?
:(
The text was updated successfully, but these errors were encountered: