You can use these paths in both of CommonJS style and ES Module style.
// Import functions and types which you would like to use:
import { type Maybe } from 'option-t/maybe';
import { type Nullable, isNotNull } from 'option-t/nullable';
import { type Undefinable } from 'option-t/undefinable';
import { type Result, createOk, isOk } from 'option-t/plain_result';
// You can also use `<TypeName>.<operatorName>`
import { Nullable } from 'option-t/nullable/namespace';
declare let numberOrNull: Nullable.Nullable<number>;
// IntelliSense can suggest and narrow down by the order of Type -> related operations.
const some = Nullable.unwrapOr(numberOrNull, -1);
// You can import only a specific function by the more detailed path.
import { type Nullable, unwrapNullable } from 'option-t/nullable/nullable';
import { unwrapOrForNullable } from 'option-t/nullable/unwrap_or';
- If your project use TypeScript, you need to set TypeScript's
--moduleResolution
withbundler
,node16
or other values that enables to supportexports
field in package.json.- If your project still use TypeScript's
--moduleResolution
withnode/node10
setting, please usev35
.
- If your project still use TypeScript's