Function Typing

Function typing allows us to make Bantam function integrate with IDEs as if it's native code. You can provide the expected inputs and outputs, and we'll handle the rest.

Example

Before documenting, let's take a look at an example, let's consider the function @simple/log.

We have a few methods (@simple/log @simple/log/warn, @simple/log/error, and @simple/log/critical), so there are a few good examples.

Inside our functions package.json file, we can put our typings like this:

"bantam": {
      {
        "title": "Info Log",
        "description": "A simple logger with level `info`. You can pass in a `message`, `info`, or both",
        "args": {
          "message": {
            "description": "A text value to go along with the log.",
            "dataType": "string"
          },
          "info": {
            "description": "Any data of the log",
            "dataType": "any"
          }
        }
      },
      {
        "title": "Warning Log",
        "description": "A simple logger with level `warn`. You can pass in a `message`, `info`, or both",
        "method": "warn",
        "args": {
          "message": {
            "description": "A text value to go along with the log.",
            "dataType": "string"
          },
          "info": {
            "description": "Any data of the log",
            "dataType": "any"
          }
        }
      },
      {
        "title": "Error Log",
        "description": "A simple logger with level `error`. You can pass in a `message`, `info`, or both",
        "method": "error",
        "args": {
          "message": {
            "description": "A text value to go along with the log.",
            "dataType": "string"
          },
          "info": {
            "description": "Any data of the log",
            "dataType": "any"
          }
        }
      },
      {
        "title": "Critical Log",
        "description": "A simple logger with level `critical`. You can pass in a `message`, `info`, or both",
        "method": "critical",
        "args": {
          "message": {
            "description": "A text value to go along with the log.",
            "dataType": "string"
          },
          "info": {
            "description": "Any data of the log",
            "dataType": "any"
          }
        }
      }

Usage

Underneath the bantam object in the function's package.json, you can provide the value typings. Each value outlines one set of method/input/output.

Each type is structured like this: