Repository: TypeScript
Issue: TSServer navtree — Way to differentiate function declarations from function expressions
Labels: Suggestion,In Discussion,API,Domain: TSServer

<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
**TypeScript Version:**  3.3.0-dev.20181214

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**
- tsserver
- navtree

**Problem**
For https://github.com/Microsoft/vscode/issues/22981, we'd like a way to differentiate function delcarations from function expressions. Consider a file:

```ts
function foo(f) { }

foo(function bar() { })

const car = function dar(f) { }
```

VS Code uses the `navtree` to get possible code lens locations. We would only like to show references code lenses on `function foo` and perhaps on `const car =`, not on the expression `foo(function bar() {})`.

Using the `navtree` request against the TS Server, we cannot tell function declarations like `foo` from function expressions like `bar` :

```
 {
            "text": "bar",
            "kind": "function",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 3,
                        "offset": 5
                    },
                    "end": {
                        "line": 3,
                        "offset": 23
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 3,
                    "offset": 14
                },
                "end": {
                    "line": 3,
                    "offset": 17
                }
            }
        },
        {
            "text": "dar",
            "kind": "function",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 5,
                        "offset": 13
                    },
                    "end": {
                        "line": 5,
                        "offset": 32
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 5,
                    "offset": 22
                },
                "end": {
                    "line": 5,
                    "offset": 25
                }
            }
        },
        {
            "text": "foo",
            "kind": "function",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 1,
                        "offset": 1
                    },
                    "end": {
                        "line": 1,
                        "offset": 20
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 1,
                    "offset": 10
                },
                "end": {
                    "line": 1,
                    "offset": 13
                }
            }
        }
    ]
```

**Proposal**
Differentiate:

```js
function foo(f) { }
```

by using a kindModifier of `"definition"` or a similar name (or do the inverse and mark `function bar() { }` with a kindModifier of `"expression"`)

Also, we correctly differentiate `car` using ` "kind": "const"` in the case of:

```js
const car = function(f) { }
```

However only `dar` is returned for for:

```js
const car = function dar(f) { }
```