{"id":25860102,"url":"https://github.com/nathanfallet/kotlin-js-interface-fix","last_synced_at":"2025-03-01T21:53:46.585Z","repository":{"id":279875395,"uuid":"940280356","full_name":"nathanfallet/kotlin-js-interface-fix","owner":"nathanfallet","description":"Allows to export Kotlin/JS interfaces to JavaScript, and use them in TypeScript without __doNotUseOrImplementIt","archived":false,"fork":false,"pushed_at":"2025-02-28T06:09:23.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T08:15:45.368Z","etag":null,"topics":["gradle-plugin","javascript","kotlin-js","typescript"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanfallet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["nathanfallet"]}},"created_at":"2025-02-27T22:54:50.000Z","updated_at":"2025-02-28T04:05:13.000Z","dependencies_parsed_at":"2025-02-28T08:15:53.347Z","dependency_job_id":"fa3b3818-4685-486f-b378-7763888373ed","html_url":"https://github.com/nathanfallet/kotlin-js-interface-fix","commit_stats":null,"previous_names":["nathanfallet/kotlin-js-interface-fix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fkotlin-js-interface-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fkotlin-js-interface-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fkotlin-js-interface-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fkotlin-js-interface-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanfallet","download_url":"https://codeload.github.com/nathanfallet/kotlin-js-interface-fix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430318,"owners_count":19961635,"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":["gradle-plugin","javascript","kotlin-js","typescript"],"created_at":"2025-03-01T21:53:45.604Z","updated_at":"2025-03-01T21:53:46.575Z","avatar_url":"https://github.com/nathanfallet.png","language":"Kotlin","funding_links":["https://github.com/sponsors/nathanfallet"],"categories":[],"sub_categories":[],"readme":"# kotlin-js-interface-fix\n\n[![License](https://img.shields.io/github/license/nathanfallet/kotlin-js-interface-fix)](LICENSE)\n[![Issues](https://img.shields.io/github/issues/nathanfallet/kotlin-js-interface-fix)]()\n[![Pull Requests](https://img.shields.io/github/issues-pr/nathanfallet/kotlin-js-interface-fix)]()\n[![Code Size](https://img.shields.io/github/languages/code-size/nathanfallet/kotlin-js-interface-fix)]()\n\nA simple Gradle plugin to fix Kotlin/JS interfaces issues.\n\nIt allows to export Kotlin/JS interfaces to JavaScript, and use them in TypeScript without __doNotUseOrImplementIt.\n\nThe idea was to fix [KT-75584](https://youtrack.jetbrains.com/issue/KT-75584)\nand [KT-56618](https://youtrack.jetbrains.com/issue/KT-56618) easily, without\nhaving to wait for JetBrains to fix it in the Compiler.\n\n\u003e Note: This plugin only works with `useEsModules()` for now. `useCommonJs()` is not supported.\n\n## Add the plugin to your project\n\nSimply add the gradle plugin to your `build.gradle(.kts)`:\n\n```kotlin\nplugins {\n    id(\"me.nathanfallet.kotlinjsinterfacefix\") version \"1.0.1\"\n}\n```\n\nYou can optionally configure which feature of the plugin is enabled (default is all of them):\n\n```kotlin\nkotlinjsinterfacefix { // The block is optional if you want to use the default values\n    exportJsInterfaces = true // Optional, default is true\n    removeDoNotUseOrImplementIt = true // Optional, default is true\n}\n```\n\n## Example\n\nWe will show you what the plugin does with the following Kotlin/JS code:\n\n```kotlin\n@JsExport\ninterface MyInterface {\n    fun doSomething()\n}\n\n@JsExport\nclass MyClass : MyInterface {\n    override fun doSomething() {\n        println(\"Hello, world!\")\n    }\n}\n```\n\n### Without the plugin\n\nHere are the generated JavaScript and TypeScript code:\n\n```javascript\ninitMetadataForInterface(MyInterface, 'MyInterface');\ninitMetadataForClass(MyClass, 'MyClass', MyClass, VOID, [MyInterface]);\n\nfunction MyClass() {\n}\n\nprotoOf(MyClass).doSomething = function () {\n    println('Hello, world!');\n};\n\nfunction MyInterface() {\n}\n\nexport {\n    MyClass as MyClass,\n};\n```\n\n```typescript\ntype Nullable\u003cT\u003e = T | null | undefined\n\nexport declare class MyClass implements MyInterface {\n    constructor();\n\n    doSomething(): void;\n\n    readonly __doNotUseOrImplementIt: MyInterface[\"__doNotUseOrImplementIt\"];\n}\n\nexport declare interface MyInterface {\n    doSomething(): void;\n\n    readonly __doNotUseOrImplementIt: {\n        readonly \"me.nathanfallet.sample.MyInterface\": unique symbol;\n    };\n}\n```\n\nYou can see that in the JavaScript code, the `MyInterface` is not exported, and in the TypeScript code, the\n`__doNotUseOrImplementIt` is present.\n\n### With the plugin\n\n```javascript\ninitMetadataForInterface(MyInterface, 'MyInterface');\ninitMetadataForClass(MyClass, 'MyClass', MyClass, VOID, [MyInterface]);\n\nfunction MyClass() {\n}\n\nprotoOf(MyClass).doSomething = function () {\n    println('Hello, world!');\n};\n\nfunction MyInterface() {\n}\n\nexport {\n    MyClass as MyClass,\n    MyInterface as MyInterface,\n};\n```\n\n```typescript\ntype Nullable\u003cT\u003e = T | null | undefined\n\nexport declare class MyClass implements MyInterface {\n    constructor();\n\n    doSomething(): void;\n}\n\nexport declare interface MyInterface {\n    doSomething(): void;\n}\n```\n\nNow, the `MyInterface` is exported in the JavaScript code, and the `__doNotUseOrImplementIt` is removed from the\nTypeScript code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfallet%2Fkotlin-js-interface-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanfallet%2Fkotlin-js-interface-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfallet%2Fkotlin-js-interface-fix/lists"}