Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
tests(ast-spec): makePunctuatorTokenToText more type-safe#3529
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@MichaelDeBoey! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day. |
nx-cloudbot commentedJun 14, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Nx Cloud ReportCI ran the following commands for commit5ef6efb. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 fromNxCloud. |
MichaelDeBoey commentedJun 20, 2021
@bradzacher@JamesHenry Do you have any idea how I can make this error out as explained in the above message? Would love to work on this one further, but don't see a solution right away. |
bradzacher commentedJun 20, 2021
can you do something similar to what I did in this?
|
codecovbot commentedJun 20, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #3529 +/- ##==========================================- Coverage 92.64% 92.63% -0.01%========================================== Files 326 325 -1 Lines 11253 11236 -17 Branches 3171 3168 -3 ==========================================- Hits 10425 10409 -16+ Misses 368 367 -1 Partials 460 460
Flags with carried forward coverage won't be shown.Click here to find out more.
|
MichaelDeBoey commentedJun 20, 2021
@bradzacher I don't see directly how I can use the mentioned test in my use-case tbh. 🤔 A bit more context (or even the test if you like) would be welcome. |
bradzacher commentedJun 20, 2021
//@ts-expect-error: purposely unusedtype_AllKeys={// no error as all PunctuationSyntaxKind are coveredreadonly[TinPunctuationSyntaxKind]:PunctuatorTokenToText[T];};// example showing if we miss one of the PunctuationSyntaxKindinterfaceAccidentallyIncomplete{[SyntaxKind.CaretEqualsToken]:'^=';}//@ts-expect-error: purposely unusedtype_AllKeysError={readonly[TinPunctuationSyntaxKind]:AccidentallyIncomplete[T];// ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Type 'T' cannot be used to index type 'AccidentallyIncomplete'.} |
MichaelDeBoey commentedJun 20, 2021
@bradzacher The problem is, it should already error out as |
bradzacher commentedJun 20, 2021
i forgot to delete it when I copy pasted - but delete the |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
bradzacher left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM - thanks for thsi!
PunctuatorTokenToText more type-safePunctuatorTokenToText more type-safe
Uh oh!
There was an error while loading.Please reload this page.
Follow-up of#3496
We should somehow test that all possible values of
PunctuationSyntaxKindare definitely included.If not, this should error out somehow.
I first tried doing
and this errored out (as expected) because
SyntaxKind.BacktickTokenisn't includes, but is included inPunctuationSyntaxKind.Not including the type makes it also of type
stringagain, which will fail#3461 ආ.This however made it a value instead of a type and had the implication that
SyntaxKind.BarBarEqualsToken,SyntaxKind.AmpersandAmpersandEqualsToken&SyntaxKind.QuestionQuestionEqualsTokencouldn't be added as they'll only be added toPunctuationSyntaxKindin TS 4.4 (they're currently included onmain).In TS 4.4 the new
SyntaxKind.HashTokenshould also be included, so I think it would be nice to have it somehow error out if we don't include that when updating our TS version.@bradzacher@JamesHenry Any idea how I can make this error out when some values aren't included or how I should write a test that can fail when a new value isn't included here?