I have a object-type with some fields defined. Now I want to dynamically create another object where each fieldname has a $
-suffix and contains an observable of the original field-type. I thought I could do this by using keyof and adding the + '$'
to it. But this wont transpile.
import { Observable } from 'rxjs';
type AllFields = {
foo: string,
bar: number
};
type ObservedFields<T> = {
[P in keyof T] + '$': Observable<T[P]>;
}
What I want to do:
const myObject: AllFields = {
foo: 'something',
bar: 7
}
const observed: ObservedFields<AllFields> = {
foo$: Observable<string>,
bar$: Observable<number>
};