Suppose
interface X{
a: string;
}
For
class Y implements X{
};
There is handy quick fix “Add unimplemented members” which will add a: string
to the class.
However, in TypeScript data can be constrained to interface as well:
const x: X = {
};
There is correct error “Type ‘{}’ is not assignable to type ‘X’. Property ‘a’ is missing in type ‘{}’.”
However, there is no quick fix.
I understand there is some complexity because data has to contain instances and not types and it is not possible to derive what will be the value of a
in that case.
But even something rudimentary will be helpful to fill structures faster or fix after interface change, even if just filling types as for regular class or, better, some placeholder e.g. a: string_value_for_a,
.
-
This topic was modified 7 years, 6 months ago by Fedor Losev.