# mod.ts
export let s = "hello";
export let n = 123;
export let b = false;
export let bi = 100n;
export let re = /hello/;
export let tpl = `foobar`;
export let complexTpl = `f${true ? "a" : 1}${true ? "b" : null}o${"c"}${1}o`;

export function test() {
  console.log("hello");
}

export async function testAsync() {
  await Promise.resolve(2);
}

export function cannotInfer() {
  if (true) {
    return something();
  }
}

export async function cannotInferAsync() {
  for (var test of testing) {
    return await something();
  }
}

export function* cannotInferGenerator() {
}

export class MyClass {
  infer() {
  }
  async inferAync() {
  }

  cannotInfer() {
    for (var i = 0; i < 10; i++) {
      return something();
    }
  }

  async cannotInferAsync() {
    return await something();
  }

  *cannotInferGenerator() {
  }
}

export namespace MyNamespace {
  // should not infer because does not have a body
  declare function cannotInfer();
}

# diagnostics
error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:1:12
  | 
1 | export let s = "hello";
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:2:12
  | 
2 | export let n = 123;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:3:12
  | 
3 | export let b = false;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:4:12
  | 
4 | export let bi = 100n;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:5:12
  | 
5 | export let re = /hello/;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:6:12
  | 
6 | export let tpl = `foobar`;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:7:12
  | 
7 | export let complexTpl = `f${true ? "a" : 1}${true ? "b" : null}o${"c"}${1}o`;
  |            ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
 --> /mod.ts:9:1
  | 
9 | export function test() {
  | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:13:1
   | 
13 | export async function testAsync() {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:17:1
   | 
17 | export function cannotInfer() {
   | ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:17:1
   | 
17 | export function cannotInfer() {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:23:1
   | 
23 | export async function cannotInferAsync() {
   | ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:23:1
   | 
23 | export async function cannotInferAsync() {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:29:1
   | 
29 | export function* cannotInferGenerator() {
   | ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:29:1
   | 
29 | export function* cannotInferGenerator() {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:32:1
   | 
32 | export class MyClass {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:33:3
   | 
33 |   infer() {
   |   ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:35:3
   | 
35 |   async inferAync() {
   |   ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:38:3
   | 
38 |   cannotInfer() {
   |   ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:38:3
   | 
38 |   cannotInfer() {
   |   ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:44:3
   | 
44 |   async cannotInferAsync() {
   |   ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:44:3
   | 
44 |   async cannotInferAsync() {
   |   ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:48:3
   | 
48 |   *cannotInferGenerator() {
   |   ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:48:3
   | 
48 |   *cannotInferGenerator() {
   |   ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:52:1
   | 
52 | export namespace MyNamespace {
   | ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
  --> /mod.ts:54:3
   | 
54 |   declare function cannotInfer();
   |   ^


error[missing-return-type]: exported function is missing an explicit return type annotation
  --> /mod.ts:54:3
   | 
54 |   declare function cannotInfer();
   |   ^

# output.txt
Defined in file:///mod.ts:16:1

function cannotInfer()

Defined in file:///mod.ts:22:1

async function cannotInferAsync()

Defined in file:///mod.ts:28:1

function* cannotInferGenerator()

Defined in file:///mod.ts:8:1

function test(): void

Defined in file:///mod.ts:12:1

async function testAsync(): Promise<void>

Defined in file:///mod.ts:2:12

let b: boolean

Defined in file:///mod.ts:3:12

let bi: bigint

Defined in file:///mod.ts:6:12

let complexTpl: `f${string | number}${string | null}o${string}${number}o`

Defined in file:///mod.ts:1:12

let n: number

Defined in file:///mod.ts:4:12

let re: RegExp

Defined in file:///mod.ts:0:12

let s: string

Defined in file:///mod.ts:5:12

let tpl: `foobar`

Defined in file:///mod.ts:31:1

class MyClass

  infer(): void
  async inferAync(): Promise<void>
  cannotInfer()
  async cannotInferAsync()
  *cannotInferGenerator()

Defined in file:///mod.ts:51:1

namespace MyNamespace

  function cannotInfer()


# output.json
{
  "symbols": [
    {
      "name": "s",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 0,
            "col": 11,
            "byteIndex": 11
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "string",
              "kind": "keyword",
              "value": "string"
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "n",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 1,
            "col": 11,
            "byteIndex": 35
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "number",
              "kind": "keyword",
              "value": "number"
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "b",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 2,
            "col": 11,
            "byteIndex": 55
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "boolean",
              "kind": "keyword",
              "value": "boolean"
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "bi",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 3,
            "col": 11,
            "byteIndex": 77
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "bigint",
              "kind": "keyword",
              "value": "bigint"
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "re",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 4,
            "col": 11,
            "byteIndex": 99
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "hello",
              "kind": "typeRef",
              "value": {
                "typeName": "RegExp"
              }
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "tpl",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 5,
            "col": 11,
            "byteIndex": 124
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "foobar",
              "kind": "literal",
              "value": {
                "kind": "template",
                "tsTypes": [
                  {
                    "repr": "foobar",
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": "foobar"
                    }
                  }
                ]
              }
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "complexTpl",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 6,
            "col": 11,
            "byteIndex": 151
          },
          "declarationKind": "export",
          "kind": "variable",
          "def": {
            "tsType": {
              "repr": "f${string | number}${string | null}o${string}${number}o",
              "kind": "literal",
              "value": {
                "kind": "template",
                "tsTypes": [
                  {
                    "repr": "f",
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": "f"
                    }
                  },
                  {
                    "kind": "union",
                    "value": [
                      {
                        "repr": "string",
                        "kind": "keyword",
                        "value": "string"
                      },
                      {
                        "repr": "number",
                        "kind": "keyword",
                        "value": "number"
                      }
                    ]
                  },
                  {
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": ""
                    }
                  },
                  {
                    "kind": "union",
                    "value": [
                      {
                        "repr": "string",
                        "kind": "keyword",
                        "value": "string"
                      },
                      {
                        "repr": "null",
                        "kind": "keyword",
                        "value": "null"
                      }
                    ]
                  },
                  {
                    "repr": "o",
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": "o"
                    }
                  },
                  {
                    "repr": "string",
                    "kind": "keyword",
                    "value": "string"
                  },
                  {
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": ""
                    }
                  },
                  {
                    "repr": "number",
                    "kind": "keyword",
                    "value": "number"
                  },
                  {
                    "repr": "o",
                    "kind": "literal",
                    "value": {
                      "kind": "string",
                      "string": "o"
                    }
                  }
                ]
              }
            },
            "kind": "let"
          }
        }
      ]
    },
    {
      "name": "test",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 8,
            "col": 0,
            "byteIndex": 219
          },
          "declarationKind": "export",
          "kind": "function",
          "def": {
            "params": [],
            "returnType": {
              "repr": "void",
              "kind": "keyword",
              "value": "void"
            },
            "hasBody": true
          }
        }
      ]
    },
    {
      "name": "testAsync",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 12,
            "col": 0,
            "byteIndex": 271
          },
          "declarationKind": "export",
          "kind": "function",
          "def": {
            "params": [],
            "returnType": {
              "repr": "Promise",
              "kind": "typeRef",
              "value": {
                "typeParams": [
                  {
                    "repr": "void",
                    "kind": "keyword",
                    "value": "void"
                  }
                ],
                "typeName": "Promise"
              }
            },
            "hasBody": true,
            "isAsync": true
          }
        }
      ]
    },
    {
      "name": "cannotInfer",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 16,
            "col": 0,
            "byteIndex": 338
          },
          "declarationKind": "export",
          "kind": "function",
          "def": {
            "params": [],
            "hasBody": true
          }
        }
      ]
    },
    {
      "name": "cannotInferAsync",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 22,
            "col": 0,
            "byteIndex": 415
          },
          "declarationKind": "export",
          "kind": "function",
          "def": {
            "params": [],
            "hasBody": true,
            "isAsync": true
          }
        }
      ]
    },
    {
      "name": "cannotInferGenerator",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 28,
            "col": 0,
            "byteIndex": 525
          },
          "declarationKind": "export",
          "kind": "function",
          "def": {
            "params": [],
            "hasBody": true,
            "isGenerator": true
          }
        }
      ]
    },
    {
      "name": "MyClass",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 31,
            "col": 0,
            "byteIndex": 570
          },
          "declarationKind": "export",
          "kind": "class",
          "def": {
            "methods": [
              {
                "name": "infer",
                "kind": "method",
                "functionDef": {
                  "params": [],
                  "returnType": {
                    "repr": "void",
                    "kind": "keyword",
                    "value": "void"
                  },
                  "hasBody": true
                },
                "location": {
                  "filename": "file:///mod.ts",
                  "line": 32,
                  "col": 2,
                  "byteIndex": 595
                }
              },
              {
                "name": "inferAync",
                "kind": "method",
                "functionDef": {
                  "params": [],
                  "returnType": {
                    "repr": "Promise",
                    "kind": "typeRef",
                    "value": {
                      "typeParams": [
                        {
                          "repr": "void",
                          "kind": "keyword",
                          "value": "void"
                        }
                      ],
                      "typeName": "Promise"
                    }
                  },
                  "hasBody": true,
                  "isAsync": true
                },
                "location": {
                  "filename": "file:///mod.ts",
                  "line": 34,
                  "col": 2,
                  "byteIndex": 611
                }
              },
              {
                "name": "cannotInfer",
                "kind": "method",
                "functionDef": {
                  "params": [],
                  "hasBody": true
                },
                "location": {
                  "filename": "file:///mod.ts",
                  "line": 37,
                  "col": 2,
                  "byteIndex": 638
                }
              },
              {
                "name": "cannotInferAsync",
                "kind": "method",
                "functionDef": {
                  "params": [],
                  "hasBody": true,
                  "isAsync": true
                },
                "location": {
                  "filename": "file:///mod.ts",
                  "line": 43,
                  "col": 2,
                  "byteIndex": 728
                }
              },
              {
                "name": "cannotInferGenerator",
                "kind": "method",
                "functionDef": {
                  "params": [],
                  "hasBody": true,
                  "isGenerator": true
                },
                "location": {
                  "filename": "file:///mod.ts",
                  "line": 47,
                  "col": 2,
                  "byteIndex": 792
                }
              }
            ]
          }
        }
      ]
    },
    {
      "name": "MyNamespace",
      "declarations": [
        {
          "location": {
            "filename": "file:///mod.ts",
            "line": 51,
            "col": 0,
            "byteIndex": 825
          },
          "declarationKind": "export",
          "kind": "namespace",
          "def": {
            "elements": [
              {
                "name": "cannotInfer",
                "declarations": [
                  {
                    "location": {
                      "filename": "file:///mod.ts",
                      "line": 53,
                      "col": 2,
                      "byteIndex": 909
                    },
                    "declarationKind": "declare",
                    "kind": "function",
                    "def": {
                      "params": []
                    }
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}
