-
Notifications
You must be signed in to change notification settings - Fork 142
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: Better Generic Support for td.object() #236
Comments
I have no idea how to TypeScript. Would you send a PR? |
I will look in to the source later (tonight afterwork?). I don't think the solution will be too difficult. Believe there only needs to be a small change to the way Proxy objects are created. |
Thanks! I met a few very nice people at NG Conf who offered to help make the typescript story for testdouble really shine, so we can find more help if needed |
Related, when you dig in there is a |
I have determined the caused TypeScript error is due to lodash's I believe solution is creating a TypeScript definition for testdouble.js. Probably what the guys at the NG Conf were thinking too. |
Someone else has done this in an index.d.ts file in this repo already right?
… On May 3, 2017, at 8:34 PM, Brian ***@***.***> wrote:
I have determined the caused TypeScript error is due to lodash's .tap() function -- docs. More specifically, I believe it's due to the function's interface definition defined in @types/lodash. Furthermore, it is working as designed: the explicit generic type parameter is suppose to match the first parameter's type.
I believe solution is creating a TypeScript definition for testdouble.js. Probably what the guys at the NG Conf were thinking too.
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
You're right! Thanks! Overloading the |
Pull #237 submitted. As for your question about |
Given the following...
The above code will set
fooBarFake
to FooBar object as expected. TypeScript andfooBarFake
behaves as I expect too. However, withoutas any
, TypeScript will throw the following error...'"FooBar"' is not assignable to parameter of 'FooBar'
Take notice of the quote marks. Without the generic parameter (
<FooBar>
), TypeScriptfooBarFake
thinks it ofString
type.I believe the parameter should not need to be cast as
any
type for the generic parameter to be accepted.As side note, I generally set TypeScript's
noImplicitAny
setting is to true.The text was updated successfully, but these errors were encountered: