{"id":14482881,"url":"https://github.com/voxpelli/types-in-js","last_synced_at":"2025-04-09T20:08:06.408Z","repository":{"id":65990331,"uuid":"319930104","full_name":"voxpelli/types-in-js","owner":"voxpelli","description":"Tips and tricks for working with types in JavaScript","archived":false,"fork":false,"pushed_at":"2024-02-29T17:18:48.000Z","size":42,"stargazers_count":253,"open_issues_count":0,"forks_count":2,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-09T20:08:02.350Z","etag":null,"topics":["badges","discussions","jsdoc","types-in-js","typescript"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voxpelli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-09T11:06:54.000Z","updated_at":"2025-03-18T17:15:12.000Z","dependencies_parsed_at":"2024-09-03T00:04:20.879Z","dependency_job_id":"7881855a-4dbf-4742-b9f1-436ae9e9dafa","html_url":"https://github.com/voxpelli/types-in-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Ftypes-in-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Ftypes-in-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Ftypes-in-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Ftypes-in-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpelli","download_url":"https://codeload.github.com/voxpelli/types-in-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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":["badges","discussions","jsdoc","types-in-js","typescript"],"created_at":"2024-09-03T00:01:21.236Z","updated_at":"2025-04-09T20:08:06.380Z","avatar_url":"https://github.com/voxpelli.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"![](https://repository-images.githubusercontent.com/319930104/97292a80-409e-11eb-80f1-577cf14431cb)\n\n# Types in JavaScript\n\nIf you love types but not transpiling, then using TypeScript itself won't be your cup of tea, but there are other approaches you can take to get pretty close.\n\n## Participate\n\n### Join our [GitHub discussions](https://github.com/voxpelli/types-in-js/discussions)!\n\nThis repo exists mainly to promote a discussion around this topic – exchange experiences, share best practices and tips and ask for help on tricky parts. The discussions is found in the [GitHub discussions](https://github.com/voxpelli/types-in-js/discussions) of this repo\n\n### Is there a readme badge?\n\nYes! If you use types in plain JS in your project, you can include thise badge in your readme to let people know that your code is typed without relying on TypeScript syntax.\n\n[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)\n\n```md\n[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)\n```\n\n## How to use types in JavaScript\n\n[TypeScript supports JavaScript](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html) and it supports quite a few [JSDoc annotations](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html) to help you type your JS code (some, like `@deprecated`, is even used in TS-code).\n\nSince TypeScript is what drives the JavaScript tools in Visual Studio Code and [its intellisense](https://code.visualstudio.com/docs/nodejs/working-with-javascript#_intellisense) the implementation is actually used more than one would initially guess.\n\n### Getting started\n\n1. Add a [`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) with eg. [`allowJs: true`](https://www.typescriptlang.org/tsconfig#allowJs) ~~or add a [`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) instead, which implies `allowJs: true`~~ _(Turns out that `jsconfig.json` implies a lot more than just `allowJs: true` and as such is not recommended. See discussion at https://github.com/voxpelli/types-in-js/discussions/25)_\n\n2. Then point it to your javascript files by using [`files`](https://www.typescriptlang.org/tsconfig#files) and/or [`include`](https://www.typescriptlang.org/tsconfig#include) properties.\n\n3. Lastly either set [`checkJs: true`](https://www.typescriptlang.org/tsconfig#checkJs) in it, to have all of those files checked, or selectively add `// @ts-check` to the top of the files you want to check.\n\n4. (optional) Add some other useful / needed configurations, see [TSConfig tips](#tsconfig-tips).\n\n4. (optional) Install [`typescript`](https://www.npmjs.com/package/typescript) locally in your project (`npm install typescript`), then validate your project using `npx tsc` ([`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) is the name of the CLI supplied by `typescript`). `tsc` can preferably be run as a part of your test scripts, locally and on CI. See [CI / linting tips](#ci--linting--additional-tools)\n\n## Articles around using types with JavaScript\n\n* [TypeScript without TypeScript -- JSDoc superpowers](https://fettblog.eu/typescript-jsdoc-superpowers/) by [@ddprrt](https://github.com/ddprrt)\n\n## TSConfig tips\n\nSee [open discussion](https://github.com/voxpelli/types-in-js/discussions/2) as well as [base configs](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#tsconfig-bases) to extend from.\n\n## CI / linting / additional tools\n\nSee [open discussion](https://github.com/voxpelli/types-in-js/discussions/3)\n\n## JSDoc syntax tips\n\nThere's a [cheatsheet available](https://devhints.io/jsdoc)\n\n## Managing third party dependencies\n\nSee [open discussion](https://github.com/voxpelli/types-in-js/discussions/7)\n\n## Other good resources\n\n* [DavidWells/types-with-jsdocs](https://github.com/DavidWells/types-with-jsdocs)\n* [TypeScript JSDoc Reference](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Ftypes-in-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpelli%2Ftypes-in-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Ftypes-in-js/lists"}