DefinitelyTyped/types/first-mate
2017-10-25 11:31:36 -07:00
..
first-mate-tests.ts Revamp services. Improve consistency. Add *Compatible types. (#20726) 2017-10-23 07:46:49 -07:00
index.d.ts Revamp services. Improve consistency. Add *Compatible types. (#20726) 2017-10-23 07:46:49 -07:00
README.md Revamp services. Improve consistency. Add *Compatible types. (#20726) 2017-10-23 07:46:49 -07:00
tsconfig.json Enable strictFunctionTypes (#20373) 2017-10-06 14:03:03 -07:00
tslint.json Revamp services. Improve consistency. Add *Compatible types. (#20726) 2017-10-23 07:46:49 -07:00

First Mate Type Definitions

TypeScript type definitions for First Mate, which is published as "first-mate" on NPM.

Usage Notes

Exports

The three classes exported from this module are: Grammar, GrammarRegistry, and ScopeSelector.

import { Grammar, GrammarRegistry, ScopeSelector } from "first-mate";
let selector = new ScopeSelector("a | b");

The FirstMate Namespace

Many of the types used by First Mate can be referenced from the FirstMate namespace.

function example(grammar: FirstMate.Grammar) {}

Exposing Private Methods and Properties

Declaration Merging can be used to augment any of the types used within First Mate. As an example, if we wanted to reveal the private getMaxTokensPerLine method within the Grammar class, then we would create a file with the following contents:

// <<filename>>.d.ts

declare namespace FirstMate {
  interface Grammar {
    getMaxTokensPerLine(): number;
  }
}

Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the Grammar class without TypeScript reporting errors.