+
Skip to content

Commas in export can cause findExports / findExportNames to add incorrect export #303

Open
@cjpearson

Description

@cjpearson

Environment

mlly@1.7.4
node v22.13.0

Reproduction

> findExports(`export const foo: Handler<string, number> = function foo(){}`)
[
  {
    type: 'declaration',
    declaration: 'const',
    name: 'foo',
    code: 'export const foo: Handler<string, number',
    start: 0,
    end: 40,
    names: [ 'foo', 'number' ],
    declarationType: 'const'
  }
]
> findExportNames(`export const foo: Handler<string, number> = function foo(){}`)
[ 'foo', 'number' ]
>

Describe the bug

I ran into a case where mlly is picking up an extra export name from a TypeScript generic argument. The comma appears to be the main suspect here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载