{"id":15391052,"url":"https://github.com/quramy/type-assert-tool","last_synced_at":"2025-07-20T12:32:31.561Z","repository":{"id":57383149,"uuid":"344172593","full_name":"Quramy/type-assert-tool","owner":"Quramy","description":"TypeScript type assertion utility","archived":false,"fork":false,"pushed_at":"2022-03-10T05:56:52.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-08T19:54:29.749Z","etag":null,"topics":["testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Quramy.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":"2021-03-03T15:27:21.000Z","updated_at":"2022-03-10T05:56:13.000Z","dependencies_parsed_at":"2022-09-13T23:51:41.231Z","dependency_job_id":null,"html_url":"https://github.com/Quramy/type-assert-tool","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Quramy/type-assert-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Ftype-assert-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Ftype-assert-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Ftype-assert-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Ftype-assert-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Quramy","download_url":"https://codeload.github.com/Quramy/type-assert-tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Ftype-assert-tool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266127212,"owners_count":23880420,"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":["testing","typescript"],"created_at":"2024-10-01T15:09:46.820Z","updated_at":"2025-07-20T12:32:31.544Z","avatar_url":"https://github.com/Quramy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-assert-tool\n\nUtility type to assert your TypeScript type.\n\n## Usage\n\n```ts\nimport { AssertIs, AssertSub, TestSuite } from \"type-assert-tool\";\n\ntype MyAwesomeType\u003cT = string\u003e = T extends string ? `Hello, ${T} !` : \"Bye.\";\n\ninterface MyAwesomeTypeTest extends TestSuite {\n  result1: AssertIs\u003cMyAwesomeType\u003c'world'\u003e, \"Hello, world !\"\u003e;\n  result2: AssertIs\u003cMyAwesomeType\u003cnumber\u003e, \"Bye.\"\u003e;\n\n  // Property 'result3' of type '[actual_type: \"Bye.\", is_not: \"Bye bye\"]' is not assignable to string index type 'AssertSuccess'.\n  result3: AssertIs\u003cMyAwesomeType\u003cnumber\u003e, \"Bye bye\"\u003e;\n\n  \"you can put cases into a section\": {\n    pattern1: AssertIs\u003cMyAwesomeType\u003c''\u003e, \"Hello,  !\"\u003e;\n    pattern2: AssertSub\u003cMyAwesomeType, string\u003e;\n\n    \"nested section\": {\n      result: AssertSub\u003c\"Hello\", string\u003e;\n    };\n  };\n}\n```\n\n[Try this in Playground!](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgQQM6oKawJKoDQrpYwDKArgEYEAqGqpZwMGcAvnAGZQQhwBEMAJ5gMAWgCGRWKJgQIAGz4BuAFAqhIuAFlByAO50eGasIwAeanAC8celGAA7AOYA+a3EsYAHswcATVFsYe2c4AH44AAMACQx5eQgCABIEanYAQki4AC5+ACFBDAA6ZTVHZigOcQBjFh19QxBjU1p6OG9fAI86BiYWBBU4OCg6MnkYAEZctEwcVDN6g1QjExEzAHI9aHk-dZcCPlj4xLgtqB24dL4XVSGR1DGYACZpqRhcBd0lldMzBzIQBQsPt8oUSjc1EMAPRQuAABW4Ilggjg63ujwAzOs4BAOHANCx1gBtGowMjieQAfQJuT4BWKfAIwFQlIcEBgtPpcAohT4AF1scy4Gz4JJUMAnA5xBR5CxZEEQk44I4-N58aZUTNiORqrV0OsioNhqNxhjXrN3vNFo1mmt-oDgQcuTyMNdVEa+IIIGQ4NVxA44GAyPA-ZhAuUIHBxLYMNUYMAIA4+LkBkMhmBxDAKg4poQLR9rcsmqtzOs9gcjgkCJc3Ub05nsy889rKJ8GkXbRgCHZHK53Wn+A4ehg-DG4wmkym62n0eNzS2KGZDnEEoyFb2IQPWLc2KpWEA)\n\n## API\n\n### `TestSuite`\n\nYou can write \"TypeScript type test\" extending this type. For example:\n\n```ts\ninterface YourTestCases extends TestSuite {\n  // write test cases as properties\n}\n```\n\nThere are no restrictions on the property names in the sub interface. However, `TestSuite` enforces as the sub interface's properties should be assignable to type `AssertSuccess` .\n\n### `AssertIs\u003cActual, Expected\u003e`\nTest equality between type `Actual` and type `Expected` . Only if succeeded, this type returns type `AssertSuccess` .\n\n### `AssertSub\u003cActual, Expected\u003e`\nTest whether type `Actual` type is a sub type of type `Expected` . Only if succeeded, this type returns type `AssertSuccess` .\n\n## Motivation\nTypeScript's capabilities of type operations are amazing. TypeScript has powerful features such as Mapped Types, Conditional Types, Recursive Types, and Template Literal Types.\n\nI needed a way to make sure that the composite types I created using these features would work as expected. I created this utility because I wanted to write tests for composite types in the same way I write unit tests for functions.\n\n## Similar repositories\n\n- [ts-expect](https://github.com/TypeStrong/ts-expect) provides function to assert type of your \"values\".\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquramy%2Ftype-assert-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquramy%2Ftype-assert-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquramy%2Ftype-assert-tool/lists"}