Skip to content

fix(types): resolve TS2411 errors under strict TypeScript settings#1

Open
nbouvrette wants to merge 1 commit intoimportantimport:mainfrom
nbouvrette:main
Open

fix(types): resolve TS2411 errors under strict TypeScript settings#1
nbouvrette wants to merge 1 commit intoimportantimport:mainfrom
nbouvrette:main

Conversation

@nbouvrette
Copy link

Summary

  • Change index signatures from [k: string]: string to [k: string]: string | undefined in three locations (engines, volta, esnext object variant) in src/types.d.ts
  • Under strict TypeScript, optional named properties have type string | undefined, which conflicts with an index signature typed as [k: string]: string, producing TS2411 errors
  • Widening the index signature to string | undefined resolves all four errors

Errors fixed

dist/index.d.ts(277,5): error TS2411: Property 'node' of type 'string | undefined' is not assignable to 'string' index type 'string'.
dist/index.d.ts(287,5): error TS2411: Property 'extends' of type 'string | undefined' is not assignable to 'string' index type 'string'.
dist/index.d.ts(356,9): error TS2411: Property 'main' of type 'string | undefined' is not assignable to 'string' index type 'string'.
dist/index.d.ts(357,9): error TS2411: Property 'browser' of type 'string | undefined' is not assignable to 'string' index type 'string'.

Changes

Type Location Optional property
engines line ~278 node?: string
volta line ~292 extends?: string
esnext object variant line ~358 main?: string, browser?: string

Note on source

src/types.d.ts is auto-generated from the upstream JSON Schema at schemastore.org via pnpm build:upstream. Since the upstream schema cannot be changed here, the fix is applied directly to the generated source file — consistent with the existing src/patch/ pattern used in this repo.

🤖 Generated with Claude Code

Change index signatures from `[k: string]: string` to
`[k: string]: string | undefined` in three locations:
- `engines` object (node? optional property)
- `volta` object (extends? optional property)
- `esnext` object variant (main? and browser? optional properties)

Under strict TypeScript, optional named properties have type
`string | undefined`, which is incompatible with an index signature
typed as `[k: string]: string`. Widening the index signature to
`string | undefined` resolves all four TS2411 errors.

Fixes:
- TS2411: Property 'node' of type 'string | undefined' is not assignable to 'string' index type 'string'.
- TS2411: Property 'extends' of type 'string | undefined' is not assignable to 'string' index type 'string'.
- TS2411: Property 'main' of type 'string | undefined' is not assignable to 'string' index type 'string'.
- TS2411: Property 'browser' of type 'string | undefined' is not assignable to 'string' index type 'string'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant