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
{{ message }}
Repository navigation
Add typed return for Object.defineProperties #41424
Yours won’t correctly handle non‑writable properties, whereas mine is much more correct:
interfaceObjectConstructor{defineProperty<T,PextendsPropertyKey,V=PextendskeyofT ? T[P] : unknown,W=PextendskeyofT ? true : false>(target: T,property: P,descriptor: TypedPropertyDescriptor<V>&{readonlywritable?: W},): (T&{readonly[KinPasWextendsfalse ? K : never]: V}&{-readonly[KinPasWextendstrue ? K : never]: V})// Needs https://github.com/microsoft/TypeScript/issues/40562:// & (asserts target is T &// { readonly [K in P as W extends false ? K : never]: V } &// { -readonly [K in P as W extends true ? K : never]: V });defineProperties<T,MextendsRecord<string|symbol,PropertyDescriptor>>(target: T,properties: M&ThisType<T>,): ({}extendsM ? T : T&{readonly[KinkeyofMasM[K]extends{readonlywritable: false} ? K : (KextendskeyofT ? never : K)]:
M[K]extendsReadonly<TypedPropertyDescriptor<infer V>> ? V : any;}&{-readonly[KinkeyofMasM[K]extends{readonlywritable: true} ? K : (KextendskeyofT ? K : never)]:
M[K]extendsReadonly<TypedPropertyDescriptor<infer V>> ? V : any;})// Needs https://github.com/microsoft/TypeScript/issues/40562:// & (asserts target is ({} extends M ? T : T & {// readonly [K in keyof M as M[K] extends { readonly writable: false } ? K : (K extends keyof T ? never : K)]:// M[K] extends Readonly<TypedPropertyDescriptor<infer V>> ? V : any;// } & {// -readonly [K in keyof M as M[K] extends { readonly writable: true } ? K : (K extends keyof T ? K : never)]:// M[K] extends Readonly<TypedPropertyDescriptor<infer V>> ? V : any;// }))}
ExE Boss (@ExE-Boss) Your definition seems far more useful. Perhaps it would make sense to turn into a PR? Is #40562 essential?
Adding proper definitions of Object.defineProperties would be one way to approach getters/setters in CoffeeScript, which doesn't currently have built-in support so recommends using defineProperty. Lack of TypeScript support came up in this discussion.
Activity
ExE-Boss commentedon Nov 6, 2020
Yours won’t correctly handle non‑
writableproperties, whereas mine is much more correct:clshortfuse commentedon Nov 6, 2020
Ah, I didn't see
TypedPropertyDescriptorwhich would make things much easier. Any reason why this isn't part of the typings?ExE-Boss commentedon Nov 7, 2020
Carlos Lopez (@clshortfuse)
It’s probably for legacy compatibility.
Which is probably the same reason as to why
strictBindCallApplyis not the default.ExE-Boss commentedon Mar 10, 2021
PR #42424 seems to be a start towards addressing this.
edemaine commentedon Jan 26, 2022
ExE Boss (@ExE-Boss) Your definition seems far more useful. Perhaps it would make sense to turn into a PR? Is #40562 essential?
Adding proper definitions of
Object.definePropertieswould be one way to approach getters/setters in CoffeeScript, which doesn't currently have built-in support so recommends usingdefineProperty. Lack of TypeScript support came up in this discussion.