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

ℹ Add TypeScript to your project

TL;DR;

npx fitbit-sdk-types apply

That's it. More details on https://github.com/SergioMorchon/fitbit-sdk-types#-automatic-configuration.

If you find any problem or have any question, don't be shy and open an issue!

 

Explanation

I was tired of manually renaming files to .ts, installing the fitbit-sdk-types module and updating the CLI generated tsconfig.json.

So this script just executes automatically the same steps that the developer needed to manually perform.

 

What I tried before

I tried to fork and change the Fitbit projects, but found some stoppers a bit frustrating for me:

  1. The fitbit-sdk-toolchain: the issue I find after trying to collaborate was that there are a lot of jest expectations with *nix file paths using spanshots, that prevents Windows developers to run tests locally. I tried to make some changes that solved most of failing tests (configuring glob to return normalized paths, or changing the snapshot serializers to replace the slashes), but still a lot of assertions kept failing.
  2. The create-fitbit-app is massive, regarding the work you expect for such a tool. It wasn't as simple as adding the 'fitbit-sdk-types' string there in sdkPackageDependencies.
  3. You need both of them working together to just get a project scaffolding.

I'm new on the Create-Cool-Project toolings, and that may be the reason why I found this overcomplicated.

  1. Scaffold the basic folders and files.
  2. Generate Ids etc.
  3. Done.
  4. Let the user to run npm install, or yarn install or whatever. Indeed, I don't use yarn, but the toolchaing generates a yarn lockfile.

My conclusion

Instead of opening PRs, I found more easy to just create a script to run after the official CLI starter steps. So it doesn't get so coupled: just take the output project generated by Fitbit tools and do the same tweaks to make it a TypeScript project.

Best Answer
0 Votes
3 REPLIES 3

Anyway to reverse this process?  I removed all the tsconfig files and converted all the files back to js but now I'm getting a weird error.

 

[15:51:17][error][app] TypeError: Cannot read property 'minify' of undefined

Best Answer
0 Votes

I think that's an unrelated problem. There's something about it in discord.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thanks!  Yep it looks like a dependency "terser" pushed a bad update Friday.  To reverse the Typescript apply I wiped node_modules and reinstalled which got that update and caused the "minify" issue.  Thanks for pointing me in the right direction!  I just manually added "terser" as a devDependancy at an earlier version to fix.

Best Answer
0 Votes