Microsoft/TypeScript

Return namespan on default exports

Open

#48,675 opened on Apr 13, 2022

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
Experience EnhancementHelp WantedSuggestion

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (Avg merge 6d 17h) (9 merged PRs in 30d)

Description

Bug Report

🔎 Search Terms

  • navTree
  • Outline
  • nameSpan

🕗 Version & Regression Information

4.7-beta

Not a regression

Related issues

  • #48674

💻 Code

For the code:

// index.ts
import bla from './index'

export default 123;
  1. Look at the navtree response for the document and look at the entry for the export

🙁 Actual behavior

The entry for the default export does not set a nameSpan:

[Trace  - 19:20:39.65] <syntax> Response received: getOutliningSpans (346). Request took 1 ms. Success: true 
Result: []
[Trace  - 19:20:39.117] <syntax> Sending request: navtree (347). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san/index.ts"
}
[Trace  - 19:20:39.118] <syntax> Response received: navtree (347). Request took 1 ms. Success: true 
Result: {
    "text": "\"index\"",
    "kind": "module",
    "kindModifiers": "",
    "spans": [
        {
            "start": {
                "line": 1,
                "offset": 1
            },
            "end": {
                "line": 4,
                "offset": 21
            }
        }
    ],
    "childItems": [
        {
            "text": "default",
            "kind": "const",
            "kindModifiers": "export",
            "spans": [
                {
                    "start": {
                        "line": 4,
                        "offset": 1
                    },
                    "end": {
                        "line": 4,
                        "offset": 20
                    }
                }
            ]
        },
        {
            "text": "bla",
            "kind": "alias",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 2,
                        "offset": 8
                    },
                    "end": {
                        "line": 2,
                        "offset": 11
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 2,
                    "offset": 8
                },
                "end": {
                    "line": 2,
                    "offset": 11
                }
            }
        }
    ]
}

🙂 Expected behavior

On the default export, a namespan is set for the span of default

This is something VS Code computes itself today. It helps us implement the references code lens

Contributor guide