2 ms·
I think this would be useful for writing rules for eslint. For example, let's say we want to ensure object types don't change for their entire lifecycle.
by pyrolistical 4y ago
I think this would be useful for writing rules for eslint.
For example, let's say we want to ensure object types don't change for their entire lifecycle.
const foo = {
answer: 42
}
// change values but not type is OK
foo.answer = 69;
// creating a new object is OK
const bar = {
baz: foo
}
// disallow adding/removing fields, IE changing type
// ERROR, expected type of foo to be {answer: number}, unexpected field reply: string
foo.reply = "nice";