#How to define export type in Typescript with Needle?

1 messages · Page 1 of 1 (latest)

agile notch
#

I am trying to integrate Google's AR Model VIewer with Needle using this AR Renderer script as a starting point, making it into a .ts Behaviour/Component with Needle to see what works/doesn't but I can't get past this declaration of an export type which gives me the generic error Unexpected token. A constructor, method, accessor, or property was expected. in VS Code and I have exhausted all suggested workarounds I could find on Stackoverflow. Is there a certain way I should declare this type in Needle? Seems to be some kind of enum. WIP script attached for full reference, keen to get some really nice AR draggable sample together.

export type ARStatus =
    'not-presenting'|'session-started'|'object-placed'|'failed';

export const ARStatus: {[index: string]: ARStatus} = {
  NOT_PRESENTING: 'not-presenting',
  SESSION_STARTED: 'session-started',
  OBJECT_PLACED: 'object-placed',
  FAILED: 'failed'
};
radiant bluff
#

Has nothing to do with Needle to be honest, we're not doing anything special.
Recommend you start by putting the ARRenderer.ts next to your component's ts file, and get it to compile by throwing out things you don't need

#

And/or pulling in additional files that seem useful / needed, e.g. Damper.js or PlacementBox.js

agile notch
#

Will do, just was wondering why that export type had some declaration in some way that typescript didn't like. I'll strip it right back

eager cape
#

Are you declaring the type twice there?

#

I see ARStatus being used multiple times

#

as a variable and a type

agile notch
#

I just realised the export types need to be outside of the class the rest of the code is in 🙂

eager cape
#

Not really

agile notch
#

Oh I see what else was causing it, a nested class and exports within the class above it

radiant bluff
#

See my message above, I recommend you put that script next to your component and not into it, and once it's compiling again you can import it and work with that