@pacote/immutable

Immutable generic type.

Usage no npm install needed!

<script type="module">
  import pacoteImmutable from 'https://cdn.skypack.dev/@pacote/immutable';
</script>

README

@pacote/immutable

version minified minified + gzip

Generic type for deeply immutable data.

Installation

yarn add @pacote/immutable

Usage

import { Immutable } from '@pacote/immutable'

type Foo = { foo: string }

const mutable: Foo[] = [{ foo: 'bar' }]

// Allowed:
mutable.push({ foo: 'baz' })
mutable[0].foo = 'baz'
delete mutable[0].foo

const immutable: Immutable<Foo[]> = [{ foo: 'bar' }]

// Not allowed:
immutable.push({ foo: 'baz' })
immutable[0].foo = 'baz'
delete immutable[0].foo

License

MIT © Luís Rodrigues.