{"id":15439785,"url":"https://github.com/bcherny/typed-trait","last_synced_at":"2025-04-19T18:59:46.274Z","repository":{"id":66101239,"uuid":"129544454","full_name":"bcherny/typed-trait","owner":"bcherny","description":"A 100% typesafe class trait util for TypeScript","archived":false,"fork":false,"pushed_at":"2018-04-14T19:55:56.000Z","size":31,"stargazers_count":22,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-17T03:03:29.889Z","etag":null,"topics":["javascript","mixin","trait","typesafe","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/bcherny.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":"2018-04-14T18:38:24.000Z","updated_at":"2024-05-31T08:40:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6d22d4e-fbc9-455a-9b38-c6189e0c9e35","html_url":"https://github.com/bcherny/typed-trait","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"07271bd6faaca3e77ff27c36acfbba78a68a0179"},"previous_names":["bcherny/magical-mixin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-trait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-trait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-trait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-trait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcherny","download_url":"https://codeload.github.com/bcherny/typed-trait/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248691524,"owners_count":21146381,"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":["javascript","mixin","trait","typesafe","typescript"],"created_at":"2024-10-01T19:09:29.388Z","updated_at":"2025-04-16T12:31:00.454Z","avatar_url":"https://github.com/bcherny.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magical-Mixin [![Build Status][build]](https://circleci.com/gh/bcherny/magical-mixin) [![npm]](https://www.npmjs.com/package/magical-mixin) [![mit]](https://opensource.org/licenses/MIT) [![ts]](https://www.typescriptlang.org/)\n\n[build]: https://img.shields.io/circleci/project/bcherny/magical-mixin.svg?branch=master\u0026style=flat-square\n[npm]: https://img.shields.io/npm/v/magical-mixin.svg?style=flat-square\n[mit]: https://img.shields.io/npm/l/magical-mixin.svg?style=flat-square\n[ts]: https://img.shields.io/badge/TypeScript-%E2%9C%93-007ACC.svg?style=flat-square\n\n\u003e The only 100% typesafe class mixin for TypeScript\n\n## Features\n\n- **Complete compile (as you type) time safety for class mixins**: Know at compile time which methods are available for your mixed in class, without the boilerplate that the [TypeScript docs](http://www.typescriptlang.org/docs/handbook/mixins.html)'s approach suffers from.\n- **Compile time error when multiple mixins implement the same method or property**: A common shortcoming of mixins is undefined behavior when multiple mixins implement the same property or method. In some languages the last mixins wins, in some the first one wins, in some you need to explicitly `override` methods, and in some overrides are forbidden. Magical-mixin takes the last approach for maximum safety and predictability.\n- **Simple, elegant syntax**: Just `extends mixin(ClassA, ClassB)`.\n\n## Installation\n\n```sh\n# Using Yarn:\nyarn add magical-mixin\n\n# Or, using NPM:\nnpm install magical-mixin --save\n```\n\n## Usage\n\n```ts\nimport { mixin } from 'magical-mixin'\n\nclass A {\n  a() {}\n}\nclass B {\n  b() {}\n}\nclass Bad {\n  a() {}\n  c() {}\n}\n\nclass MyClass extends mixin(A, B) {}\nlet c = new MyClass\nc.a() // OK\nc.b() // OK\n\nclass MyBadClass extends mixin(A, Bad) {}\n// Compile Error: Type '\"Error: Multiple mixins implement the following methods:\" \u0026 Methods\u003c\"a\"\u003e' is not a constructor function type.\n\nclass MyOtherBadClass extends mixin(A, B, Bad) {}\n// Compile Error: Type '\"Error: Multiple mixins implement the following methods:\" \u0026 Methods\u003c\"a\"\u003e' is not a constructor function type.\n```\n\n## TODO\n\n- [ ] Add support for calling `mixin()` with more than 3 parameters\n- [ ] Define behavior for constructors\n- [ ] Don't export `Methods` utility class\n\n## Tests\n\n```sh\nyarn test\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Ftyped-trait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcherny%2Ftyped-trait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Ftyped-trait/lists"}