josdejong / josdejong/mathjs

Easier types when working with "create"

Open
#2,322 1 comment 0 reactions 0 assignees View on GitHub
bug help wanted typescript
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I followed the [custom bundling](https://mathjs.org/docs/custom_bundling.html) docs and created my own instance of math.js, like this:

```ts
const math = create({ addDependencies, bignumberDependencies, divideDependencies, meanDependencies }, config);
const mbn = this.math.bignumber!;
```

What I don't like is that I have to use the `!` non-null assertion operator, even if it is clear that the `bignumber` property should be non-null (as per the `bignumberDependencies` object passed to `create`).

I further had to disable the [@typescript-eslint/no-non-null-assertion](https://github.com/typescript-eslint/typescript-eslint/blob/13b7de508e0f8eac492879ff9ab99acd8d3e977e/packages/eslint-plugin/docs/rules/no-non-null-assertion.md) ESLint rule, because the lint task was failing.

My feature request: let the compiler know that the objects returned by `create` are non-null, based on the inputs provided.

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.