google / google/gts

Documentation is missing

Open
#416 3 comments 0 reactions 0 assignees View on GitHub
type: docs
Dominant language
TypeScript
Stars
5.3k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

@alexeagle mentioned that the TS style guide has lots of documentation, but it doesn't seem like any of that is available here.
The most common issue we run into is type coercion. Apparently this is what the docs for that should say:
TypeScript code may use the `String()` and `Boolean()` (note: no `new`!) functions, string template literals, or `!!` to coerce types.

```ts
const bool = Boolean(false);
const str = String(aNumber);
const bool2 = !!str;
const str2 = `result: ${bool2}`;
```
Using string concatenation to cast to string is discouraged, as we check that operands to the plus operator are of matching types.

Code must use `Number()` to parse numeric values, and must check its return for `NaN` values explicitly, unless failing to parse is impossible from context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.