{"id":13846956,"url":"https://github.com/johanholmerin/ts-annotate","last_synced_at":"2025-03-28T17:13:48.015Z","repository":{"id":57380456,"uuid":"453400024","full_name":"johanholmerin/ts-annotate","owner":"johanholmerin","description":"Auto-annotate TypeScript using runtime profiling","archived":false,"fork":false,"pushed_at":"2022-01-31T17:23:37.000Z","size":108,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:09:38.116Z","etag":null,"topics":["monkeytype","pyannotate","typeprof","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johanholmerin.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}},"created_at":"2022-01-29T13:06:45.000Z","updated_at":"2024-05-07T10:50:00.000Z","dependencies_parsed_at":"2022-09-05T13:51:32.990Z","dependency_job_id":null,"html_url":"https://github.com/johanholmerin/ts-annotate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanholmerin%2Fts-annotate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanholmerin%2Fts-annotate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanholmerin%2Fts-annotate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanholmerin%2Fts-annotate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johanholmerin","download_url":"https://codeload.github.com/johanholmerin/ts-annotate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068302,"owners_count":20718503,"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":["monkeytype","pyannotate","typeprof","typescript"],"created_at":"2024-08-04T18:00:51.105Z","updated_at":"2025-03-28T17:13:47.988Z","avatar_url":"https://github.com/johanholmerin.png","language":"JavaScript","readme":"# ts-annotate\n\nAutomatically adds TypeScript declarations based on actual types passed at runtime, as determined by [V8][v8-profiling].\n\n#### Before\n\n```javascript\nfunction add(a, b) {\n  return a + b;\n}\n\nadd(1, 2);\n```\n\n#### After\n\n```javascript\nfunction add(a: number, b: number): number {\n  return a + b;\n}\n\nadd(1, 2);\n```\n\n## Instructions\n\n```sh\n# 1. Generate type data by running the code\nnpx ts-annotate run ./src/index.js\n\n# 2. Add type declaration to source code\nnpx ts-annotate apply ./src/**/*.js\n\n# 3. Rename .js to .ts\n# 4. Cleanup/improve types\n```\n\n## Supported types\n\n- Primitives - `string`, `number`, `boolean`, etc.\n- Class instances(includes arrays, objects, promises, etc.)\n- Functions(i.e. callbacks)\n\nOnly simple types are inferred - objects are `Record\u003cstring, any\u003e`, arrays\n`any[]`, and functions `(...args: any[]) =\u003e any`.\n\n## Commands\n\n- `run` - Same as running `node` but saves type data to `ts-annotate-map.json`\n- `apply` - Adds type declarations to the specified files using data in `ts-annotate-map.json`\n\n## Passing flags to Node\n\n```sh\nnode --flag ./node_modules/.bin/ts-annotate ...\n```\n\n## Prior work\n\n- https://github.com/fhinkel/type-profile\n\n[v8-profiling]: https://docs.google.com/document/d/1JY7pUCAk8gegyi6UkIdln6j_AeJqQucZg92advaMJY4/edit\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanholmerin%2Fts-annotate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohanholmerin%2Fts-annotate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanholmerin%2Fts-annotate/lists"}