Skip to content

Change suggestions to readonly arrays in index.d.ts - #5

Open
Finchasaurus wants to merge 1 commit into
KYRORBLX:mainfrom
Finchasaurus:patch-1
Open

Change suggestions to readonly arrays in index.d.ts#5
Finchasaurus wants to merge 1 commit into
KYRORBLX:mainfrom
Finchasaurus:patch-1

Conversation

@Finchasaurus

Copy link
Copy Markdown
Contributor

This PR changed the suggestions field of Arguments to be readonly, which allows code such as this to work:

const foo = ["a", "b", "c"] as const;
Konsole.define({
	name: "test",
	args: [{ suggestions: foo }],
});

This PR also added a suggestions field of never to Player and Players argument types which allow indexing of arguments through context (ctx.kommand.args[0].suggestions). Previously, TypeScript didn't recognize the suggestions field because it may or may not have been applicable.

Changed suggestions to be readonly arrays and provided suggestion fields for other argument types.
@dullflowerr dullflowerr self-assigned this Jul 22, 2026
Loner1536 added a commit to Loner1536/Konsole that referenced this pull request Jul 24, 2026
…ever-hole on player/players

Konsole never mutates these after handing them back out - Command.args/aliases,
Rank.aliases, KommandModule.schemas(), and the default config's
input.activationKeys/commands.aliases are all live references into internal
tables, so exposing them as mutable arrays let consumers silently corrupt
shared state. Also caught the same "suggestions on player/players" gap
Finchasaurus flagged on the Argument union in KYRORBLX#5 - those variants never read
.suggestions, so it should be excluded there too, not just on string/number/boolean.
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.

2 participants