Skip to content

Commit

Permalink
doc(README): Add Observable.create gotcha.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed May 6, 2017
1 parent 56a8af0 commit 4be98ab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,16 @@ The package includes the following rules:
| `rxjs-add` | Enforces the importation of patched observables or operators used in the module. |
| `rxjs-no-add` | Disallows the importation of patched observables and operators. |
| `rxjs-no-unused-add` | Disallows the importation of patched observables or operators that are not used in the module. |
| `rxjs-prefer-add` | Disallows the importation of `rxjs` or `rxjs/Rx`. |
| `rxjs-prefer-add` | Disallows the importation of `rxjs` or `rxjs/Rx`. |

## Gotchas

### `Observable.create`

`Observable.create` is [declared as a `Function`](https://github.com/ReactiveX/rxjs/blob/5.3.1/src/Observable.ts#L46-L58), which means that its return type is `any`. This results in an observable that's not seen by the rules, as they use TypeScript's [TypeChecker](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#using-the-type-checker) to determine whether or not a call involves an observable.

The rule implementations include no special handling for this case, so if spurious errors are effected due to `Observable.create`, explicit typing can resolve them. For example:

```ts
const ob: Observable<number> = Observable.create((observer: Observer<number>) => { ...
```

0 comments on commit 4be98ab

Please sign in to comment.