Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(experimental-utils): fixeslint-utils' negative predicates' return types inast-utils#3461

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

Merged
bradzacher merged 1 commit intotypescript-eslint:masterfromMichaelDeBoey:patch-8
Jun 17, 2021

Conversation

@MichaelDeBoey
Copy link
Contributor

Just like it's done withisNotCommentToken

constisNotCommentToken=eslintUtils.isNotCommentTokenas(
token:TSESTree.Token,
)=>token isExclude<TSESTree.Token,TSESTree.Comment>;

@typescript-eslint
Copy link
Contributor

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.

@MichaelDeBoeyMichaelDeBoeyforce-pushed thepatch-8 branch 2 times, most recently from12b9c08 to3547451CompareJune 4, 2021 17:10
@bradzacherbradzacher added the repo maintenancethings to do with maintenance of the repo, and not with code/docs labelJun 4, 2021
@bradzacher
Copy link
Member

bradzacher commentedJun 6, 2021
edited
Loading

While Idefinitely like the idea of this, ultimately this doesn't actually do anything.

The type ofToken['value'] isstring.
Because TypeScript doesn't support exclusions from the primitive types -Excludes<string, '=>'> just results instring.

Exclude<TSESTree.Token, TSESTree.Comment> OTOH does do something asComment is a distinct type in the union, which can be excluded.

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelJun 6, 2021
@MichaelDeBoey
Copy link
ContributorAuthor

MichaelDeBoey commentedJun 7, 2021
edited
Loading

@bradzacher You think there's another way of getting the correct type then?

Edit: postedhttps://twitter.com/MichaelDeBoey93/status/1401920255404953604 to get some help

@bradzacher
Copy link
Member

bradzacher commentedJun 7, 2021
edited
Loading

There is unfortunately not right now.
There was a TS issue about "negative" types a while back. It's something the TS team has thought about but has not implemented.

Edit: orta dug up the issue:microsoft/TypeScript#29317

@MichaelDeBoey
Copy link
ContributorAuthor

MichaelDeBoey commentedJun 7, 2021
edited
Loading

@bradzachermicrosoft/TypeScript#29317 is the issue as mentioned by@orta inhttps://twitter.com/orta/status/1401934733634846723

So there's no other way to do this then?
Not even when it's a complicated way?

@bradzacher Making thevalue ofPunctuatorToken equal to'=>' | '}' | ']' | ')' | ':' | ',' | '{' | '[' | ... for instance? 🤔

interfacePunctuatorTokenextendsBaseToken{type:AST_TOKEN_TYPES.Punctuator;value:'=>'|'}'|']'|')'|':'|','|'{'|'['| ...;}

@bradzacher
Copy link
Member

Correct, but then we would have to attempt to list out every single possible token string and keep it up to date.

Not an impossible task, just a (relatively) low value one.

Also it's not a great thing because custom parsers (babel, Vue, markdown, angular) may add new tokens, which then causes our types to be wrong. By-and-large our rules shouldn't make assumptions about the parser.

@MichaelDeBoey
Copy link
ContributorAuthor

@bradzacher This PR adds type-safety and type guards for those functions.
I know I'm biased, but I think the "low value maintenance" of thevalue type is subordinate to the extra value you get from having the type guards I think?

What do you think?
Should we proceed here?

I'm happy to create another PR to update thevalue type if that's preferred btw.

@nx-cloud
Copy link

nx-cloudbot commentedJun 12, 2021
edited
Loading

Nx Cloud Report

CI ran the following commands for commit0127fc9. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

StatusCommand
#000000nx run-many --target=build --all --parallel
#000000nx run-many --target=typecheck --all --parallel

Sent with 💌 fromNxCloud.

@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelJun 13, 2021
@MichaelDeBoey
Copy link
ContributorAuthor

@bradzacher Now that#3496 is merged, this one can be merged too I think?

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

yup - looks good now and it should all work!!

MichaelDeBoey reacted with thumbs up emoji
@bradzacherbradzacher merged commit614b0a3 intotypescript-eslint:masterJun 17, 2021
@MichaelDeBoeyMichaelDeBoey deleted the patch-8 branchJune 17, 2021 08:22
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 18, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees

No one assigned

Labels

repo maintenancethings to do with maintenance of the repo, and not with code/docs

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@MichaelDeBoey@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp