hughsk / hughsk/flat

`flatten` accepts null/undefined type

Open
#187 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
197
PR merge metrics
No merged PRs in 30d

Description

The signature flatten(target: T, ...): R leaves T unconstrained, so TypeScript lets you pass `null | undefined`. However, at runtime the function expects an object and crashes.

Reproduction: https://playcode.io/2592924

Ideally this is prevented at compile time, by constraining T:
```
export function flatten>(
target: T,
options?: FlattenOptions
): R;
```

Related: https://github.com/hughsk/flat/pull/185

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the TypeScript declaration for the flatten entry point and inspect the signature that leaves T unconstrained. Use the reported Playcode reproduction or the repository's type-checking setup to verify that null and undefined are rejected while valid object targets remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.