Why are Kotlin std-lib dependencies of type implementation and not api?

According to https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#adding-dependencies, dependencies should be of type api or implementation.
That makes perfectly sense to me.

However, the example at https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-a-multiplatform-project

sourceSets {
    val commonMain by getting {
        dependencies {
            implementation(kotlin("stdlib-common"))
        }
    }
    val commonTest by getting {
        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
        }
    }
   ...
}

suggests that dependencies to the Kotlin std-lib should be of type implementation.

This I don’t understand.
I would have expected this dependencies to be of type api because every library uses for example the Kotlin types Int, String, List, …

What am I missing?

If you are doing not a library, but an application, then you do not need transitive dependencies. Also in some cases you want for used application to use its own version of stdlib.

Agreed, if I’m doing an application, I should use implementation.

So you are also saying, that I should use api for Kotlin std-lib dependencies of a library?

Or, as you suggested, if I don’t want to force the Kotlin version, I could even use compileOnly for the dependencies.
Would compileOnly be the recommended way for the Kotlin depenencies of a library or should I use api?

I think it really depends on the specific case. I use api scope by default for libraries. If user uses more recent kotlin version, gradle just overrides it. Manipulation with the scope are needed only when you expect your library to be a part of a complicated framework.

I’ve filed https://youtrack.jetbrains.com/issue/KT-33834 to change the configuration of the stdlib dependency generated by the new MPP project wizard.

Thanks for the update.