Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typescript4.3+ 属性装饰器不支持Object.defineProperty #11

Open
xizher opened this issue Oct 13, 2021 · 0 comments
Open

fix: typescript4.3+ 属性装饰器不支持Object.defineProperty #11

xizher opened this issue Oct 13, 2021 · 0 comments
Labels
bug Something isn't working
Projects

Comments

@xizher
Copy link
Owner

xizher commented Oct 13, 2021

Decorators in 4.3.x can't use Object.defineProperty anymore.

export function ObservableProperty (fireName: string) {
  return function (target: Observable<any>, key: string) { // eslint-disable-line
    let property = target[key]
    const getter = () => property
    const setter = (newVal: unknown) => {
      target.fire(fireName, {
        [key]: newVal,
        [`old${key.replace(key[0], key[0].toUpperCase())}`]: property,
      })
      property = newVal
    }
    Object.defineProperty(target, key, {
      get: getter,
      set: setter,
      enumerable: true,
      configurable: true,
    })
  }
}

暂定处理方法:等待装饰器提案完善

@xizher xizher added the bug Something isn't working label Oct 13, 2021
@xizher xizher added this to TODO in @nhz/utils via automation Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant