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

refactor(typescript-estree): add type guards for typescript-estree#3078

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

Closed
armano2 wants to merge17 commits intomasterfromrefactor/converter-types-1

Conversation

@armano2
Copy link
Collaborator

@armano2armano2 commentedFeb 20, 2021
edited
Loading

This PR aims to add proper types to conversion done by typescript-estree

this PR is currently blocked by#2933,#3081

changes from#3081 has been merged to this branch


detected issues with AST so far

LeftHandSideExpression can be aAwaitExpression#3083

consta=++(awaitx)

IntrinsicKeyword is not defined in AST#3081

typeUppercase<Sextendsstring>=intrinsic;

PrivateIdentifier is not defined in AST#2933

classx{ #y}

TryStatement finalizer can benull#3083

try{}catch{}

RegExpLiteral value can benull if regexp is invalid or unsupported by env#3083

good example in this case can be any proposal that has not been accepted yet
eg.https://github.com/tc39/proposal-regexp-match-indices

constx=/a+(?<Z>z)?/d

JSXOpeningElement attributes can be aJSXSpreadAttribute#3083

constfoo=<x{...spread}></x>

TSModuleDeclaration body can beTSModuleDeclaration#3083

// TSModuleDeclaration without bodymodule"x";// TSModuleDeclaration -> TSModuleBlockmodulex{}// TSModuleDeclaration -> TSModuleDeclaration **modulex.x{}

issues that need additional investigation

Type '(PropertyComputedName | PropertyNonComputedName | TSEmptyBodyFunctionExpression | TSAbstractMethodDefinitionComputedName | ... 4 more ... | SpreadElement)[]' is not assignable to type 'ObjectLiteralElementLike[]'.  Type 'PropertyComputedName | PropertyNonComputedName | TSEmptyBodyFunctionExpression | TSAbstractMethodDefinitionComputedName | ... 4 more ... | SpreadElement' is not assignable to type 'ObjectLiteralElementLike'.    Type 'TSEmptyBodyFunctionExpression' is not assignable to type 'ObjectLiteralElementLike'.      Type 'TSEmptyBodyFunctionExpression' is missing the following properties from type 'MethodDefinitionNonComputedName': key, computed, value, static, kind
Type '(PropertyComputedName | PropertyNonComputedName | RestElement | AssignmentPattern)[]' is not assignable to type '(PropertyComputedName | PropertyNonComputedName | RestElement)[]'.  Type 'PropertyComputedName | PropertyNonComputedName | RestElement | AssignmentPattern' is not assignable to type 'PropertyComputedName | PropertyNonComputedName | RestElement'.    Type 'AssignmentPattern' is not assignable to type 'PropertyComputedName | PropertyNonComputedName | RestElement'.      Property 'argument' is missing in type 'AssignmentPattern' but required in type 'RestElement'.

@armano2armano2 added the package: typescript-estreeIssues related to @typescript-eslint/typescript-estree labelFeb 20, 2021
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@armano2!

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.

@codecov
Copy link

codecovbot commentedFeb 20, 2021
edited
Loading

Codecov Report

Merging#3078 (8433bbe) intomaster (509a117) willincrease coverage by0.00%.
The diff coverage is100.00%.

@@           Coverage Diff           @@##           master    #3078   +/-   ##=======================================  Coverage   92.83%   92.83%           =======================================  Files         314      314             Lines       10672    10675    +3       Branches     3027     3027           =======================================+ Hits         9907     9910    +3  Misses        348      348             Partials      417      417
FlagCoverage Δ
unittest92.83% <100.00%> (+<0.01%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
...pt-estree/src/ts-estree/estree-to-ts-node-types.ts100.00% <ø> (ø)
packages/typescript-estree/src/convert.ts98.37% <100.00%> (+<0.01%)⬆️
packages/eslint-plugin/src/rules/no-unused-vars.ts96.66% <0.00%> (-0.03%)⬇️
packages/visitor-keys/src/visitor-keys.ts100.00% <0.00%> (ø)
.../src/rules/sort-type-union-intersection-members.ts92.53% <0.00%> (ø)

@armano2armano2 marked this pull request as draftFebruary 20, 2021 01:20
@armano2armano2 changed the titlefix: improve TSNode typesrefactor(typescript-estree): add type guards for typescript-estreeFeb 20, 2021
@armano2armano2 added the refactorPRs that refactor code only labelFeb 20, 2021
Conflicts:packages/types/src/ts-estree.tspackages/typescript-estree/src/convert.ts
allowPattern?:boolean,
):any{
allowPattern?:P,
):TSESTreeToTSNodeGuard<typeofnode,P>{
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this works the way you think it will - typescript will not parameterise the passed type ofnode, meaning this type will be the same asTSESTreeToTSNodeGuard<TSNodeConvertable, P>

Copy link
CollaboratorAuthor

@armano2armano2Feb 22, 2021
edited
Loading

Choose a reason for hiding this comment

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

yea i know that this type is not going to work, and it seem that there is no easy way around it, for now i just wanted to validate if we are missing anything in ast, best aproach i can think of is

privateconvertJSXTagName<Textendsts.JsxTagNameExpression>(node:T,parent:ts.Node,):Textendsts.JsxTagNamePropertyAccess    ?TSESTree.JSXMemberExpression    :Textendsts.ThisExpression|ts.Identifier    ?TSESTree.JSXIdentifier    :TSESTree.JSXMemberExpression|TSESTree.JSXIdentifier;privateconvertJSXTagName(node:ts.JsxTagNameExpression,parent:ts.Node,):TSESTree.JSXMemberExpression|TSESTree.JSXIdentifier{

different function but same issue

Copy link
CollaboratorAuthor

@armano2armano2Feb 22, 2021
edited
Loading

Choose a reason for hiding this comment

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

https://www.typescriptlang.org/play?ts=4.1.5#code/JYOwLgpgTgZghgYwgAgEJwM4QHIHsAmKA3gLABQylykGYAjAFzK1SgDm5AvueaJLIhR5CdZBAAekEPgxpMOAsXJVkAa1D4mdZVRi5cTFuy48yfaPCTJhEAExjJEabPRYbyUhSrrpTWzsoAIzgoQzBWEA4ybjJyAHo45ABaFNS09IzMrNMYAFcQBDBgXBBqCFpRAAoQRSYbUQAfa0VbAEomMABPAAcIXBhkGsIHKRlmkWQAfmQAcjoZ5A6evoGhlAlR2Rt7aZnbBaYQXIAbY48A5GAB6sUAOh98ZABeF+Q6VvOvFUo1271cZ6zeYXFQJZAAATAGCSEl6hRhUCguCgIKov2CUEBcxmqMoUAgYFyUFK2IunDExywl2uvwez1ebU+3zRdwxWP2uOQYMh0NhEHh0CRKK+31+-3ZOJFKnxhOJsw5Ipi0oJRNKR1OJliZDBWV1et1OXyhWKpRoYFsAB4ACojJxjerIJrbAB8yBuhCYVvayBtGztW0Uol280WPttznGdim8oOgxOZ08KiubtpGnpTzeH0TzMGd3FGdJUqo3KhMPEcLACKFnPRISxwKLeJVcsLKnJEEpKGT7og9zTLwzjOzzNrmILCpzXMSPLLFaryJref0Es5MtVMbJFzXcvVx018US+qPx9MhAQxxCKDyBSKJUuGHqPaYcBAnW9a3vke0ZDPF-xyGvY072AB8WifZAXzfQ5FE-bZTHIQDb1NcpzWtcN7UDR1I1sV1wK9T10IDCZg1jX1HAjbZoz2WNdyZKhuxAx81laLNF0IP5lwLBtJxLXly35StBQXRtc3YtkuMlSdtxJbiqHbTtqTdRiwOY1iRNHFcRN42cBPnYVJzFTiNxE6TjLbLdmzVeNNSAA

@armano2armano2 deleted the refactor/converter-types-1 branchFebruary 22, 2021 05:12
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMar 25, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@bradzacherbradzacherbradzacher left review comments

Assignees

No one assigned

Labels

package: typescript-estreeIssues related to @typescript-eslint/typescript-estreerefactorPRs that refactor code only

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@armano2@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp