My large classes contain functions that return complex objects which I am looking to refactor.
class BigClass {
...
getReferenceInfo(word: string): { isInReferenceList:boolean, referenceLabels:string[] } {
...
}
}
I am considering something like this (defining it close to the function):
class Foo {
...
type ReturnObject = { isInReferenceList:boolean, referenceLabels:string[] };
getReferenceInfo(word: string):ReturnObject {
...
}
}
However, at present Typescript restricts me to declaring interfaces/types outside of the class:
type ReturnObject = { isInReferenceList:boolean, referenceLabels:string[] };
class Foo {
...
getReferenceInfo(word: string):ReturnObject {
...
}
}
Is there a way to have nested interfaces in Typescript?