-
-
Notifications
You must be signed in to change notification settings - Fork 146
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Update
able to handle arrays
#83
Comments
@mcpower If you have time to do this, otherwise I'll do this a bit later. When merging your last PRs, I did not find the time to transform |
Exciting, I am just searching a way to convert a instance array(tuple) to constructor type array(tuple). |
@maroon1 can you provide a full example of what you are trying to do? |
// convert
type Constructors = [typeof ClassA, typeof ClassA, typeof ClassA];
// to
type InstanceTypes = [ClassA, ClassA, ClassA]; For example: type MapToInstances<T> = { [K in keyof T]: InstanceType<T[K]>}; // it doesn't not work~
export class Transformer<T> {
constructor(statics: T) {}
transform(): MapToInstances<T>;
}
const transfomer = new Transformer([ClassA, ClassA, ClassA]);
transformer.transform(); // [classA, classA, classA] |
You issue isn't related to this one: For your problem, you needed to use import {A, C} from 'ts-toolbelt'
class ClassA {}
// convert
type Constructors = [typeof ClassA, typeof ClassA, typeof ClassA];
// to
type InstanceTypes = [ClassA, ClassA, ClassA];
type MapToInstances<T extends readonly C.Class[]> = {
[K in keyof T]: C.InstanceOf<A.Cast<T[K], C.Class>>
};
export class Transformer<T extends readonly C.Class[]> {
constructor(statics: T) {}
transform(): MapToInstances<T> {
return {} as any
}
}
const transformer = new Transformer([ClassA, ClassA, ClassA] as const)
const transformed = transformer.transform() // [ClassA, ClassA, ClassA] If you remove If you have more questions, you're welcome to open an issue for it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
馃崺 Feature Request
Is your feature request related to a problem?
Describe the solution you'd like
Describe alternatives you've considered
Teachability, Documentation, Adoption, Migration Strategy
The text was updated successfully, but these errors were encountered: