├── .gitignore ├── .npmignore ├── .travis.yml ├── README.md ├── build.sh ├── gulpfile.js ├── index.js ├── package.json ├── reporter.js ├── ruleFailure.js ├── specs ├── fixtures │ └── TestSrc.ts ├── reporter.spec.ts ├── ruleFailure.spec.ts ├── specRunner.spec.ts ├── stylishFormatter.spec.ts └── support.ts ├── src ├── index.ts ├── reporter.ts ├── ruleFailure.ts └── stylishFormatter.ts ├── stylishFormatter.js ├── tslint.json └── typings ├── mocha.d.ts ├── node.d.ts ├── stylish.d.ts ├── tslint.d.ts ├── typescriptServices.d.ts └── vinyl.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.log 3 | .idea 4 | compiled/ 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | specs/ 2 | src/ 3 | typings/ 4 | compiled/ 5 | tslint.json 6 | .travis.yml 7 | build.sh 8 | gulpfile.js 9 | .gitignore -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5.0.0" 4 | - "4.0.0" 5 | - "3.0.0" 6 | script: 7 | ./build.sh -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | tslint-stylish 2 | =================== 3 | ![Dependencies](https://david-dm.org/adamfitzpatrick/tslint-stylish.svg) 4 | ![Build Status](https://travis-ci.org/adamfitzpatrick/tslint-stylish.svg?branch=master) 5 | 6 | This package has been deprecated. The folks over at Palantir have added a stylish formatter to the list of core 7 | formatters for tslint which provides essentially the same output as this one. 8 | 9 | 10 | Typescript lint reporter for tslint and gulp-tslint along the lines of jshint-stylish. This formatter can be implemented 11 | easily using the original tslint package, as well as gulp-tslint, grunt-tslint and webpack. 12 | 13 | To everyone who downloaded this package: This was my first attempt at an npm package as a brand new software developer. 14 | Thank you for downloading this package and gulp-tslint-stylish more than 215,000 times - more than I ever imagined 15 | possible. 16 | 17 | Thank you to 18 | [Sindre Sorhus](https://github.com/sindresorhus) for the reporter design, and to 19 | [Panu Horsmalahti](https://github.com/panuhorsmalahti) for creating 20 | [gulp-tslint](https://github.com/panuhorsmalahti/gulp-tslint). 21 | 22 | 23 | Installation 24 | ------------ 25 | Note that this is designed to accept output from tslint and gulp-tslint, which must be installed separately. 26 | To install this package: 27 | 28 | ``` 29 | npm install tslint-stylish 30 | ``` 31 | 32 | Usage 33 | ----- 34 | Tslint 35 | 36 | - Install Tslint & tslint-stylish: 37 | 38 | ``` 39 | npm install tslint 40 | npm install tslint-stylish 41 | ``` 42 | 43 | - Apply as named formatter: 44 | 45 | ``` 46 | tslint -s node_modules/tslint-stylish -t stylish 47 | ``` 48 | 49 | 50 | Gulp 51 | 52 | ``` 53 | var gulp = require('gulp'); 54 | var tslint = require('gulp-tslint'); 55 | var stylish = require('tslint-stylish'); 56 | 57 | gulp.task('lint', function () { 58 | gulp.src('SourceFiles.ts') 59 | .pipe(tslint()) 60 | .pipe(tslint.report(stylish, { 61 | emitError: false, 62 | sort: true, 63 | bell: true 64 | })); 65 | ``` 66 | 67 | Options 68 | ------- 69 | - `sort` 70 | - Default is `true` 71 | - When true, failures are sorted by line number. 72 | - `bell` 73 | - Default is `true` 74 | - When true, emits the system bell with report. 75 | - `fullPath` 76 | - Default is `true` 77 | - When true, full path to file is included with report. When false, only the filename is included. 78 | - Contribution courtesy of [Sagar Vadodaria](https://github.com/sagarvadodaria) 79 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | npm install 4 | gulp prod 5 | 6 | EXITSTATUS=$? 7 | 8 | npm run tslint-test 9 | 10 | exit $EXITSTATUS -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | "use strict"; 3 | 4 | var del = require("del"); 5 | var gulp = require("gulp"); 6 | var mocha = require("gulp-mocha"); 7 | var tslint = require("gulp-tslint"); 8 | var tsc = require("gulp-typescript"); 9 | var watch = require("gulp-watch"); 10 | var batch = require("gulp-batch"); 11 | var debug = require("gulp-debug"); 12 | var minimist = require("minimist"); 13 | require("gulp-help")(gulp, { 14 | description: "Help listing" 15 | }); 16 | 17 | var options = minimist(process.argv.slice(2)); 18 | function isProd() { 19 | return options._[0] === "prod"; 20 | } 21 | 22 | var typescriptOptions = { 23 | declarationFiles: false, 24 | noExternalResolve: false, 25 | module: "commonjs" 26 | }; 27 | 28 | function clean(cb) { 29 | del([ 30 | "compiled", 31 | "index.js", 32 | "stylishFormatter.js", 33 | "reporter.js", 34 | "ruleFailure.js" 35 | ]); 36 | cb(); 37 | } 38 | 39 | gulp.task("clean", clean); 40 | 41 | function tsCompile() { 42 | return gulp.src("src/**/*.ts") 43 | .pipe(tslint()) 44 | .pipe(tslint.report("verbose", { 45 | emitError: isProd() 46 | })) 47 | .pipe(tsc(typescriptOptions)) 48 | .js.pipe(gulp.dest("compiled/src")); 49 | } 50 | 51 | function specCompile() { 52 | return gulp.src(["specs/**/*.ts", "!specs/fixtures/**/*"]) 53 | .pipe(tslint()) 54 | .pipe(tslint.report("verbose", { 55 | emitError: isProd() 56 | })) 57 | .pipe(tsc(typescriptOptions)) 58 | .js.pipe(gulp.dest("compiled/specs")); 59 | } 60 | 61 | gulp.task("compile:src", "Compile source typescript to javascript.", ["clean"], tsCompile); 62 | gulp.task("compile:spec", "Compile typescript specs to javascript.", ["clean"], specCompile); 63 | 64 | function unitTests() { 65 | return gulp.src("compiled/specs/*.spec.js") 66 | .pipe(mocha({reporter: "spec"})); 67 | } 68 | 69 | gulp.task("default", "Compile source and specs to javascript and run tests.", ["compile:src", "compile:spec"], unitTests); 70 | 71 | function prod() { 72 | return gulp.src([ 73 | "compiled/src/*.js" 74 | ]) 75 | .pipe(gulp.dest("./")); 76 | } 77 | gulp.task("prod", "Build for production: fails on error.", ["default"], prod); 78 | 79 | gulp.task("watch", function () { 80 | gulp.watch(["src/**/*.ts", "specs/**/*.ts"], ["default"]); 81 | }); 82 | 83 | }()); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var Reporter = require("./reporter"); 4 | module.exports = function (linterOut, file, options) { 5 | var reporter = new Reporter(linterOut, file, options); 6 | reporter.publish(); 7 | }; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tslint-stylish", 3 | "version": "2.1.0", 4 | "description": "Reporter for tslint along the lines of jshint-stylish", 5 | "author": "Adam Fitzpatrick ", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/adamfitzpatrick/tslint-stylish/issues", 9 | "email": "adam@muneris.net" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git@github.com:adamfitzpatrick/tslint-stylish.git" 14 | }, 15 | "main": "index.js", 16 | "scripts": { 17 | "tslint-test": "tslint specs/fixtures/TestSrc.ts -s . -t stylish" 18 | }, 19 | "keywords": [ 20 | "gulp", 21 | "gulpplugin", 22 | "grunt", 23 | "typescript", 24 | "tslint", 25 | "stylish", 26 | "reporter" 27 | ], 28 | "devDependencies": { 29 | "del": "^2.0.2", 30 | "gulp": "^3.8.11", 31 | "gulp-batch": "^1.0.5", 32 | "gulp-debug": "^2.1.2", 33 | "gulp-help": "^1.3.4", 34 | "gulp-mocha": "^2.0.1", 35 | "gulp-notify": "^2.2.0", 36 | "gulp-tslint": "^3.4.0", 37 | "gulp-typescript": "^2.9.2", 38 | "gulp-watch": "^4.2.4", 39 | "minimist": "^1.2.0" 40 | }, 41 | "dependencies": { 42 | "chalk": "^1.1.1", 43 | "lodash": "^3.10.1", 44 | "log-symbols": "^1.0.2", 45 | "text-table": "^0.2.0", 46 | "tslint": "^2.5.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /reporter.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var chalk = require("chalk"); 4 | var table = require("text-table"); 5 | var logSymbols = require("log-symbols"); 6 | var _ = require("lodash"); 7 | var path = require("path"); 8 | var RuleFailure = require("./ruleFailure"); 9 | var Reporter = (function () { 10 | function Reporter(linterOutputArray, file, options) { 11 | this.parseOptions(options); 12 | this.parseFilename(file); 13 | this.ruleFailures = RuleFailure.ruleFailureFactory(linterOutputArray); 14 | this.count = this.ruleFailures.length; 15 | } 16 | Reporter.prototype.getFileName = function () { return this.fileName; }; 17 | Reporter.prototype.getCount = function () { return this.count; }; 18 | Reporter.prototype.getRuleFailures = function () { return this.ruleFailures; }; 19 | Reporter.prototype.getOptions = function () { return this.options; }; 20 | Reporter.prototype.toString = function () { 21 | var count = " " + chalk.red(logSymbols.error) + " " + 22 | this.count + " error" + 23 | (this.ruleFailures.length > 1 ? "s" : ""); 24 | var output = "\n" + chalk.underline(this.fileName) + "\n" + 25 | this.generateFailureStrings() + 26 | "\n\n" + count + "\n\n"; 27 | if (this.options.bell) { 28 | output += "\x07"; 29 | } 30 | return output; 31 | }; 32 | Reporter.prototype.publish = function () { 33 | process.stdout.write(this.toString()); 34 | }; 35 | Reporter.prototype.generateFailureStrings = function () { 36 | var failures = []; 37 | if (this.options.sort) { 38 | this.ruleFailures = _.sortBy(this.ruleFailures, function (n) { 39 | return n.startPosition.line; 40 | }); 41 | } 42 | this.ruleFailures.forEach(function (failure) { 43 | // Error positions are zero-based from tslint, and must be incremented by 1 44 | failures.push([ 45 | " ", 46 | chalk.gray("line " + (failure.getStartPosition().line + 1)), 47 | chalk.gray("col " + (failure.getStartPosition().character + 1)), 48 | chalk.red(failure.getFailure()) 49 | ]); 50 | }); 51 | return table(failures, { align: ["l", "l", "l", "l"] }); 52 | }; 53 | Reporter.prototype.parseOptions = function (options) { 54 | this.options = options || {}; 55 | if (this.options.sort !== false) { 56 | this.options.sort = true; 57 | } 58 | if (this.options.bell !== false) { 59 | this.options.bell = true; 60 | } 61 | if (this.options.fullPath !== false) { 62 | this.options.fullPath = true; 63 | } 64 | }; 65 | Reporter.prototype.parseFilename = function (file) { 66 | this.fileName = file.path || file; 67 | if (!this.options.fullPath) { 68 | this.fileName = path.basename(this.fileName); 69 | } 70 | }; 71 | return Reporter; 72 | }()); 73 | module.exports = Reporter; 74 | -------------------------------------------------------------------------------- /ruleFailure.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /// 3 | var _ = require("lodash"); 4 | var RuleFailure = (function () { 5 | function RuleFailure(ruleFailure) { 6 | this.fileName = ruleFailure.fileName; 7 | this.ruleName = ruleFailure.ruleName; 8 | this.failure = ruleFailure.failure; 9 | if (ruleFailure.startPosition.lineAndCharacter) { 10 | var start = ruleFailure.startPosition; 11 | this.startPosition = { 12 | position: start.position, 13 | line: start.lineAndCharacter.line, 14 | character: start.lineAndCharacter.character 15 | }; 16 | var end = ruleFailure.endPosition; 17 | this.endPosition = { 18 | position: end.position, 19 | line: end.lineAndCharacter.line, 20 | character: end.lineAndCharacter.character 21 | }; 22 | } 23 | else { 24 | this.startPosition = ruleFailure.startPosition; 25 | this.endPosition = ruleFailure.endPosition; 26 | } 27 | } 28 | RuleFailure.ruleFailureFactory = function (linterOutputArray) { 29 | return _.map(linterOutputArray, function (lint) { return new RuleFailure(lint); }); 30 | }; 31 | RuleFailure.prototype.getFileName = function () { return this.fileName; }; 32 | RuleFailure.prototype.getRuleName = function () { return this.ruleName; }; 33 | RuleFailure.prototype.getFailure = function () { return this.failure; }; 34 | RuleFailure.prototype.getStartPosition = function () { return this.startPosition; }; 35 | RuleFailure.prototype.getEndPosition = function () { return this.endPosition; }; 36 | return RuleFailure; 37 | }()); 38 | module.exports = RuleFailure; 39 | -------------------------------------------------------------------------------- /specs/fixtures/TestSrc.ts: -------------------------------------------------------------------------------- 1 | class Student { 2 | fullname : string; 3 | constructor(public firstname, public middleinitial, public lastname) { 4 | this.fullname = firstname + " " + middleinitial + " " + lastname; 5 | } 6 | } 7 | 8 | interface Person { 9 | firstname: string; 10 | lastname: string; 11 | } 12 | 13 | function greeter(person : Person) { 14 | return "Hello, " + person.firstname + " " + person.lastname; 15 | } 16 | 17 | var user = new Student('Jane', "M.", "User"); 18 | 19 | console.log(greeter(user)); -------------------------------------------------------------------------------- /specs/reporter.spec.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var stylish = require(process.cwd() + "/compiled/src/index"); 4 | var assert = require("assert"); 5 | var tslint = require("gulp-tslint"); 6 | 7 | import Support = require("./support"); 8 | import Reporter = require("../src/reporter"); 9 | import RuleFailure = require("../src/ruleFailure"); 10 | 11 | var TestConstants = Support.TestConstants; 12 | 13 | class ReporterSpec { 14 | private logInterceptor: Support.LogInterceptor; 15 | private nextTest: () => void; 16 | 17 | constructor() { 18 | this.logInterceptor = new Support.LogInterceptor(); 19 | } 20 | 21 | public run(nextTest?: () => void): void { 22 | if (nextTest) { this.nextTest = nextTest; } 23 | var reporter: Reporter; 24 | describe("Reporter", () => { 25 | 26 | beforeEach(() => { 27 | reporter = new Reporter(TestConstants.PALANTIRLINTOUTPUT, 28 | "TestSrc.ts", { bell: false, sort: false, fullPath: false }); 29 | }); 30 | 31 | after(() => { 32 | this.tearDown(); 33 | }); 34 | 35 | describe("constructors", () => { 36 | it("should accept palantir/tslint input", () => { 37 | var expected = TestConstants.PALANTIRLINTOUTPUT[0]; 38 | var actual = reporter.getRuleFailures()[0]; 39 | assert.equal(actual.getFailure(), expected.failure); 40 | assert.equal(actual.getStartPosition().line, expected.startPosition.lineAndCharacter.line); 41 | }); 42 | 43 | it("should accept non-palantir input", () => { 44 | var expected = TestConstants.LINTOUTPUT[0]; 45 | var reporter = new Reporter(TestConstants.LINTOUTPUT, TestConstants.LINTEDFILE); 46 | var actual = reporter.getRuleFailures()[0]; 47 | assert.equal(actual.getFailure(), expected.failure); 48 | assert.equal(actual.getStartPosition().line, expected.startPosition.line); 49 | }); 50 | }); 51 | 52 | describe("accessors", () => { 53 | it("should get the formated filename", () => { 54 | assert.equal(reporter.getFileName(), "TestSrc.ts"); 55 | }); 56 | 57 | it("should get the failure count", () => { 58 | assert.equal(reporter.getCount(), TestConstants.LINTOUTPUT.length); 59 | }); 60 | 61 | it("should get a list of rule failures", () => { 62 | assert.deepEqual(reporter.getRuleFailures(), TestConstants.LINTOUTPUT); 63 | }); 64 | 65 | it("should get the options object", () => { 66 | var expected = { bell: false, sort: false, fullPath: false }; 67 | assert.deepEqual(reporter.getOptions(), expected); 68 | }); 69 | }); 70 | 71 | describe("toString", () => { 72 | it("should return the stylish string unsorted with short path & no bell", () => { 73 | var expected = TestConstants.FORMATTEDOUTPUT.filename + 74 | TestConstants.FORMATTEDOUTPUT.contentUnsorted + 75 | TestConstants.FORMATTEDOUTPUT.count; 76 | assert.equal(reporter.toString(), expected); 77 | }); 78 | 79 | it("should return the stylish string sorted with short path & no bell", () => { 80 | var options = { bell: false, fullPath: false }; 81 | var reporter = new Reporter(TestConstants.LINTOUTPUT, 82 | TestConstants.LINTEDFILE, options); 83 | var expected = TestConstants.FORMATTEDOUTPUT.filename + 84 | TestConstants.FORMATTEDOUTPUT.contentSorted + 85 | TestConstants.FORMATTEDOUTPUT.count; 86 | assert.equal(reporter.toString(), expected); 87 | }); 88 | 89 | it("should return the stylish string sorted with short path & bell", () => { 90 | var options = { fullPath: false }; 91 | var reporter = new Reporter(TestConstants.LINTOUTPUT, 92 | TestConstants.LINTEDFILE, options); 93 | var expected = TestConstants.FORMATTEDOUTPUT.filename + 94 | TestConstants.FORMATTEDOUTPUT.contentSorted + 95 | TestConstants.FORMATTEDOUTPUT.count + 96 | TestConstants.FORMATTEDOUTPUT.bell; 97 | assert.equal(reporter.toString(), expected); 98 | }); 99 | 100 | it("should return the stylish string sorted with full path & bell", () => { 101 | var reporter = new Reporter(TestConstants.LINTOUTPUT, 102 | TestConstants.LINTEDFILE); 103 | var expected = TestConstants.FORMATTEDOUTPUT.fullPath + 104 | TestConstants.FORMATTEDOUTPUT.contentSorted + 105 | TestConstants.FORMATTEDOUTPUT.count + 106 | TestConstants.FORMATTEDOUTPUT.bell; 107 | assert.equal(reporter.toString(), expected); 108 | }); 109 | }); 110 | 111 | describe("publish", () => { 112 | it("should output the stylish string to stdout", () => { 113 | var reporter = new Reporter(TestConstants.LINTOUTPUT, 114 | TestConstants.LINTEDFILE); 115 | var expected = TestConstants.FORMATTEDOUTPUT.fullPath + 116 | TestConstants.FORMATTEDOUTPUT.contentSorted + 117 | TestConstants.FORMATTEDOUTPUT.count + 118 | TestConstants.FORMATTEDOUTPUT.bell; 119 | this.logInterceptor.clearLog(); 120 | reporter.publish(); 121 | assert.equal(this.logInterceptor.getLog(), expected); 122 | }); 123 | }); 124 | }); 125 | } 126 | 127 | public tearDown = (): void => { 128 | this.logInterceptor.destroy(); 129 | if (this.nextTest) { this.nextTest(); } 130 | }; 131 | } 132 | 133 | export = ReporterSpec; 134 | -------------------------------------------------------------------------------- /specs/ruleFailure.spec.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var assert = require("assert"); 4 | 5 | import RuleFailure = require("../src/ruleFailure"); 6 | import Support = require("./support"); 7 | 8 | var TestConstants = Support.TestConstants; 9 | 10 | class RuleFailureSpec { 11 | 12 | public run() { 13 | var ruleFailure: RuleFailure; 14 | var expectation = TestConstants.LINTOUTPUT[0]; 15 | 16 | describe("RuleFailure", () => { 17 | beforeEach(() => { 18 | ruleFailure = new RuleFailure(TestConstants.PALANTIRLINTOUTPUT[0]); 19 | }); 20 | 21 | describe("constructors", () => { 22 | it("should accept palantir/tslint input and reconfigure it", () => { 23 | assert.equal(ruleFailure.getFileName(), expectation.fileName); 24 | assert.deepEqual(ruleFailure.getStartPosition(), expectation.startPosition); 25 | }); 26 | 27 | it("should accept gulp-tslint input", () => { 28 | ruleFailure = new RuleFailure(TestConstants.LINTOUTPUT[0]); 29 | assert.equal(ruleFailure.getFileName(), expectation.fileName); 30 | assert.deepEqual(ruleFailure.getStartPosition(), expectation.startPosition); 31 | }); 32 | }); 33 | 34 | describe("accessors", () => { 35 | it("should return the file name", () => { 36 | assert.equal(ruleFailure.getFileName(), expectation.fileName); 37 | }); 38 | 39 | it("should return the rule name", () => { 40 | assert.equal(ruleFailure.getRuleName(), expectation.ruleName); 41 | }); 42 | 43 | it("should return the failure description", () => { 44 | assert.equal(ruleFailure.getFailure(), expectation.failure); 45 | }); 46 | 47 | it("should return the start position", () => { 48 | assert.deepEqual(ruleFailure.getStartPosition(), expectation.startPosition); 49 | }); 50 | 51 | it("should return the end position", () => { 52 | assert.deepEqual(ruleFailure.getEndPosition(), expectation.endPosition); 53 | }); 54 | }); 55 | }); 56 | } 57 | } 58 | 59 | export = RuleFailureSpec; 60 | -------------------------------------------------------------------------------- /specs/specRunner.spec.ts: -------------------------------------------------------------------------------- 1 | import ReporterSpec = require("./reporter.spec"); 2 | import RuleFailureSpec = require("./ruleFailure.spec"); 3 | import StylishFormatterSpec = require("./stylishFormatter.spec"); 4 | 5 | var stylishRun = (): void => { 6 | var stylishFormatterSpec = new StylishFormatterSpec(); 7 | stylishFormatterSpec.run(); 8 | }; 9 | 10 | var reporterSpec = new ReporterSpec(); 11 | reporterSpec.run(stylishRun); 12 | 13 | var ruleFailureSpec = new RuleFailureSpec(); 14 | ruleFailureSpec.run(); 15 | -------------------------------------------------------------------------------- /specs/stylishFormatter.spec.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | var assert = require("assert"); 5 | var fs = require("fs"); 6 | 7 | import StylishFormatter = require("../src/stylishFormatter"); 8 | import support = require("./support"); 9 | 10 | var Formatter = StylishFormatter.Formatter; 11 | var TestConstants = support.TestConstants; 12 | 13 | class StylishFormatterSpecs { 14 | private nextTest: () => void; 15 | 16 | public run(nextTest?: () => void) { 17 | if (nextTest) { this.nextTest = nextTest; } 18 | 19 | describe("stylishFormatter", () => { 20 | var formatter; 21 | beforeEach(() => { 22 | formatter = new Formatter(); 23 | }); 24 | 25 | after(() => { 26 | this.tearDown(); 27 | }); 28 | 29 | it("outputs properly formatted stylish data", () => { 30 | var report = formatter.format(TestConstants.LINTOUTPUT); 31 | var formattedOutput = TestConstants.FORMATTEDOUTPUT; 32 | var expected = formattedOutput.noFile + 33 | formattedOutput.contentSorted + formattedOutput.count; 34 | assert.equal(expected, report); 35 | }); 36 | }); 37 | } 38 | 39 | public tearDown = (): void => { 40 | if (this.nextTest) { this.nextTest(); } 41 | }; 42 | } 43 | 44 | export = StylishFormatterSpecs; 45 | -------------------------------------------------------------------------------- /specs/support.ts: -------------------------------------------------------------------------------- 1 | var util = require("util"); 2 | import RuleFailure = require("../src/ruleFailure"); 3 | 4 | export class LogInterceptor { 5 | private static _instance: LogInterceptor = null; 6 | private _log: string[] = []; 7 | private _write = process.stdout.write.bind(process.stdout); 8 | private _clog = console.log; 9 | 10 | constructor() { 11 | if (LogInterceptor._instance) { 12 | throw new Error("Error: Instantiation failed. Singleton class already instantiated."); 13 | } 14 | LogInterceptor._instance = this; 15 | 16 | process.stdout.write = (str: any): any => { 17 | this._log.push(str); 18 | }; 19 | 20 | console.log = (...args: string[]) => { 21 | this._write(util.format.apply(null, args) + "\n"); 22 | }; 23 | } 24 | 25 | public getLog(): Array { 26 | return this._log; 27 | } 28 | 29 | public clearLog(): void { 30 | this._log = []; 31 | } 32 | 33 | public destroy(): void { 34 | process.stdout.write = this._write; 35 | console.log = this._clog; 36 | LogInterceptor._instance = null; 37 | } 38 | } 39 | 40 | export class TestConstants { 41 | static LINTEDFILE = { 42 | path: process.cwd() + "/specs/fixtures/TestSrc.ts" 43 | }; 44 | static PALANTIRLINTOUTPUT: Stylish.IPalantirRuleFailureObject[] = [ 45 | { 46 | "fileName": "NOFILE", 47 | "failure": "file should end with a newline", 48 | "startPosition": { 49 | "position": 442, 50 | "lineAndCharacter": { 51 | "line": 18, 52 | "character": 27 53 | } 54 | }, 55 | "endPosition": { 56 | "position": 442, 57 | "lineAndCharacter": { 58 | "line": 18, 59 | "character": 27 60 | } 61 | }, 62 | "ruleName": "eofline" 63 | }, { 64 | "fileName": "NOFILE", 65 | "failure": "\' should be \"", 66 | "startPosition": { 67 | "position": 391, 68 | "lineAndCharacter": { 69 | "line": 16, 70 | "character": 23 71 | } 72 | }, 73 | "endPosition": { 74 | "position": 397, 75 | "lineAndCharacter": { 76 | "line": 16, 77 | "character": 29 78 | } 79 | }, 80 | "ruleName": "quotemark" 81 | } 82 | ]; 83 | static LINTOUTPUT: Stylish.IRuleFailureObject[] = [ 84 | { 85 | "fileName": "NOFILE", 86 | "failure": "file should end with a newline", 87 | "startPosition": { 88 | "position": 442, 89 | "line": 18, 90 | "character": 27 91 | }, 92 | "endPosition": { 93 | "position": 442, 94 | "line": 18, 95 | "character": 27 96 | }, 97 | "ruleName": "eofline" 98 | }, { 99 | "fileName": "NOFILE", 100 | "failure": "\' should be \"", 101 | "startPosition": { 102 | "position": 391, 103 | "line": 16, 104 | "character": 23 105 | }, 106 | "endPosition": { 107 | "position": 397, 108 | "line": 16, 109 | "character": 29 110 | }, 111 | "ruleName": "quotemark" 112 | } 113 | ]; 114 | static FORMATTEDOUTPUT = { 115 | fullPath: "\n\u001b[4m" + process.cwd() + "/specs/fixtures/TestSrc.ts" + "\u001b[24m\n", 116 | filename: "\n\u001b[4mTestSrc.ts\u001b[24m\n", 117 | noFile: "\n\u001b[4mNOFILE\u001b[24m\n", 118 | contentSorted: " \u001b[90mline 17\u001b[39m \u001b[90mcol 24\u001b[39m" + 119 | " \u001b[31m\' should be \"\u001b[39m\n \u001b[90mline 19\u001b[39m " + 120 | "\u001b[90mcol 28\u001b[39m \u001b[31mfile should end with a " + 121 | "newline\u001b[39m", 122 | contentUnsorted: " \u001b[90mline 19\u001b[39m \u001b[90mcol 28\u001b[39m " + 123 | "\u001b[31mfile should end with a newline\u001b[39m\n \u001b[90mline " + 124 | "17\u001b[39m \u001b[90mcol 24\u001b[39m \u001b[31m\' should be \"\u001b[39m", 125 | count: "\n\n \u001b[31m\u001b[31m✖\u001b[31m\u001b[39m 2 errors\n\n", 126 | bell: "\u0007" 127 | }; 128 | } 129 | export function clone(object: Object): Object { 130 | return JSON.parse(JSON.stringify(object)); 131 | } 132 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import RuleFailure = require("./ruleFailure"); 4 | import Reporter = require("./reporter"); 5 | 6 | module.exports = function (linterOut: Stylish.IRuleFailureObject[], file: Vinyl.File, options?: Stylish.IOptions) { 7 | var reporter = new Reporter(linterOut, file, options); 8 | reporter.publish(); 9 | }; 10 | -------------------------------------------------------------------------------- /src/reporter.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var chalk = require("chalk"); 4 | var table = require("text-table"); 5 | var logSymbols = require("log-symbols"); 6 | var _ = require("lodash"); 7 | var path = require("path"); 8 | 9 | import RuleFailure = require("./ruleFailure"); 10 | 11 | type IPalantirRuleFailureObject = Stylish.IPalantirRuleFailureObject; 12 | type IRuleFailureObject = Stylish.IRuleFailureObject; 13 | type IOptions = Stylish.IOptions; 14 | 15 | class Reporter { 16 | private fileName: string; 17 | private count: number; 18 | private ruleFailures: RuleFailure[]; 19 | private options: IOptions; 20 | 21 | constructor(linterOutputArray: IRuleFailureObject[], file: Vinyl.File, options?: IOptions); 22 | constructor(linterOutputArray: IPalantirRuleFailureObject[], file: string, options?: IOptions); 23 | constructor(linterOutputArray: any, file: any, options?: any) { 24 | this.parseOptions(options); 25 | this.parseFilename(file); 26 | this.ruleFailures = RuleFailure.ruleFailureFactory(linterOutputArray); 27 | this.count = this.ruleFailures.length; 28 | } 29 | 30 | public getFileName(): string { return this.fileName; } 31 | 32 | public getCount(): number { return this.count; } 33 | 34 | public getRuleFailures(): RuleFailure[] { return this.ruleFailures; } 35 | 36 | public getOptions(): IOptions { return this.options; } 37 | 38 | public toString(): string { 39 | var count = " " + chalk.red(logSymbols.error) + " " + 40 | this.count + " error" + 41 | (this.ruleFailures.length > 1 ? "s" : ""); 42 | var output = "\n" + chalk.underline(this.fileName) + "\n" + 43 | this.generateFailureStrings() + 44 | "\n\n" + count + "\n\n"; 45 | if (this.options.bell) { output += "\x07"; } 46 | return output; 47 | } 48 | 49 | 50 | public publish(): void { 51 | process.stdout.write(this.toString()); 52 | } 53 | 54 | private generateFailureStrings(): string { 55 | var failures = []; 56 | 57 | if (this.options.sort) { 58 | this.ruleFailures = _.sortBy(this.ruleFailures, function (n) { 59 | return n.startPosition.line; 60 | }); 61 | } 62 | 63 | this.ruleFailures.forEach((failure: RuleFailure) => { 64 | // Error positions are zero-based from tslint, and must be incremented by 1 65 | failures.push([ 66 | " ", 67 | chalk.gray("line " + (failure.getStartPosition().line + 1)), 68 | chalk.gray("col " + (failure.getStartPosition().character + 1)), 69 | chalk.red(failure.getFailure()) 70 | ]); 71 | }); 72 | 73 | return table(failures, { align: [ "l", "l", "l", "l" ] }); 74 | } 75 | 76 | private parseOptions(options): void { 77 | this.options = options || {}; 78 | if (this.options.sort !== false) { this.options.sort = true; } 79 | if (this.options.bell !== false) { this.options.bell = true; } 80 | if (this.options.fullPath !== false) { this.options.fullPath = true; } 81 | } 82 | 83 | private parseFilename(file): void { 84 | this.fileName = file.path || file; 85 | if (!this.options.fullPath) { this.fileName = path.basename(this.fileName); } 86 | } 87 | } 88 | 89 | export = Reporter 90 | -------------------------------------------------------------------------------- /src/ruleFailure.ts: -------------------------------------------------------------------------------- 1 | /// 2 | var _ = require("lodash"); 3 | 4 | type IPalantirRuleFailureObject = Stylish.IPalantirRuleFailureObject; 5 | type IRuleFailureObject = Stylish.IRuleFailureObject; 6 | type IPosition = Stylish.IPosition; 7 | 8 | class RuleFailure { 9 | protected fileName: string; 10 | protected ruleName: string; 11 | protected failure: string; 12 | protected startPosition: Stylish.IPosition; 13 | protected endPosition: Stylish.IPosition; 14 | 15 | public static ruleFailureFactory(linterOutputArray: IPalantirRuleFailureObject[]): RuleFailure[]; 16 | public static ruleFailureFactory(linterOutputArray: IRuleFailureObject[]): RuleFailure[]; 17 | public static ruleFailureFactory(linterOutputArray: any[]): RuleFailure[] { 18 | return _.map(linterOutputArray, (lint) => new RuleFailure(lint)); 19 | } 20 | 21 | constructor(ruleFailure: IPalantirRuleFailureObject); 22 | constructor(ruleFailure: IRuleFailureObject); 23 | constructor(ruleFailure: any) { 24 | this.fileName = ruleFailure.fileName; 25 | this.ruleName = ruleFailure.ruleName; 26 | this.failure = ruleFailure.failure; 27 | 28 | if (ruleFailure.startPosition.lineAndCharacter) { 29 | var start = ruleFailure.startPosition; 30 | this.startPosition = { 31 | position: start.position, 32 | line: start.lineAndCharacter.line, 33 | character: start.lineAndCharacter.character 34 | }; 35 | var end = ruleFailure.endPosition; 36 | this.endPosition = { 37 | position: end.position, 38 | line: end.lineAndCharacter.line, 39 | character: end.lineAndCharacter.character 40 | }; 41 | } else { 42 | this.startPosition = ruleFailure.startPosition; 43 | this.endPosition = ruleFailure.endPosition; 44 | } 45 | } 46 | 47 | public getFileName(): string { return this.fileName; } 48 | 49 | public getRuleName(): string { return this.ruleName; } 50 | 51 | public getFailure(): string { return this.failure; } 52 | 53 | public getStartPosition(): IPosition { return this.startPosition; } 54 | 55 | public getEndPosition(): IPosition { return this.endPosition; } 56 | } 57 | 58 | export = RuleFailure; 59 | -------------------------------------------------------------------------------- /src/stylishFormatter.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var _ = require("lodash"); 4 | 5 | import Reporter = require("./reporter"); 6 | 7 | export class Formatter { 8 | 9 | private files: { [name: string]: Stylish.IPalantirRuleFailureObject[] } = {}; 10 | 11 | public format(failures: Stylish.IPalantirRuleFailureObject[]): string { 12 | this.invertLints(failures); 13 | var output = ""; 14 | _.forEach(this.files, (linterOutput: Stylish.IPalantirRuleFailureObject[]) => { 15 | var reporter = new Reporter(linterOutput, linterOutput[0].fileName, { bell: false }); 16 | output += reporter.toString(); 17 | }); 18 | return output; 19 | } 20 | 21 | private invertLints(failures: Stylish.IPalantirRuleFailureObject[]): void { 22 | failures.forEach((failure: Stylish.IPalantirRuleFailureObject) => { 23 | if (!this.files[failure.fileName]) { this.files[failure.fileName] = []; } 24 | this.files[failure.fileName].push(failure); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /stylishFormatter.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var _ = require("lodash"); 4 | var Reporter = require("./reporter"); 5 | var Formatter = (function () { 6 | function Formatter() { 7 | this.files = {}; 8 | } 9 | Formatter.prototype.format = function (failures) { 10 | this.invertLints(failures); 11 | var output = ""; 12 | _.forEach(this.files, function (linterOutput) { 13 | var reporter = new Reporter(linterOutput, linterOutput[0].fileName, { bell: false }); 14 | output += reporter.toString(); 15 | }); 16 | return output; 17 | }; 18 | Formatter.prototype.invertLints = function (failures) { 19 | var _this = this; 20 | failures.forEach(function (failure) { 21 | if (!_this.files[failure.fileName]) { 22 | _this.files[failure.fileName] = []; 23 | } 24 | _this.files[failure.fileName].push(failure); 25 | }); 26 | }; 27 | return Formatter; 28 | }()); 29 | exports.Formatter = Formatter; 30 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "curly": true, 5 | "eofline": true, 6 | "forin": true, 7 | "indent": [true, "spaces"], 8 | "label-position": true, 9 | "label-undefined": true, 10 | "max-line-length": [true, 140], 11 | "no-arg": true, 12 | "no-bitwise": true, 13 | "no-console": [true, 14 | "debug", 15 | "info", 16 | "time", 17 | "timeEnd", 18 | "trace" 19 | ], 20 | "no-construct": true, 21 | "no-debugger": true, 22 | "no-duplicate-key": true, 23 | "no-duplicate-variable": true, 24 | "no-empty": true, 25 | "no-eval": true, 26 | "no-string-literal": true, 27 | "no-switch-case-fall-through": true, 28 | "no-trailing-comma": true, 29 | "no-trailing-whitespace": true, 30 | "no-unused-expression": true, 31 | "no-unused-variable": false, 32 | "no-unreachable": true, 33 | "no-use-before-declare": true, 34 | "one-line": [true, 35 | "check-open-brace", 36 | "check-catch", 37 | "check-else", 38 | "check-whitespace" 39 | ], 40 | "quotemark": [true, "double"], 41 | "radix": true, 42 | "semicolon": true, 43 | "triple-equals": [true, "allow-null-check"], 44 | "variable-name": false, 45 | "whitespace": [true, 46 | "check-branch", 47 | "check-decl", 48 | "check-operator", 49 | "check-separator", 50 | "check-type" 51 | ] 52 | } 53 | } -------------------------------------------------------------------------------- /typings/mocha.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mocha 2.0.1 2 | // Project: http://mochajs.org/ 3 | // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | interface Mocha { 7 | // Setup mocha with the given setting options. 8 | setup(options: MochaSetupOptions): Mocha; 9 | 10 | //Run tests and invoke `fn()` when complete. 11 | run(callback?: () => void): void; 12 | 13 | // Set reporter as function 14 | reporter(reporter: () => void): Mocha; 15 | 16 | // Set reporter, defaults to "dot" 17 | reporter(reporter: string): Mocha; 18 | 19 | // Enable growl support. 20 | growl(): Mocha 21 | } 22 | 23 | interface MochaSetupOptions { 24 | //milliseconds to wait before considering a test slow 25 | slow?: number; 26 | 27 | // timeout in milliseconds 28 | timeout?: number; 29 | 30 | // ui name "bdd", "tdd", "exports" etc 31 | ui?: string; 32 | 33 | //array of accepted globals 34 | globals?: any[]; 35 | 36 | // reporter instance (function or string), defaults to `mocha.reporters.Dot` 37 | reporter?: any; 38 | 39 | // bail on the first test failure 40 | bail?: boolean; 41 | 42 | // ignore global leaks 43 | ignoreLeaks?: boolean; 44 | 45 | // grep string or regexp to filter tests with 46 | grep?: any; 47 | } 48 | 49 | interface MochaDone { 50 | (error?: Error): void; 51 | } 52 | 53 | declare var mocha: Mocha; 54 | 55 | declare var describe : { 56 | (description: string, spec: () => void): void; 57 | only(description: string, spec: () => void): void; 58 | skip(description: string, spec: () => void): void; 59 | timeout(ms: number): void; 60 | } 61 | 62 | // alias for `describe` 63 | declare var context : { 64 | (contextTitle: string, spec: () => void): void; 65 | only(contextTitle: string, spec: () => void): void; 66 | skip(contextTitle: string, spec: () => void): void; 67 | timeout(ms: number): void; 68 | } 69 | 70 | declare var it: { 71 | (expectation: string, assertion?: () => void): void; 72 | (expectation: string, assertion?: (done: MochaDone) => void): void; 73 | only(expectation: string, assertion?: () => void): void; 74 | only(expectation: string, assertion?: (done: MochaDone) => void): void; 75 | skip(expectation: string, assertion?: () => void): void; 76 | skip(expectation: string, assertion?: (done: MochaDone) => void): void; 77 | timeout(ms: number): void; 78 | }; 79 | 80 | declare function before(action: () => void): void; 81 | 82 | declare function before(action: (done: MochaDone) => void): void; 83 | 84 | declare function setup(action: () => void): void; 85 | 86 | declare function setup(action: (done: MochaDone) => void): void; 87 | 88 | declare function after(action: () => void): void; 89 | 90 | declare function after(action: (done: MochaDone) => void): void; 91 | 92 | declare function teardown(action: () => void): void; 93 | 94 | declare function teardown(action: (done: MochaDone) => void): void; 95 | 96 | declare function beforeEach(action: () => void): void; 97 | 98 | declare function beforeEach(action: (done: MochaDone) => void): void; 99 | 100 | declare function suiteSetup(action: () => void): void; 101 | 102 | declare function suiteSetup(action: (done: MochaDone) => void): void; 103 | 104 | declare function afterEach(action: () => void): void; 105 | 106 | declare function afterEach(action: (done: MochaDone) => void): void; 107 | 108 | declare function suiteTeardown(action: () => void): void; 109 | 110 | declare function suiteTeardown(action: (done: MochaDone) => void): void; 111 | 112 | declare module "mocha" { 113 | 114 | class Mocha { 115 | constructor(options?: { 116 | grep?: RegExp; 117 | ui?: string; 118 | reporter?: string; 119 | timeout?: number; 120 | bail?: boolean; 121 | }); 122 | 123 | bail(value?: boolean): Mocha; 124 | addFile(file: string): Mocha; 125 | reporter(value: string): Mocha; 126 | ui(value: string): Mocha; 127 | grep(value: string): Mocha; 128 | grep(value: RegExp): Mocha; 129 | invert(): Mocha; 130 | ignoreLeaks(value: boolean): Mocha; 131 | checkLeaks(): Mocha; 132 | growl(): Mocha; 133 | globals(value: string): Mocha; 134 | globals(values: string[]): Mocha; 135 | useColors(value: boolean): Mocha; 136 | useInlineDiffs(value: boolean): Mocha; 137 | timeout(value: number): Mocha; 138 | slow(value: number): Mocha; 139 | enableTimeouts(value: boolean): Mocha; 140 | asyncOnly(value: boolean): Mocha; 141 | noHighlighting(value: boolean): Mocha; 142 | 143 | run(onComplete?: (failures: number) => void): void; 144 | } 145 | 146 | export = Mocha; 147 | } -------------------------------------------------------------------------------- /typings/node.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Node.js v0.10.1 2 | // Project: http://nodejs.org/ 3 | // Definitions by: Microsoft TypeScript , DefinitelyTyped 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /************************************************ 7 | * * 8 | * Node.js v0.10.1 API * 9 | * * 10 | ************************************************/ 11 | 12 | /************************************************ 13 | * * 14 | * GLOBAL * 15 | * * 16 | ************************************************/ 17 | declare var process: NodeJS.Process; 18 | declare var global: any; 19 | 20 | declare var __filename: string; 21 | declare var __dirname: string; 22 | 23 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; 24 | declare function clearTimeout(timeoutId: NodeJS.Timer): void; 25 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; 26 | declare function clearInterval(intervalId: NodeJS.Timer): void; 27 | declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; 28 | declare function clearImmediate(immediateId: any): void; 29 | 30 | declare var require: { 31 | (id: string): any; 32 | resolve(id:string): string; 33 | cache: any; 34 | extensions: any; 35 | main: any; 36 | }; 37 | 38 | declare var module: { 39 | exports: any; 40 | require(id: string): any; 41 | id: string; 42 | filename: string; 43 | loaded: boolean; 44 | parent: any; 45 | children: any[]; 46 | }; 47 | 48 | // Same as module.exports 49 | declare var exports: any; 50 | declare var SlowBuffer: { 51 | new (str: string, encoding?: string): Buffer; 52 | new (size: number): Buffer; 53 | new (array: any[]): Buffer; 54 | prototype: Buffer; 55 | isBuffer(obj: any): boolean; 56 | byteLength(string: string, encoding?: string): number; 57 | concat(list: Buffer[], totalLength?: number): Buffer; 58 | }; 59 | 60 | 61 | // Buffer class 62 | interface Buffer extends NodeBuffer {} 63 | declare var Buffer: { 64 | new (str: string, encoding?: string): Buffer; 65 | new (size: number): Buffer; 66 | new (array: any[]): Buffer; 67 | prototype: Buffer; 68 | isBuffer(obj: any): boolean; 69 | byteLength(string: string, encoding?: string): number; 70 | concat(list: Buffer[], totalLength?: number): Buffer; 71 | }; 72 | 73 | /************************************************ 74 | * * 75 | * GLOBAL INTERFACES * 76 | * * 77 | ************************************************/ 78 | declare module NodeJS { 79 | export interface ErrnoException extends Error { 80 | errno?: any; 81 | code?: string; 82 | path?: string; 83 | syscall?: string; 84 | } 85 | 86 | export interface EventEmitter { 87 | addListener(event: string, listener: Function): EventEmitter; 88 | on(event: string, listener: Function): EventEmitter; 89 | once(event: string, listener: Function): EventEmitter; 90 | removeListener(event: string, listener: Function): EventEmitter; 91 | removeAllListeners(event?: string): EventEmitter; 92 | setMaxListeners(n: number): void; 93 | listeners(event: string): Function[]; 94 | emit(event: string, ...args: any[]): boolean; 95 | } 96 | 97 | export interface ReadableStream extends EventEmitter { 98 | readable: boolean; 99 | read(size?: number): any; 100 | setEncoding(encoding: string): void; 101 | pause(): void; 102 | resume(): void; 103 | pipe(destination: T, options?: { end?: boolean; }): T; 104 | unpipe(destination?: T): void; 105 | unshift(chunk: string): void; 106 | unshift(chunk: Buffer): void; 107 | wrap(oldStream: ReadableStream): ReadableStream; 108 | } 109 | 110 | export interface WritableStream extends EventEmitter { 111 | writable: boolean; 112 | write(buffer: Buffer, cb?: Function): boolean; 113 | write(str: string, cb?: Function): boolean; 114 | write(str: string, encoding?: string, cb?: Function): boolean; 115 | end(): void; 116 | end(buffer: Buffer, cb?: Function): void; 117 | end(str: string, cb?: Function): void; 118 | end(str: string, encoding?: string, cb?: Function): void; 119 | } 120 | 121 | export interface ReadWriteStream extends ReadableStream, WritableStream {} 122 | 123 | export interface Process extends EventEmitter { 124 | stdout: WritableStream; 125 | stderr: WritableStream; 126 | stdin: ReadableStream; 127 | argv: string[]; 128 | execPath: string; 129 | abort(): void; 130 | chdir(directory: string): void; 131 | cwd(): string; 132 | env: any; 133 | exit(code?: number): void; 134 | getgid(): number; 135 | setgid(id: number): void; 136 | setgid(id: string): void; 137 | getuid(): number; 138 | setuid(id: number): void; 139 | setuid(id: string): void; 140 | version: string; 141 | versions: { 142 | http_parser: string; 143 | node: string; 144 | v8: string; 145 | ares: string; 146 | uv: string; 147 | zlib: string; 148 | openssl: string; 149 | }; 150 | config: { 151 | target_defaults: { 152 | cflags: any[]; 153 | default_configuration: string; 154 | defines: string[]; 155 | include_dirs: string[]; 156 | libraries: string[]; 157 | }; 158 | variables: { 159 | clang: number; 160 | host_arch: string; 161 | node_install_npm: boolean; 162 | node_install_waf: boolean; 163 | node_prefix: string; 164 | node_shared_openssl: boolean; 165 | node_shared_v8: boolean; 166 | node_shared_zlib: boolean; 167 | node_use_dtrace: boolean; 168 | node_use_etw: boolean; 169 | node_use_openssl: boolean; 170 | target_arch: string; 171 | v8_no_strict_aliasing: number; 172 | v8_use_snapshot: boolean; 173 | visibility: string; 174 | }; 175 | }; 176 | kill(pid: number, signal?: string): void; 177 | pid: number; 178 | title: string; 179 | arch: string; 180 | platform: string; 181 | memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; 182 | nextTick(callback: Function): void; 183 | umask(mask?: number): number; 184 | uptime(): number; 185 | hrtime(time?:number[]): number[]; 186 | 187 | // Worker 188 | send?(message: any, sendHandle?: any): void; 189 | } 190 | 191 | export interface Timer { 192 | ref() : void; 193 | unref() : void; 194 | } 195 | } 196 | 197 | /** 198 | * @deprecated 199 | */ 200 | interface NodeBuffer { 201 | [index: number]: number; 202 | write(string: string, offset?: number, length?: number, encoding?: string): number; 203 | toString(encoding?: string, start?: number, end?: number): string; 204 | toJSON(): any; 205 | length: number; 206 | copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; 207 | slice(start?: number, end?: number): Buffer; 208 | readUInt8(offset: number, noAsset?: boolean): number; 209 | readUInt16LE(offset: number, noAssert?: boolean): number; 210 | readUInt16BE(offset: number, noAssert?: boolean): number; 211 | readUInt32LE(offset: number, noAssert?: boolean): number; 212 | readUInt32BE(offset: number, noAssert?: boolean): number; 213 | readInt8(offset: number, noAssert?: boolean): number; 214 | readInt16LE(offset: number, noAssert?: boolean): number; 215 | readInt16BE(offset: number, noAssert?: boolean): number; 216 | readInt32LE(offset: number, noAssert?: boolean): number; 217 | readInt32BE(offset: number, noAssert?: boolean): number; 218 | readFloatLE(offset: number, noAssert?: boolean): number; 219 | readFloatBE(offset: number, noAssert?: boolean): number; 220 | readDoubleLE(offset: number, noAssert?: boolean): number; 221 | readDoubleBE(offset: number, noAssert?: boolean): number; 222 | writeUInt8(value: number, offset: number, noAssert?: boolean): void; 223 | writeUInt16LE(value: number, offset: number, noAssert?: boolean): void; 224 | writeUInt16BE(value: number, offset: number, noAssert?: boolean): void; 225 | writeUInt32LE(value: number, offset: number, noAssert?: boolean): void; 226 | writeUInt32BE(value: number, offset: number, noAssert?: boolean): void; 227 | writeInt8(value: number, offset: number, noAssert?: boolean): void; 228 | writeInt16LE(value: number, offset: number, noAssert?: boolean): void; 229 | writeInt16BE(value: number, offset: number, noAssert?: boolean): void; 230 | writeInt32LE(value: number, offset: number, noAssert?: boolean): void; 231 | writeInt32BE(value: number, offset: number, noAssert?: boolean): void; 232 | writeFloatLE(value: number, offset: number, noAssert?: boolean): void; 233 | writeFloatBE(value: number, offset: number, noAssert?: boolean): void; 234 | writeDoubleLE(value: number, offset: number, noAssert?: boolean): void; 235 | writeDoubleBE(value: number, offset: number, noAssert?: boolean): void; 236 | fill(value: any, offset?: number, end?: number): void; 237 | } 238 | 239 | /************************************************ 240 | * * 241 | * MODULES * 242 | * * 243 | ************************************************/ 244 | declare module "buffer" { 245 | export var INSPECT_MAX_BYTES: number; 246 | } 247 | 248 | declare module "querystring" { 249 | export function stringify(obj: any, sep?: string, eq?: string): string; 250 | export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; 251 | export function escape(): any; 252 | export function unescape(): any; 253 | } 254 | 255 | declare module "events" { 256 | export class EventEmitter implements NodeJS.EventEmitter { 257 | static listenerCount(emitter: EventEmitter, event: string): number; 258 | 259 | addListener(event: string, listener: Function): EventEmitter; 260 | on(event: string, listener: Function): EventEmitter; 261 | once(event: string, listener: Function): EventEmitter; 262 | removeListener(event: string, listener: Function): EventEmitter; 263 | removeAllListeners(event?: string): EventEmitter; 264 | setMaxListeners(n: number): void; 265 | listeners(event: string): Function[]; 266 | emit(event: string, ...args: any[]): boolean; 267 | } 268 | } 269 | 270 | declare module "http" { 271 | import events = require("events"); 272 | import net = require("net"); 273 | import stream = require("stream"); 274 | 275 | export interface Server extends events.EventEmitter { 276 | listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; 277 | listen(path: string, callback?: Function): Server; 278 | listen(handle: any, listeningListener?: Function): Server; 279 | close(cb?: any): Server; 280 | address(): { port: number; family: string; address: string; }; 281 | maxHeadersCount: number; 282 | } 283 | export interface ServerRequest extends events.EventEmitter, stream.Readable { 284 | method: string; 285 | url: string; 286 | headers: any; 287 | trailers: string; 288 | httpVersion: string; 289 | setEncoding(encoding?: string): void; 290 | pause(): void; 291 | resume(): void; 292 | connection: net.Socket; 293 | } 294 | export interface ServerResponse extends events.EventEmitter, stream.Writable { 295 | // Extended base methods 296 | write(buffer: Buffer): boolean; 297 | write(buffer: Buffer, cb?: Function): boolean; 298 | write(str: string, cb?: Function): boolean; 299 | write(str: string, encoding?: string, cb?: Function): boolean; 300 | write(str: string, encoding?: string, fd?: string): boolean; 301 | 302 | writeContinue(): void; 303 | writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; 304 | writeHead(statusCode: number, headers?: any): void; 305 | statusCode: number; 306 | setHeader(name: string, value: string): void; 307 | sendDate: boolean; 308 | getHeader(name: string): string; 309 | removeHeader(name: string): void; 310 | write(chunk: any, encoding?: string): any; 311 | addTrailers(headers: any): void; 312 | 313 | // Extended base methods 314 | end(): void; 315 | end(buffer: Buffer, cb?: Function): void; 316 | end(str: string, cb?: Function): void; 317 | end(str: string, encoding?: string, cb?: Function): void; 318 | end(data?: any, encoding?: string): void; 319 | } 320 | export interface ClientRequest extends events.EventEmitter, stream.Writable { 321 | // Extended base methods 322 | write(buffer: Buffer): boolean; 323 | write(buffer: Buffer, cb?: Function): boolean; 324 | write(str: string, cb?: Function): boolean; 325 | write(str: string, encoding?: string, cb?: Function): boolean; 326 | write(str: string, encoding?: string, fd?: string): boolean; 327 | 328 | write(chunk: any, encoding?: string): void; 329 | abort(): void; 330 | setTimeout(timeout: number, callback?: Function): void; 331 | setNoDelay(noDelay?: boolean): void; 332 | setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; 333 | 334 | // Extended base methods 335 | end(): void; 336 | end(buffer: Buffer, cb?: Function): void; 337 | end(str: string, cb?: Function): void; 338 | end(str: string, encoding?: string, cb?: Function): void; 339 | end(data?: any, encoding?: string): void; 340 | } 341 | export interface ClientResponse extends events.EventEmitter, stream.Readable { 342 | statusCode: number; 343 | httpVersion: string; 344 | headers: any; 345 | trailers: any; 346 | setEncoding(encoding?: string): void; 347 | pause(): void; 348 | resume(): void; 349 | } 350 | export interface Agent { maxSockets: number; sockets: any; requests: any; } 351 | 352 | export var STATUS_CODES: { 353 | [errorCode: number]: string; 354 | [errorCode: string]: string; 355 | }; 356 | export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server; 357 | export function createClient(port?: number, host?: string): any; 358 | export function request(options: any, callback?: Function): ClientRequest; 359 | export function get(options: any, callback?: Function): ClientRequest; 360 | export var globalAgent: Agent; 361 | } 362 | 363 | declare module "cluster" { 364 | import child = require("child_process"); 365 | import events = require("events"); 366 | 367 | export interface ClusterSettings { 368 | exec?: string; 369 | args?: string[]; 370 | silent?: boolean; 371 | } 372 | 373 | export class Worker extends events.EventEmitter { 374 | id: string; 375 | process: child.ChildProcess; 376 | suicide: boolean; 377 | send(message: any, sendHandle?: any): void; 378 | kill(signal?: string): void; 379 | destroy(signal?: string): void; 380 | disconnect(): void; 381 | } 382 | 383 | export var settings: ClusterSettings; 384 | export var isMaster: boolean; 385 | export var isWorker: boolean; 386 | export function setupMaster(settings?: ClusterSettings): void; 387 | export function fork(env?: any): Worker; 388 | export function disconnect(callback?: Function): void; 389 | export var worker: Worker; 390 | export var workers: Worker[]; 391 | 392 | // Event emitter 393 | export function addListener(event: string, listener: Function): void; 394 | export function on(event: string, listener: Function): any; 395 | export function once(event: string, listener: Function): void; 396 | export function removeListener(event: string, listener: Function): void; 397 | export function removeAllListeners(event?: string): void; 398 | export function setMaxListeners(n: number): void; 399 | export function listeners(event: string): Function[]; 400 | export function emit(event: string, ...args: any[]): boolean; 401 | } 402 | 403 | declare module "zlib" { 404 | import stream = require("stream"); 405 | export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } 406 | 407 | export interface Gzip extends stream.Transform { } 408 | export interface Gunzip extends stream.Transform { } 409 | export interface Deflate extends stream.Transform { } 410 | export interface Inflate extends stream.Transform { } 411 | export interface DeflateRaw extends stream.Transform { } 412 | export interface InflateRaw extends stream.Transform { } 413 | export interface Unzip extends stream.Transform { } 414 | 415 | export function createGzip(options?: ZlibOptions): Gzip; 416 | export function createGunzip(options?: ZlibOptions): Gunzip; 417 | export function createDeflate(options?: ZlibOptions): Deflate; 418 | export function createInflate(options?: ZlibOptions): Inflate; 419 | export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; 420 | export function createInflateRaw(options?: ZlibOptions): InflateRaw; 421 | export function createUnzip(options?: ZlibOptions): Unzip; 422 | 423 | export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 424 | export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 425 | export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 426 | export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 427 | export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 428 | export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 429 | export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 430 | 431 | // Constants 432 | export var Z_NO_FLUSH: number; 433 | export var Z_PARTIAL_FLUSH: number; 434 | export var Z_SYNC_FLUSH: number; 435 | export var Z_FULL_FLUSH: number; 436 | export var Z_FINISH: number; 437 | export var Z_BLOCK: number; 438 | export var Z_TREES: number; 439 | export var Z_OK: number; 440 | export var Z_STREAM_END: number; 441 | export var Z_NEED_DICT: number; 442 | export var Z_ERRNO: number; 443 | export var Z_STREAM_ERROR: number; 444 | export var Z_DATA_ERROR: number; 445 | export var Z_MEM_ERROR: number; 446 | export var Z_BUF_ERROR: number; 447 | export var Z_VERSION_ERROR: number; 448 | export var Z_NO_COMPRESSION: number; 449 | export var Z_BEST_SPEED: number; 450 | export var Z_BEST_COMPRESSION: number; 451 | export var Z_DEFAULT_COMPRESSION: number; 452 | export var Z_FILTERED: number; 453 | export var Z_HUFFMAN_ONLY: number; 454 | export var Z_RLE: number; 455 | export var Z_FIXED: number; 456 | export var Z_DEFAULT_STRATEGY: number; 457 | export var Z_BINARY: number; 458 | export var Z_TEXT: number; 459 | export var Z_ASCII: number; 460 | export var Z_UNKNOWN: number; 461 | export var Z_DEFLATED: number; 462 | export var Z_NULL: number; 463 | } 464 | 465 | declare module "os" { 466 | export function tmpDir(): string; 467 | export function hostname(): string; 468 | export function type(): string; 469 | export function platform(): string; 470 | export function arch(): string; 471 | export function release(): string; 472 | export function uptime(): number; 473 | export function loadavg(): number[]; 474 | export function totalmem(): number; 475 | export function freemem(): number; 476 | export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; 477 | export function networkInterfaces(): any; 478 | export var EOL: string; 479 | } 480 | 481 | declare module "https" { 482 | import tls = require("tls"); 483 | import events = require("events"); 484 | import http = require("http"); 485 | 486 | export interface ServerOptions { 487 | pfx?: any; 488 | key?: any; 489 | passphrase?: string; 490 | cert?: any; 491 | ca?: any; 492 | crl?: any; 493 | ciphers?: string; 494 | honorCipherOrder?: boolean; 495 | requestCert?: boolean; 496 | rejectUnauthorized?: boolean; 497 | NPNProtocols?: any; 498 | SNICallback?: (servername: string) => any; 499 | } 500 | 501 | export interface RequestOptions { 502 | host?: string; 503 | hostname?: string; 504 | port?: number; 505 | path?: string; 506 | method?: string; 507 | headers?: any; 508 | auth?: string; 509 | agent?: any; 510 | pfx?: any; 511 | key?: any; 512 | passphrase?: string; 513 | cert?: any; 514 | ca?: any; 515 | ciphers?: string; 516 | rejectUnauthorized?: boolean; 517 | } 518 | 519 | export interface Agent { 520 | maxSockets: number; 521 | sockets: any; 522 | requests: any; 523 | } 524 | export var Agent: { 525 | new (options?: RequestOptions): Agent; 526 | }; 527 | export interface Server extends tls.Server { } 528 | export function createServer(options: ServerOptions, requestListener?: Function): Server; 529 | export function request(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; 530 | export function get(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; 531 | export var globalAgent: Agent; 532 | } 533 | 534 | declare module "punycode" { 535 | export function decode(string: string): string; 536 | export function encode(string: string): string; 537 | export function toUnicode(domain: string): string; 538 | export function toASCII(domain: string): string; 539 | export var ucs2: ucs2; 540 | interface ucs2 { 541 | decode(string: string): string; 542 | encode(codePoints: number[]): string; 543 | } 544 | export var version: any; 545 | } 546 | 547 | declare module "repl" { 548 | import stream = require("stream"); 549 | import events = require("events"); 550 | 551 | export interface ReplOptions { 552 | prompt?: string; 553 | input?: NodeJS.ReadableStream; 554 | output?: NodeJS.WritableStream; 555 | terminal?: boolean; 556 | eval?: Function; 557 | useColors?: boolean; 558 | useGlobal?: boolean; 559 | ignoreUndefined?: boolean; 560 | writer?: Function; 561 | } 562 | export function start(options: ReplOptions): events.EventEmitter; 563 | } 564 | 565 | declare module "readline" { 566 | import events = require("events"); 567 | import stream = require("stream"); 568 | 569 | export interface ReadLine extends events.EventEmitter { 570 | setPrompt(prompt: string, length: number): void; 571 | prompt(preserveCursor?: boolean): void; 572 | question(query: string, callback: Function): void; 573 | pause(): void; 574 | resume(): void; 575 | close(): void; 576 | write(data: any, key?: any): void; 577 | } 578 | export interface ReadLineOptions { 579 | input: NodeJS.ReadableStream; 580 | output: NodeJS.WritableStream; 581 | completer?: Function; 582 | terminal?: boolean; 583 | } 584 | export function createInterface(options: ReadLineOptions): ReadLine; 585 | } 586 | 587 | declare module "vm" { 588 | export interface Context { } 589 | export interface Script { 590 | runInThisContext(): void; 591 | runInNewContext(sandbox?: Context): void; 592 | } 593 | export function runInThisContext(code: string, filename?: string): void; 594 | export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; 595 | export function runInContext(code: string, context: Context, filename?: string): void; 596 | export function createContext(initSandbox?: Context): Context; 597 | export function createScript(code: string, filename?: string): Script; 598 | } 599 | 600 | declare module "child_process" { 601 | import events = require("events"); 602 | import stream = require("stream"); 603 | 604 | export interface ChildProcess extends events.EventEmitter { 605 | stdin: stream.Writable; 606 | stdout: stream.Readable; 607 | stderr: stream.Readable; 608 | pid: number; 609 | kill(signal?: string): void; 610 | send(message: any, sendHandle: any): void; 611 | disconnect(): void; 612 | } 613 | 614 | export function spawn(command: string, args?: string[], options?: { 615 | cwd?: string; 616 | stdio?: any; 617 | custom?: any; 618 | env?: any; 619 | detached?: boolean; 620 | }): ChildProcess; 621 | export function exec(command: string, options: { 622 | cwd?: string; 623 | stdio?: any; 624 | customFds?: any; 625 | env?: any; 626 | encoding?: string; 627 | timeout?: number; 628 | maxBuffer?: number; 629 | killSignal?: string; 630 | }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 631 | export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 632 | export function execFile(file: string, args: string[], options: { 633 | cwd?: string; 634 | stdio?: any; 635 | customFds?: any; 636 | env?: any; 637 | encoding?: string; 638 | timeout?: number; 639 | maxBuffer?: string; 640 | killSignal?: string; 641 | }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 642 | export function fork(modulePath: string, args?: string[], options?: { 643 | cwd?: string; 644 | env?: any; 645 | encoding?: string; 646 | }): ChildProcess; 647 | } 648 | 649 | declare module "url" { 650 | export interface Url { 651 | href: string; 652 | protocol: string; 653 | auth: string; 654 | hostname: string; 655 | port: string; 656 | host: string; 657 | pathname: string; 658 | search: string; 659 | query: string; 660 | slashes: boolean; 661 | hash?: string; 662 | path?: string; 663 | } 664 | 665 | export interface UrlOptions { 666 | protocol?: string; 667 | auth?: string; 668 | hostname?: string; 669 | port?: string; 670 | host?: string; 671 | pathname?: string; 672 | search?: string; 673 | query?: any; 674 | hash?: string; 675 | path?: string; 676 | } 677 | 678 | export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; 679 | export function format(url: UrlOptions): string; 680 | export function resolve(from: string, to: string): string; 681 | } 682 | 683 | declare module "dns" { 684 | export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; 685 | export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; 686 | export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 687 | export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 688 | export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 689 | export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 690 | export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 691 | export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 692 | export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 693 | export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 694 | export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 695 | export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; 696 | } 697 | 698 | declare module "net" { 699 | import stream = require("stream"); 700 | 701 | export interface Socket extends stream.Duplex { 702 | // Extended base methods 703 | write(buffer: Buffer): boolean; 704 | write(buffer: Buffer, cb?: Function): boolean; 705 | write(str: string, cb?: Function): boolean; 706 | write(str: string, encoding?: string, cb?: Function): boolean; 707 | write(str: string, encoding?: string, fd?: string): boolean; 708 | 709 | connect(port: number, host?: string, connectionListener?: Function): void; 710 | connect(path: string, connectionListener?: Function): void; 711 | bufferSize: number; 712 | setEncoding(encoding?: string): void; 713 | write(data: any, encoding?: string, callback?: Function): void; 714 | destroy(): void; 715 | pause(): void; 716 | resume(): void; 717 | setTimeout(timeout: number, callback?: Function): void; 718 | setNoDelay(noDelay?: boolean): void; 719 | setKeepAlive(enable?: boolean, initialDelay?: number): void; 720 | address(): { port: number; family: string; address: string; }; 721 | remoteAddress: string; 722 | remotePort: number; 723 | bytesRead: number; 724 | bytesWritten: number; 725 | 726 | // Extended base methods 727 | end(): void; 728 | end(buffer: Buffer, cb?: Function): void; 729 | end(str: string, cb?: Function): void; 730 | end(str: string, encoding?: string, cb?: Function): void; 731 | end(data?: any, encoding?: string): void; 732 | } 733 | 734 | export var Socket: { 735 | new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; 736 | }; 737 | 738 | export interface Server extends Socket { 739 | listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; 740 | listen(path: string, listeningListener?: Function): Server; 741 | listen(handle: any, listeningListener?: Function): Server; 742 | close(callback?: Function): Server; 743 | address(): { port: number; family: string; address: string; }; 744 | maxConnections: number; 745 | connections: number; 746 | } 747 | export function createServer(connectionListener?: (socket: Socket) =>void ): Server; 748 | export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; 749 | export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; 750 | export function connect(port: number, host?: string, connectionListener?: Function): Socket; 751 | export function connect(path: string, connectionListener?: Function): Socket; 752 | export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; 753 | export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; 754 | export function createConnection(path: string, connectionListener?: Function): Socket; 755 | export function isIP(input: string): number; 756 | export function isIPv4(input: string): boolean; 757 | export function isIPv6(input: string): boolean; 758 | } 759 | 760 | declare module "dgram" { 761 | import events = require("events"); 762 | 763 | export function createSocket(type: string, callback?: Function): Socket; 764 | 765 | interface Socket extends events.EventEmitter { 766 | send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; 767 | bind(port: number, address?: string): void; 768 | close(): void; 769 | address: { address: string; family: string; port: number; }; 770 | setBroadcast(flag: boolean): void; 771 | setMulticastTTL(ttl: number): void; 772 | setMulticastLoopback(flag: boolean): void; 773 | addMembership(multicastAddress: string, multicastInterface?: string): void; 774 | dropMembership(multicastAddress: string, multicastInterface?: string): void; 775 | } 776 | } 777 | 778 | declare module "fs" { 779 | import stream = require("stream"); 780 | import events = require("events"); 781 | 782 | interface Stats { 783 | isFile(): boolean; 784 | isDirectory(): boolean; 785 | isBlockDevice(): boolean; 786 | isCharacterDevice(): boolean; 787 | isSymbolicLink(): boolean; 788 | isFIFO(): boolean; 789 | isSocket(): boolean; 790 | dev: number; 791 | ino: number; 792 | mode: number; 793 | nlink: number; 794 | uid: number; 795 | gid: number; 796 | rdev: number; 797 | size: number; 798 | blksize: number; 799 | blocks: number; 800 | atime: Date; 801 | mtime: Date; 802 | ctime: Date; 803 | } 804 | 805 | interface FSWatcher extends events.EventEmitter { 806 | close(): void; 807 | } 808 | 809 | export interface ReadStream extends stream.Readable {} 810 | export interface WriteStream extends stream.Writable {} 811 | 812 | export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 813 | export function renameSync(oldPath: string, newPath: string): void; 814 | export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 815 | export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 816 | export function truncateSync(path: string, len?: number): void; 817 | export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 818 | export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 819 | export function ftruncateSync(fd: number, len?: number): void; 820 | export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 821 | export function chownSync(path: string, uid: number, gid: number): void; 822 | export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 823 | export function fchownSync(fd: number, uid: number, gid: number): void; 824 | export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 825 | export function lchownSync(path: string, uid: number, gid: number): void; 826 | export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 827 | export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 828 | export function chmodSync(path: string, mode: number): void; 829 | export function chmodSync(path: string, mode: string): void; 830 | export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 831 | export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 832 | export function fchmodSync(fd: number, mode: number): void; 833 | export function fchmodSync(fd: number, mode: string): void; 834 | export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 835 | export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 836 | export function lchmodSync(path: string, mode: number): void; 837 | export function lchmodSync(path: string, mode: string): void; 838 | export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 839 | export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 840 | export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 841 | export function statSync(path: string): Stats; 842 | export function lstatSync(path: string): Stats; 843 | export function fstatSync(fd: number): Stats; 844 | export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 845 | export function linkSync(srcpath: string, dstpath: string): void; 846 | export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 847 | export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; 848 | export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; 849 | export function readlinkSync(path: string): string; 850 | export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; 851 | export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; 852 | export function realpathSync(path: string, cache?: {[path: string]: string}): string; 853 | export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 854 | export function unlinkSync(path: string): void; 855 | export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 856 | export function rmdirSync(path: string): void; 857 | export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 858 | export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 859 | export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 860 | export function mkdirSync(path: string, mode?: number): void; 861 | export function mkdirSync(path: string, mode?: string): void; 862 | export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; 863 | export function readdirSync(path: string): string[]; 864 | export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 865 | export function closeSync(fd: number): void; 866 | export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 867 | export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 868 | export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 869 | export function openSync(path: string, flags: string, mode?: number): number; 870 | export function openSync(path: string, flags: string, mode?: string): number; 871 | export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 872 | export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; 873 | export function utimesSync(path: string, atime: number, mtime: number): void; 874 | export function utimesSync(path: string, atime: Date, mtime: Date): void; 875 | export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 876 | export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; 877 | export function futimesSync(fd: number, atime: number, mtime: number): void; 878 | export function futimesSync(fd: number, atime: Date, mtime: Date): void; 879 | export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 880 | export function fsyncSync(fd: number): void; 881 | export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; 882 | export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; 883 | export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; 884 | export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; 885 | export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; 886 | export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; 887 | export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; 888 | export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void ): void; 889 | export function readFileSync(filename: string, encoding: string): string; 890 | export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; 891 | export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; 892 | export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; 893 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 894 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 895 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; 896 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; 897 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 898 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 899 | export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; 900 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; 901 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; 902 | export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; 903 | export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; 904 | export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; 905 | export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; 906 | export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; 907 | export function exists(path: string, callback?: (exists: boolean) => void): void; 908 | export function existsSync(path: string): boolean; 909 | export function createReadStream(path: string, options?: { 910 | flags?: string; 911 | encoding?: string; 912 | fd?: string; 913 | mode?: number; 914 | bufferSize?: number; 915 | }): ReadStream; 916 | export function createReadStream(path: string, options?: { 917 | flags?: string; 918 | encoding?: string; 919 | fd?: string; 920 | mode?: string; 921 | bufferSize?: number; 922 | }): ReadStream; 923 | export function createWriteStream(path: string, options?: { 924 | flags?: string; 925 | encoding?: string; 926 | string?: string; 927 | }): WriteStream; 928 | } 929 | 930 | declare module "path" { 931 | export function normalize(p: string): string; 932 | export function join(...paths: any[]): string; 933 | export function resolve(...pathSegments: any[]): string; 934 | export function relative(from: string, to: string): string; 935 | export function dirname(p: string): string; 936 | export function basename(p: string, ext?: string): string; 937 | export function extname(p: string): string; 938 | export var sep: string; 939 | } 940 | 941 | declare module "string_decoder" { 942 | export interface NodeStringDecoder { 943 | write(buffer: Buffer): string; 944 | detectIncompleteChar(buffer: Buffer): number; 945 | } 946 | export var StringDecoder: { 947 | new (encoding: string): NodeStringDecoder; 948 | }; 949 | } 950 | 951 | declare module "tls" { 952 | import crypto = require("crypto"); 953 | import net = require("net"); 954 | import stream = require("stream"); 955 | 956 | var CLIENT_RENEG_LIMIT: number; 957 | var CLIENT_RENEG_WINDOW: number; 958 | 959 | export interface TlsOptions { 960 | pfx?: any; //string or buffer 961 | key?: any; //string or buffer 962 | passphrase?: string; 963 | cert?: any; 964 | ca?: any; //string or buffer 965 | crl?: any; //string or string array 966 | ciphers?: string; 967 | honorCipherOrder?: any; 968 | requestCert?: boolean; 969 | rejectUnauthorized?: boolean; 970 | NPNProtocols?: any; //array or Buffer; 971 | SNICallback?: (servername: string) => any; 972 | } 973 | 974 | export interface ConnectionOptions { 975 | host?: string; 976 | port?: number; 977 | socket?: net.Socket; 978 | pfx?: any; //string | Buffer 979 | key?: any; //string | Buffer 980 | passphrase?: string; 981 | cert?: any; //string | Buffer 982 | ca?: any; //Array of string | Buffer 983 | rejectUnauthorized?: boolean; 984 | NPNProtocols?: any; //Array of string | Buffer 985 | servername?: string; 986 | } 987 | 988 | export interface Server extends net.Server { 989 | // Extended base methods 990 | listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; 991 | listen(path: string, listeningListener?: Function): Server; 992 | listen(handle: any, listeningListener?: Function): Server; 993 | 994 | listen(port: number, host?: string, callback?: Function): Server; 995 | close(): Server; 996 | address(): { port: number; family: string; address: string; }; 997 | addContext(hostName: string, credentials: { 998 | key: string; 999 | cert: string; 1000 | ca: string; 1001 | }): void; 1002 | maxConnections: number; 1003 | connections: number; 1004 | } 1005 | 1006 | export interface ClearTextStream extends stream.Duplex { 1007 | authorized: boolean; 1008 | authorizationError: Error; 1009 | getPeerCertificate(): any; 1010 | getCipher: { 1011 | name: string; 1012 | version: string; 1013 | }; 1014 | address: { 1015 | port: number; 1016 | family: string; 1017 | address: string; 1018 | }; 1019 | remoteAddress: string; 1020 | remotePort: number; 1021 | } 1022 | 1023 | export interface SecurePair { 1024 | encrypted: any; 1025 | cleartext: any; 1026 | } 1027 | 1028 | export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; 1029 | export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; 1030 | export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; 1031 | export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; 1032 | export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; 1033 | } 1034 | 1035 | declare module "crypto" { 1036 | export interface CredentialDetails { 1037 | pfx: string; 1038 | key: string; 1039 | passphrase: string; 1040 | cert: string; 1041 | ca: any; //string | string array 1042 | crl: any; //string | string array 1043 | ciphers: string; 1044 | } 1045 | export interface Credentials { context?: any; } 1046 | export function createCredentials(details: CredentialDetails): Credentials; 1047 | export function createHash(algorithm: string): Hash; 1048 | export function createHmac(algorithm: string, key: string): Hmac; 1049 | interface Hash { 1050 | update(data: any, input_encoding?: string): Hash; 1051 | digest(encoding?: string): string; 1052 | } 1053 | interface Hmac { 1054 | update(data: any, input_encoding?: string): Hmac; 1055 | digest(encoding?: string): string; 1056 | } 1057 | export function createCipher(algorithm: string, password: any): Cipher; 1058 | export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; 1059 | interface Cipher { 1060 | update(data: any, input_encoding?: string, output_encoding?: string): string; 1061 | final(output_encoding?: string): string; 1062 | setAutoPadding(auto_padding: boolean): void; 1063 | createDecipher(algorithm: string, password: any): Decipher; 1064 | createDecipheriv(algorithm: string, key: any, iv: any): Decipher; 1065 | } 1066 | interface Decipher { 1067 | update(data: any, input_encoding?: string, output_encoding?: string): void; 1068 | final(output_encoding?: string): string; 1069 | setAutoPadding(auto_padding: boolean): void; 1070 | } 1071 | export function createSign(algorithm: string): Signer; 1072 | interface Signer { 1073 | update(data: any): void; 1074 | sign(private_key: string, output_format: string): string; 1075 | } 1076 | export function createVerify(algorith: string): Verify; 1077 | interface Verify { 1078 | update(data: any): void; 1079 | verify(object: string, signature: string, signature_format?: string): boolean; 1080 | } 1081 | export function createDiffieHellman(prime_length: number): DiffieHellman; 1082 | export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; 1083 | interface DiffieHellman { 1084 | generateKeys(encoding?: string): string; 1085 | computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; 1086 | getPrime(encoding?: string): string; 1087 | getGenerator(encoding: string): string; 1088 | getPublicKey(encoding?: string): string; 1089 | getPrivateKey(encoding?: string): string; 1090 | setPublicKey(public_key: string, encoding?: string): void; 1091 | setPrivateKey(public_key: string, encoding?: string): void; 1092 | } 1093 | export function getDiffieHellman(group_name: string): DiffieHellman; 1094 | export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; 1095 | export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; 1096 | export function randomBytes(size: number): Buffer; 1097 | export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; 1098 | export function pseudoRandomBytes(size: number): Buffer; 1099 | export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; 1100 | } 1101 | 1102 | declare module "stream" { 1103 | import events = require("events"); 1104 | 1105 | export interface ReadableOptions { 1106 | highWaterMark?: number; 1107 | encoding?: string; 1108 | objectMode?: boolean; 1109 | } 1110 | 1111 | export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { 1112 | readable: boolean; 1113 | constructor(opts?: ReadableOptions); 1114 | _read(size: number): void; 1115 | read(size?: number): any; 1116 | setEncoding(encoding: string): void; 1117 | pause(): void; 1118 | resume(): void; 1119 | pipe(destination: T, options?: { end?: boolean; }): T; 1120 | unpipe(destination?: T): void; 1121 | unshift(chunk: string): void; 1122 | unshift(chunk: Buffer): void; 1123 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; 1124 | push(chunk: any, encoding?: string): boolean; 1125 | } 1126 | 1127 | export interface WritableOptions { 1128 | highWaterMark?: number; 1129 | decodeStrings?: boolean; 1130 | } 1131 | 1132 | export class Writable extends events.EventEmitter implements NodeJS.WritableStream { 1133 | writable: boolean; 1134 | constructor(opts?: WritableOptions); 1135 | _write(data: Buffer, encoding: string, callback: Function): void; 1136 | _write(data: string, encoding: string, callback: Function): void; 1137 | write(buffer: Buffer, cb?: Function): boolean; 1138 | write(str: string, cb?: Function): boolean; 1139 | write(str: string, encoding?: string, cb?: Function): boolean; 1140 | end(): void; 1141 | end(buffer: Buffer, cb?: Function): void; 1142 | end(str: string, cb?: Function): void; 1143 | end(str: string, encoding?: string, cb?: Function): void; 1144 | } 1145 | 1146 | export interface DuplexOptions extends ReadableOptions, WritableOptions { 1147 | allowHalfOpen?: boolean; 1148 | } 1149 | 1150 | // Note: Duplex extends both Readable and Writable. 1151 | export class Duplex extends Readable implements NodeJS.ReadWriteStream { 1152 | writable: boolean; 1153 | constructor(opts?: DuplexOptions); 1154 | _write(data: Buffer, encoding: string, callback: Function): void; 1155 | _write(data: string, encoding: string, callback: Function): void; 1156 | write(buffer: Buffer, cb?: Function): boolean; 1157 | write(str: string, cb?: Function): boolean; 1158 | write(str: string, encoding?: string, cb?: Function): boolean; 1159 | end(): void; 1160 | end(buffer: Buffer, cb?: Function): void; 1161 | end(str: string, cb?: Function): void; 1162 | end(str: string, encoding?: string, cb?: Function): void; 1163 | } 1164 | 1165 | export interface TransformOptions extends ReadableOptions, WritableOptions {} 1166 | 1167 | // Note: Transform lacks the _read and _write methods of Readable/Writable. 1168 | export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { 1169 | readable: boolean; 1170 | writable: boolean; 1171 | constructor(opts?: TransformOptions); 1172 | _transform(chunk: Buffer, encoding: string, callback: Function): void; 1173 | _transform(chunk: string, encoding: string, callback: Function): void; 1174 | _flush(callback: Function): void; 1175 | read(size?: number): any; 1176 | setEncoding(encoding: string): void; 1177 | pause(): void; 1178 | resume(): void; 1179 | pipe(destination: T, options?: { end?: boolean; }): T; 1180 | unpipe(destination?: T): void; 1181 | unshift(chunk: string): void; 1182 | unshift(chunk: Buffer): void; 1183 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; 1184 | push(chunk: any, encoding?: string): boolean; 1185 | write(buffer: Buffer, cb?: Function): boolean; 1186 | write(str: string, cb?: Function): boolean; 1187 | write(str: string, encoding?: string, cb?: Function): boolean; 1188 | end(): void; 1189 | end(buffer: Buffer, cb?: Function): void; 1190 | end(str: string, cb?: Function): void; 1191 | end(str: string, encoding?: string, cb?: Function): void; 1192 | } 1193 | 1194 | export class PassThrough extends Transform {} 1195 | } 1196 | 1197 | declare module "util" { 1198 | export interface InspectOptions { 1199 | showHidden?: boolean; 1200 | depth?: number; 1201 | colors?: boolean; 1202 | customInspect?: boolean; 1203 | } 1204 | 1205 | export function format(format: any, ...param: any[]): string; 1206 | export function debug(string: string): void; 1207 | export function error(...param: any[]): void; 1208 | export function puts(...param: any[]): void; 1209 | export function print(...param: any[]): void; 1210 | export function log(string: string): void; 1211 | export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; 1212 | export function inspect(object: any, options: InspectOptions): string; 1213 | export function isArray(object: any): boolean; 1214 | export function isRegExp(object: any): boolean; 1215 | export function isDate(object: any): boolean; 1216 | export function isError(object: any): boolean; 1217 | export function inherits(constructor: any, superConstructor: any): void; 1218 | } 1219 | 1220 | declare module "assert" { 1221 | // Need to fudge this because phpStorm insists on not reading this module properly. 1222 | /* 1223 | function internal (value: any, message?: string): void; 1224 | module internal { 1225 | export class AssertionError implements Error { 1226 | name: string; 1227 | message: string; 1228 | actual: any; 1229 | expected: any; 1230 | operator: string; 1231 | generatedMessage: boolean; 1232 | 1233 | constructor(options?: {message?: string; actual?: any; expected?: any; 1234 | operator?: string; stackStartFunction?: Function}); 1235 | } 1236 | 1237 | export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; 1238 | export function ok(value: any, message?: string): void; 1239 | export function equal(actual: any, expected: any, message?: string): void; 1240 | export function notEqual(actual: any, expected: any, message?: string): void; 1241 | export function deepEqual(actual: any, expected: any, message?: string): void; 1242 | export function notDeepEqual(acutal: any, expected: any, message?: string): void; 1243 | export function strictEqual(actual: any, expected: any, message?: string): void; 1244 | export function notStrictEqual(actual: any, expected: any, message?: string): void; 1245 | export var throws: { 1246 | (block: Function, message?: string): void; 1247 | (block: Function, error: Function, message?: string): void; 1248 | (block: Function, error: RegExp, message?: string): void; 1249 | (block: Function, error: (err: any) => boolean, message?: string): void; 1250 | }; 1251 | 1252 | export var doesNotThrow: { 1253 | (block: Function, message?: string): void; 1254 | (block: Function, error: Function, message?: string): void; 1255 | (block: Function, error: RegExp, message?: string): void; 1256 | (block: Function, error: (err: any) => boolean, message?: string): void; 1257 | }; 1258 | 1259 | export function ifError(value: any): void; 1260 | } 1261 | 1262 | export = internal; 1263 | */ 1264 | export class AssertionError implements Error { 1265 | name: string; 1266 | message: string; 1267 | actual: any; 1268 | expected: any; 1269 | operator: string; 1270 | generatedMessage: boolean; 1271 | 1272 | constructor(options?: {message?: string; actual?: any; expected?: any; 1273 | operator?: string; stackStartFunction?: Function}); 1274 | } 1275 | 1276 | export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; 1277 | export function ok(value: any, message?: string): void; 1278 | export function equal(actual: any, expected: any, message?: string): void; 1279 | export function notEqual(actual: any, expected: any, message?: string): void; 1280 | export function deepEqual(actual: any, expected: any, message?: string): void; 1281 | export function notDeepEqual(acutal: any, expected: any, message?: string): void; 1282 | export function strictEqual(actual: any, expected: any, message?: string): void; 1283 | export function notStrictEqual(actual: any, expected: any, message?: string): void; 1284 | export var throws: { 1285 | (block: Function, message?: string): void; 1286 | (block: Function, error: Function, message?: string): void; 1287 | (block: Function, error: RegExp, message?: string): void; 1288 | (block: Function, error: (err: any) => boolean, message?: string): void; 1289 | }; 1290 | 1291 | export var doesNotThrow: { 1292 | (block: Function, message?: string): void; 1293 | (block: Function, error: Function, message?: string): void; 1294 | (block: Function, error: RegExp, message?: string): void; 1295 | (block: Function, error: (err: any) => boolean, message?: string): void; 1296 | }; 1297 | 1298 | export function ifError(value: any): void; 1299 | } 1300 | 1301 | declare module "tty" { 1302 | import net = require("net"); 1303 | 1304 | export function isatty(fd: number): boolean; 1305 | export interface ReadStream extends net.Socket { 1306 | isRaw: boolean; 1307 | setRawMode(mode: boolean): void; 1308 | } 1309 | export interface WriteStream extends net.Socket { 1310 | columns: number; 1311 | rows: number; 1312 | } 1313 | } 1314 | 1315 | declare module "domain" { 1316 | import events = require("events"); 1317 | 1318 | export class Domain extends events.EventEmitter { 1319 | run(fn: Function): void; 1320 | add(emitter: events.EventEmitter): void; 1321 | remove(emitter: events.EventEmitter): void; 1322 | bind(cb: (err: Error, data: any) => any): any; 1323 | intercept(cb: (data: any) => any): any; 1324 | dispose(): void; 1325 | 1326 | addListener(event: string, listener: Function): Domain; 1327 | on(event: string, listener: Function): Domain; 1328 | once(event: string, listener: Function): Domain; 1329 | removeListener(event: string, listener: Function): Domain; 1330 | removeAllListeners(event?: string): Domain; 1331 | } 1332 | 1333 | export function create(): Domain; 1334 | } -------------------------------------------------------------------------------- /typings/stylish.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | 7 | declare module Stylish { 8 | interface IPosition { 9 | position: number; 10 | line: number; 11 | character: number; 12 | } 13 | 14 | interface IRuleFailureObject { 15 | fileName: string; 16 | failure: string; 17 | startPosition: IPosition; 18 | endPosition: IPosition; 19 | ruleName: string; 20 | } 21 | 22 | interface ILineAndCharacter { 23 | line: number; 24 | character: number; 25 | } 26 | 27 | interface IPalantirPosition { 28 | position: number; 29 | lineAndCharacter: ILineAndCharacter; 30 | } 31 | 32 | interface IPalantirRuleFailureObject { 33 | fileName: string; 34 | failure: string; 35 | startPosition: IPalantirPosition; 36 | endPosition: IPalantirPosition; 37 | ruleName: string; 38 | } 39 | 40 | interface IOptions { 41 | sort?: boolean; 42 | bell?: boolean; 43 | fullPath?: boolean; 44 | } 45 | } -------------------------------------------------------------------------------- /typings/tslint.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module Lint { 4 | class SyntaxWalker { 5 | walk(node: ts.Node): void; 6 | protected visitAnyKeyword(node: ts.Node): void; 7 | protected visitArrowFunction(node: ts.FunctionLikeDeclaration): void; 8 | protected visitBinaryExpression(node: ts.BinaryExpression): void; 9 | protected visitBindingElement(node: ts.BindingElement): void; 10 | protected visitBlock(node: ts.Block): void; 11 | protected visitBreakStatement(node: ts.BreakOrContinueStatement): void; 12 | protected visitCallExpression(node: ts.CallExpression): void; 13 | protected visitCaseClause(node: ts.CaseClause): void; 14 | protected visitClassDeclaration(node: ts.ClassDeclaration): void; 15 | protected visitCatchClause(node: ts.CatchClause): void; 16 | protected visitConditionalExpression(node: ts.ConditionalExpression): void; 17 | protected visitConstructorDeclaration(node: ts.ConstructorDeclaration): void; 18 | protected visitConstructorType(node: ts.FunctionOrConstructorTypeNode): void; 19 | protected visitContinueStatement(node: ts.BreakOrContinueStatement): void; 20 | protected visitDebuggerStatement(node: ts.Statement): void; 21 | protected visitDefaultClause(node: ts.DefaultClause): void; 22 | protected visitDoStatement(node: ts.DoStatement): void; 23 | protected visitElementAccessExpression(node: ts.ElementAccessExpression): void; 24 | protected visitEnumDeclaration(node: ts.EnumDeclaration): void; 25 | protected visitExportAssignment(node: ts.ExportAssignment): void; 26 | protected visitExpressionStatement(node: ts.ExpressionStatement): void; 27 | protected visitForStatement(node: ts.ForStatement): void; 28 | protected visitForInStatement(node: ts.ForInStatement): void; 29 | protected visitForOfStatement(node: ts.ForOfStatement): void; 30 | protected visitFunctionDeclaration(node: ts.FunctionDeclaration): void; 31 | protected visitFunctionExpression(node: ts.FunctionExpression): void; 32 | protected visitFunctionType(node: ts.FunctionOrConstructorTypeNode): void; 33 | protected visitGetAccessor(node: ts.AccessorDeclaration): void; 34 | protected visitIdentifier(node: ts.Identifier): void; 35 | protected visitIfStatement(node: ts.IfStatement): void; 36 | protected visitImportDeclaration(node: ts.ImportDeclaration): void; 37 | protected visitImportEqualsDeclaration(node: ts.ImportEqualsDeclaration): void; 38 | protected visitIndexSignatureDeclaration(node: ts.IndexSignatureDeclaration): void; 39 | protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void; 40 | protected visitLabeledStatement(node: ts.LabeledStatement): void; 41 | protected visitMethodDeclaration(node: ts.MethodDeclaration): void; 42 | protected visitMethodSignature(node: ts.SignatureDeclaration): void; 43 | protected visitModuleDeclaration(node: ts.ModuleDeclaration): void; 44 | protected visitNamedImports(node: ts.NamedImports): void; 45 | protected visitNamespaceImport(node: ts.NamespaceImport): void; 46 | protected visitNewExpression(node: ts.NewExpression): void; 47 | protected visitObjectLiteralExpression(node: ts.ObjectLiteralExpression): void; 48 | protected visitParameterDeclaration(node: ts.ParameterDeclaration): void; 49 | protected visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression): void; 50 | protected visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression): void; 51 | protected visitPropertyAccessExpression(node: ts.PropertyAccessExpression): void; 52 | protected visitPropertyAssignment(node: ts.PropertyAssignment): void; 53 | protected visitPropertyDeclaration(node: ts.PropertyDeclaration): void; 54 | protected visitPropertySignature(node: ts.Node): void; 55 | protected visitRegularExpressionLiteral(node: ts.Node): void; 56 | protected visitReturnStatement(node: ts.ReturnStatement): void; 57 | protected visitSetAccessor(node: ts.AccessorDeclaration): void; 58 | protected visitSourceFile(node: ts.SourceFile): void; 59 | protected visitSwitchStatement(node: ts.SwitchStatement): void; 60 | protected visitTemplateExpression(node: ts.TemplateExpression): void; 61 | protected visitThrowStatement(node: ts.ThrowStatement): void; 62 | protected visitTryStatement(node: ts.TryStatement): void; 63 | protected visitTypeAssertionExpression(node: ts.TypeAssertion): void; 64 | protected visitTypeLiteral(node: ts.TypeLiteralNode): void; 65 | protected visitVariableDeclaration(node: ts.VariableDeclaration): void; 66 | protected visitVariableStatement(node: ts.VariableStatement): void; 67 | protected visitWhileStatement(node: ts.WhileStatement): void; 68 | protected visitNode(node: ts.Node): void; 69 | protected walkChildren(node: ts.Node): void; 70 | } 71 | } 72 | declare module Lint { 73 | class RuleWalker extends Lint.SyntaxWalker { 74 | private limit; 75 | private position; 76 | private options; 77 | private failures; 78 | private sourceFile; 79 | private disabledIntervals; 80 | private ruleName; 81 | constructor(sourceFile: ts.SourceFile, options: Lint.IOptions); 82 | getSourceFile(): ts.SourceFile; 83 | getFailures(): RuleFailure[]; 84 | getLimit(): number; 85 | getOptions(): any; 86 | hasOption(option: string): boolean; 87 | skip(node: ts.Node): void; 88 | createFailure(start: number, width: number, failure: string): RuleFailure; 89 | addFailure(failure: RuleFailure): void; 90 | private existsFailure(failure); 91 | } 92 | } 93 | declare module Lint { 94 | class ScopeAwareRuleWalker extends RuleWalker { 95 | private scopeStack; 96 | constructor(sourceFile: ts.SourceFile, options?: any); 97 | createScope(): T; 98 | getCurrentScope(): T; 99 | getAllScopes(): T[]; 100 | getCurrentDepth(): number; 101 | onScopeStart(): void; 102 | onScopeEnd(): void; 103 | protected visitNode(node: ts.Node): void; 104 | protected isScopeBoundary(node: ts.Node): boolean; 105 | } 106 | } 107 | declare module Lint.Formatters { 108 | class AbstractFormatter implements Lint.IFormatter { 109 | format(failures: Lint.RuleFailure[]): string; 110 | } 111 | } 112 | declare module Lint { 113 | interface IFormatter { 114 | format(failures: Lint.RuleFailure[]): string; 115 | } 116 | } 117 | declare module Lint { 118 | function createLanguageServiceHost(fileName: string, source: string): ts.LanguageServiceHost; 119 | } 120 | declare module Lint.Rules { 121 | class AbstractRule implements Lint.IRule { 122 | private value; 123 | private options; 124 | constructor(ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]); 125 | getOptions(): Lint.IOptions; 126 | apply(sourceFile: ts.SourceFile): RuleFailure[]; 127 | applyWithWalker(walker: Lint.RuleWalker): RuleFailure[]; 128 | isEnabled(): boolean; 129 | } 130 | } 131 | declare module Lint { 132 | interface IOptions { 133 | ruleArguments?: any[]; 134 | ruleName: string; 135 | disabledIntervals: Lint.IDisabledInterval[]; 136 | } 137 | interface IDisabledInterval { 138 | startPosition: number; 139 | endPosition: number; 140 | } 141 | interface IRule { 142 | getOptions(): IOptions; 143 | isEnabled(): boolean; 144 | apply(sourceFile: ts.SourceFile): RuleFailure[]; 145 | applyWithWalker(walker: Lint.RuleWalker): RuleFailure[]; 146 | } 147 | class RuleFailurePosition { 148 | private position; 149 | private lineAndCharacter; 150 | constructor(position: number, lineAndCharacter: ts.LineAndCharacter); 151 | getPosition(): number; 152 | getLineAndCharacter(): ts.LineAndCharacter; 153 | toJson(): { 154 | character: number; 155 | line: number; 156 | position: number; 157 | }; 158 | equals(ruleFailurePosition: RuleFailurePosition): boolean; 159 | } 160 | class RuleFailure { 161 | private sourceFile; 162 | private fileName; 163 | private startPosition; 164 | private endPosition; 165 | private failure; 166 | private ruleName; 167 | constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string); 168 | getFileName(): string; 169 | getRuleName(): string; 170 | getStartPosition(): RuleFailurePosition; 171 | getEndPosition(): RuleFailurePosition; 172 | getFailure(): string; 173 | toJson(): any; 174 | equals(ruleFailure: RuleFailure): boolean; 175 | private createFailurePosition(position); 176 | } 177 | } 178 | declare module Lint { 179 | function getSourceFile(fileName: string, source: string): ts.SourceFile; 180 | function createCompilerOptions(): ts.CompilerOptions; 181 | function doesIntersect(failure: RuleFailure, disabledIntervals: Lint.IDisabledInterval[]): boolean; 182 | function abstract(): string; 183 | function scanAllTokens(scanner: ts.Scanner, callback: (s: ts.Scanner) => void): void; 184 | function hasModifier(modifiers: ts.ModifiersArray, ...modifierKinds: ts.SyntaxKind[]): boolean; 185 | function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean; 186 | function isBlockScopedBindingElement(node: ts.BindingElement): boolean; 187 | function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean; 188 | } 189 | declare module Lint { 190 | class BlockScopeAwareRuleWalker extends ScopeAwareRuleWalker { 191 | private blockScopeStack; 192 | constructor(sourceFile: ts.SourceFile, options?: any); 193 | createBlockScope(): U; 194 | getCurrentBlockScope(): U; 195 | onBlockScopeStart(): void; 196 | getCurrentBlockDepth(): number; 197 | onBlockScopeEnd(): void; 198 | protected visitNode(node: ts.Node): void; 199 | private isBlockScopeBoundary(node); 200 | } 201 | } 202 | declare module Lint { 203 | class SkippableTokenAwareRuleWalker extends RuleWalker { 204 | protected tokensToSkipStartEndMap: { 205 | [start: number]: number; 206 | }; 207 | constructor(sourceFile: ts.SourceFile, options: Lint.IOptions); 208 | protected visitRegularExpressionLiteral(node: ts.Node): void; 209 | protected visitIdentifier(node: ts.Identifier): void; 210 | protected visitTemplateExpression(node: ts.TemplateExpression): void; 211 | private addTokenToSkipFromNode(node); 212 | } 213 | } 214 | declare module Lint.Configuration { 215 | function findConfiguration(configFile: string, inputFileLocation: string): any; 216 | } 217 | declare module Lint { 218 | class EnableDisableRulesWalker extends Lint.SkippableTokenAwareRuleWalker { 219 | enableDisableRuleMap: { 220 | [rulename: string]: Lint.IEnableDisablePosition[]; 221 | }; 222 | visitSourceFile(node: ts.SourceFile): void; 223 | private handlePossibleTslintSwitch(commentText, startingPosition); 224 | } 225 | } 226 | declare module Lint { 227 | function findFormatter(name: string, formattersDirectory?: string): any; 228 | } 229 | declare module Lint { 230 | interface IEnableDisablePosition { 231 | isEnabled: boolean; 232 | position: number; 233 | } 234 | function loadRules(ruleConfiguration: { 235 | [name: string]: any; 236 | }, enableDisableRuleMap: { 237 | [rulename: string]: Lint.IEnableDisablePosition[]; 238 | }, rulesDirectory?: string): IRule[]; 239 | function findRule(name: string, rulesDirectory?: string): any; 240 | } 241 | declare module Lint { 242 | interface LintResult { 243 | failureCount: number; 244 | failures: RuleFailure[]; 245 | format: string; 246 | output: string; 247 | } 248 | interface ILinterOptions { 249 | configuration: any; 250 | formatter: string; 251 | formattersDirectory: string; 252 | rulesDirectory: string; 253 | } 254 | class Linter { 255 | static VERSION: string; 256 | private fileName; 257 | private source; 258 | private options; 259 | constructor(fileName: string, source: string, options: ILinterOptions); 260 | lint(): LintResult; 261 | private getRelativePath(directory); 262 | private containsRule(rules, rule); 263 | } 264 | } 265 | declare module "tslint" { 266 | export = Lint; 267 | } -------------------------------------------------------------------------------- /typings/typescriptServices.d.ts: -------------------------------------------------------------------------------- 1 | /*! ***************************************************************************** 2 | Copyright (c) Microsoft Corporation. All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 | MERCHANTABLITY OR NON-INFRINGEMENT. 11 | 12 | See the Apache Version 2.0 License for specific language governing permissions 13 | and limitations under the License. 14 | ***************************************************************************** */ 15 | 16 | declare module ts { 17 | interface Map { 18 | [index: string]: T; 19 | } 20 | interface FileMap { 21 | get(fileName: string): T; 22 | set(fileName: string, value: T): void; 23 | contains(fileName: string): boolean; 24 | remove(fileName: string): void; 25 | forEachValue(f: (v: T) => void): void; 26 | } 27 | interface TextRange { 28 | pos: number; 29 | end: number; 30 | } 31 | const enum SyntaxKind { 32 | Unknown = 0, 33 | EndOfFileToken = 1, 34 | SingleLineCommentTrivia = 2, 35 | MultiLineCommentTrivia = 3, 36 | NewLineTrivia = 4, 37 | WhitespaceTrivia = 5, 38 | ConflictMarkerTrivia = 6, 39 | NumericLiteral = 7, 40 | StringLiteral = 8, 41 | RegularExpressionLiteral = 9, 42 | NoSubstitutionTemplateLiteral = 10, 43 | TemplateHead = 11, 44 | TemplateMiddle = 12, 45 | TemplateTail = 13, 46 | OpenBraceToken = 14, 47 | CloseBraceToken = 15, 48 | OpenParenToken = 16, 49 | CloseParenToken = 17, 50 | OpenBracketToken = 18, 51 | CloseBracketToken = 19, 52 | DotToken = 20, 53 | DotDotDotToken = 21, 54 | SemicolonToken = 22, 55 | CommaToken = 23, 56 | LessThanToken = 24, 57 | GreaterThanToken = 25, 58 | LessThanEqualsToken = 26, 59 | GreaterThanEqualsToken = 27, 60 | EqualsEqualsToken = 28, 61 | ExclamationEqualsToken = 29, 62 | EqualsEqualsEqualsToken = 30, 63 | ExclamationEqualsEqualsToken = 31, 64 | EqualsGreaterThanToken = 32, 65 | PlusToken = 33, 66 | MinusToken = 34, 67 | AsteriskToken = 35, 68 | SlashToken = 36, 69 | PercentToken = 37, 70 | PlusPlusToken = 38, 71 | MinusMinusToken = 39, 72 | LessThanLessThanToken = 40, 73 | GreaterThanGreaterThanToken = 41, 74 | GreaterThanGreaterThanGreaterThanToken = 42, 75 | AmpersandToken = 43, 76 | BarToken = 44, 77 | CaretToken = 45, 78 | ExclamationToken = 46, 79 | TildeToken = 47, 80 | AmpersandAmpersandToken = 48, 81 | BarBarToken = 49, 82 | QuestionToken = 50, 83 | ColonToken = 51, 84 | AtToken = 52, 85 | EqualsToken = 53, 86 | PlusEqualsToken = 54, 87 | MinusEqualsToken = 55, 88 | AsteriskEqualsToken = 56, 89 | SlashEqualsToken = 57, 90 | PercentEqualsToken = 58, 91 | LessThanLessThanEqualsToken = 59, 92 | GreaterThanGreaterThanEqualsToken = 60, 93 | GreaterThanGreaterThanGreaterThanEqualsToken = 61, 94 | AmpersandEqualsToken = 62, 95 | BarEqualsToken = 63, 96 | CaretEqualsToken = 64, 97 | Identifier = 65, 98 | BreakKeyword = 66, 99 | CaseKeyword = 67, 100 | CatchKeyword = 68, 101 | ClassKeyword = 69, 102 | ConstKeyword = 70, 103 | ContinueKeyword = 71, 104 | DebuggerKeyword = 72, 105 | DefaultKeyword = 73, 106 | DeleteKeyword = 74, 107 | DoKeyword = 75, 108 | ElseKeyword = 76, 109 | EnumKeyword = 77, 110 | ExportKeyword = 78, 111 | ExtendsKeyword = 79, 112 | FalseKeyword = 80, 113 | FinallyKeyword = 81, 114 | ForKeyword = 82, 115 | FunctionKeyword = 83, 116 | IfKeyword = 84, 117 | ImportKeyword = 85, 118 | InKeyword = 86, 119 | InstanceOfKeyword = 87, 120 | NewKeyword = 88, 121 | NullKeyword = 89, 122 | ReturnKeyword = 90, 123 | SuperKeyword = 91, 124 | SwitchKeyword = 92, 125 | ThisKeyword = 93, 126 | ThrowKeyword = 94, 127 | TrueKeyword = 95, 128 | TryKeyword = 96, 129 | TypeOfKeyword = 97, 130 | VarKeyword = 98, 131 | VoidKeyword = 99, 132 | WhileKeyword = 100, 133 | WithKeyword = 101, 134 | ImplementsKeyword = 102, 135 | InterfaceKeyword = 103, 136 | LetKeyword = 104, 137 | PackageKeyword = 105, 138 | PrivateKeyword = 106, 139 | ProtectedKeyword = 107, 140 | PublicKeyword = 108, 141 | StaticKeyword = 109, 142 | YieldKeyword = 110, 143 | AsKeyword = 111, 144 | AnyKeyword = 112, 145 | BooleanKeyword = 113, 146 | ConstructorKeyword = 114, 147 | DeclareKeyword = 115, 148 | GetKeyword = 116, 149 | ModuleKeyword = 117, 150 | NamespaceKeyword = 118, 151 | RequireKeyword = 119, 152 | NumberKeyword = 120, 153 | SetKeyword = 121, 154 | StringKeyword = 122, 155 | SymbolKeyword = 123, 156 | TypeKeyword = 124, 157 | FromKeyword = 125, 158 | OfKeyword = 126, 159 | QualifiedName = 127, 160 | ComputedPropertyName = 128, 161 | TypeParameter = 129, 162 | Parameter = 130, 163 | Decorator = 131, 164 | PropertySignature = 132, 165 | PropertyDeclaration = 133, 166 | MethodSignature = 134, 167 | MethodDeclaration = 135, 168 | Constructor = 136, 169 | GetAccessor = 137, 170 | SetAccessor = 138, 171 | CallSignature = 139, 172 | ConstructSignature = 140, 173 | IndexSignature = 141, 174 | TypeReference = 142, 175 | FunctionType = 143, 176 | ConstructorType = 144, 177 | TypeQuery = 145, 178 | TypeLiteral = 146, 179 | ArrayType = 147, 180 | TupleType = 148, 181 | UnionType = 149, 182 | ParenthesizedType = 150, 183 | ObjectBindingPattern = 151, 184 | ArrayBindingPattern = 152, 185 | BindingElement = 153, 186 | ArrayLiteralExpression = 154, 187 | ObjectLiteralExpression = 155, 188 | PropertyAccessExpression = 156, 189 | ElementAccessExpression = 157, 190 | CallExpression = 158, 191 | NewExpression = 159, 192 | TaggedTemplateExpression = 160, 193 | TypeAssertionExpression = 161, 194 | ParenthesizedExpression = 162, 195 | FunctionExpression = 163, 196 | ArrowFunction = 164, 197 | DeleteExpression = 165, 198 | TypeOfExpression = 166, 199 | VoidExpression = 167, 200 | PrefixUnaryExpression = 168, 201 | PostfixUnaryExpression = 169, 202 | BinaryExpression = 170, 203 | ConditionalExpression = 171, 204 | TemplateExpression = 172, 205 | YieldExpression = 173, 206 | SpreadElementExpression = 174, 207 | ClassExpression = 175, 208 | OmittedExpression = 176, 209 | ExpressionWithTypeArguments = 177, 210 | TemplateSpan = 178, 211 | SemicolonClassElement = 179, 212 | Block = 180, 213 | VariableStatement = 181, 214 | EmptyStatement = 182, 215 | ExpressionStatement = 183, 216 | IfStatement = 184, 217 | DoStatement = 185, 218 | WhileStatement = 186, 219 | ForStatement = 187, 220 | ForInStatement = 188, 221 | ForOfStatement = 189, 222 | ContinueStatement = 190, 223 | BreakStatement = 191, 224 | ReturnStatement = 192, 225 | WithStatement = 193, 226 | SwitchStatement = 194, 227 | LabeledStatement = 195, 228 | ThrowStatement = 196, 229 | TryStatement = 197, 230 | DebuggerStatement = 198, 231 | VariableDeclaration = 199, 232 | VariableDeclarationList = 200, 233 | FunctionDeclaration = 201, 234 | ClassDeclaration = 202, 235 | InterfaceDeclaration = 203, 236 | TypeAliasDeclaration = 204, 237 | EnumDeclaration = 205, 238 | ModuleDeclaration = 206, 239 | ModuleBlock = 207, 240 | CaseBlock = 208, 241 | ImportEqualsDeclaration = 209, 242 | ImportDeclaration = 210, 243 | ImportClause = 211, 244 | NamespaceImport = 212, 245 | NamedImports = 213, 246 | ImportSpecifier = 214, 247 | ExportAssignment = 215, 248 | ExportDeclaration = 216, 249 | NamedExports = 217, 250 | ExportSpecifier = 218, 251 | MissingDeclaration = 219, 252 | ExternalModuleReference = 220, 253 | CaseClause = 221, 254 | DefaultClause = 222, 255 | HeritageClause = 223, 256 | CatchClause = 224, 257 | PropertyAssignment = 225, 258 | ShorthandPropertyAssignment = 226, 259 | EnumMember = 227, 260 | SourceFile = 228, 261 | SyntaxList = 229, 262 | Count = 230, 263 | FirstAssignment = 53, 264 | LastAssignment = 64, 265 | FirstReservedWord = 66, 266 | LastReservedWord = 101, 267 | FirstKeyword = 66, 268 | LastKeyword = 126, 269 | FirstFutureReservedWord = 102, 270 | LastFutureReservedWord = 110, 271 | FirstTypeNode = 142, 272 | LastTypeNode = 150, 273 | FirstPunctuation = 14, 274 | LastPunctuation = 64, 275 | FirstToken = 0, 276 | LastToken = 126, 277 | FirstTriviaToken = 2, 278 | LastTriviaToken = 6, 279 | FirstLiteralToken = 7, 280 | LastLiteralToken = 10, 281 | FirstTemplateToken = 10, 282 | LastTemplateToken = 13, 283 | FirstBinaryOperator = 24, 284 | LastBinaryOperator = 64, 285 | FirstNode = 127, 286 | } 287 | const enum NodeFlags { 288 | Export = 1, 289 | Ambient = 2, 290 | Public = 16, 291 | Private = 32, 292 | Protected = 64, 293 | Static = 128, 294 | Default = 256, 295 | MultiLine = 512, 296 | Synthetic = 1024, 297 | DeclarationFile = 2048, 298 | Let = 4096, 299 | Const = 8192, 300 | OctalLiteral = 16384, 301 | Namespace = 32768, 302 | ExportContext = 65536, 303 | Modifier = 499, 304 | AccessibilityModifier = 112, 305 | BlockScoped = 12288, 306 | } 307 | interface Node extends TextRange { 308 | kind: SyntaxKind; 309 | flags: NodeFlags; 310 | decorators?: NodeArray; 311 | modifiers?: ModifiersArray; 312 | parent?: Node; 313 | } 314 | interface NodeArray extends Array, TextRange { 315 | hasTrailingComma?: boolean; 316 | } 317 | interface ModifiersArray extends NodeArray { 318 | flags: number; 319 | } 320 | interface Identifier extends PrimaryExpression { 321 | text: string; 322 | originalKeywordKind?: SyntaxKind; 323 | } 324 | interface QualifiedName extends Node { 325 | left: EntityName; 326 | right: Identifier; 327 | } 328 | type EntityName = Identifier | QualifiedName; 329 | type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; 330 | interface Declaration extends Node { 331 | _declarationBrand: any; 332 | name?: DeclarationName; 333 | } 334 | interface ComputedPropertyName extends Node { 335 | expression: Expression; 336 | } 337 | interface Decorator extends Node { 338 | expression: LeftHandSideExpression; 339 | } 340 | interface TypeParameterDeclaration extends Declaration { 341 | name: Identifier; 342 | constraint?: TypeNode; 343 | expression?: Expression; 344 | } 345 | interface SignatureDeclaration extends Declaration { 346 | typeParameters?: NodeArray; 347 | parameters: NodeArray; 348 | type?: TypeNode; 349 | } 350 | interface VariableDeclaration extends Declaration { 351 | parent?: VariableDeclarationList; 352 | type?: TypeNode; 353 | initializer?: Expression; 354 | } 355 | interface VariableDeclarationList extends Node { 356 | declarations: NodeArray; 357 | } 358 | interface ParameterDeclaration extends Declaration { 359 | dotDotDotToken?: Node; 360 | questionToken?: Node; 361 | type?: TypeNode; 362 | initializer?: Expression; 363 | } 364 | interface BindingElement extends Declaration { 365 | propertyName?: Identifier; 366 | dotDotDotToken?: Node; 367 | initializer?: Expression; 368 | } 369 | interface PropertyDeclaration extends Declaration, ClassElement { 370 | name: DeclarationName; 371 | questionToken?: Node; 372 | type?: TypeNode; 373 | initializer?: Expression; 374 | } 375 | interface ObjectLiteralElement extends Declaration { 376 | _objectLiteralBrandBrand: any; 377 | } 378 | interface PropertyAssignment extends ObjectLiteralElement { 379 | _propertyAssignmentBrand: any; 380 | name: DeclarationName; 381 | questionToken?: Node; 382 | initializer: Expression; 383 | } 384 | interface ShorthandPropertyAssignment extends ObjectLiteralElement { 385 | name: Identifier; 386 | questionToken?: Node; 387 | } 388 | interface VariableLikeDeclaration extends Declaration { 389 | propertyName?: Identifier; 390 | dotDotDotToken?: Node; 391 | name: DeclarationName; 392 | questionToken?: Node; 393 | type?: TypeNode; 394 | initializer?: Expression; 395 | } 396 | interface BindingPattern extends Node { 397 | elements: NodeArray; 398 | } 399 | /** 400 | * Several node kinds share function-like features such as a signature, 401 | * a name, and a body. These nodes should extend FunctionLikeDeclaration. 402 | * Examples: 403 | * FunctionDeclaration 404 | * MethodDeclaration 405 | * AccessorDeclaration 406 | */ 407 | interface FunctionLikeDeclaration extends SignatureDeclaration { 408 | _functionLikeDeclarationBrand: any; 409 | asteriskToken?: Node; 410 | questionToken?: Node; 411 | body?: Block | Expression; 412 | } 413 | interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { 414 | name?: Identifier; 415 | body?: Block; 416 | } 417 | interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { 418 | body?: Block; 419 | } 420 | interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { 421 | body?: Block; 422 | } 423 | interface SemicolonClassElement extends ClassElement { 424 | _semicolonClassElementBrand: any; 425 | } 426 | interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { 427 | _accessorDeclarationBrand: any; 428 | body: Block; 429 | } 430 | interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { 431 | _indexSignatureDeclarationBrand: any; 432 | } 433 | interface TypeNode extends Node { 434 | _typeNodeBrand: any; 435 | } 436 | interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { 437 | _functionOrConstructorTypeNodeBrand: any; 438 | } 439 | interface TypeReferenceNode extends TypeNode { 440 | typeName: EntityName; 441 | typeArguments?: NodeArray; 442 | } 443 | interface TypeQueryNode extends TypeNode { 444 | exprName: EntityName; 445 | } 446 | interface TypeLiteralNode extends TypeNode, Declaration { 447 | members: NodeArray; 448 | } 449 | interface ArrayTypeNode extends TypeNode { 450 | elementType: TypeNode; 451 | } 452 | interface TupleTypeNode extends TypeNode { 453 | elementTypes: NodeArray; 454 | } 455 | interface UnionTypeNode extends TypeNode { 456 | types: NodeArray; 457 | } 458 | interface ParenthesizedTypeNode extends TypeNode { 459 | type: TypeNode; 460 | } 461 | interface StringLiteral extends LiteralExpression, TypeNode { 462 | _stringLiteralBrand: any; 463 | } 464 | interface Expression extends Node { 465 | _expressionBrand: any; 466 | contextualType?: Type; 467 | } 468 | interface UnaryExpression extends Expression { 469 | _unaryExpressionBrand: any; 470 | } 471 | interface PrefixUnaryExpression extends UnaryExpression { 472 | operator: SyntaxKind; 473 | operand: UnaryExpression; 474 | } 475 | interface PostfixUnaryExpression extends PostfixExpression { 476 | operand: LeftHandSideExpression; 477 | operator: SyntaxKind; 478 | } 479 | interface PostfixExpression extends UnaryExpression { 480 | _postfixExpressionBrand: any; 481 | } 482 | interface LeftHandSideExpression extends PostfixExpression { 483 | _leftHandSideExpressionBrand: any; 484 | } 485 | interface MemberExpression extends LeftHandSideExpression { 486 | _memberExpressionBrand: any; 487 | } 488 | interface PrimaryExpression extends MemberExpression { 489 | _primaryExpressionBrand: any; 490 | } 491 | interface DeleteExpression extends UnaryExpression { 492 | expression: UnaryExpression; 493 | } 494 | interface TypeOfExpression extends UnaryExpression { 495 | expression: UnaryExpression; 496 | } 497 | interface VoidExpression extends UnaryExpression { 498 | expression: UnaryExpression; 499 | } 500 | interface YieldExpression extends Expression { 501 | asteriskToken?: Node; 502 | expression: Expression; 503 | } 504 | interface BinaryExpression extends Expression { 505 | left: Expression; 506 | operatorToken: Node; 507 | right: Expression; 508 | } 509 | interface ConditionalExpression extends Expression { 510 | condition: Expression; 511 | questionToken: Node; 512 | whenTrue: Expression; 513 | colonToken: Node; 514 | whenFalse: Expression; 515 | } 516 | interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { 517 | name?: Identifier; 518 | body: Block | Expression; 519 | } 520 | interface ArrowFunction extends Expression, FunctionLikeDeclaration { 521 | equalsGreaterThanToken: Node; 522 | } 523 | interface LiteralExpression extends PrimaryExpression { 524 | text: string; 525 | isUnterminated?: boolean; 526 | hasExtendedUnicodeEscape?: boolean; 527 | } 528 | interface TemplateExpression extends PrimaryExpression { 529 | head: LiteralExpression; 530 | templateSpans: NodeArray; 531 | } 532 | interface TemplateSpan extends Node { 533 | expression: Expression; 534 | literal: LiteralExpression; 535 | } 536 | interface ParenthesizedExpression extends PrimaryExpression { 537 | expression: Expression; 538 | } 539 | interface ArrayLiteralExpression extends PrimaryExpression { 540 | elements: NodeArray; 541 | } 542 | interface SpreadElementExpression extends Expression { 543 | expression: Expression; 544 | } 545 | interface ObjectLiteralExpression extends PrimaryExpression, Declaration { 546 | properties: NodeArray; 547 | } 548 | interface PropertyAccessExpression extends MemberExpression { 549 | expression: LeftHandSideExpression; 550 | dotToken: Node; 551 | name: Identifier; 552 | } 553 | interface ElementAccessExpression extends MemberExpression { 554 | expression: LeftHandSideExpression; 555 | argumentExpression?: Expression; 556 | } 557 | interface CallExpression extends LeftHandSideExpression { 558 | expression: LeftHandSideExpression; 559 | typeArguments?: NodeArray; 560 | arguments: NodeArray; 561 | } 562 | interface ExpressionWithTypeArguments extends TypeNode { 563 | expression: LeftHandSideExpression; 564 | typeArguments?: NodeArray; 565 | } 566 | interface NewExpression extends CallExpression, PrimaryExpression { 567 | } 568 | interface TaggedTemplateExpression extends MemberExpression { 569 | tag: LeftHandSideExpression; 570 | template: LiteralExpression | TemplateExpression; 571 | } 572 | type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; 573 | interface TypeAssertion extends UnaryExpression { 574 | type: TypeNode; 575 | expression: UnaryExpression; 576 | } 577 | interface Statement extends Node, ModuleElement { 578 | _statementBrand: any; 579 | } 580 | interface Block extends Statement { 581 | statements: NodeArray; 582 | } 583 | interface VariableStatement extends Statement { 584 | declarationList: VariableDeclarationList; 585 | } 586 | interface ExpressionStatement extends Statement { 587 | expression: Expression; 588 | } 589 | interface IfStatement extends Statement { 590 | expression: Expression; 591 | thenStatement: Statement; 592 | elseStatement?: Statement; 593 | } 594 | interface IterationStatement extends Statement { 595 | statement: Statement; 596 | } 597 | interface DoStatement extends IterationStatement { 598 | expression: Expression; 599 | } 600 | interface WhileStatement extends IterationStatement { 601 | expression: Expression; 602 | } 603 | interface ForStatement extends IterationStatement { 604 | initializer?: VariableDeclarationList | Expression; 605 | condition?: Expression; 606 | incrementor?: Expression; 607 | } 608 | interface ForInStatement extends IterationStatement { 609 | initializer: VariableDeclarationList | Expression; 610 | expression: Expression; 611 | } 612 | interface ForOfStatement extends IterationStatement { 613 | initializer: VariableDeclarationList | Expression; 614 | expression: Expression; 615 | } 616 | interface BreakOrContinueStatement extends Statement { 617 | label?: Identifier; 618 | } 619 | interface ReturnStatement extends Statement { 620 | expression?: Expression; 621 | } 622 | interface WithStatement extends Statement { 623 | expression: Expression; 624 | statement: Statement; 625 | } 626 | interface SwitchStatement extends Statement { 627 | expression: Expression; 628 | caseBlock: CaseBlock; 629 | } 630 | interface CaseBlock extends Node { 631 | clauses: NodeArray; 632 | } 633 | interface CaseClause extends Node { 634 | expression?: Expression; 635 | statements: NodeArray; 636 | } 637 | interface DefaultClause extends Node { 638 | statements: NodeArray; 639 | } 640 | type CaseOrDefaultClause = CaseClause | DefaultClause; 641 | interface LabeledStatement extends Statement { 642 | label: Identifier; 643 | statement: Statement; 644 | } 645 | interface ThrowStatement extends Statement { 646 | expression: Expression; 647 | } 648 | interface TryStatement extends Statement { 649 | tryBlock: Block; 650 | catchClause?: CatchClause; 651 | finallyBlock?: Block; 652 | } 653 | interface CatchClause extends Node { 654 | variableDeclaration: VariableDeclaration; 655 | block: Block; 656 | } 657 | interface ModuleElement extends Node { 658 | _moduleElementBrand: any; 659 | } 660 | interface ClassLikeDeclaration extends Declaration { 661 | name?: Identifier; 662 | typeParameters?: NodeArray; 663 | heritageClauses?: NodeArray; 664 | members: NodeArray; 665 | } 666 | interface ClassDeclaration extends ClassLikeDeclaration, Statement { 667 | } 668 | interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { 669 | } 670 | interface ClassElement extends Declaration { 671 | _classElementBrand: any; 672 | } 673 | interface InterfaceDeclaration extends Declaration, ModuleElement { 674 | name: Identifier; 675 | typeParameters?: NodeArray; 676 | heritageClauses?: NodeArray; 677 | members: NodeArray; 678 | } 679 | interface HeritageClause extends Node { 680 | token: SyntaxKind; 681 | types?: NodeArray; 682 | } 683 | interface TypeAliasDeclaration extends Declaration, ModuleElement { 684 | name: Identifier; 685 | type: TypeNode; 686 | } 687 | interface EnumMember extends Declaration { 688 | name: DeclarationName; 689 | initializer?: Expression; 690 | } 691 | interface EnumDeclaration extends Declaration, ModuleElement { 692 | name: Identifier; 693 | members: NodeArray; 694 | } 695 | interface ModuleDeclaration extends Declaration, ModuleElement { 696 | name: Identifier | LiteralExpression; 697 | body: ModuleBlock | ModuleDeclaration; 698 | } 699 | interface ModuleBlock extends Node, ModuleElement { 700 | statements: NodeArray; 701 | } 702 | interface ImportEqualsDeclaration extends Declaration, ModuleElement { 703 | name: Identifier; 704 | moduleReference: EntityName | ExternalModuleReference; 705 | } 706 | interface ExternalModuleReference extends Node { 707 | expression?: Expression; 708 | } 709 | interface ImportDeclaration extends ModuleElement { 710 | importClause?: ImportClause; 711 | moduleSpecifier: Expression; 712 | } 713 | interface ImportClause extends Declaration { 714 | name?: Identifier; 715 | namedBindings?: NamespaceImport | NamedImports; 716 | } 717 | interface NamespaceImport extends Declaration { 718 | name: Identifier; 719 | } 720 | interface ExportDeclaration extends Declaration, ModuleElement { 721 | exportClause?: NamedExports; 722 | moduleSpecifier?: Expression; 723 | } 724 | interface NamedImportsOrExports extends Node { 725 | elements: NodeArray; 726 | } 727 | type NamedImports = NamedImportsOrExports; 728 | type NamedExports = NamedImportsOrExports; 729 | interface ImportOrExportSpecifier extends Declaration { 730 | propertyName?: Identifier; 731 | name: Identifier; 732 | } 733 | type ImportSpecifier = ImportOrExportSpecifier; 734 | type ExportSpecifier = ImportOrExportSpecifier; 735 | interface ExportAssignment extends Declaration, ModuleElement { 736 | isExportEquals?: boolean; 737 | expression: Expression; 738 | } 739 | interface FileReference extends TextRange { 740 | fileName: string; 741 | } 742 | interface CommentRange extends TextRange { 743 | hasTrailingNewLine?: boolean; 744 | kind: SyntaxKind; 745 | } 746 | interface SourceFile extends Declaration { 747 | statements: NodeArray; 748 | endOfFileToken: Node; 749 | fileName: string; 750 | text: string; 751 | amdDependencies: { 752 | path: string; 753 | name: string; 754 | }[]; 755 | moduleName: string; 756 | referencedFiles: FileReference[]; 757 | hasNoDefaultLib: boolean; 758 | languageVersion: ScriptTarget; 759 | } 760 | interface ScriptReferenceHost { 761 | getCompilerOptions(): CompilerOptions; 762 | getSourceFile(fileName: string): SourceFile; 763 | getCurrentDirectory(): string; 764 | } 765 | interface ParseConfigHost { 766 | readDirectory(rootDir: string, extension: string): string[]; 767 | } 768 | interface WriteFileCallback { 769 | (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; 770 | } 771 | interface Program extends ScriptReferenceHost { 772 | /** 773 | * Get a list of files in the program 774 | */ 775 | getSourceFiles(): SourceFile[]; 776 | /** 777 | * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then 778 | * the JavaScript and declaration files will be produced for all the files in this program. 779 | * If targetSourceFile is specified, then only the JavaScript and declaration for that 780 | * specific file will be generated. 781 | * 782 | * If writeFile is not specified then the writeFile callback from the compiler host will be 783 | * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter 784 | * will be invoked when writing the JavaScript and declaration files. 785 | */ 786 | emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; 787 | getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; 788 | getGlobalDiagnostics(): Diagnostic[]; 789 | getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; 790 | getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; 791 | /** 792 | * Gets a type checker that can be used to semantically analyze source fils in the program. 793 | */ 794 | getTypeChecker(): TypeChecker; 795 | } 796 | interface SourceMapSpan { 797 | /** Line number in the .js file. */ 798 | emittedLine: number; 799 | /** Column number in the .js file. */ 800 | emittedColumn: number; 801 | /** Line number in the .ts file. */ 802 | sourceLine: number; 803 | /** Column number in the .ts file. */ 804 | sourceColumn: number; 805 | /** Optional name (index into names array) associated with this span. */ 806 | nameIndex?: number; 807 | /** .ts file (index into sources array) associated with this span */ 808 | sourceIndex: number; 809 | } 810 | interface SourceMapData { 811 | sourceMapFilePath: string; 812 | jsSourceMappingURL: string; 813 | sourceMapFile: string; 814 | sourceMapSourceRoot: string; 815 | sourceMapSources: string[]; 816 | sourceMapSourcesContent?: string[]; 817 | inputSourceFileNames: string[]; 818 | sourceMapNames?: string[]; 819 | sourceMapMappings: string; 820 | sourceMapDecodedMappings: SourceMapSpan[]; 821 | } 822 | /** Return code used by getEmitOutput function to indicate status of the function */ 823 | enum ExitStatus { 824 | Success = 0, 825 | DiagnosticsPresent_OutputsSkipped = 1, 826 | DiagnosticsPresent_OutputsGenerated = 2, 827 | } 828 | interface EmitResult { 829 | emitSkipped: boolean; 830 | diagnostics: Diagnostic[]; 831 | } 832 | interface TypeCheckerHost { 833 | getCompilerOptions(): CompilerOptions; 834 | getSourceFiles(): SourceFile[]; 835 | getSourceFile(fileName: string): SourceFile; 836 | } 837 | interface TypeChecker { 838 | getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; 839 | getDeclaredTypeOfSymbol(symbol: Symbol): Type; 840 | getPropertiesOfType(type: Type): Symbol[]; 841 | getPropertyOfType(type: Type, propertyName: string): Symbol; 842 | getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; 843 | getIndexTypeOfType(type: Type, kind: IndexKind): Type; 844 | getReturnTypeOfSignature(signature: Signature): Type; 845 | getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; 846 | getSymbolAtLocation(node: Node): Symbol; 847 | getShorthandAssignmentValueSymbol(location: Node): Symbol; 848 | getTypeAtLocation(node: Node): Type; 849 | typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; 850 | symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; 851 | getSymbolDisplayBuilder(): SymbolDisplayBuilder; 852 | getFullyQualifiedName(symbol: Symbol): string; 853 | getAugmentedPropertiesOfType(type: Type): Symbol[]; 854 | getRootSymbols(symbol: Symbol): Symbol[]; 855 | getContextualType(node: Expression): Type; 856 | getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; 857 | getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; 858 | isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; 859 | isUndefinedSymbol(symbol: Symbol): boolean; 860 | isArgumentsSymbol(symbol: Symbol): boolean; 861 | getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; 862 | isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; 863 | getAliasedSymbol(symbol: Symbol): Symbol; 864 | getExportsOfModule(moduleSymbol: Symbol): Symbol[]; 865 | } 866 | interface SymbolDisplayBuilder { 867 | buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 868 | buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; 869 | buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 870 | buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 871 | buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 872 | buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; 873 | buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 874 | buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 875 | buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; 876 | } 877 | interface SymbolWriter { 878 | writeKeyword(text: string): void; 879 | writeOperator(text: string): void; 880 | writePunctuation(text: string): void; 881 | writeSpace(text: string): void; 882 | writeStringLiteral(text: string): void; 883 | writeParameter(text: string): void; 884 | writeSymbol(text: string, symbol: Symbol): void; 885 | writeLine(): void; 886 | increaseIndent(): void; 887 | decreaseIndent(): void; 888 | clear(): void; 889 | trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; 890 | } 891 | const enum TypeFormatFlags { 892 | None = 0, 893 | WriteArrayAsGenericType = 1, 894 | UseTypeOfFunction = 2, 895 | NoTruncation = 4, 896 | WriteArrowStyleSignature = 8, 897 | WriteOwnNameForAnyLike = 16, 898 | WriteTypeArgumentsOfSignature = 32, 899 | InElementType = 64, 900 | UseFullyQualifiedType = 128, 901 | } 902 | const enum SymbolFormatFlags { 903 | None = 0, 904 | WriteTypeParametersOrArguments = 1, 905 | UseOnlyExternalAliasing = 2, 906 | } 907 | const enum SymbolFlags { 908 | FunctionScopedVariable = 1, 909 | BlockScopedVariable = 2, 910 | Property = 4, 911 | EnumMember = 8, 912 | Function = 16, 913 | Class = 32, 914 | Interface = 64, 915 | ConstEnum = 128, 916 | RegularEnum = 256, 917 | ValueModule = 512, 918 | NamespaceModule = 1024, 919 | TypeLiteral = 2048, 920 | ObjectLiteral = 4096, 921 | Method = 8192, 922 | Constructor = 16384, 923 | GetAccessor = 32768, 924 | SetAccessor = 65536, 925 | Signature = 131072, 926 | TypeParameter = 262144, 927 | TypeAlias = 524288, 928 | ExportValue = 1048576, 929 | ExportType = 2097152, 930 | ExportNamespace = 4194304, 931 | Alias = 8388608, 932 | Instantiated = 16777216, 933 | Merged = 33554432, 934 | Transient = 67108864, 935 | Prototype = 134217728, 936 | UnionProperty = 268435456, 937 | Optional = 536870912, 938 | ExportStar = 1073741824, 939 | Enum = 384, 940 | Variable = 3, 941 | Value = 107455, 942 | Type = 793056, 943 | Namespace = 1536, 944 | Module = 1536, 945 | Accessor = 98304, 946 | FunctionScopedVariableExcludes = 107454, 947 | BlockScopedVariableExcludes = 107455, 948 | ParameterExcludes = 107455, 949 | PropertyExcludes = 107455, 950 | EnumMemberExcludes = 107455, 951 | FunctionExcludes = 106927, 952 | ClassExcludes = 899583, 953 | InterfaceExcludes = 792992, 954 | RegularEnumExcludes = 899327, 955 | ConstEnumExcludes = 899967, 956 | ValueModuleExcludes = 106639, 957 | NamespaceModuleExcludes = 0, 958 | MethodExcludes = 99263, 959 | GetAccessorExcludes = 41919, 960 | SetAccessorExcludes = 74687, 961 | TypeParameterExcludes = 530912, 962 | TypeAliasExcludes = 793056, 963 | AliasExcludes = 8388608, 964 | ModuleMember = 8914931, 965 | ExportHasLocal = 944, 966 | HasLocals = 255504, 967 | HasExports = 1952, 968 | HasMembers = 6240, 969 | IsContainer = 262128, 970 | PropertyOrAccessor = 98308, 971 | Export = 7340032, 972 | } 973 | interface Symbol { 974 | flags: SymbolFlags; 975 | name: string; 976 | declarations?: Declaration[]; 977 | members?: SymbolTable; 978 | exports?: SymbolTable; 979 | valueDeclaration?: Declaration; 980 | } 981 | interface SymbolTable { 982 | [index: string]: Symbol; 983 | } 984 | const enum TypeFlags { 985 | Any = 1, 986 | String = 2, 987 | Number = 4, 988 | Boolean = 8, 989 | Void = 16, 990 | Undefined = 32, 991 | Null = 64, 992 | Enum = 128, 993 | StringLiteral = 256, 994 | TypeParameter = 512, 995 | Class = 1024, 996 | Interface = 2048, 997 | Reference = 4096, 998 | Tuple = 8192, 999 | Union = 16384, 1000 | Anonymous = 32768, 1001 | ObjectLiteral = 131072, 1002 | ESSymbol = 1048576, 1003 | StringLike = 258, 1004 | NumberLike = 132, 1005 | ObjectType = 48128, 1006 | } 1007 | interface Type { 1008 | flags: TypeFlags; 1009 | symbol?: Symbol; 1010 | } 1011 | interface StringLiteralType extends Type { 1012 | text: string; 1013 | } 1014 | interface ObjectType extends Type { 1015 | } 1016 | interface InterfaceType extends ObjectType { 1017 | typeParameters: TypeParameter[]; 1018 | } 1019 | interface InterfaceTypeWithBaseTypes extends InterfaceType { 1020 | baseTypes: ObjectType[]; 1021 | } 1022 | interface InterfaceTypeWithDeclaredMembers extends InterfaceType { 1023 | declaredProperties: Symbol[]; 1024 | declaredCallSignatures: Signature[]; 1025 | declaredConstructSignatures: Signature[]; 1026 | declaredStringIndexType: Type; 1027 | declaredNumberIndexType: Type; 1028 | } 1029 | interface TypeReference extends ObjectType { 1030 | target: GenericType; 1031 | typeArguments: Type[]; 1032 | } 1033 | interface GenericType extends InterfaceType, TypeReference { 1034 | } 1035 | interface TupleType extends ObjectType { 1036 | elementTypes: Type[]; 1037 | baseArrayType: TypeReference; 1038 | } 1039 | interface UnionType extends Type { 1040 | types: Type[]; 1041 | } 1042 | interface TypeParameter extends Type { 1043 | constraint: Type; 1044 | } 1045 | const enum SignatureKind { 1046 | Call = 0, 1047 | Construct = 1, 1048 | } 1049 | interface Signature { 1050 | declaration: SignatureDeclaration; 1051 | typeParameters: TypeParameter[]; 1052 | parameters: Symbol[]; 1053 | } 1054 | const enum IndexKind { 1055 | String = 0, 1056 | Number = 1, 1057 | } 1058 | interface DiagnosticMessage { 1059 | key: string; 1060 | category: DiagnosticCategory; 1061 | code: number; 1062 | } 1063 | /** 1064 | * A linked list of formatted diagnostic messages to be used as part of a multiline message. 1065 | * It is built from the bottom up, leaving the head to be the "main" diagnostic. 1066 | * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, 1067 | * the difference is that messages are all preformatted in DMC. 1068 | */ 1069 | interface DiagnosticMessageChain { 1070 | messageText: string; 1071 | category: DiagnosticCategory; 1072 | code: number; 1073 | next?: DiagnosticMessageChain; 1074 | } 1075 | interface Diagnostic { 1076 | file: SourceFile; 1077 | start: number; 1078 | length: number; 1079 | messageText: string | DiagnosticMessageChain; 1080 | category: DiagnosticCategory; 1081 | code: number; 1082 | } 1083 | enum DiagnosticCategory { 1084 | Warning = 0, 1085 | Error = 1, 1086 | Message = 2, 1087 | } 1088 | interface CompilerOptions { 1089 | allowNonTsExtensions?: boolean; 1090 | charset?: string; 1091 | declaration?: boolean; 1092 | diagnostics?: boolean; 1093 | emitBOM?: boolean; 1094 | help?: boolean; 1095 | inlineSourceMap?: boolean; 1096 | inlineSources?: boolean; 1097 | listFiles?: boolean; 1098 | locale?: string; 1099 | mapRoot?: string; 1100 | module?: ModuleKind; 1101 | newLine?: NewLineKind; 1102 | noEmit?: boolean; 1103 | noEmitHelpers?: boolean; 1104 | noEmitOnError?: boolean; 1105 | noErrorTruncation?: boolean; 1106 | noImplicitAny?: boolean; 1107 | noLib?: boolean; 1108 | noResolve?: boolean; 1109 | out?: string; 1110 | outDir?: string; 1111 | preserveConstEnums?: boolean; 1112 | project?: string; 1113 | removeComments?: boolean; 1114 | rootDir?: string; 1115 | sourceMap?: boolean; 1116 | sourceRoot?: string; 1117 | suppressImplicitAnyIndexErrors?: boolean; 1118 | target?: ScriptTarget; 1119 | version?: boolean; 1120 | watch?: boolean; 1121 | isolatedModules?: boolean; 1122 | experimentalDecorators?: boolean; 1123 | emitDecoratorMetadata?: boolean; 1124 | [option: string]: string | number | boolean; 1125 | } 1126 | const enum ModuleKind { 1127 | None = 0, 1128 | CommonJS = 1, 1129 | AMD = 2, 1130 | UMD = 3, 1131 | System = 4, 1132 | } 1133 | const enum NewLineKind { 1134 | CarriageReturnLineFeed = 0, 1135 | LineFeed = 1, 1136 | } 1137 | interface LineAndCharacter { 1138 | line: number; 1139 | character: number; 1140 | } 1141 | const enum ScriptTarget { 1142 | ES3 = 0, 1143 | ES5 = 1, 1144 | ES6 = 2, 1145 | Latest = 2, 1146 | } 1147 | interface ParsedCommandLine { 1148 | options: CompilerOptions; 1149 | fileNames: string[]; 1150 | errors: Diagnostic[]; 1151 | } 1152 | interface CancellationToken { 1153 | isCancellationRequested(): boolean; 1154 | } 1155 | interface CompilerHost { 1156 | getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; 1157 | getDefaultLibFileName(options: CompilerOptions): string; 1158 | getCancellationToken?(): CancellationToken; 1159 | writeFile: WriteFileCallback; 1160 | getCurrentDirectory(): string; 1161 | getCanonicalFileName(fileName: string): string; 1162 | useCaseSensitiveFileNames(): boolean; 1163 | getNewLine(): string; 1164 | } 1165 | interface TextSpan { 1166 | start: number; 1167 | length: number; 1168 | } 1169 | interface TextChangeRange { 1170 | span: TextSpan; 1171 | newLength: number; 1172 | } 1173 | } 1174 | declare module ts { 1175 | interface System { 1176 | args: string[]; 1177 | newLine: string; 1178 | useCaseSensitiveFileNames: boolean; 1179 | write(s: string): void; 1180 | readFile(path: string, encoding?: string): string; 1181 | writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; 1182 | watchFile?(path: string, callback: (path: string) => void): FileWatcher; 1183 | resolvePath(path: string): string; 1184 | fileExists(path: string): boolean; 1185 | directoryExists(path: string): boolean; 1186 | createDirectory(path: string): void; 1187 | getExecutingFilePath(): string; 1188 | getCurrentDirectory(): string; 1189 | readDirectory(path: string, extension?: string): string[]; 1190 | getMemoryUsage?(): number; 1191 | exit(exitCode?: number): void; 1192 | } 1193 | interface FileWatcher { 1194 | close(): void; 1195 | } 1196 | var sys: System; 1197 | } 1198 | declare module ts { 1199 | interface ErrorCallback { 1200 | (message: DiagnosticMessage, length: number): void; 1201 | } 1202 | interface Scanner { 1203 | getStartPos(): number; 1204 | getToken(): SyntaxKind; 1205 | getTextPos(): number; 1206 | getTokenPos(): number; 1207 | getTokenText(): string; 1208 | getTokenValue(): string; 1209 | hasExtendedUnicodeEscape(): boolean; 1210 | hasPrecedingLineBreak(): boolean; 1211 | isIdentifier(): boolean; 1212 | isReservedWord(): boolean; 1213 | isUnterminated(): boolean; 1214 | reScanGreaterToken(): SyntaxKind; 1215 | reScanSlashToken(): SyntaxKind; 1216 | reScanTemplateToken(): SyntaxKind; 1217 | scan(): SyntaxKind; 1218 | setText(text: string, start?: number, length?: number): void; 1219 | setOnError(onError: ErrorCallback): void; 1220 | setScriptTarget(scriptTarget: ScriptTarget): void; 1221 | setTextPos(textPos: number): void; 1222 | lookAhead(callback: () => T): T; 1223 | tryScan(callback: () => T): T; 1224 | } 1225 | function tokenToString(t: SyntaxKind): string; 1226 | function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; 1227 | function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; 1228 | function isWhiteSpace(ch: number): boolean; 1229 | function isLineBreak(ch: number): boolean; 1230 | function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; 1231 | function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; 1232 | function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; 1233 | function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; 1234 | /** Creates a scanner over a (possibly unspecified) range of a piece of text. */ 1235 | function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; 1236 | } 1237 | declare module ts { 1238 | function getDefaultLibFileName(options: CompilerOptions): string; 1239 | function textSpanEnd(span: TextSpan): number; 1240 | function textSpanIsEmpty(span: TextSpan): boolean; 1241 | function textSpanContainsPosition(span: TextSpan, position: number): boolean; 1242 | function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; 1243 | function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; 1244 | function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; 1245 | function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; 1246 | function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; 1247 | function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; 1248 | function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; 1249 | function createTextSpan(start: number, length: number): TextSpan; 1250 | function createTextSpanFromBounds(start: number, end: number): TextSpan; 1251 | function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; 1252 | function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; 1253 | function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; 1254 | let unchangedTextChangeRange: TextChangeRange; 1255 | /** 1256 | * Called to merge all the changes that occurred across several versions of a script snapshot 1257 | * into a single change. i.e. if a user keeps making successive edits to a script we will 1258 | * have a text change from V1 to V2, V2 to V3, ..., Vn. 1259 | * 1260 | * This function will then merge those changes into a single change range valid between V1 and 1261 | * Vn. 1262 | */ 1263 | function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; 1264 | } 1265 | declare module ts { 1266 | function getNodeConstructor(kind: SyntaxKind): new () => Node; 1267 | function createNode(kind: SyntaxKind): Node; 1268 | function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; 1269 | function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; 1270 | function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; 1271 | } 1272 | declare module ts { 1273 | /** The version of the TypeScript compiler release */ 1274 | const version: string; 1275 | function findConfigFile(searchPath: string): string; 1276 | function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; 1277 | function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[]; 1278 | function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; 1279 | function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; 1280 | } 1281 | declare module ts { 1282 | function parseCommandLine(commandLine: string[]): ParsedCommandLine; 1283 | /** 1284 | * Read tsconfig.json file 1285 | * @param fileName The path to the config file 1286 | */ 1287 | function readConfigFile(fileName: string): { 1288 | config?: any; 1289 | error?: Diagnostic; 1290 | }; 1291 | /** 1292 | * Parse the text of the tsconfig.json file 1293 | * @param fileName The path to the config file 1294 | * @param jsonText The text of the config file 1295 | */ 1296 | function parseConfigFileText(fileName: string, jsonText: string): { 1297 | config?: any; 1298 | error?: Diagnostic; 1299 | }; 1300 | /** 1301 | * Parse the contents of a config file (tsconfig.json). 1302 | * @param json The contents of the config file to parse 1303 | * @param basePath A root directory to resolve relative path entries in the config 1304 | * file to. e.g. outDir 1305 | */ 1306 | function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; 1307 | } 1308 | declare module ts { 1309 | /** The version of the language service API */ 1310 | let servicesVersion: string; 1311 | interface Node { 1312 | getSourceFile(): SourceFile; 1313 | getChildCount(sourceFile?: SourceFile): number; 1314 | getChildAt(index: number, sourceFile?: SourceFile): Node; 1315 | getChildren(sourceFile?: SourceFile): Node[]; 1316 | getStart(sourceFile?: SourceFile): number; 1317 | getFullStart(): number; 1318 | getEnd(): number; 1319 | getWidth(sourceFile?: SourceFile): number; 1320 | getFullWidth(): number; 1321 | getLeadingTriviaWidth(sourceFile?: SourceFile): number; 1322 | getFullText(sourceFile?: SourceFile): string; 1323 | getText(sourceFile?: SourceFile): string; 1324 | getFirstToken(sourceFile?: SourceFile): Node; 1325 | getLastToken(sourceFile?: SourceFile): Node; 1326 | } 1327 | interface Symbol { 1328 | getFlags(): SymbolFlags; 1329 | getName(): string; 1330 | getDeclarations(): Declaration[]; 1331 | getDocumentationComment(): SymbolDisplayPart[]; 1332 | } 1333 | interface Type { 1334 | getFlags(): TypeFlags; 1335 | getSymbol(): Symbol; 1336 | getProperties(): Symbol[]; 1337 | getProperty(propertyName: string): Symbol; 1338 | getApparentProperties(): Symbol[]; 1339 | getCallSignatures(): Signature[]; 1340 | getConstructSignatures(): Signature[]; 1341 | getStringIndexType(): Type; 1342 | getNumberIndexType(): Type; 1343 | } 1344 | interface Signature { 1345 | getDeclaration(): SignatureDeclaration; 1346 | getTypeParameters(): Type[]; 1347 | getParameters(): Symbol[]; 1348 | getReturnType(): Type; 1349 | getDocumentationComment(): SymbolDisplayPart[]; 1350 | } 1351 | interface SourceFile { 1352 | getLineAndCharacterOfPosition(pos: number): LineAndCharacter; 1353 | getLineStarts(): number[]; 1354 | getPositionOfLineAndCharacter(line: number, character: number): number; 1355 | update(newText: string, textChangeRange: TextChangeRange): SourceFile; 1356 | } 1357 | /** 1358 | * Represents an immutable snapshot of a script at a specified time.Once acquired, the 1359 | * snapshot is observably immutable. i.e. the same calls with the same parameters will return 1360 | * the same values. 1361 | */ 1362 | interface IScriptSnapshot { 1363 | /** Gets a portion of the script snapshot specified by [start, end). */ 1364 | getText(start: number, end: number): string; 1365 | /** Gets the length of this script snapshot. */ 1366 | getLength(): number; 1367 | /** 1368 | * Gets the TextChangeRange that describe how the text changed between this text and 1369 | * an older version. This information is used by the incremental parser to determine 1370 | * what sections of the script need to be re-parsed. 'undefined' can be returned if the 1371 | * change range cannot be determined. However, in that case, incremental parsing will 1372 | * not happen and the entire document will be re - parsed. 1373 | */ 1374 | getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; 1375 | /** Releases all resources held by this script snapshot */ 1376 | dispose?(): void; 1377 | } 1378 | module ScriptSnapshot { 1379 | function fromString(text: string): IScriptSnapshot; 1380 | } 1381 | interface PreProcessedFileInfo { 1382 | referencedFiles: FileReference[]; 1383 | importedFiles: FileReference[]; 1384 | isLibFile: boolean; 1385 | } 1386 | interface LanguageServiceHost { 1387 | getCompilationSettings(): CompilerOptions; 1388 | getNewLine?(): string; 1389 | getProjectVersion?(): string; 1390 | getScriptFileNames(): string[]; 1391 | getScriptVersion(fileName: string): string; 1392 | getScriptSnapshot(fileName: string): IScriptSnapshot; 1393 | getLocalizedDiagnosticMessages?(): any; 1394 | getCancellationToken?(): CancellationToken; 1395 | getCurrentDirectory(): string; 1396 | getDefaultLibFileName(options: CompilerOptions): string; 1397 | log?(s: string): void; 1398 | trace?(s: string): void; 1399 | error?(s: string): void; 1400 | useCaseSensitiveFileNames?(): boolean; 1401 | } 1402 | interface LanguageService { 1403 | cleanupSemanticCache(): void; 1404 | getSyntacticDiagnostics(fileName: string): Diagnostic[]; 1405 | getSemanticDiagnostics(fileName: string): Diagnostic[]; 1406 | getCompilerOptionsDiagnostics(): Diagnostic[]; 1407 | /** 1408 | * @deprecated Use getEncodedSyntacticClassifications instead. 1409 | */ 1410 | getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; 1411 | /** 1412 | * @deprecated Use getEncodedSemanticClassifications instead. 1413 | */ 1414 | getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; 1415 | getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; 1416 | getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; 1417 | getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; 1418 | getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; 1419 | getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; 1420 | getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; 1421 | getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; 1422 | getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; 1423 | getRenameInfo(fileName: string, position: number): RenameInfo; 1424 | findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; 1425 | getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; 1426 | getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; 1427 | getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; 1428 | findReferences(fileName: string, position: number): ReferencedSymbol[]; 1429 | getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; 1430 | /** @deprecated */ 1431 | getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; 1432 | getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[]; 1433 | getNavigationBarItems(fileName: string): NavigationBarItem[]; 1434 | getOutliningSpans(fileName: string): OutliningSpan[]; 1435 | getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; 1436 | getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; 1437 | getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; 1438 | getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; 1439 | getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; 1440 | getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; 1441 | getEmitOutput(fileName: string): EmitOutput; 1442 | getProgram(): Program; 1443 | getSourceFile(fileName: string): SourceFile; 1444 | dispose(): void; 1445 | } 1446 | interface Classifications { 1447 | spans: number[]; 1448 | endOfLineState: EndOfLineState; 1449 | } 1450 | interface ClassifiedSpan { 1451 | textSpan: TextSpan; 1452 | classificationType: string; 1453 | } 1454 | interface NavigationBarItem { 1455 | text: string; 1456 | kind: string; 1457 | kindModifiers: string; 1458 | spans: TextSpan[]; 1459 | childItems: NavigationBarItem[]; 1460 | indent: number; 1461 | bolded: boolean; 1462 | grayed: boolean; 1463 | } 1464 | interface TodoCommentDescriptor { 1465 | text: string; 1466 | priority: number; 1467 | } 1468 | interface TodoComment { 1469 | descriptor: TodoCommentDescriptor; 1470 | message: string; 1471 | position: number; 1472 | } 1473 | class TextChange { 1474 | span: TextSpan; 1475 | newText: string; 1476 | } 1477 | interface RenameLocation { 1478 | textSpan: TextSpan; 1479 | fileName: string; 1480 | } 1481 | interface ReferenceEntry { 1482 | textSpan: TextSpan; 1483 | fileName: string; 1484 | isWriteAccess: boolean; 1485 | } 1486 | interface DocumentHighlights { 1487 | fileName: string; 1488 | highlightSpans: HighlightSpan[]; 1489 | } 1490 | module HighlightSpanKind { 1491 | const none: string; 1492 | const definition: string; 1493 | const reference: string; 1494 | const writtenReference: string; 1495 | } 1496 | interface HighlightSpan { 1497 | textSpan: TextSpan; 1498 | kind: string; 1499 | } 1500 | interface NavigateToItem { 1501 | name: string; 1502 | kind: string; 1503 | kindModifiers: string; 1504 | matchKind: string; 1505 | isCaseSensitive: boolean; 1506 | fileName: string; 1507 | textSpan: TextSpan; 1508 | containerName: string; 1509 | containerKind: string; 1510 | } 1511 | interface EditorOptions { 1512 | IndentSize: number; 1513 | TabSize: number; 1514 | NewLineCharacter: string; 1515 | ConvertTabsToSpaces: boolean; 1516 | } 1517 | interface FormatCodeOptions extends EditorOptions { 1518 | InsertSpaceAfterCommaDelimiter: boolean; 1519 | InsertSpaceAfterSemicolonInForStatements: boolean; 1520 | InsertSpaceBeforeAndAfterBinaryOperators: boolean; 1521 | InsertSpaceAfterKeywordsInControlFlowStatements: boolean; 1522 | InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; 1523 | InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; 1524 | PlaceOpenBraceOnNewLineForFunctions: boolean; 1525 | PlaceOpenBraceOnNewLineForControlBlocks: boolean; 1526 | [s: string]: boolean | number | string; 1527 | } 1528 | interface DefinitionInfo { 1529 | fileName: string; 1530 | textSpan: TextSpan; 1531 | kind: string; 1532 | name: string; 1533 | containerKind: string; 1534 | containerName: string; 1535 | } 1536 | interface ReferencedSymbol { 1537 | definition: DefinitionInfo; 1538 | references: ReferenceEntry[]; 1539 | } 1540 | enum SymbolDisplayPartKind { 1541 | aliasName = 0, 1542 | className = 1, 1543 | enumName = 2, 1544 | fieldName = 3, 1545 | interfaceName = 4, 1546 | keyword = 5, 1547 | lineBreak = 6, 1548 | numericLiteral = 7, 1549 | stringLiteral = 8, 1550 | localName = 9, 1551 | methodName = 10, 1552 | moduleName = 11, 1553 | operator = 12, 1554 | parameterName = 13, 1555 | propertyName = 14, 1556 | punctuation = 15, 1557 | space = 16, 1558 | text = 17, 1559 | typeParameterName = 18, 1560 | enumMemberName = 19, 1561 | functionName = 20, 1562 | regularExpressionLiteral = 21, 1563 | } 1564 | interface SymbolDisplayPart { 1565 | text: string; 1566 | kind: string; 1567 | } 1568 | interface QuickInfo { 1569 | kind: string; 1570 | kindModifiers: string; 1571 | textSpan: TextSpan; 1572 | displayParts: SymbolDisplayPart[]; 1573 | documentation: SymbolDisplayPart[]; 1574 | } 1575 | interface RenameInfo { 1576 | canRename: boolean; 1577 | localizedErrorMessage: string; 1578 | displayName: string; 1579 | fullDisplayName: string; 1580 | kind: string; 1581 | kindModifiers: string; 1582 | triggerSpan: TextSpan; 1583 | } 1584 | interface SignatureHelpParameter { 1585 | name: string; 1586 | documentation: SymbolDisplayPart[]; 1587 | displayParts: SymbolDisplayPart[]; 1588 | isOptional: boolean; 1589 | } 1590 | /** 1591 | * Represents a single signature to show in signature help. 1592 | * The id is used for subsequent calls into the language service to ask questions about the 1593 | * signature help item in the context of any documents that have been updated. i.e. after 1594 | * an edit has happened, while signature help is still active, the host can ask important 1595 | * questions like 'what parameter is the user currently contained within?'. 1596 | */ 1597 | interface SignatureHelpItem { 1598 | isVariadic: boolean; 1599 | prefixDisplayParts: SymbolDisplayPart[]; 1600 | suffixDisplayParts: SymbolDisplayPart[]; 1601 | separatorDisplayParts: SymbolDisplayPart[]; 1602 | parameters: SignatureHelpParameter[]; 1603 | documentation: SymbolDisplayPart[]; 1604 | } 1605 | /** 1606 | * Represents a set of signature help items, and the preferred item that should be selected. 1607 | */ 1608 | interface SignatureHelpItems { 1609 | items: SignatureHelpItem[]; 1610 | applicableSpan: TextSpan; 1611 | selectedItemIndex: number; 1612 | argumentIndex: number; 1613 | argumentCount: number; 1614 | } 1615 | interface CompletionInfo { 1616 | isMemberCompletion: boolean; 1617 | isNewIdentifierLocation: boolean; 1618 | entries: CompletionEntry[]; 1619 | } 1620 | interface CompletionEntry { 1621 | name: string; 1622 | kind: string; 1623 | kindModifiers: string; 1624 | sortText: string; 1625 | } 1626 | interface CompletionEntryDetails { 1627 | name: string; 1628 | kind: string; 1629 | kindModifiers: string; 1630 | displayParts: SymbolDisplayPart[]; 1631 | documentation: SymbolDisplayPart[]; 1632 | } 1633 | interface OutliningSpan { 1634 | /** The span of the document to actually collapse. */ 1635 | textSpan: TextSpan; 1636 | /** The span of the document to display when the user hovers over the collapsed span. */ 1637 | hintSpan: TextSpan; 1638 | /** The text to display in the editor for the collapsed region. */ 1639 | bannerText: string; 1640 | /** 1641 | * Whether or not this region should be automatically collapsed when 1642 | * the 'Collapse to Definitions' command is invoked. 1643 | */ 1644 | autoCollapse: boolean; 1645 | } 1646 | interface EmitOutput { 1647 | outputFiles: OutputFile[]; 1648 | emitSkipped: boolean; 1649 | } 1650 | const enum OutputFileType { 1651 | JavaScript = 0, 1652 | SourceMap = 1, 1653 | Declaration = 2, 1654 | } 1655 | interface OutputFile { 1656 | name: string; 1657 | writeByteOrderMark: boolean; 1658 | text: string; 1659 | } 1660 | const enum EndOfLineState { 1661 | None = 0, 1662 | InMultiLineCommentTrivia = 1, 1663 | InSingleQuoteStringLiteral = 2, 1664 | InDoubleQuoteStringLiteral = 3, 1665 | InTemplateHeadOrNoSubstitutionTemplate = 4, 1666 | InTemplateMiddleOrTail = 5, 1667 | InTemplateSubstitutionPosition = 6, 1668 | } 1669 | enum TokenClass { 1670 | Punctuation = 0, 1671 | Keyword = 1, 1672 | Operator = 2, 1673 | Comment = 3, 1674 | Whitespace = 4, 1675 | Identifier = 5, 1676 | NumberLiteral = 6, 1677 | StringLiteral = 7, 1678 | RegExpLiteral = 8, 1679 | } 1680 | interface ClassificationResult { 1681 | finalLexState: EndOfLineState; 1682 | entries: ClassificationInfo[]; 1683 | } 1684 | interface ClassificationInfo { 1685 | length: number; 1686 | classification: TokenClass; 1687 | } 1688 | interface Classifier { 1689 | /** 1690 | * Gives lexical classifications of tokens on a line without any syntactic context. 1691 | * For instance, a token consisting of the text 'string' can be either an identifier 1692 | * named 'string' or the keyword 'string', however, because this classifier is not aware, 1693 | * it relies on certain heuristics to give acceptable results. For classifications where 1694 | * speed trumps accuracy, this function is preferable; however, for true accuracy, the 1695 | * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the 1696 | * lexical, syntactic, and semantic classifiers may issue the best user experience. 1697 | * 1698 | * @param text The text of a line to classify. 1699 | * @param lexState The state of the lexical classifier at the end of the previous line. 1700 | * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier. 1701 | * If there is no syntactic classifier (syntacticClassifierAbsent=true), 1702 | * certain heuristics may be used in its place; however, if there is a 1703 | * syntactic classifier (syntacticClassifierAbsent=false), certain 1704 | * classifications which may be incorrectly categorized will be given 1705 | * back as Identifiers in order to allow the syntactic classifier to 1706 | * subsume the classification. 1707 | * @deprecated Use getLexicalClassifications instead. 1708 | */ 1709 | getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; 1710 | getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; 1711 | } 1712 | /** 1713 | * The document registry represents a store of SourceFile objects that can be shared between 1714 | * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) 1715 | * of files in the context. 1716 | * SourceFile objects account for most of the memory usage by the language service. Sharing 1717 | * the same DocumentRegistry instance between different instances of LanguageService allow 1718 | * for more efficient memory utilization since all projects will share at least the library 1719 | * file (lib.d.ts). 1720 | * 1721 | * A more advanced use of the document registry is to serialize sourceFile objects to disk 1722 | * and re-hydrate them when needed. 1723 | * 1724 | * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it 1725 | * to all subsequent createLanguageService calls. 1726 | */ 1727 | interface DocumentRegistry { 1728 | /** 1729 | * Request a stored SourceFile with a given fileName and compilationSettings. 1730 | * The first call to acquire will call createLanguageServiceSourceFile to generate 1731 | * the SourceFile if was not found in the registry. 1732 | * 1733 | * @param fileName The name of the file requested 1734 | * @param compilationSettings Some compilation settings like target affects the 1735 | * shape of a the resulting SourceFile. This allows the DocumentRegistry to store 1736 | * multiple copies of the same file for different compilation settings. 1737 | * @parm scriptSnapshot Text of the file. Only used if the file was not found 1738 | * in the registry and a new one was created. 1739 | * @parm version Current version of the file. Only used if the file was not found 1740 | * in the registry and a new one was created. 1741 | */ 1742 | acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; 1743 | /** 1744 | * Request an updated version of an already existing SourceFile with a given fileName 1745 | * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile 1746 | * to get an updated SourceFile. 1747 | * 1748 | * @param fileName The name of the file requested 1749 | * @param compilationSettings Some compilation settings like target affects the 1750 | * shape of a the resulting SourceFile. This allows the DocumentRegistry to store 1751 | * multiple copies of the same file for different compilation settings. 1752 | * @param scriptSnapshot Text of the file. 1753 | * @param version Current version of the file. 1754 | */ 1755 | updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; 1756 | /** 1757 | * Informs the DocumentRegistry that a file is not needed any longer. 1758 | * 1759 | * Note: It is not allowed to call release on a SourceFile that was not acquired from 1760 | * this registry originally. 1761 | * 1762 | * @param fileName The name of the file to be released 1763 | * @param compilationSettings The compilation settings used to acquire the file 1764 | */ 1765 | releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; 1766 | } 1767 | module ScriptElementKind { 1768 | const unknown: string; 1769 | const warning: string; 1770 | const keyword: string; 1771 | const scriptElement: string; 1772 | const moduleElement: string; 1773 | const classElement: string; 1774 | const interfaceElement: string; 1775 | const typeElement: string; 1776 | const enumElement: string; 1777 | const variableElement: string; 1778 | const localVariableElement: string; 1779 | const functionElement: string; 1780 | const localFunctionElement: string; 1781 | const memberFunctionElement: string; 1782 | const memberGetAccessorElement: string; 1783 | const memberSetAccessorElement: string; 1784 | const memberVariableElement: string; 1785 | const constructorImplementationElement: string; 1786 | const callSignatureElement: string; 1787 | const indexSignatureElement: string; 1788 | const constructSignatureElement: string; 1789 | const parameterElement: string; 1790 | const typeParameterElement: string; 1791 | const primitiveType: string; 1792 | const label: string; 1793 | const alias: string; 1794 | const constElement: string; 1795 | const letElement: string; 1796 | } 1797 | module ScriptElementKindModifier { 1798 | const none: string; 1799 | const publicMemberModifier: string; 1800 | const privateMemberModifier: string; 1801 | const protectedMemberModifier: string; 1802 | const exportedModifier: string; 1803 | const ambientModifier: string; 1804 | const staticModifier: string; 1805 | } 1806 | class ClassificationTypeNames { 1807 | static comment: string; 1808 | static identifier: string; 1809 | static keyword: string; 1810 | static numericLiteral: string; 1811 | static operator: string; 1812 | static stringLiteral: string; 1813 | static whiteSpace: string; 1814 | static text: string; 1815 | static punctuation: string; 1816 | static className: string; 1817 | static enumName: string; 1818 | static interfaceName: string; 1819 | static moduleName: string; 1820 | static typeParameterName: string; 1821 | static typeAliasName: string; 1822 | static parameterName: string; 1823 | } 1824 | const enum ClassificationType { 1825 | comment = 1, 1826 | identifier = 2, 1827 | keyword = 3, 1828 | numericLiteral = 4, 1829 | operator = 5, 1830 | stringLiteral = 6, 1831 | regularExpressionLiteral = 7, 1832 | whiteSpace = 8, 1833 | text = 9, 1834 | punctuation = 10, 1835 | className = 11, 1836 | enumName = 12, 1837 | interfaceName = 13, 1838 | moduleName = 14, 1839 | typeParameterName = 15, 1840 | typeAliasName = 16, 1841 | parameterName = 17, 1842 | } 1843 | interface DisplayPartsSymbolWriter extends SymbolWriter { 1844 | displayParts(): SymbolDisplayPart[]; 1845 | } 1846 | function displayPartsToString(displayParts: SymbolDisplayPart[]): string; 1847 | function getDefaultCompilerOptions(): CompilerOptions; 1848 | class OperationCanceledException { 1849 | } 1850 | class CancellationTokenObject { 1851 | private cancellationToken; 1852 | static None: CancellationTokenObject; 1853 | constructor(cancellationToken: CancellationToken); 1854 | isCancellationRequested(): boolean; 1855 | throwIfCancellationRequested(): void; 1856 | } 1857 | function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; 1858 | function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; 1859 | let disableIncrementalParsing: boolean; 1860 | function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; 1861 | function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; 1862 | function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; 1863 | function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; 1864 | function createClassifier(): Classifier; 1865 | /** 1866 | * Get the path of the default library file (lib.d.ts) as distributed with the typescript 1867 | * node package. 1868 | * The functionality is not supported if the ts module is consumed outside of a node module. 1869 | */ 1870 | function getDefaultLibFilePath(options: CompilerOptions): string; 1871 | } -------------------------------------------------------------------------------- /typings/vinyl.d.ts: -------------------------------------------------------------------------------- 1 | declare module Vinyl { 2 | export interface File { 3 | path: string; 4 | cwd: string; 5 | base: string; 6 | } 7 | } --------------------------------------------------------------------------------