An open API service indexing awesome lists of open source software.

https://github.com/hasparus/yoink-ts

print a type of a value into an existing file to avoid circular `any`
https://github.com/hasparus/yoink-ts

Last synced: 10 months ago
JSON representation

print a type of a value into an existing file to avoid circular `any`

Awesome Lists containing this project

README

          

This would have been just a `ReturnType`, but I needed to
declaration merge the inferred result with `process.env` which was used inside of the function, resulting in `any`.

```js
// env.mjs
const env = required({
SOME_ENV_VAR: process.env.SOME_ENV_VAR,
});
```

```ts
// types.d.ts
import { env } from "./env.mjs";

interface Env {
SOME_ENV_VAR: string;
}
declare global {
namespace NodeJS {
interface ProcessEnv extends Env {}
}
}
```