@types/coffeescript

  • Version 2.5.1
  • Published
  • 32.2 kB
  • 1 dependency
  • MIT license

Install

npm i @types/coffeescript
yarn add @types/coffeescript
pnpm add @types/coffeescript

Overview

TypeScript definitions for CoffeeScript

Index

Variables

variable FILE_EXTENSIONS

let FILE_EXTENSIONS: ['.coffee', '.coffee.md', '.litcoffee'];
  • List of precompiled CoffeeScript file extensions.

variable VERSION

let VERSION: string;
  • Version number of the CoffeeScript compiler.

Functions

function compile

compile: {
(code: string, options: SourceMapOptions): CodeWithSourceMap;
(code: string, options?: Options): string;
};
  • Compiles CoffeeScript to JavaScript code, then outputs it as a string.

    Parameter code

    CoffeeScript code to be compiled.

    Parameter options

    CoffeeScript compiler options.

    Parameter

    options.ast If true, output an abstract syntax tree of the input CoffeeScript source code.

    Parameter

    options.bare If true, omit a top-level IIFE safety wrapper.

    Parameter

    options.filename File name to compile.

    Parameter

    options.header If true, output the Generated by CoffeeScript header.

    Parameter

    options.inlineMap If true, output the source map as a base64-encoded string in a comment at the bottom.

    Parameter

    options.sourceMap If true, output a source map object with the code.

    Parameter

    options.transpile Babel transpilation options - see Babel.TransformOptions.

    Returns

    Compiled and unevaluated JavaScript code if options.sourceMap is falsy and/or undefined. If options.sourceMap is true, this returns a {js, v3SourceMap, sourceMap} object, where sourceMap is a SourceMap object handy for doing programmatic lookups.

function nodes

nodes: (code: string, options?: Options) => ASTBody;
  • Parse a string of CoffeeScript code or an array of lexed tokens, and return the AST. You can then compile it by calling .compile() on the root, or traverse it by using .traverseChildren() with a callback.

    Parameter code

    CoffeeScript code to be compiled.

    Parameter options

    CoffeeScript compiler options.

    Parameter

    options.ast If true, output an abstract syntax tree of the input CoffeeScript source code.

    Parameter

    options.bare If true, omit a top-level IIFE safety wrapper.

    Parameter

    options.filename File name to compile.

    Parameter

    options.header If true, output the Generated by CoffeeScript header.

    Parameter

    options.inlineMap If true, output the source map as a base64-encoded string in a comment at the bottom.

    Parameter

    options.sourceMap If true, output a source map object with the code.

    Parameter

    options.transpile Babel transpilation options - see Babel.TransformOptions.

    Returns

    Compiled and unevaluated JavaScript code.

function register

register: () => { (path: string): object; [path: string]: object };
  • Node's module loader, patched to be able to handle multi-dot extensions. This is a horrible thing that should not be required.

function run

run: (code: string, options?: Options) => any;
  • Compiles and executes a CoffeeScript string in the NodeJS environment. Evaluates __filename and __dirname correctly in order to execute the CoffeeScript input.

    Parameter code

    CoffeeScript code to be compiled.

    Parameter options

    CoffeeScript compiler options.

    Parameter

    options.ast If true, output an abstract syntax tree of the input CoffeeScript source code.

    Parameter

    options.bare If true, omit a top-level IIFE safety wrapper.

    Parameter

    options.filename File name to compile.

    Parameter

    options.header If true, output the Generated by CoffeeScript header.

    Parameter

    options.inlineMap If true, output the source map as a base64-encoded string in a comment at the bottom.

    Parameter

    options.sourceMap If true, output a source map object with the code.

    Parameter

    options.transpile Babel transpilation options - see Babel.TransformOptions.

    Returns

    Output of evaluated CoffeeScript code in the NodeJS environment.

function transpile

transpile: (code: string, options?: Options) => Babel.BabelFileResult;
  • Transpiles CoffeeScript to legacy, high-compatibility ECMAScript versions using Babel.

    Parameter code

    CoffeeScript code to be compiled.

    Parameter options

    CoffeeScript compiler options.

    Parameter

    options.ast If true, output an abstract syntax tree of the input CoffeeScript source code.

    Parameter

    options.bare If true, omit a top-level IIFE safety wrapper.

    Parameter

    options.filename File name to compile.

    Parameter

    options.header If true, output the Generated by CoffeeScript header.

    Parameter

    options.inlineMap If true, output the source map as a base64-encoded string in a comment at the bottom.

    Parameter

    options.sourceMap If true, output a source map object with the code.

    Parameter

    options.transpile Babel transpilation options - see Babel.TransformOptions.

    Returns

    Babel transpiler result for file.

Interfaces

interface AcornLocationData

interface AcornLocationData {}
  • Acorn.js parser location data object.

property end

end: number;

    property loc

    loc: {
    end: {
    line: number;
    column: number;
    };
    start: {
    line: number;
    column: number;
    };
    };

      property range

      range: LineMap;

        property start

        start: number;

          interface ASTBody

          interface ASTBody {}
          • Container interface for CoffeeScript abstract syntax trees.

          property classBody

          classBody?: boolean;

            property expressions

            expressions: ASTNode[] | [];

              property locationData

              locationData: LocationData;

                interface ASTNode

                interface ASTNode {}
                • CoffeeScript's abstract syntax tree node interfaces with all possible node properties.

                property args

                args?: ASTNode[];

                  property array

                  array?: boolean | ASTNode;

                    property asKey

                    asKey?: boolean;

                      property base

                      base?: ASTNode;

                        property body

                        body?: ASTBody | ASTNode;

                          property bound

                          bound?: boolean;

                            property boundFuncs

                            boundFuncs?: ASTNode[];

                              property cases

                              cases?: ASTNode[][];

                                property classBody

                                classBody?: boolean;

                                  property comments

                                  comments?: string[];

                                    property condition

                                    condition?: ASTNode;

                                      property context

                                      context?: string;

                                        property elseBody

                                        elseBody?: ASTNode | null;

                                          property expression

                                          expression?: ASTNode;

                                            property expressions

                                            expressions?: ASTNode[];

                                              property first

                                              first?: ASTNode;

                                                property flip

                                                flip?: boolean;

                                                  property generated

                                                  generated?: boolean;

                                                    property guard

                                                    guard?: ASTNode;

                                                      property index

                                                      index?: ASTNode;

                                                        property isChain

                                                        isChain?: boolean;

                                                          property isGenerator

                                                          isGenerator?: boolean;

                                                            property isNew

                                                            isNew?: boolean;

                                                              property isSuper

                                                              isSuper?: boolean;

                                                                property locationData

                                                                locationData: LocationData;

                                                                  property name

                                                                  name?: ASTNode;

                                                                    property negated

                                                                    negated?: boolean;

                                                                      property object

                                                                      object?: boolean | ASTNode;

                                                                        property objects

                                                                        objects?: ASTNode[];

                                                                          property operator

                                                                          operator?: string;

                                                                            property otherwise

                                                                            otherwise?: ASTNode;

                                                                              property own

                                                                              own?: boolean;

                                                                                property param

                                                                                param?: boolean;

                                                                                  property params

                                                                                  params?: ASTNode[];

                                                                                    property parent

                                                                                    parent?: ASTNode | null;

                                                                                      property pattern

                                                                                      pattern?: boolean;

                                                                                        property properties

                                                                                        properties?: ASTNode[];

                                                                                          property range

                                                                                          range?: boolean | ASTNodeRange[];

                                                                                            property returns

                                                                                            returns?: boolean;

                                                                                              property second

                                                                                              second?: ASTNode;

                                                                                                property soak

                                                                                                soak?: boolean;

                                                                                                  property source

                                                                                                  source?: ASTNode;

                                                                                                    property subject

                                                                                                    subject?: ASTNode;

                                                                                                      property subpattern

                                                                                                      subpattern?: boolean;

                                                                                                        property this

                                                                                                        this?: boolean;

                                                                                                          property val

                                                                                                          val?: string;

                                                                                                            property value

                                                                                                            value?: ASTNode | string;

                                                                                                              property variable

                                                                                                              variable?: ASTNode;

                                                                                                                interface ASTNodeRange

                                                                                                                interface ASTNodeRange {}
                                                                                                                • Range data interface for CoffeeScript abstract syntax tree nodes.

                                                                                                                property equals

                                                                                                                equals: string;

                                                                                                                  property exclusive

                                                                                                                  exclusive: boolean;

                                                                                                                    property from

                                                                                                                    from: ASTNode | null;

                                                                                                                      property locationData

                                                                                                                      locationData: LocationData;

                                                                                                                        property to

                                                                                                                        to: ASTNode | null;

                                                                                                                          interface CodeWithSourceMap

                                                                                                                          interface CodeWithSourceMap {}
                                                                                                                          • Output of CoffeeScript.compile when options.sourceMap is true. Emitted as an object in the form {js, v3SourceMap, sourceMap}.

                                                                                                                          property js

                                                                                                                          js: string;

                                                                                                                            property sourceMap

                                                                                                                            sourceMap: SourceMap;

                                                                                                                              property v3SourceMap

                                                                                                                              v3SourceMap: ReturnType<SourceMap['generate']>;

                                                                                                                                interface eval

                                                                                                                                interface eval {}
                                                                                                                                • Compiles and executes a CoffeeScript string in a NodeJS-like browser environment. The CoffeeScript REPL uses this to run the input.

                                                                                                                                  Parameter code

                                                                                                                                  CoffeeScript code to be compiled.

                                                                                                                                  Parameter options

                                                                                                                                  CoffeeScript compiler options.

                                                                                                                                  Parameter

                                                                                                                                  options.ast If true, output an abstract syntax tree of the input CoffeeScript source code.

                                                                                                                                  Parameter

                                                                                                                                  options.bare If true, omit a top-level IIFE safety wrapper.

                                                                                                                                  Parameter

                                                                                                                                  options.filename File name to compile.

                                                                                                                                  Parameter

                                                                                                                                  options.header If true, output the Generated by CoffeeScript header.

                                                                                                                                  Parameter

                                                                                                                                  options.inlineMap If true, output the source map as a Base64-encoded string in a comment at the bottom.

                                                                                                                                  Parameter

                                                                                                                                  options.sourceMap If true, output a source map object with the code.

                                                                                                                                  Parameter

                                                                                                                                  options.transpile Babel transpilation options - see Babel.TransformOptions.

                                                                                                                                  Returns

                                                                                                                                  Output of compiled CoffeeScript code.

                                                                                                                                call signature

                                                                                                                                (code: string, options?: Options): any;

                                                                                                                                  interface helpers

                                                                                                                                  interface helpers {}
                                                                                                                                  • Helpers used internally to compile CoffeeScript code.

                                                                                                                                  property some

                                                                                                                                  some:
                                                                                                                                  | typeof Array.prototype.some
                                                                                                                                  | ((this: any[], predicate: (value: any) => unknown) => boolean);
                                                                                                                                  • Polyfill for Array.prototype.some used pre-transpilation in the compiler. Determines whether the specified callback function returns true for any element of an array.

                                                                                                                                    Parameter fn

                                                                                                                                    Predicate function test for each array element.

                                                                                                                                    Returns

                                                                                                                                    Whether one or more elements return true when passed to the predicate fn(...).

                                                                                                                                  method addDataToNode

                                                                                                                                  addDataToNode: (
                                                                                                                                  parserState: object,
                                                                                                                                  firstLocationData: LocationData,
                                                                                                                                  firstValue: ASTNode,
                                                                                                                                  lastLocationData: LocationData,
                                                                                                                                  lastValue: ASTNode,
                                                                                                                                  forceUpdateLocation?: boolean
                                                                                                                                  ) => (obj: any) => any;
                                                                                                                                  • Generates a setter function that updates the location data of an object if it is a CoffeeScript abstract syntax tree node.

                                                                                                                                    Parameter parserState

                                                                                                                                    CoffeeScript parser state.

                                                                                                                                    Parameter firstLocationData

                                                                                                                                    Location data for first node.

                                                                                                                                    Parameter firstValue

                                                                                                                                    Abstract syntax tree for first node.

                                                                                                                                    Parameter lastLocationData

                                                                                                                                    Location data for last node.

                                                                                                                                    Parameter lastValue

                                                                                                                                    Abstract syntax tree for first node.

                                                                                                                                    Parameter forceUpdateLocation

                                                                                                                                    Whether to override the location data of the container and child nodes if the container has location data already.

                                                                                                                                  method attachCommentsToNode

                                                                                                                                  attachCommentsToNode: (comments: string[], node: ASTNode) => any;
                                                                                                                                  • Attaches a set of comments to the supplied node.

                                                                                                                                    Parameter comments

                                                                                                                                    Collection of comment strings.

                                                                                                                                    Parameter node

                                                                                                                                    Node associated with comments.

                                                                                                                                    Returns

                                                                                                                                    The node merged with the comments array.

                                                                                                                                  method baseFileName

                                                                                                                                  baseFileName: (file: string, stripExt?: boolean, useWinPathSep?: any) => string;
                                                                                                                                  • A .coffee.md compatible version of path.basename.

                                                                                                                                    Parameter file

                                                                                                                                    File name path. Can be relative, absolute or missing a directory.

                                                                                                                                    Parameter stripExt

                                                                                                                                    Whether to strip the file extension in the output.

                                                                                                                                    Parameter useWinPathSep

                                                                                                                                    Whether to use the Windows path separator \ as well as the Unix path separator /.

                                                                                                                                    Returns

                                                                                                                                    File name without extension.

                                                                                                                                  method buildTokenDataDictionary

                                                                                                                                  buildTokenDataDictionary: (tokens: ASTNode[]) => object;
                                                                                                                                  • Build a dictionary of token comments organized by tokens’ locations used as lookup hashes.

                                                                                                                                    Though multiple tokens can have the same location hash, using exclusive location data allows to distinguish between zero-length generated tokens and actual source tokens, for example.

                                                                                                                                    The ranges for "overlapping" tokens with the same location data and and matching token hashes are merged into one array.

                                                                                                                                    If there are duplicate comments, they will get sorted out later.

                                                                                                                                    Parameter tokens

                                                                                                                                    List of CoffeeScript abstract syntax tree tokens with or without comments.

                                                                                                                                    Returns

                                                                                                                                    Hashmap of token comments vs token location offsets.

                                                                                                                                  method compact

                                                                                                                                  compact: (array: any[]) => any[];
                                                                                                                                  • Trim out all falsy values from an array.

                                                                                                                                    Parameter array

                                                                                                                                    Array of boolean-operator indeterminate values.

                                                                                                                                    Returns

                                                                                                                                    Array of truthy values.

                                                                                                                                  method count

                                                                                                                                  count: (string: string, substr: string) => number;
                                                                                                                                  • Count the number of occurrences of a search string in another string.

                                                                                                                                    Parameter string

                                                                                                                                    Target string to search.

                                                                                                                                    Parameter substring

                                                                                                                                    Search string to compute against target.

                                                                                                                                    Returns

                                                                                                                                    Number of times the search string appears in the target string.

                                                                                                                                  method del

                                                                                                                                  del: (obj: object, key: any) => any;
                                                                                                                                  • Delete a key from an object, returning the value. Useful when a node is looking for a particular method in an options hash.

                                                                                                                                    Parameter obj

                                                                                                                                    Object to delete a key from.

                                                                                                                                    Parameter key

                                                                                                                                    Target key of object for the deletion operation.

                                                                                                                                    Returns

                                                                                                                                    The value of the deleted object entry.

                                                                                                                                  method ends

                                                                                                                                  ends: (string: string, literal: string, back?: number) => boolean;
                                                                                                                                  • Peek at the end of a given string to see if it matches a sequence.

                                                                                                                                    Parameter string

                                                                                                                                    Target string to check the suffix literal against.

                                                                                                                                    Parameter literal

                                                                                                                                    Literal string to use for the suffix check.

                                                                                                                                    Parameter back

                                                                                                                                    Zero-indexed backtracking position of the prefix. The offset following the last character of the string is 0.

                                                                                                                                    Returns

                                                                                                                                    Whether the literal suffix is found in string at the backtracking position or end of the string.

                                                                                                                                  method extend

                                                                                                                                  extend: (object: object, properties: object) => object;
                                                                                                                                  • Extend a source object with the properties of another object (shallow copy).

                                                                                                                                    Parameter object

                                                                                                                                    Target object to extend.

                                                                                                                                    Parameter properties

                                                                                                                                    Source object to extend the source object.

                                                                                                                                    Returns

                                                                                                                                    The original object extended by the properties object.

                                                                                                                                  method extractAllCommentTokens

                                                                                                                                  extractAllCommentTokens: (tokens: ASTNode[]) => string[];
                                                                                                                                  • Build a list of all comments attached to tokens.

                                                                                                                                    Parameter tokens

                                                                                                                                    Collection of CoffeeScript abstract syntax tree tokens, all sorted by source order.

                                                                                                                                    Returns

                                                                                                                                    List of comment strings present in CoffeeScript AST.

                                                                                                                                  method flatten

                                                                                                                                  flatten: (array: any[]) => any[];
                                                                                                                                  • Flattens an array recursively. Handy for getting a list of descendants from the nodes.

                                                                                                                                    Parameter array

                                                                                                                                    Array containing array and non-array elements.

                                                                                                                                    Returns

                                                                                                                                    A flattened version of the array with an array depth of 0.

                                                                                                                                  method invertLiterate

                                                                                                                                  invertLiterate: (code: string) => string;
                                                                                                                                  • Helper function for extracting code from Literate CoffeeScript by stripping out all non-code blocks, producing a string of CoffeeScript code that can be compiled "normally."

                                                                                                                                    Parameter code

                                                                                                                                    Literate CoffeeScript code to extract code blocks from.

                                                                                                                                    Returns

                                                                                                                                    CoffeeScript code without surrounding Markdown documentation.

                                                                                                                                  method isBoolean

                                                                                                                                  isBoolean: (obj: any) => boolean;
                                                                                                                                  • Checks if an value is a primitive boolean or Boolean instance.

                                                                                                                                    Parameter obj

                                                                                                                                    JavaScript value to check.

                                                                                                                                    Returns

                                                                                                                                    True if obj is a boolean.

                                                                                                                                  method isCoffee

                                                                                                                                  isCoffee: (file: string) => boolean;
                                                                                                                                  • Determine if a filename represents a CoffeeScript file. A CoffeeScript file has the file extensions .coffee, .coffee.md or .litcoffee.

                                                                                                                                    Parameter file

                                                                                                                                    Filename without directories.

                                                                                                                                    Returns

                                                                                                                                    Whether a filename is a CoffeeScript file.

                                                                                                                                  method isFunction

                                                                                                                                  isFunction: (obj: any) => boolean;
                                                                                                                                  • Checks if a value is a function.

                                                                                                                                    Parameter obj

                                                                                                                                    JavaScript value to check.

                                                                                                                                    Returns

                                                                                                                                    True if obj is a function.

                                                                                                                                  method isLiterate

                                                                                                                                  isLiterate: (file: string) => boolean;
                                                                                                                                  • Determine if a filename represents a Literate CoffeeScript file. A Literate CoffeeScript file has the file extensions .litcoffee, or .coffee.md.

                                                                                                                                    Parameter file

                                                                                                                                    Filename without directories.

                                                                                                                                    Returns

                                                                                                                                    Whether a filename is a CoffeeScript file.

                                                                                                                                  method isNumber

                                                                                                                                  isNumber: (obj: any) => boolean;
                                                                                                                                  • Checks if a value is a number.

                                                                                                                                    Parameter obj

                                                                                                                                    JavaScript value to check.

                                                                                                                                    Returns

                                                                                                                                    True if obj is a number.

                                                                                                                                  method isPlainObject

                                                                                                                                  isPlainObject: (obj: any) => boolean;
                                                                                                                                  • Checks if an value is a literal JS object - {}.

                                                                                                                                    Parameter obj

                                                                                                                                    JavaScript value to check.

                                                                                                                                    Returns

                                                                                                                                    True if obj is a literal JS object.

                                                                                                                                  method isString

                                                                                                                                  isString: (obj: any) => boolean;
                                                                                                                                  • Checks if an value is a string.

                                                                                                                                    Parameter obj

                                                                                                                                    JavaScript value to check.

                                                                                                                                    Returns

                                                                                                                                    True if obj is a string.

                                                                                                                                  method locationDataToString

                                                                                                                                  locationDataToString: (obj: LocationData | ASTNode) => string;
                                                                                                                                  • Convert JISON location data to a string.

                                                                                                                                    Parameter obj

                                                                                                                                    Token or CoffeeScriptASTLocationData object.

                                                                                                                                    Returns

                                                                                                                                    String representation of location data.

                                                                                                                                  method merge

                                                                                                                                  merge: (options: object, overrides: object) => object;
                                                                                                                                  • Merge objects, returning a fresh copy with attributes from both sides. Used every time CoffeeScript.compile is called, to allow properties in the options hash to propagate down the tree without polluting other branches.

                                                                                                                                    Parameter options

                                                                                                                                    Original, target object for merge operation.

                                                                                                                                    Parameter overrides

                                                                                                                                    Map of override key-values for merge operation.

                                                                                                                                    Returns

                                                                                                                                    Cloned object that merges options with overrides. The overrides properties have a higher merge priority than options properties.

                                                                                                                                  method nameWhitespaceCharacter

                                                                                                                                  nameWhitespaceCharacter: (string: any) => string;
                                                                                                                                  • Maps a whitespace character to a character name.

                                                                                                                                    Parameter Single

                                                                                                                                    character string.

                                                                                                                                    Returns

                                                                                                                                    Human-readable identifier for whitespace character, or the string parameter.

                                                                                                                                  method parseNumber

                                                                                                                                  parseNumber: (string: string) => number;
                                                                                                                                  • Parses a CoffeeScript number string to a primitive JS number.

                                                                                                                                    Parameter string

                                                                                                                                    String representation of a number. Parsed float or integer corresponding to number.

                                                                                                                                  method repeat

                                                                                                                                  repeat: (str: string, n: number) => string;
                                                                                                                                  • Repeat a string n times. Uses a clever algorithm to have O(log(n)) string concatenation operations.

                                                                                                                                    Parameter str

                                                                                                                                    String to repeat.

                                                                                                                                    Parameter n

                                                                                                                                    1-indexed number of repetitions.

                                                                                                                                    Returns

                                                                                                                                    Repeated string.

                                                                                                                                  method replaceUnicodeCodePointEscapes

                                                                                                                                  replaceUnicodeCodePointEscapes: (
                                                                                                                                  str: string,
                                                                                                                                  options?: ReplaceUnicodeCodePointEscapesOptions
                                                                                                                                  ) => string;
                                                                                                                                  • Replace \u{...} with \uxxxx[\uxxxx] in regexes without the u flag.

                                                                                                                                    Parameter str

                                                                                                                                    String that may contain Unicode brace syntax - \u{...}.

                                                                                                                                    Parameter options

                                                                                                                                    Options for Unicode replacement.

                                                                                                                                    Parameter

                                                                                                                                    [options.delimiter] Separator between two Unicode characters in str parameter of coffeescript.helpers.replaceUnicodeCodePointEscapes.

                                                                                                                                    Parameter

                                                                                                                                    [options.error=unicode code point escapes greater than \u{10ffff} are not allowed] Error message if coffeescript.helpers.replaceUnicodeCodePointEscapes fails.

                                                                                                                                    Parameter

                                                                                                                                    [options.flags] Which flags are present in the regular expression for the replacement operation. Must include u if provided to support Unicode escapes.

                                                                                                                                    Returns

                                                                                                                                    RegExp string with Unicode brace groups in the format \uxxxx[\uxxxx].

                                                                                                                                  method starts

                                                                                                                                  starts: (string: string, literal: string, start: number) => boolean;
                                                                                                                                  • Peek at the start of a given string to see if it matches a sequence.

                                                                                                                                    Parameter string

                                                                                                                                    Target string to check the prefix literal against.

                                                                                                                                    Parameter literal

                                                                                                                                    Literal string to use for the prefix check.

                                                                                                                                    Parameter start

                                                                                                                                    Zero-indexed starting position of the prefix. The offset preceding the first character of the string is 0.

                                                                                                                                    Returns

                                                                                                                                    Whether the literal prefix is found in string at the provided start position.

                                                                                                                                  method throwSyntaxError

                                                                                                                                  throwSyntaxError: (message: any, location: any) => never;
                                                                                                                                  • Throws a CoffeeScriptSyntaxError from a given location. The error's toString will return an error message following the "standard" format <filename>:<line>:<col>: <message> plus the line with the error and a marker showing where the error is.

                                                                                                                                    Instead of showing the compiler's stacktrace, show our custom error message (this is useful when the error bubbles up in Node.js applications that compile CoffeeScript for example).

                                                                                                                                    Throws

                                                                                                                                    Error object with location data and string representation.

                                                                                                                                  method updateSyntaxError

                                                                                                                                  updateSyntaxError: (error: any, code: string, filename: string) => any;
                                                                                                                                  • Update a compiler SyntaxError with source code information if it didn't have it already.

                                                                                                                                    Parameter error

                                                                                                                                    Syntax error with or without source code information.

                                                                                                                                    Parameter code

                                                                                                                                    Source code that produced the syntax error.

                                                                                                                                    Parameter filename

                                                                                                                                    File name for invalid CoffeeScript resource.

                                                                                                                                    Returns

                                                                                                                                    Syntax error with source code.

                                                                                                                                  interface JisonLocationData

                                                                                                                                  interface JisonLocationData {}
                                                                                                                                  • Jison parser location data object.

                                                                                                                                  property first_column

                                                                                                                                  first_column: number;

                                                                                                                                    property first_line

                                                                                                                                    first_line: number;

                                                                                                                                      property last_column

                                                                                                                                      last_column: number;

                                                                                                                                        property last_line

                                                                                                                                        last_line: number;

                                                                                                                                          interface LineMap

                                                                                                                                          interface LineMap {}
                                                                                                                                          • Tracker object for line and column positions for a single line. Used to implement the SourceMap class.

                                                                                                                                          property add

                                                                                                                                          add: (
                                                                                                                                          column: number,
                                                                                                                                          source: SourceLocation,
                                                                                                                                          options?: { noReplace: boolean }
                                                                                                                                          ) => SourceLocation | undefined;
                                                                                                                                          • Add source location data to line map.

                                                                                                                                            Parameter column

                                                                                                                                            Zero-indexed column number.

                                                                                                                                            Parameter source

                                                                                                                                            Source line and column to insert into map.

                                                                                                                                            Parameter options

                                                                                                                                            Column insertion options,

                                                                                                                                            Parameter

                                                                                                                                            options.noReplace If true, column replacement is allowed.

                                                                                                                                            Returns

                                                                                                                                            Added source location data.

                                                                                                                                          property columns

                                                                                                                                          columns: Array<{
                                                                                                                                          column: number;
                                                                                                                                          line: number;
                                                                                                                                          sourceColumn: number;
                                                                                                                                          sourceLine: number;
                                                                                                                                          }>;

                                                                                                                                            property line

                                                                                                                                            line: number;

                                                                                                                                              property sourceLocation

                                                                                                                                              sourceLocation: (column: number) => SourceLocation | void;
                                                                                                                                              • Fetch source location data for a specific column.

                                                                                                                                                Parameter column

                                                                                                                                                Zero-indexed column number.

                                                                                                                                                Returns

                                                                                                                                                [sourceLine, sourceColumn] if it exists in line map.

                                                                                                                                              interface Options

                                                                                                                                              interface Options {}
                                                                                                                                              • CoffeeScript compiler options.

                                                                                                                                              property ast

                                                                                                                                              ast?: boolean;
                                                                                                                                              • If true, output an abstract syntax tree of the input CoffeeScript source code.

                                                                                                                                              property bare

                                                                                                                                              bare?: boolean;
                                                                                                                                              • If true, omit a top-level IIFE safety wrapper.

                                                                                                                                              property filename

                                                                                                                                              filename?: string;
                                                                                                                                              • File name to compile - defaults to index.js.

                                                                                                                                              property header

                                                                                                                                              header?: boolean;
                                                                                                                                              • If true, output the Generated by CoffeeScript header.

                                                                                                                                              property inlineMap

                                                                                                                                              inlineMap?: boolean;
                                                                                                                                              • If true, output the source map as a base64-encoded string in a comment at the bottom.

                                                                                                                                              property sourceMap

                                                                                                                                              sourceMap?: boolean;
                                                                                                                                              • If true, output a source map object with the code.

                                                                                                                                              property transpile

                                                                                                                                              transpile?: Babel.TransformOptions;
                                                                                                                                              • Babel transpilation options - see Babel.TransformOptions.

                                                                                                                                              interface RawSourceMap

                                                                                                                                              interface RawSourceMap {}
                                                                                                                                              • Mozilla V3 raw source map.

                                                                                                                                              property file

                                                                                                                                              file: string;
                                                                                                                                              • The generated filename this source map is associated with (optional).

                                                                                                                                              property mappings

                                                                                                                                              mappings: string;
                                                                                                                                              • A string of base64 VLQs which contain the actual mappings.

                                                                                                                                              property names

                                                                                                                                              names: string[];
                                                                                                                                              • An array of identifiers which can be referenced by individual mappings.

                                                                                                                                              property sourceRoot

                                                                                                                                              sourceRoot?: string;
                                                                                                                                              • The URL root from which all sources are relative (optional).

                                                                                                                                              property sources

                                                                                                                                              sources: string[];
                                                                                                                                              • An array of URLs to the original source files.

                                                                                                                                              property sourcesContent

                                                                                                                                              sourcesContent?: string[];
                                                                                                                                              • An array of contents of the original source files (optional).

                                                                                                                                              property version

                                                                                                                                              version: number;
                                                                                                                                              • Which version of the source map spec this map is following.

                                                                                                                                              interface ReplaceUnicodeCodePointEscapesOptions

                                                                                                                                              interface ReplaceUnicodeCodePointEscapesOptions {}
                                                                                                                                              • Options for coffeescript.helpers.replaceUnicodeCodePointEscapes.

                                                                                                                                              property delimiter

                                                                                                                                              delimiter?: string;
                                                                                                                                              • Which flags are present in the regular expression for the replacement operation. Must include u if provided to support Unicode escapes.

                                                                                                                                              property error

                                                                                                                                              error?: string;
                                                                                                                                              • Separator between two Unicode characters in str parameter of coffeescript.helpers.replaceUnicodeCodePointEscapes.

                                                                                                                                              property flags

                                                                                                                                              flags?: string;
                                                                                                                                              • Error message if coffeescript.helpers.replaceUnicodeCodePointEscapes fails. Default: unicode code point escapes greater than \\u{10ffff} are not allowed.

                                                                                                                                              interface require

                                                                                                                                              interface require {}
                                                                                                                                              • Synchronous module definitions for the CoffeeScript library files.

                                                                                                                                                Parameter path

                                                                                                                                                Path to CoffeeScript library submodule relative to the ./lib/coffeescript directory.

                                                                                                                                                Returns

                                                                                                                                                CoffeeScript library submodule.

                                                                                                                                              call signature

                                                                                                                                              (path: string): require[keyof require];

                                                                                                                                                index signature

                                                                                                                                                [path: string]: object;

                                                                                                                                                  interface SourceMap

                                                                                                                                                  interface SourceMap {}
                                                                                                                                                  • Maps locations.

                                                                                                                                                  property add

                                                                                                                                                  add: (
                                                                                                                                                  sourceLocation: SourceLocation,
                                                                                                                                                  generatedLocation: SourceLocation,
                                                                                                                                                  options?: { noReplace: boolean }
                                                                                                                                                  ) => ReturnType<LineMap['add']>;
                                                                                                                                                  • Adds a mapping to the source map.

                                                                                                                                                    Parameter sourceLocation

                                                                                                                                                    Zero-indexed source location.

                                                                                                                                                    Parameter generatedLocation

                                                                                                                                                    Source line and column to insert into map.

                                                                                                                                                    Parameter options

                                                                                                                                                    Column insertion options.

                                                                                                                                                    Parameter

                                                                                                                                                    [options.noReplace] If true, column replacement is allowed.

                                                                                                                                                    Returns

                                                                                                                                                    Added source location data.

                                                                                                                                                  property encodeBase64

                                                                                                                                                  encodeBase64: (value: string) => string;
                                                                                                                                                  • Base-64 encoding for byte number.

                                                                                                                                                    Parameter value

                                                                                                                                                    Byte number in ASCII.

                                                                                                                                                    Returns

                                                                                                                                                    Base-64 encoded value or undefined.

                                                                                                                                                    Throws

                                                                                                                                                    "Cannot Base64 encode value: ${value}"

                                                                                                                                                  property encodeVlq

                                                                                                                                                  encodeVlq: (value: string) => string;
                                                                                                                                                  • VLQ encoding in reverse byte order.

                                                                                                                                                    Parameter value

                                                                                                                                                    Base-64 encoded value.

                                                                                                                                                    Returns

                                                                                                                                                    Reversed VLQ-encoded value.

                                                                                                                                                    Throws

                                                                                                                                                    "Cannot Base64 encode value: ${value}"

                                                                                                                                                  property generate

                                                                                                                                                  generate: (
                                                                                                                                                  column: number,
                                                                                                                                                  source: SourceLocation,
                                                                                                                                                  options?: { noReplace: boolean }
                                                                                                                                                  ) => string;
                                                                                                                                                  • Generates a V3 source map, returning the generated JSON as a string.

                                                                                                                                                    Parameter options

                                                                                                                                                    Column insertion options

                                                                                                                                                    Parameter

                                                                                                                                                    [options.generatedFile] Property generatedFile in source map.

                                                                                                                                                    Parameter

                                                                                                                                                    [options.sourceFiles] Property sources in source map.

                                                                                                                                                    Parameter

                                                                                                                                                    [options.sourceRoot] Property sourceRoot in source map.

                                                                                                                                                    Returns

                                                                                                                                                    Added source location data.

                                                                                                                                                  property lines

                                                                                                                                                  lines: LineMap[];

                                                                                                                                                    property sourceLocation

                                                                                                                                                    sourceLocation: (column: number) => SourceLocation | void;
                                                                                                                                                    • Fetch source location data for a specific column.

                                                                                                                                                      Parameter column

                                                                                                                                                      Zero-indexed column number.

                                                                                                                                                      Returns

                                                                                                                                                      [sourceLine, sourceColumn] if it exists in line map.

                                                                                                                                                    interface SourceMapOptions

                                                                                                                                                    interface SourceMapOptions {}
                                                                                                                                                    • CoffeeScript compiler options for source map output. Type for compiler options when sourceMap is true.

                                                                                                                                                    property ast

                                                                                                                                                    ast?: boolean;
                                                                                                                                                    • If true, output an abstract syntax tree of the input CoffeeScript source code.

                                                                                                                                                    property bare

                                                                                                                                                    bare?: boolean;
                                                                                                                                                    • If true, omit a top-level IIFE safety wrapper.

                                                                                                                                                    property filename

                                                                                                                                                    filename?: string;
                                                                                                                                                    • File name to compile - defaults to index.js.

                                                                                                                                                    property header

                                                                                                                                                    header?: boolean;
                                                                                                                                                    • If true, output the Generated by CoffeeScript header.

                                                                                                                                                    property inlineMap

                                                                                                                                                    inlineMap?: boolean;
                                                                                                                                                    • If true, output the source map as a base64-encoded string in a comment at the bottom.

                                                                                                                                                    property sourceMap

                                                                                                                                                    sourceMap: true;
                                                                                                                                                    • Output a source map object with the code.

                                                                                                                                                    property transpile

                                                                                                                                                    transpile?: Babel.TransformOptions;
                                                                                                                                                    • Babel transpilation options - see Babel.TransformOptions.

                                                                                                                                                    interface SyntaxError

                                                                                                                                                    interface SyntaxError {}
                                                                                                                                                    • Syntax error thrown by CoffeeScript compiler.

                                                                                                                                                    property code

                                                                                                                                                    code?: string;
                                                                                                                                                    • Source code that generated the coffee compiler error

                                                                                                                                                    property filename

                                                                                                                                                    filename?: string;
                                                                                                                                                    • File name for invalid CoffeeScript resource.

                                                                                                                                                    property location

                                                                                                                                                    location: LocationData;
                                                                                                                                                    • Starting and ending location data.

                                                                                                                                                    property stack

                                                                                                                                                    stack: ReturnType<SyntaxError['toString']>;
                                                                                                                                                    • String representation of syntax error.

                                                                                                                                                    property toString

                                                                                                                                                    toString: () => string;
                                                                                                                                                    • Stack trace generator for error.

                                                                                                                                                    Type Aliases

                                                                                                                                                    type LocationData

                                                                                                                                                    type LocationData = AcornLocationData | JisonLocationData;
                                                                                                                                                    • CoffeeScript abstract syntax tree location data.

                                                                                                                                                    type SourceLocation

                                                                                                                                                    type SourceLocation = [
                                                                                                                                                    /** Zero-indexed line number. */
                                                                                                                                                    number,
                                                                                                                                                    /** Zero-indexed column number. */
                                                                                                                                                    number
                                                                                                                                                    ];
                                                                                                                                                    • Source location array.

                                                                                                                                                    Package Files (1)

                                                                                                                                                    Dependencies (1)

                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                    No dev dependencies.

                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                    No peer dependencies.

                                                                                                                                                    Badge

                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/coffeescript.

                                                                                                                                                    • Markdown
                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/coffeescript)
                                                                                                                                                    • HTML
                                                                                                                                                      <a href="https://www.jsdocs.io/package/@types/coffeescript"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>