# 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:17:1

function cannotInfer()

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

async function cannotInferAsync()

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

function* cannotInferGenerator()

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

function test(): void

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

async function testAsync(): Promise<void>

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

let b: boolean

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

let bi: bigint

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

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

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

let n: number

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

let re: RegExp

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

let s: string

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

let tpl: `foobar`

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

class MyClass

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

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

namespace MyNamespace

  function cannotInfer()


# output.json
[
  {
    "name": "s",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 1,
      "col": 11,
      "byteIndex": 11
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "kind": "let"
    }
  },
  {
    "name": "n",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 2,
      "col": 11,
      "byteIndex": 35
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "number",
        "kind": "keyword",
        "keyword": "number"
      },
      "kind": "let"
    }
  },
  {
    "name": "b",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 3,
      "col": 11,
      "byteIndex": 55
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "boolean",
        "kind": "keyword",
        "keyword": "boolean"
      },
      "kind": "let"
    }
  },
  {
    "name": "bi",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 4,
      "col": 11,
      "byteIndex": 77
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "bigint",
        "kind": "keyword",
        "keyword": "bigint"
      },
      "kind": "let"
    }
  },
  {
    "name": "re",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 5,
      "col": 11,
      "byteIndex": 99
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "hello",
        "kind": "typeRef",
        "typeRef": {
          "typeParams": null,
          "typeName": "RegExp"
        }
      },
      "kind": "let"
    }
  },
  {
    "name": "tpl",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 6,
      "col": 11,
      "byteIndex": 124
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "foobar",
        "kind": "literal",
        "literal": {
          "kind": "template",
          "tsTypes": [
            {
              "repr": "foobar",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": "foobar"
              }
            }
          ]
        }
      },
      "kind": "let"
    }
  },
  {
    "name": "complexTpl",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 7,
      "col": 11,
      "byteIndex": 151
    },
    "declarationKind": "export",
    "kind": "variable",
    "variableDef": {
      "tsType": {
        "repr": "f${string | number}${string | null}o${string}${number}o",
        "kind": "literal",
        "literal": {
          "kind": "template",
          "tsTypes": [
            {
              "repr": "f",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": "f"
              }
            },
            {
              "repr": "",
              "kind": "union",
              "union": [
                {
                  "repr": "string",
                  "kind": "keyword",
                  "keyword": "string"
                },
                {
                  "repr": "number",
                  "kind": "keyword",
                  "keyword": "number"
                }
              ]
            },
            {
              "repr": "",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": ""
              }
            },
            {
              "repr": "",
              "kind": "union",
              "union": [
                {
                  "repr": "string",
                  "kind": "keyword",
                  "keyword": "string"
                },
                {
                  "repr": "null",
                  "kind": "keyword",
                  "keyword": "null"
                }
              ]
            },
            {
              "repr": "o",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": "o"
              }
            },
            {
              "repr": "string",
              "kind": "keyword",
              "keyword": "string"
            },
            {
              "repr": "",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": ""
              }
            },
            {
              "repr": "number",
              "kind": "keyword",
              "keyword": "number"
            },
            {
              "repr": "o",
              "kind": "literal",
              "literal": {
                "kind": "string",
                "string": "o"
              }
            }
          ]
        }
      },
      "kind": "let"
    }
  },
  {
    "name": "test",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 9,
      "col": 0,
      "byteIndex": 219
    },
    "declarationKind": "export",
    "kind": "function",
    "functionDef": {
      "params": [],
      "returnType": {
        "repr": "void",
        "kind": "keyword",
        "keyword": "void"
      },
      "hasBody": true,
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "name": "testAsync",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 13,
      "col": 0,
      "byteIndex": 271
    },
    "declarationKind": "export",
    "kind": "function",
    "functionDef": {
      "params": [],
      "returnType": {
        "repr": "Promise",
        "kind": "typeRef",
        "typeRef": {
          "typeParams": [
            {
              "repr": "void",
              "kind": "keyword",
              "keyword": "void"
            }
          ],
          "typeName": "Promise"
        }
      },
      "hasBody": true,
      "isAsync": true,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "name": "cannotInfer",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 17,
      "col": 0,
      "byteIndex": 338
    },
    "declarationKind": "export",
    "kind": "function",
    "functionDef": {
      "params": [],
      "returnType": null,
      "hasBody": true,
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "name": "cannotInferAsync",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 23,
      "col": 0,
      "byteIndex": 415
    },
    "declarationKind": "export",
    "kind": "function",
    "functionDef": {
      "params": [],
      "returnType": null,
      "hasBody": true,
      "isAsync": true,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "name": "cannotInferGenerator",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 29,
      "col": 0,
      "byteIndex": 525
    },
    "declarationKind": "export",
    "kind": "function",
    "functionDef": {
      "params": [],
      "returnType": null,
      "hasBody": true,
      "isAsync": false,
      "isGenerator": true,
      "typeParams": []
    }
  },
  {
    "name": "MyClass",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 32,
      "col": 0,
      "byteIndex": 570
    },
    "declarationKind": "export",
    "kind": "class",
    "classDef": {
      "isAbstract": false,
      "constructors": [],
      "properties": [],
      "indexSignatures": [],
      "methods": [
        {
          "accessibility": null,
          "optional": false,
          "isAbstract": false,
          "isStatic": false,
          "name": "infer",
          "kind": "method",
          "functionDef": {
            "params": [],
            "returnType": {
              "repr": "void",
              "kind": "keyword",
              "keyword": "void"
            },
            "hasBody": true,
            "isAsync": false,
            "isGenerator": false,
            "typeParams": []
          },
          "location": {
            "filename": "file:///mod.ts",
            "line": 33,
            "col": 2,
            "byteIndex": 595
          }
        },
        {
          "accessibility": null,
          "optional": false,
          "isAbstract": false,
          "isStatic": false,
          "name": "inferAync",
          "kind": "method",
          "functionDef": {
            "params": [],
            "returnType": {
              "repr": "Promise",
              "kind": "typeRef",
              "typeRef": {
                "typeParams": [
                  {
                    "repr": "void",
                    "kind": "keyword",
                    "keyword": "void"
                  }
                ],
                "typeName": "Promise"
              }
            },
            "hasBody": true,
            "isAsync": true,
            "isGenerator": false,
            "typeParams": []
          },
          "location": {
            "filename": "file:///mod.ts",
            "line": 35,
            "col": 2,
            "byteIndex": 611
          }
        },
        {
          "accessibility": null,
          "optional": false,
          "isAbstract": false,
          "isStatic": false,
          "name": "cannotInfer",
          "kind": "method",
          "functionDef": {
            "params": [],
            "returnType": null,
            "hasBody": true,
            "isAsync": false,
            "isGenerator": false,
            "typeParams": []
          },
          "location": {
            "filename": "file:///mod.ts",
            "line": 38,
            "col": 2,
            "byteIndex": 638
          }
        },
        {
          "accessibility": null,
          "optional": false,
          "isAbstract": false,
          "isStatic": false,
          "name": "cannotInferAsync",
          "kind": "method",
          "functionDef": {
            "params": [],
            "returnType": null,
            "hasBody": true,
            "isAsync": true,
            "isGenerator": false,
            "typeParams": []
          },
          "location": {
            "filename": "file:///mod.ts",
            "line": 44,
            "col": 2,
            "byteIndex": 728
          }
        },
        {
          "accessibility": null,
          "optional": false,
          "isAbstract": false,
          "isStatic": false,
          "name": "cannotInferGenerator",
          "kind": "method",
          "functionDef": {
            "params": [],
            "returnType": null,
            "hasBody": true,
            "isAsync": false,
            "isGenerator": true,
            "typeParams": []
          },
          "location": {
            "filename": "file:///mod.ts",
            "line": 48,
            "col": 2,
            "byteIndex": 792
          }
        }
      ],
      "extends": null,
      "implements": [],
      "typeParams": [],
      "superTypeParams": []
    }
  },
  {
    "name": "MyNamespace",
    "isDefault": false,
    "location": {
      "filename": "file:///mod.ts",
      "line": 52,
      "col": 0,
      "byteIndex": 825
    },
    "declarationKind": "export",
    "kind": "namespace",
    "namespaceDef": {
      "elements": [
        {
          "name": "cannotInfer",
          "isDefault": false,
          "location": {
            "filename": "file:///mod.ts",
            "line": 54,
            "col": 2,
            "byteIndex": 909
          },
          "declarationKind": "declare",
          "kind": "function",
          "functionDef": {
            "params": [],
            "returnType": null,
            "isAsync": false,
            "isGenerator": false,
            "typeParams": []
          }
        }
      ]
    }
  }
]
