Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example as FAQ #42

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,18 @@ You can skip the whole `node_modules` by adding to `tsconfig.json`:
}
}
```

### Checking the type of the return value

To check the return value of a library, simply set the type to the variable in your `index.d.ts`:

```ts
const test: string = await myFunction();
```

If the function only returns a string a never a number, then this will fail:

```ts
// FAILS
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use different control comment for errors. And we need to add error text to it (to be sure that it is exactly the conflict with return type

const test: number = await myFunction();
```