{"id":20589107,"url":"https://github.com/trezm/type-doc","last_synced_at":"2025-06-18T03:37:30.045Z","repository":{"id":57383187,"uuid":"67873003","full_name":"trezm/type-doc","owner":"trezm","description":"Static type checking for pure JavaScript","archived":false,"fork":false,"pushed_at":"2017-09-29T00:04:20.000Z","size":224,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-15T22:24:12.291Z","etag":null,"topics":["cli","generic-types","javascript","type-safe","type-safety","types","vanillajs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trezm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-10T13:37:22.000Z","updated_at":"2019-02-06T00:34:02.000Z","dependencies_parsed_at":"2022-09-13T23:50:22.333Z","dependency_job_id":null,"html_url":"https://github.com/trezm/type-doc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trezm/type-doc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trezm%2Ftype-doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trezm%2Ftype-doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trezm%2Ftype-doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trezm%2Ftype-doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trezm","download_url":"https://codeload.github.com/trezm/type-doc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trezm%2Ftype-doc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260323117,"owners_count":22991950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","generic-types","javascript","type-safe","type-safety","types","vanillajs"],"created_at":"2024-11-16T07:27:52.574Z","updated_at":"2025-06-18T03:37:24.978Z","avatar_url":"https://github.com/trezm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeDoc\n\nType checking with valid JavaScript\n\n## Table of Contents\n- [Introduction](#introduction)\n- [Setup](#setup)\n- [cli](#cli)\n- [Type Comments](#type-comments)\n- [What Works?](#what-works-right-now)\n\n## Introduction\n\n_Warning:_ TypeDoc is still very much in development and there are definitely plenty of bugs.\n\nTypeDoc aims to provide a static type checking without changing JavaScript. This is accomplished by adding type annotations via comments near declarations.\n\nTake, for example, the following function to apply a transform to an input. There is an error in that `results` is defined as a `String`, yet is getting assigned a `Number`. TypeDoc aims to catch errors like this during static analysis rather than waiting until run time.\n\n```\nfunction transform(input /* t:a */, translationFunction /* t:a -\u003e b */) /* t:b */ {\n  return translationFunction(input);\n}\n\nconst aNumber /* t:Number */ = 4\nconst results /* t:String */ = transform(aNumber, (theNumber) =\u003e theNumber);\n\n```\n\nStill not sure? Check out the [vs-code extension](https://marketplace.visualstudio.com/items?itemName=Trezm.type-doc-vscode)!\n\n## Setup\n\n### Install dependencies\n```\n\u003e yarn\n```\nor\n```\n\u003e npm install\n```\n\nThen, to build,\n\n```\n\u003e ./node_modules/.bin/gulp build:dev\n```\n\n## CLI\nTypeDoc has a basic cli for testing files. You can run it like so. _Note:_ type-doc must be compiled prior to running the CLI.\n```\n\u003e bin/type-doc \u003csome-file\u003e\n```\n\nFor example,\n```\n\u003e bin/type-doc ./examples/importDirectory.test.js\n```\n\n### Functional testing\nSimply add the `-f`, or `--functional`, argument to also check for strictly functional, i.e.\n\n```\n\u003e bin/type-doc --functional ./examples/functional.test.js\n```\n\n## Type Comments\nTypes are recognized as capitalized words, for example `Number` is a type. Types do not need to be existing types in the JavaScript system, type could be any capitalized word, for example, `Jedi`.\n\nFunction or method types are formatted as capitalized words separated by `-\u003e`, for example, a function that tells you the color of a Jedi's lightsaber would have a type like this:\n```\nJedi -\u003e Color\n```\n\nUnions are also allowed, for example, if you wanted to know who would win in a Jedi vs Sith fight, you could write a function with the signature\n```\nJedi -\u003e Sith -\u003e Jedi | Sith\n```\n\nTypeDoc also allows Generic Types. Any word that does not begin with a capital will be considered a generic type. An example to get the apprentice associated with a certain Jedi or Sith lord could look something like:\n```\nalignment -\u003e Apprentice alignment\n```\n\nBelow you'll find a list of comment formats that TypeDoc recognizes.\n\n### Inline variables\n```\nconst aString /* t:String */ = 'hi';\n```\n\n### Function declarations\nTypeDoc style:\n```\nfunction mayTheForceBeWithYou(name /* t:String */) /* t:String */ {\n  return 'And with you, ' + name;\n}\n```\nJSDoc style:\n```\n/**\n * Let's you know if it's a trap\n *\n * @param {String} a - the thing you're tryinig to figure out\n * @returns {Boolean} - whether or not the argument is a trap\n */\nfunction isItA(thing) {\n  return thing === 'Trap';\n}\n```\n\n### Class declarations\nTypeDoc style:\n```\n/**\n  * class :: TestClass\n  *   aString :: String\n  *   aGoodMethod :: String -\u003e String\n  */\nclass TestClass {\n  constructor() {\n    this.aString = 'hello';\n  }\n\n  aGoodMethod(s /* t:String */) /* t:String */ {\n    return s;\n  }\n}\n```\n\nJSDoc style:\n```\n/**\n * @class TestClass\n */\nclass TestClass {\n  constructor() {\n    const s /* t:String */ = this.add(1, 2);\n  }\n\n  /**\n   * Add two Numbers\n   *\n   * @memberOf TestClass\n   * @param {Number} a - The first Number\n   * @param {Number} b - The second Number\n   * @returns {Number} - the sum of the arguments\n   */\n  add(a, b) {\n    return a + b;\n  }\n}\n```\n\n## What works right now?\nHere's a highlights view of what TypeDoc can do so far. For a more complete list, please check out `src/integrationTests`!\n\nType Checking:\n\n- [x] Generic types\n- [x] Multiple files\n- [x] Assignment checking\n- [x] Checking vs literals\n- [x] Param checking\n- [x] Return checking\n- [x] Class checking\n- [x] Class method checking (params and returns.)\n\nFunctional:\n\n- [x] Prevent out of scope variable changes\n- [x] Prevent modifying properties on Immutable objects\n- [x] Prevent calling `push`, `pop`, `shift`, `unshift` outside of the declared scope (i.e. in child scopes).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrezm%2Ftype-doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrezm%2Ftype-doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrezm%2Ftype-doc/lists"}