# Kotlin Script - Passing generic types via providedProperties / implicitReceivers

**URL:** <https://discuss.kotlinlang.org/t/kotlin-script-passing-generic-types-via-providedproperties-implicitreceivers/22521>\
**Category:** Support\
**Created:** [July 26, 2021, 2:03am UTC](https://discuss.kotlinlang.org/t/kotlin-script-passing-generic-types-via-providedproperties-implicitreceivers/22521 "2021-07-26T02:03:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jhyub](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jhyub/32/8760_2.png) [@Jhyub](https://discuss.kotlinlang.org/u/Jhyub)\
**Post date:** [July 26, 2021, 2:03am UTC](https://discuss.kotlinlang.org/t/kotlin-script-passing-generic-types-via-providedproperties-implicitreceivers/22521/1 "2021-07-26T02:03:44Z")

</div>

Hello, I’ve been trying to pass some generic types (such as `kotlinx.html.TagConsumer<String>` or `kotlin.collections.Map<String, Any?>`), but I found it not working properly.  
When I decompiled the .class file generated by `kotlin.script.experimental.jvmhost.BasicJvmScriptClassFilesGenerator`, its type was displayed as `kotlinx.html.TagConsumer<[ERROR : Unknown type parameter 0. Please try recompiling module containing "[container not found]"]>`.  
I’ve looked into the actual code of the kotlin scripting api, and found that the class `kotlin.script.experimental.api.KotlinType` (which is the type that providedProperties and implicitReceivers of `ScriptCompilationConfiguration` requires) would change a KType instance to a KClass classifier (which would erase type parameters) and then build a KotlinType of it.  
Is there any other way to pass generic typed values to a kotlin script?

---

<div class="post-metadata">

**Author:** ![devgg](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@devgg](https://discuss.kotlinlang.org/u/devgg)\
**Post date:** [January 7, 2022, 4:23pm UTC](https://discuss.kotlinlang.org/t/kotlin-script-passing-generic-types-via-providedproperties-implicitreceivers/22521/2 "2022-01-07T16:23:21Z")

</div>

I encountered the same problem.

Providing a generic type in providedProperties does not seem to work:

ScriptCompilationConfiguration:

```auto
providedProperties(
  "test1" to
    Map::class.createType(
      arguments =
        listOf(
          KTypeProjection.invariant(String::class.createType()),
          KTypeProjection.invariant(String::class.createType())
        )
    )
)

```

ScriptEvaluationConfiguration:  
`providedProperties("test1" to mapOf("test2" to "output")) `

Script:  
`test1["test2"]`

I am getting  
`[ERROR] Type inference failed. The value of the type parameter K should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.`
