Microsoft/TypeScript

Return namespan on default exports

Aperta

#48.675 aperta il 13 apr 2022

 (0 commenti) (0 reazioni) (0 assegnatari)TypeScript (13.395 fork)batch import
Experience EnhancementHelp WantedSuggestion

Metriche repository

Star
 (108.860 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor