(type...)
Declares how a function should look, what parameters and return data types it needs to use. It is primarily used with function references, tables, and the call_indirect instruction.

Syntax

(type $label
  (func (param...) (result...))
)

Parameters

$label
The label that is used to link to the function type information.

Examples

;; Create simple function type
(type $functionType
  (func (param i32) (result i32))
)

;; Create Add 1 function
(func $add1 (type $functionType)
  ;; Add one to parameter and return result
  local.get 0
  i32.const 1
  i32.add
)
;; Create callback function type
(type $callbackFunctionType
  (func (param i32 i32) (result i32))
)