Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting up typescript project problems

Hello world.

 

New here. Just started developing a game for fitbit. First I used fitbit studio and made a working prototype in js. But then I read typescript was supported. New on ts and wanted to get used to it for my job. Had trouble getting even console to work.

But then I found this: https://community.fitbit.com/t5/SDK-Development/TypeScript-support/td-p/2990908

And set up the project locally with node and VSStudio. Got the console to work with writing outputs. Still I get css warnings for new fitbit stuff like text-length/x/y (unkown property).

But even worse, how to use style on an element?

 

this.hud = document.getElementById("hud")!
this.hud.style.visibility = "hidden";​

 

Get the error: "Property 'style' does not exist on type 'Element'.ts(2339)"

Should I use HTMLElement somehow?
Best Answer
0 Votes
3 REPLIES 3

No answer and just found out about the tiny js memory.


Ok I guess ts is not worth it with only 64k memory. Going back to js and try to simplify things.

Best Answer
0 Votes

You can checkout the #typescript channel on Discord, our resident expert Sergius can probably give some advice. I know there's some specific optimizations which can help reduce memory overhead.

Best Answer
0 Votes

That's because `getElementById` returns just `Element`s that may or may not be `GraphicElement`, the ones that habe the `.style` property.

See an example of what you have to do: https://github.com/SergioMorchon/fitbit-sdk-types/blob/master/test-code-samples/app/user-interface/m...

 

`document.getElementById('demo') as GraphicsElement `

Best Answer