0

I have this type

{timeStamp: number, rectangle:number[]}

and I want to use it multiple times(within the same file), is there any way to do it like:

type detectionParams = {timeStamp: number, rectangle:number[]};
private detection: detectionParams[];
2
  • 2
    Exactly like that, actually. Note that the convention is that types begin with a Capital letter, so type DetectionParams = ... would be better. Commented Feb 25, 2018 at 12:29
  • ohh, I just placed it in the wrong place... Thanks for reassuring. Commented Feb 25, 2018 at 13:00

1 Answer 1

1

Since you have a plain object type, rather than using the type alias its more common to use an interface instead.

interface DetectionParams {
    timeStamp: number;
    rectangle: number[];
};

If any other files are to use this Object structure, just export it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.