Skip to content

Generalize missing token hints to more constructs #35597

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

Closed
16 tasks
DanielRosenwasser opened this issue Dec 10, 2019 · 8 comments · Fixed by #36317 or #40884
Closed
16 tasks

Generalize missing token hints to more constructs #35597

DanielRosenwasser opened this issue Dec 10, 2019 · 8 comments · Fixed by #36317 or #40884
Labels
Domain: Error Messages The issue relates to error messaging Domain: Related Error Spans Specifying regions for error messages/diagnostics on multiple locations. Experience Enhancement Noncontroversial enhancements Good First Issue Well scoped, documented and has the green light Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 Suggestion An idea for TypeScript
Milestone

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 10, 2019

@Toxyxer recently fixed #34870. As mentioned:


A great follow-up would be to make this work for

  • } braces in
    • object literals
    • interfaces and object type literals
    • namespaces and augmentations
    • jsx expressions
  • Parentheses in
    • parenthesized expressions
    • parenthesized types
    • argument lists
    • parameter lists
  • Square brackets for
    • arrays
    • element accesses
    • indexed access types
    • tuple types
  • Angle brackets for
    • type parameter lists
    • type argument lists
    • jsx tags
  • For the : in ternaries, eg a ? b : c (maybe?)

Originally posted by @DanielRosenwasser in #34870 (comment)

@DanielRosenwasser DanielRosenwasser added Domain: Error Messages The issue relates to error messaging Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Dec 10, 2019
@DanielRosenwasser DanielRosenwasser added this to the Backlog milestone Dec 10, 2019
@DanielRosenwasser DanielRosenwasser added the Domain: Related Error Spans Specifying regions for error messages/diagnostics on multiple locations. label Dec 10, 2019
@JvPy
Copy link

JvPy commented Dec 10, 2019

I would like to help on this, but I may need help,If thats ok

@Akshaykataria08
Copy link

I would also like to help on this. I want an entry point in the Open Source community

@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Dec 12, 2019
@sheonhan
Copy link
Contributor

Hi @DanielRosenwasser, I created a PR to make this work for closing braces here. #36317

@sheonhan
Copy link
Contributor

sheonhan commented Mar 12, 2020

@sandersn Shouldn't this issue remain open because #36317 only covers the first case?

@sandersn
Copy link
Member

Yep, sorry about that auto-close.

@sandersn sandersn reopened this Mar 13, 2020
ayazhafiz pushed a commit to ayazhafiz/TypeScript that referenced this issue Mar 20, 2020
… types

This commit adds token hints for missing close braces in

- Class definitions
- Enum definitions
- JSX expressions
- Module definitions (this includes augmentations and namespaces)
- Type member lists (this includes interfaces)

The token hint refers to the opening brace for which the parser expected
a corresponding closing brace.

Note that this commit *does not* update all occurences of an expectation
for a close brace to provide token hints. Constructs for which this
token hint is not provided include:

- Mapped types
- Switch statements
- Object binding patterns
- JSX spread attributes (`<div {...props}></div>`)
- JSDoc implements/augments tags (`/* @implements {SomeInterface} */`)

Part of microsoft#35597.
ayazhafiz pushed a commit to ayazhafiz/TypeScript that referenced this issue Mar 20, 2020
… types

This commit adds token hints for missing close braces in

- Class definitions
- Enum definitions
- JSX expressions
- Module definitions (this includes augmentations and namespaces)
- Type member lists (this includes interfaces)

The token hint refers to the opening brace for which the parser expected
a corresponding closing brace.

Note that this commit *does not* update all occurences of an expectation
for a close brace to provide token hints. Constructs for which this
token hint is not provided include:

- Mapped types
- Switch statements
- Object binding patterns
- JSX spread attributes (`<div {...props}></div>`)
- JSDoc implements/augments tags (`/* @implements {SomeInterface} */`)

Part of microsoft#35597.
@ayazhafiz
Copy link
Contributor

Hints for more constructs that may have missing closing braces: #37497.

ayazhafiz pushed a commit to ayazhafiz/TypeScript that referenced this issue Mar 20, 2020
… types

This commit adds token hints for missing close braces in

- Class definitions
- Enum definitions
- JSX expressions
- Module definitions (this includes augmentations and namespaces)
- Type member lists (this includes interfaces)

The token hint refers to the opening brace for which the parser expected
a corresponding closing brace.

Note that this commit *does not* update all occurences of an expectation
for a close brace to provide token hints. Constructs for which this
token hint is not provided include:

- Mapped types
- Switch statements
- Object binding patterns
- JSX spread attributes (`<div {...props}></div>`)
- JSDoc implements/augments tags (`/* @implements {SomeInterface} */`)

Part of microsoft#35597.
ayazhafiz pushed a commit to ayazhafiz/TypeScript that referenced this issue May 14, 2020
… types

This commit adds token hints for missing close braces in

- Class definitions
- Enum definitions
- JSX expressions
- Module definitions (this includes augmentations and namespaces)
- Type member lists (this includes interfaces)

The token hint refers to the opening brace for which the parser expected
a corresponding closing brace.

Note that this commit *does not* update all occurences of an expectation
for a close brace to provide token hints. Constructs for which this
token hint is not provided include:

- Mapped types
- Switch statements
- Object binding patterns
- JSX spread attributes (`<div {...props}></div>`)
- JSDoc implements/augments tags (`/* @implements {SomeInterface} */`)

Part of microsoft#35597.
@sandersn sandersn added the PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 label Sep 18, 2020
@richa008
Copy link
Contributor

richa008 commented Oct 1, 2020

I would like to work on this as a part of Grace Hopper OSD if no one is working on it.

@richa008
Copy link
Contributor

richa008 commented Oct 2, 2020

@DanielRosenwasser, I have 2 questions!!

  1. From what I understand the issue is that parseDiagnostics will not always return the most recent error message? In that case should the de-duping logic be removed?

  2. As per your comment you want the parseErrorAtPosition to create a diagnostic outside of the if (!lastError || start !== lastError.start) and return it always correct? And that needs to be used instead on the last entry in parseDiagnostics. What do you think of keeping a "currentDiagnostic" member variable on the Parser, setting the value in parseErrorAtPosition and using that value in the parseCloseBrace method? That would avoid a significant refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Error Messages The issue relates to error messaging Domain: Related Error Spans Specifying regions for error messages/diagnostics on multiple locations. Experience Enhancement Noncontroversial enhancements Good First Issue Well scoped, documented and has the green light Help Wanted You can do this PursuitFellowship Help wanted from Pursuit fellowship; others please avoid until Dec 19 Suggestion An idea for TypeScript
Projects
None yet
8 participants