-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped typesIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Aurelia follows the convention that for any field foo
, when foo
is changed by the framework, then an attempt to call fooChanged()
is made. There is (seemingly) no way to describe this convention as a type (automatically) via the Mapped Type functionality alone.
I would like to open discussion to the prospect of augmenting property keys during mapping.
For example: via arthimetic:
type Changed<T> =
{
[ P in keyof T ] + "Changed" ?: Function;
}
class Foo{
field:number;
}
let foo = <Foo & Changed<Foo>> new Foo();
foo.field = 10;
if(foo.fieldChanged)
foo.fieldChanged();
in this use-case specifically it probably would require #12424 too, but that is beside the point here.
aluanhaddad, grofit, ryanatkn, impworks, ForNeVeR and 352 moreanilanar and waitingsongseungha-kim, lightsound and bl-ueTwilightOwl, seungha-kim, MikeKovetsky, david-deepblocks, kettanaito and 6 moreandreElrico, jacksteamdev, TwilightOwl, raphaelfaria, sheerlox and 22 morerodrigok, TwilightOwl, seungha-kim, MikeKovetsky, david-deepblocks and 8 moresheerlox, seungha-kim, trikadin, david-deepblocks, levenleven and 11 more
Metadata
Metadata
Assignees
Labels
Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean lit
41B9
erals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped typesIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript