0

I'm trying to wrap this simple API: https://github.com/github-tools/github, just for study purpose. So, I created this external classes:

package index

import com.github.jesty.githubapi.Result
import com.github.jesty.githubapi.User
import kotlin.js.Promise

external class GitHub(user: User) {
    fun getUser(): GHUser
}

external class GHUser {
    fun listStarredRepos(): Promise<Result>
}

In a simple KotlinJS project everything is ok, but when I try to use in a project created with Create React Kotlin App I have the error below:

ReferenceError: GitHub is not defined 

1 Answer 1

0

Just solved, I need to annotate the external class with @JsModule("github-api"):

package com.github.jesty.githubapi

import kotlin.js.Promise

@JsModule("github-api")
external class GitHub(user: User) {
    fun getUser(): GHUser
}

@JsModule("github-api")
external class GHUser {
    fun listStarredRepos(): Promise<Result>
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.