class A {
// specified explicitly for properties only
declare foo(): string;
// allowed for a property but not a method declaration
declare bar: string;
}
What is the reasoning behind this specific restriction? Can someone provide an explanation?
I am curious about why this distinction exists, what purpose does it serve?
PS: This should not be confused with:
class A {
declare foo: () => string;
}
This is a property of a function type. It can be assigned unlike a method. One could argue for adding readonly
, but that might introduce complexity.