export class A {
private variableType: number | string;
public static func ( x: variableType) {
//code
}
}
How do I make x of the type variableType? I tried using 'this.variableType' but it's not available in a static member of the class. Also 'A.variableType' complains that A is a type but is being used as a namespace here.
Note- There were a lot of similar questions but I didn't get the solution to this. Sorry if this has already been answered.
For your case, I'd do this way below by creating a type
type VariableType = number | string;
export class A {
private variableType: VariableType;
public static func (x: VariableType) {
//code
}
}
Alternatively,
public static func (x: A['variableType') {
//code
}
it also works but I feel like using type is a bit cleaner.