1.0.17 • Published 3 years ago

@ergodark/next-types v1.0.17

Weekly downloads
3
License
Unlicense
Repository
github
Last release
3 years ago

npm
version

@ergodark/next-types

This package contains various utility and helper types that can be imported by a Next.js project.

This package only contains TypeScript types. This package also exports all the types from @ergodark/types, so there is no need to install both packages.

Install

npm install @ergodark/next-types

Usage

You can use this library's types in your TypeScript projects like so:

import type { TypeNameHere } from '@ergodark/next-types'

const variable: TypeNameHere;
import type * as ErgoDark from '@ergodark/next-types'

const variable: ErgoDark.TypeNameHere;

Type Glossary

Along with the types exposed by @ergodark/types, this library provides the following types:

NextParamsRR<T>

Represents an object with well-defined NextApiRequest and NextApiResponse properties where generic type T is passed to NextApiResponse<T>.

Specifying T is optional. By default, T = Record<string, unknown>.

import type { NextParamsRR } from '@ergodark/next-types'

export async function addToRequestLog({ req, res }: NextParamsRR) {
    ...
}

WithConfig<T>

Adds a config property to type T. Useful for dealing with Next endpoints that require custom configuration when writing unit tests.

import * as Endpoint from 'pages/api-endpoint'

import type { WithConfig } from '@ergodark/next-types'

const endpoint: WithConfig<typeof Endpoint.default> = Endpoint.default;
endpoint.config = Endpoint.config;

Contributing

Issues and pull requests are welcome! In lieu of a formal styleguide, take care to maintain the existing coding style.

Please test your code!

Release History

  • 1.0.x Initial release
1.0.17

3 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago