E4008

E4008#

FFI function cannot have type parameters.

Erroneous Example#

extern "js" fn id[T](x: T) -> T = "(x) => x"

The example declares an FFI function (marked extern) with a type parameter, which is not allowed.

Suggestion#

Consider using a concrete type that suits your needs:

extern "js" fn int_id(x: Int) -> Int = "(x) => x"

For more complicated scenarios, consider adding an extra trait:

///|
trait Ider {
  id(Self) -> Self
}

///|
impl Ider for Int with id(self) { int_id(self) }