Skip to content

Conversation

@david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Oct 15, 2024

I noticed while working on #2361 that instanceCan allows any string as a key, which means you can do instanceCan.detaaaaaach(instance) and not get a type error. The goal here was to make that a type error without affecting the API, so we don't have to change any call sites. After some back and forth with myself around several ways one could make this work, I landed on this, which is more verbose than I prefer, but it's fine. I did it.

Rather than try to explain the other stuff I tried, here is a fun and exciting video of me suffering.

2024-10-15-typescript-pain.mp4

@vercel
Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Oct 15, 2024 7:37pm

// @ts-expect-error typechecker rejects actions that don't exist
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
diskCan.abc
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the @ts-expect-errors fail on main:

Screenshot 2024-10-15 at 2 03 47 PM

@david-crespo
Copy link
Collaborator Author

Well, recording that video made me realize how to do it the nice way. So that's nice.

@david-crespo david-crespo enabled auto-merge (squash) October 15, 2024 19:34
@david-crespo david-crespo merged commit 226d421 into main Oct 15, 2024
@david-crespo david-crespo deleted the refactor-can-test branch October 15, 2024 19:46
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