Skip to content
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

Empty JSDocTemplateTag has single type parameter with zero width #36692

Open
dsherret opened this issue Feb 8, 2020 · 9 comments
Open

Empty JSDocTemplateTag has single type parameter with zero width #36692

dsherret opened this issue Feb 8, 2020 · 9 comments

Comments

@dsherret
Copy link
Contributor

@dsherret dsherret commented Feb 8, 2020

TypeScript Version: 3.8.0-dev.20200208

Search Terms: JSDocTemplateTag typeParameters

Code

ts.version; // 3.8.0-dev.20200208
const sourceFile = ts.createSourceFile("test.ts", "/**\n * @template\n */\nlet x;");

console.log(sourceFile.statements[0].jsDoc[0].tags[0].typeParameters);

Expected behavior: Empty array.

Actual behavior: Array with single element: [{pos: 16, end: 16, …}]

image

https://ts-ast-viewer.com/#code/PQKhCgAIUgBAXApgWwA4BsCGSomOdReSADwG4g (select typescript@next and check show internals)

@RyanCavanaugh
Copy link
Member

@RyanCavanaugh RyanCavanaugh commented Feb 26, 2020

This is a pretty normal parse when we encounter syntax where an identifier is mandatory. You'd see the same for e.g.

export { x as }

the second Identifier has an empty span

@dsherret
Copy link
Contributor Author

@dsherret dsherret commented Feb 28, 2020

@RyanCavanaugh I don't believe that's an equivalent example because this is an array. Nowhere else in the AST does this to my knowledge.

This would be like:

export { };

Parsing as:

NamedExports {
    elements: [
        ExportSpecifier {
            pos: 8,
            end: 8,
        }
    ]
}

Instead of:

// (this is what it does and is correct)
NamedExports {
    elements: []
}
@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Mar 4, 2020

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

@sandersn
Copy link
Member

@sandersn sandersn commented Mar 4, 2020

A better example is

class C<> {

}

Which does produce an empty array for typeParameters.

@sandersn sandersn reopened this Mar 4, 2020
@sandersn sandersn added Bug and removed Question labels Mar 4, 2020
@sandersn sandersn added this to the Backlog milestone Mar 4, 2020
@Rustin-Liu
Copy link
Contributor

@Rustin-Liu Rustin-Liu commented Mar 26, 2020

I want to fix it, Can I take this?

@orta
Copy link
Member

@orta orta commented Mar 26, 2020

Give it a shot!

@Ivan-Z
Copy link

@Ivan-Z Ivan-Z commented Apr 26, 2020

@Rustin-Liu are you still working on this? If not, I'd like to take a shot a this.

@Rustin-Liu
Copy link
Contributor

@Rustin-Liu Rustin-Liu commented Apr 26, 2020

@Rustin-Liu are you still working on this? If not, I'd like to take a shot a this.

Please feel free take it.

@michaelhankin
Copy link

@michaelhankin michaelhankin commented May 11, 2020

@Ivan-Z are you still working on this? If not, I'm gonna give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.