I have two generic indexed types
typeExtendedService<T>={[KinkeyofT]: T[K]&{__$daemonMode?: string;__$action?: string;};};typeService<T>={[KinkeyofT]: T[K]&{id?: string};};And use them like this
exportconstcreateService=<T>(ServiceCtr: ExtendedService<T>&Service<T>)=>{
...
Object.keys(ServiceCtr).forEach(key=>{constmethod=(ServiceCtr)[keyaskeyofT];const{__$daemonMode, __$action, id}=method;
...
}}VS Code output for method type is
constmethod: ({[KinkeyofT]: T[K]&{__$daemonMode?: string;__$action?: string;};}&Service<T>)[keyofT]Expected behavior:
properties __$daemonMode, __$action, id exists on method variable;
const {__$daemonMode, __$action, id} = method; has no errors;
Actual behavior:
I got an error
[ts] Type '(ExtendedService<T> & Service<T>)[keyof T]' has no property '__$daemonMode' and no string index signature.
__$action and id produces the same error;
P.S.
Expression
constx: (ExtendedService<{z: {}}>&Service<{z: {}}>)['z'];const{__$daemonMode, __$action, id}=x;works as expected
I have two generic indexed types
And use them like this
VS Code output for
methodtype isExpected behavior:
properties
__$daemonMode,__$action,idexists onmethodvariable;const {__$daemonMode, __$action, id} = method;has no errors;Actual behavior:
I got an error
__$actionandidproduces the same error;P.S.
Expression
works as expected