0

I'm working with a legacy variable defined quite some time ago.

export const constellationNancyRomanTable = [
  [0.0000,24.0000,88.0000,'UMi'],
  [8.0000,14.5000,86.5000,'UMi'],
  [21.0000,23.0000,86.1667,'UMi'],
  [18.0000,21.0000,86.0000,'UMi'],
  ...
]

However, I'm very new to Typescript - so I'm half thinking of porting this variable to a new object based syntax as I understand type definitions for objects, but this array of arrays is alluding me. However, I was wondering how to define such a type / interface?

I'm thinking something along this line:

export interface ConstellationNancyRoman = Array<Array<[number, number, number, string]>>

Is somewhat correct?

2
  • What exactly you want? what is your expected result? Commented Jul 12, 2021 at 11:23
  • Why not try it out? Right now that's not even a syntactically valid interface, looks like you've confused it with a type. Commented Jul 12, 2021 at 11:23

1 Answer 1

3

You're almost there: you have simply nested it one Array to deep, since you're defining your tuples already. This should work (use type not interface):

export type ConstellationNancyRoman = Array<[number, number, number, string]>;

See example on TypeScript playground.

You can use bracket notation all the way, even though for some people it might not be as readable as before:

export type ConstellationNancyRoman = [number, number, number, string][];
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Terry, ahhh simple - thank you for helping with this!

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.