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`
- Host: GitHub
- URL: https://github.com/hasparus/yoink-ts
- Owner: hasparus
- License: isc
- Created: 2023-10-17T16:04:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T18:53:06.000Z (over 2 years ago)
- Last Synced: 2024-10-19T05:18:14.091Z (over 1 year ago)
- Language: TypeScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 {}
}
}
```