-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I mentioned this issue in #7
import { trait, derive, derived } from "@traits-ts/core"
const HasA = trait(B => class extends B {
a = 'a';
});
const HasB = trait(B => class extends B {
b = 'b';
});
const Greeting = trait([HasA, HasB], B => class extends B {
hi() {
console.log(this.a); // a: string // Good
console.log(this.b); // b: any // Not good
console.log(this.c); // c: any // Really bad
}
});
It looks like there is a bug in typing logic / TS compiler itself that allows accessing anything on the instance:
instance.absolutely.anything // :any
Which is very dangerous.
There are still types for defined properties though:
this.a // string
this.b // number
I'm creating a separate issue as it seems to be quite critical type safety issue and more dangerous than the other one.
Metadata
Metadata
Assignees
Labels
No labels