You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My current task is writing typings for library, that makes all interface sync methods as async. I found how to cast method result, but I didn't found way to cast argument types.
TypeScript Version: 2.5.3 Code
interfaceTest{method(arg: number/* always 1 argument */): string;}typePromisify<T>={[PinkeyofT]: (/* cast arguments from T[P] somehow */)=>Promise<P[T]/* don't know how it works, maybe it's a bug */>;}consttest: Promisify<Test>;test.method(256/* no autocomplete */).then((data)=>{console.log(data.charCodeAt(0);// works right);});
Expected behavior:
User can get method argument types.
Actual behavior:
Typescript should have some special key for getting method arguments,
something like (args: argumentsof T[P]).
The text was updated successfully, but these errors were encountered:
johnthecat
changed the title
No cast of mapped interface arguments
No type cast of mapped interface arguments
Oct 8, 2017
This is not currently supported. Obviously it's very useful behavior and #6606 tracks adding it to the language. I'm not sure why it currently works for return types as the syntax doesn't make any sense. It may be a bug as you say.
@aluanhaddad Linked proposal looks good, but it’s exactly what I want.
In my example with this proposal it should looks like
’’’ts
type Promisify = {
[K in keyof T]: (a: typeof P[T][“arguments”][0] /* wtf? */) => Promise<P[T]>
}
’’’
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
My current task is writing typings for library, that makes all interface sync methods as async. I found how to cast method result, but I didn't found way to cast argument types.
TypeScript Version: 2.5.3
Code
Expected behavior:
User can get method argument types.
Actual behavior:
Typescript should have some special key for getting method arguments,
something like
(args: argumentsof T[P])
.The text was updated successfully, but these errors were encountered: