aurelia / aurelia/binding

Feature: Update @computedFrom to support typing

Open
#727 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
110
Forks
98
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a feature request**

* **Library Version:**
1.7.3

**Please tell us about your environment:**
* **Operating System:**
Windows 10

* **Node Version:**
v8.11.1

* **Yarn Version:**
1.5.1

* **Language:**
TypeScript 3.0

**Current behavior:**
We do not get any type safety when using @computedFrom. A few blogs give users a method for extending @computedFrom manually, but why not just make this an upstream feature we can use?

**What is the expected behavior?**
That @computedFrom can give us type safety out-of-the-box.

https://medium.com/tech-effectory/creating-a-typed-version-of-aurelias-computedfrom-decorator-with-typescript-27219651ecee

Example:
```ts
import {computedFrom as originalComputedFrom} from "aurelia-framework";
export function computedFrom(...rest: Array) {
return originalComputedFrom(...rest);
}
```
```ts
import {computedFrom} from './typedcomputedfrom';
export class App {
public foo = "a";
public bar = "b";

@computedFrom("foo")
public get foobar () {
return `${this.foo} ${this.bar}`;
}
}
```

**What is the motivation / use case for changing the behavior?**
- More bugs can be caught at compile-time, this will reduce chance of "typo" mistakes when using @computedFrom
- Rather than individual projects adopt this pattern and import a "fake" version of @computedFrom across their codebase, it's standard.

Contributor guide

Open the contributing guide

Research direction

Start at the @computedFrom decorator and its public type declarations; use the linked typed-wrapper article and the TypeScript example as the behavioral reference. The work is done when valid property names remain supported and invalid names are caught by TypeScript without requiring a project-specific wrapper.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.