Skip to main content
Version: 1.5.2

TypeError

The TypeError() constructor creates a new error when an operation could not be performed, typically (but not exclusively) when a value is not of the expected type.

Syntax

new TypeError()
new TypeError(message)
new TypeError(message, options)
new TypeError(message, fileName)
new TypeError(message, fileName, lineNumber)

TypeError()
TypeError(message)
TypeError(message, options)
TypeError(message, fileName)
TypeError(message, fileName, lineNumber)

Note: TypeError() can be called with or without new. Both create a new TypeError instance.

Parameters

  • message optional
    • : Human-readable description of the error
  • options optional
    • : An object that has the following properties:
      • cause optional
        • : A property indicating the specific cause of the error. When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass the original error.