fitbit-sdk-types
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "fitbit-sdk-types", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Types for Fitbit SDK.", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "tsc -p test", | ||
@@ -26,3 +25,2 @@ "prettier": "prettier **/*.ts **/*.tsx **/*.json **/*.md", | ||
"typescript", | ||
"definition", | ||
"fitbit", | ||
@@ -29,0 +27,0 @@ "sdk" |
@@ -1,2 +0,2 @@ | ||
# Fitbit SDK Types | ||
# Fitbit SDK Types ✔ | ||
@@ -6,8 +6,8 @@ [](https://badge.fury.io/js/fitbit-sdk-types) | ||
Add types to your Fitbit project to use safely the SDK, work safely with TypeScript preventing you of doing stupid mistakes. | ||
Add types to your Fitbit CLI project and work safely with TypeScript preventing you of doing stupid mistakes. | ||
## How to use in your app project | ||
## ⚙ How to use in your app project | ||
1. Execute `npm install --save-dev fitbit-sdk-types` to add this type definitions. | ||
2. `include` them in your project's `tsconfig.json` file. It sould look like this **tsconfig.json**: | ||
2. `include` them in your project's `tsconfig.json` file. It may look like this **tsconfig.json**: | ||
@@ -17,3 +17,3 @@ ```json | ||
"extends": "./node_modules/@fitbit/sdk/sdk-tsconfig.json", | ||
"include": ["node_modules/fitbit-sdk-types/src", "./**/*.ts", "./**/*.tsx"] | ||
"include": ["node_modules/fitbit-sdk-types/src", "**/*.ts", "**/*.tsx"] | ||
} | ||
@@ -32,2 +32,25 @@ ``` | ||
## Benefits of using types | ||
### Discoverability | ||
Know what is available to build your ideas right from your code. | ||
**Enumerated and strict string literals** | ||
 | ||
**Also in JSX for settings** | ||
 | ||
### Integrated with the Fitbit CLI build process | ||
It is fully integrated within the Fitbit CLI build process that _already_ uses TypeScript. With this approach you are just _extending_ its knowledge about what can you use and how. | ||
So if your code is not ok, then it won't build. That way it will prevent you from wasting a lot of time with typos, undefined functions and trivial bugs, letting you focus on what really matters. | ||
**Code error, so the build process fails** | ||
 | ||
## Examples | ||
@@ -39,2 +62,14 @@ | ||
- 🧐 **To have a _full type experience_**: add the `strict` mode to your **tsconfig.json**: | ||
```json | ||
{ | ||
"extends": "./node_modules/@fitbit/sdk/sdk-tsconfig.json", | ||
"compilerOptions": { | ||
"strict": true | ||
}, | ||
"include": ["node_modules/fitbit-sdk-types/src", "**/*.ts", "**/*.tsx"] | ||
} | ||
``` | ||
- **Avoid using `any` in callbacks of defined functions**: | ||
@@ -49,2 +84,10 @@ TypeScript will give it the correct type, but only if you let it be. If you cast them as any other type, you could be hiding errors (either in your code or in this type definition, or even in the official documentation). | ||
Make a PR submitting _at least_ the desired test examples to work under the `.test` path, ideally with some link to any of the Fitbit official sources to get more info. | ||
### ❗ Open an issue | ||
If you have a question, suggestion or bug report, don't be shy and open an issue 🎈. | ||
### 💪 Make a PR with: | ||
1. The use cases you think that must be covered, under a meaningful section inside **tests/**. | ||
1. The type definition in the appropiate **src/** file. | ||
1. If possible, a link to the official documentation or community forum thread. |
declare module 'geolocation' { | ||
type WatchId = number; | ||
interface PositionErrorCallback {} | ||
interface PositionCallback {} | ||
interface PositionErrorCallback { | ||
(error: PositionError): void; | ||
} | ||
interface PositionCallback { | ||
(position: Position): void; | ||
} | ||
interface Geolocation { | ||
@@ -6,0 +10,0 @@ clearWatch(watchId: WatchId): void; |
35712
89
45
1212