{"id":15826091,"url":"https://github.com/frigus02/test-ts-add-declaration-to-symbol-set","last_synced_at":"2025-08-03T21:34:10.427Z","repository":{"id":153282683,"uuid":"620792535","full_name":"frigus02/test-ts-add-declaration-to-symbol-set","owner":"frigus02","description":"Test for https://github.com/microsoft/TypeScript/issues/53565","archived":false,"fork":false,"pushed_at":"2023-03-29T11:43:08.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-19T14:23:27.473Z","etag":null,"topics":[],"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/frigus02.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-29T11:37:54.000Z","updated_at":"2023-03-31T16:20:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab5721c5-efa5-4929-9c3d-28abc408a750","html_url":"https://github.com/frigus02/test-ts-add-declaration-to-symbol-set","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frigus02/test-ts-add-declaration-to-symbol-set","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frigus02%2Ftest-ts-add-declaration-to-symbol-set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frigus02%2Ftest-ts-add-declaration-to-symbol-set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frigus02%2Ftest-ts-add-declaration-to-symbol-set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frigus02%2Ftest-ts-add-declaration-to-symbol-set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frigus02","download_url":"https://codeload.github.com/frigus02/test-ts-add-declaration-to-symbol-set/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frigus02%2Ftest-ts-add-declaration-to-symbol-set/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268617308,"owners_count":24279230,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-05T09:42:39.967Z","updated_at":"2025-08-03T21:34:10.345Z","avatar_url":"https://github.com/frigus02.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test TypeScript compiler performance for many symbols declared in repeated namespaces\n\nWe have a .d.ts generator that emits symbols in nested namespaces. For simplicity the generator always emits the entire namespace. Example:\n\n```ts\ndeclare namespace __generated.foo.bar {\n  export class A {}\n}\ndeclare namespace __generated.foo.bar {\n  export class B {}\n}\ndeclare namespace __generated.foo.bar.baz {\n  export class C {}\n}\n```\n\nIt seems this pattern runs into a performance issue inside `addDeclarationToSymbol`. It calls `appendIfUnique(symbol.declarations, node)`, which iterates through the `symbol.declarations` array. The code above leads to lots of declarations of the symbols `__generated`, `__generated.foo`, etc.\n\nThe patch `tsc_patch.diff` uses a `Set` rather than iterating the array. This seems to speed up the build time significantly.\n\n## Run the test\n\n```sh\n# Install TypeScript\n$ npm ci\n\n# Create a patched version of tsc.js\n$ npm run patch_tsc\n\n# Generate code with 100 symbols and build with stable and the patched tsc version\n# --\u003e \"Total time\" should be similar.\n$ npm run generate_code_100\n$ npm build_stable\n$ npm build_patched\n\n# Generate code with 5000 symbols and build with stable and the patched tsc version\n# --\u003e \"Total time\" should be much faster with the patched version.\n$ npm run generate_code_5000\n$ npm build_stable\n$ npm build_patched\n```\n\n## Performance on my machine\n\nGenerated on 2023-03-29. Omitted irrelevant output.\n\n```\n$ npm run generate_code_100\n\n$ npm run build_stable\nBind time:       0.16s\nTotal time:      0.65s\n\n$ npm run build_patched\nBind time:       0.17s\nTotal time:      0.62s\n\n$ npm run generate_code_5000\n\n$ npm run build_stable\nBind time:        4.87s\nTotal time:       5.61s\n\n$ npm run build_patched\nBind time:        0.45s\nTotal time:       1.19s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrigus02%2Ftest-ts-add-declaration-to-symbol-set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrigus02%2Ftest-ts-add-declaration-to-symbol-set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrigus02%2Ftest-ts-add-declaration-to-symbol-set/lists"}