Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non keywords not inferred in some chained at cases #1288

Open
ssalbdivad opened this issue Feb 2, 2025 · 0 comments
Open

Non keywords not inferred in some chained at cases #1288

ssalbdivad opened this issue Feb 2, 2025 · 0 comments

Comments

@ssalbdivad
Copy link
Member

ssalbdivad commented Feb 2, 2025

const m2 = match.in<{ id: 0 | 1 | 2 }>().at("id", {
  // Parameter 'o' implicitly has any type
  "0": (o) => o.id,
  // correctly inferred
  number: (o) => o.id,
});

// can be resolved with explicit annotation
const m = match.in<{ id: 0 | 1 | 2 }>().at("id", {
	"0": (o: { id: 0 }) => o.id
})

// or better yet, just chain the `.match` off `.at`instead of using the second param

const m = match
	.in<{ id: 0 | 1 | 2 }>()
	.at("id")
	.match({
		"0": o => o.id,
		// correctly inferred
		number: o => o.id
	})

My instinct says this may be fixable but the validation + completions setup here is already quite temperamental, so leaving it as is for now.

@github-project-automation github-project-automation bot moved this to To do in arktypeio Feb 2, 2025
@ssalbdivad ssalbdivad moved this from To do to Backlog in arktypeio Feb 4, 2025
@ssalbdivad ssalbdivad changed the title Non keywords not inferred in some chained at cases: Non keywords not inferred in some chained at cases Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant