瀏覽代碼

Initial version

Johannes Rieken 9 年之前
父節點
當前提交
331acc5fef
共有 26 個文件被更改,包括 7643 次插入2 次删除
  1. 3 0
      .gitignore
  2. 8 0
      .npmignore
  3. 9 0
      .vscode/settings.json
  4. 21 0
      LICENSE.md
  5. 12 2
      README.md
  6. 273 0
      gulpfile.js
  7. 6 0
      lib/lib-es6-ts.d.ts
  8. 7 0
      lib/lib-es6-ts.js
  9. 6 0
      lib/lib-ts.d.ts
  10. 7 0
      lib/lib-ts.js
  11. 2348 0
      lib/typescriptServices.d.ts
  12. 3078 0
      lib/typescriptServices.js
  13. 33 0
      package.json
  14. 540 0
      src/languageFeatures.ts
  15. 110 0
      src/mode.ts
  16. 35 0
      src/monaco.contribution.ts
  17. 163 0
      src/tokenization.ts
  18. 96 0
      src/typescript.ts
  19. 181 0
      src/worker.ts
  20. 104 0
      src/workerManager.ts
  21. 12 0
      test/all.js
  22. 44 0
      test/assert.d.ts
  23. 13 0
      test/mocha.d.ts
  24. 3 0
      test/mocha.opts
  25. 502 0
      test/tokenization.test.ts
  26. 29 0
      tsconfig.json

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/node_modules/
+/out/
+/release/

+ 8 - 0
.npmignore

@@ -0,0 +1,8 @@
+/.vscode/
+/lib/
+/out/
+/src/
+/test/
+/gulpfile.js
+/tsconfig.json
+/.npmignore

+ 9 - 0
.vscode/settings.json

@@ -0,0 +1,9 @@
+// Place your settings in this file to overwrite default and user settings.
+{
+	"files.trimTrailingWhitespace": true,
+	"search.exclude": {
+		"**/node_modules": true,
+		"**/release": true,
+		"**/out": true
+	}
+}

+ 21 - 0
LICENSE.md

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 12 - 2
README.md

@@ -1,2 +1,12 @@
-# monaco-typescript
-TypeScript/JavaScript language support for the Monaco Editor
+# Monaco TypeScript
+
+TypeScript and JavaScript language support for the Monaco Editor.
+
+![typescript](https://cloud.githubusercontent.com/assets/5047891/15926623/5262fe08-2e3d-11e6-9b90-1d43fda07178.gif)
+
+## Installing
+
+This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module.
+
+## License
+[MIT](https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md)

+ 273 - 0
gulpfile.js

@@ -0,0 +1,273 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+var gulp = require('gulp');
+var tsb = require('gulp-tsb');
+var assign = require('object-assign');
+var fs = require('fs');
+var path = require('path');
+var merge = require('merge-stream');
+var rjs = require('gulp-requirejs');
+var uglify = require('gulp-uglify');
+var rimraf = require('rimraf');
+var es = require('event-stream');
+
+var TYPESCRIPT_LIB_SOURCE = path.join(__dirname, 'node_modules', 'typescript', 'lib');
+var TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, 'lib');
+
+gulp.task('clean-release', function(cb) { rimraf('release', { maxBusyTries: 1 }, cb); });
+gulp.task('release', ['clean-release','compile'], function() {
+
+	var sha1 = getGitVersion(__dirname);
+	var semver = require('./package.json').version;
+	var headerVersion = semver + '(' + sha1 + ')';
+
+	var BUNDLED_FILE_HEADER = [
+		'/*!-----------------------------------------------------------------------------',
+		' * Copyright (c) Microsoft Corporation. All rights reserved.',
+		' * monaco-typescript version: ' + headerVersion,
+		' * Released under the MIT license',
+		' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
+		' *-----------------------------------------------------------------------------*/',
+		''
+	].join('\n');
+
+	function bundleOne(moduleId, exclude) {
+		return rjs({
+			baseUrl: '/out/',
+			name: 'vs/language/typescript/' + moduleId,
+			out: moduleId + '.js',
+			exclude: exclude,
+			paths: {
+				'vs/language/typescript': __dirname + '/out'
+			}
+		})
+	}
+
+	return merge(
+			bundleOne('src/monaco.contribution'),
+			bundleOne('lib/typescriptServices'),
+			bundleOne('src/mode', ['vs/language/typescript/lib/typescriptServices']),
+			bundleOne('src/worker', ['vs/language/typescript/lib/typescriptServices'])
+		)
+		.pipe(uglify({
+			preserveComments: 'some'
+		}))
+		.pipe(es.through(function(data) {
+			data.contents = new Buffer(
+				BUNDLED_FILE_HEADER
+				+ data.contents.toString()
+			);
+			this.emit('data', data);
+		}))
+		.pipe(gulp.dest('./release/'));
+});
+
+
+var compilation = tsb.create(assign({ verbose: true }, require('./tsconfig.json').compilerOptions));
+
+var tsSources = require('./tsconfig.json').filesGlob;
+
+function compileTask() {
+	return merge(
+		gulp.src('lib/*.js', { base: '.' }),
+		gulp.src(tsSources).pipe(compilation())
+	)
+	.pipe(gulp.dest('out'));
+}
+
+gulp.task('clean-out', function(cb) { rimraf('out', { maxBusyTries: 1 }, cb); });
+gulp.task('compile', ['clean-out'], compileTask);
+gulp.task('compile-without-clean', compileTask);
+gulp.task('watch', ['compile'], function() {
+	gulp.watch(tsSources, ['compile-without-clean']);
+});
+
+
+/**
+ * Import files from TypeScript's dist
+ */
+gulp.task('import-typescript', function() {
+	try {
+		fs.statSync(TYPESCRIPT_LIB_DESTINATION);
+	} catch (err) {
+		fs.mkdirSync(TYPESCRIPT_LIB_DESTINATION);
+	}
+	importLibDeclarationFile('lib.d.ts');
+	importLibDeclarationFile('lib.es6.d.ts');
+
+	var tsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.js')).toString();
+	tsServices +=
+`
+// MONACOCHANGE
+define([], function() { return ts; });
+// END MONACOCHANGE
+`;
+	fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.js'), tsServices);
+
+	var dtsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.d.ts')).toString();
+	dtsServices +=
+`
+// MONACOCHANGE
+export = ts;
+// END MONACOCHANGE
+`;
+	fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'), dtsServices);
+});
+
+/**
+ * Import a lib*.d.ts file from TypeScript's dist
+ */
+function importLibDeclarationFile(name) {
+	var dstName = name.replace(/\.d\.ts$/, '').replace(/\./g, '-') + '-ts';
+	var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, name);
+
+	var contents = fs.readFileSync(srcPath).toString();
+
+	var dstPath1 = path.join(TYPESCRIPT_LIB_DESTINATION, dstName + '.js');
+	fs.writeFileSync(dstPath1,
+`/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+// This is a generated file from ${name}
+
+define([], function() { return { contents: "${escapeText(contents)}"}; });
+
+`);
+
+	var dstPath2 = path.join(TYPESCRIPT_LIB_DESTINATION, dstName + '.d.ts');
+	fs.writeFileSync(dstPath2,
+`/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+export declare var contents: string;
+`);
+}
+
+/**
+ * Escape text such that it can be used in a javascript string enclosed by double quotes (")
+ */
+function escapeText(text) {
+	// http://www.javascriptkit.com/jsref/escapesequence.shtml
+	// \b	Backspace.
+	// \f	Form feed.
+	// \n	Newline.
+	// \O	Nul character.
+	// \r	Carriage return.
+	// \t	Horizontal tab.
+	// \v	Vertical tab.
+	// \'	Single quote or apostrophe.
+	// \"	Double quote.
+	// \\	Backslash.
+	// \ddd	The Latin-1 character specified by the three octal digits between 0 and 377. ie, copyright symbol is \251.
+	// \xdd	The Latin-1 character specified by the two hexadecimal digits dd between 00 and FF.  ie, copyright symbol is \xA9.
+	// \udddd	The Unicode character specified by the four hexadecimal digits dddd. ie, copyright symbol is \u00A9.
+	var _backspace = '\b'.charCodeAt(0);
+	var _formFeed = '\f'.charCodeAt(0);
+	var _newLine = '\n'.charCodeAt(0);
+	var _nullChar = 0;
+	var _carriageReturn = '\r'.charCodeAt(0);
+	var _tab = '\t'.charCodeAt(0);
+	var _verticalTab = '\v'.charCodeAt(0);
+	var _backslash = '\\'.charCodeAt(0);
+	var _doubleQuote = '"'.charCodeAt(0);
+
+	var startPos = 0, chrCode, replaceWith = null, resultPieces = [];
+
+	for (var i = 0, len = text.length; i < len; i++) {
+		chrCode = text.charCodeAt(i);
+		switch (chrCode) {
+			case _backspace:
+				replaceWith = '\\b';
+				break;
+			case _formFeed:
+				replaceWith = '\\f';
+				break;
+			case _newLine:
+				replaceWith = '\\n';
+				break;
+			case _nullChar:
+				replaceWith = '\\0';
+				break;
+			case _carriageReturn:
+				replaceWith = '\\r';
+				break;
+			case _tab:
+				replaceWith = '\\t';
+				break;
+			case _verticalTab:
+				replaceWith = '\\v';
+				break;
+			case _backslash:
+				replaceWith = '\\\\';
+				break;
+			case _doubleQuote:
+				replaceWith = '\\"';
+				break;
+		}
+		if (replaceWith !== null) {
+			resultPieces.push(text.substring(startPos, i));
+			resultPieces.push(replaceWith);
+			startPos = i + 1;
+			replaceWith = null;
+		}
+	}
+	resultPieces.push(text.substring(startPos, len));
+	return resultPieces.join('');
+}
+
+function getGitVersion(repo) {
+	var git = path.join(repo, '.git');
+	var headPath = path.join(git, 'HEAD');
+	var head;
+
+	try {
+		head = fs.readFileSync(headPath, 'utf8').trim();
+	} catch (e) {
+		return void 0;
+	}
+
+	if (/^[0-9a-f]{40}$/i.test(head)) {
+		return head;
+	}
+
+	var refMatch = /^ref: (.*)$/.exec(head);
+
+	if (!refMatch) {
+		return void 0;
+	}
+
+	var ref = refMatch[1];
+	var refPath = path.join(git, ref);
+
+	try {
+		return fs.readFileSync(refPath, 'utf8').trim();
+	} catch (e) {
+		// noop
+	}
+
+	var packedRefsPath = path.join(git, 'packed-refs');
+	var refsRaw;
+
+	try {
+		refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
+	} catch (e) {
+		return void 0;
+	}
+
+	var refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
+	var refsMatch;
+	var refs = {};
+
+	while (refsMatch = refsRegex.exec(refsRaw)) {
+		refs[refsMatch[2]] = refsMatch[1];
+	}
+
+	return refs[ref];
+}

+ 6 - 0
lib/lib-es6-ts.d.ts

@@ -0,0 +1,6 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+export declare var contents: string;

File diff suppressed because it is too large
+ 7 - 0
lib/lib-es6-ts.js


+ 6 - 0
lib/lib-ts.d.ts

@@ -0,0 +1,6 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+export declare var contents: string;

File diff suppressed because it is too large
+ 7 - 0
lib/lib-ts.js


+ 2348 - 0
lib/typescriptServices.d.ts

@@ -0,0 +1,2348 @@
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved. 
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0  
+ 
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
+MERCHANTABLITY OR NON-INFRINGEMENT. 
+ 
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+
+declare namespace ts {
+    interface Map<T> {
+        [index: string]: T;
+    }
+    type Path = string & {
+        __pathBrand: any;
+    };
+    interface FileMap<T> {
+        get(fileName: Path): T;
+        set(fileName: Path, value: T): void;
+        contains(fileName: Path): boolean;
+        remove(fileName: Path): void;
+        forEachValue(f: (key: Path, v: T) => void): void;
+        clear(): void;
+    }
+    interface TextRange {
+        pos: number;
+        end: number;
+    }
+    enum SyntaxKind {
+        Unknown = 0,
+        EndOfFileToken = 1,
+        SingleLineCommentTrivia = 2,
+        MultiLineCommentTrivia = 3,
+        NewLineTrivia = 4,
+        WhitespaceTrivia = 5,
+        ShebangTrivia = 6,
+        ConflictMarkerTrivia = 7,
+        NumericLiteral = 8,
+        StringLiteral = 9,
+        RegularExpressionLiteral = 10,
+        NoSubstitutionTemplateLiteral = 11,
+        TemplateHead = 12,
+        TemplateMiddle = 13,
+        TemplateTail = 14,
+        OpenBraceToken = 15,
+        CloseBraceToken = 16,
+        OpenParenToken = 17,
+        CloseParenToken = 18,
+        OpenBracketToken = 19,
+        CloseBracketToken = 20,
+        DotToken = 21,
+        DotDotDotToken = 22,
+        SemicolonToken = 23,
+        CommaToken = 24,
+        LessThanToken = 25,
+        LessThanSlashToken = 26,
+        GreaterThanToken = 27,
+        LessThanEqualsToken = 28,
+        GreaterThanEqualsToken = 29,
+        EqualsEqualsToken = 30,
+        ExclamationEqualsToken = 31,
+        EqualsEqualsEqualsToken = 32,
+        ExclamationEqualsEqualsToken = 33,
+        EqualsGreaterThanToken = 34,
+        PlusToken = 35,
+        MinusToken = 36,
+        AsteriskToken = 37,
+        AsteriskAsteriskToken = 38,
+        SlashToken = 39,
+        PercentToken = 40,
+        PlusPlusToken = 41,
+        MinusMinusToken = 42,
+        LessThanLessThanToken = 43,
+        GreaterThanGreaterThanToken = 44,
+        GreaterThanGreaterThanGreaterThanToken = 45,
+        AmpersandToken = 46,
+        BarToken = 47,
+        CaretToken = 48,
+        ExclamationToken = 49,
+        TildeToken = 50,
+        AmpersandAmpersandToken = 51,
+        BarBarToken = 52,
+        QuestionToken = 53,
+        ColonToken = 54,
+        AtToken = 55,
+        EqualsToken = 56,
+        PlusEqualsToken = 57,
+        MinusEqualsToken = 58,
+        AsteriskEqualsToken = 59,
+        AsteriskAsteriskEqualsToken = 60,
+        SlashEqualsToken = 61,
+        PercentEqualsToken = 62,
+        LessThanLessThanEqualsToken = 63,
+        GreaterThanGreaterThanEqualsToken = 64,
+        GreaterThanGreaterThanGreaterThanEqualsToken = 65,
+        AmpersandEqualsToken = 66,
+        BarEqualsToken = 67,
+        CaretEqualsToken = 68,
+        Identifier = 69,
+        BreakKeyword = 70,
+        CaseKeyword = 71,
+        CatchKeyword = 72,
+        ClassKeyword = 73,
+        ConstKeyword = 74,
+        ContinueKeyword = 75,
+        DebuggerKeyword = 76,
+        DefaultKeyword = 77,
+        DeleteKeyword = 78,
+        DoKeyword = 79,
+        ElseKeyword = 80,
+        EnumKeyword = 81,
+        ExportKeyword = 82,
+        ExtendsKeyword = 83,
+        FalseKeyword = 84,
+        FinallyKeyword = 85,
+        ForKeyword = 86,
+        FunctionKeyword = 87,
+        IfKeyword = 88,
+        ImportKeyword = 89,
+        InKeyword = 90,
+        InstanceOfKeyword = 91,
+        NewKeyword = 92,
+        NullKeyword = 93,
+        ReturnKeyword = 94,
+        SuperKeyword = 95,
+        SwitchKeyword = 96,
+        ThisKeyword = 97,
+        ThrowKeyword = 98,
+        TrueKeyword = 99,
+        TryKeyword = 100,
+        TypeOfKeyword = 101,
+        VarKeyword = 102,
+        VoidKeyword = 103,
+        WhileKeyword = 104,
+        WithKeyword = 105,
+        ImplementsKeyword = 106,
+        InterfaceKeyword = 107,
+        LetKeyword = 108,
+        PackageKeyword = 109,
+        PrivateKeyword = 110,
+        ProtectedKeyword = 111,
+        PublicKeyword = 112,
+        StaticKeyword = 113,
+        YieldKeyword = 114,
+        AbstractKeyword = 115,
+        AsKeyword = 116,
+        AnyKeyword = 117,
+        AsyncKeyword = 118,
+        AwaitKeyword = 119,
+        BooleanKeyword = 120,
+        ConstructorKeyword = 121,
+        DeclareKeyword = 122,
+        GetKeyword = 123,
+        IsKeyword = 124,
+        ModuleKeyword = 125,
+        NamespaceKeyword = 126,
+        RequireKeyword = 127,
+        NumberKeyword = 128,
+        SetKeyword = 129,
+        StringKeyword = 130,
+        SymbolKeyword = 131,
+        TypeKeyword = 132,
+        FromKeyword = 133,
+        GlobalKeyword = 134,
+        OfKeyword = 135,
+        QualifiedName = 136,
+        ComputedPropertyName = 137,
+        TypeParameter = 138,
+        Parameter = 139,
+        Decorator = 140,
+        PropertySignature = 141,
+        PropertyDeclaration = 142,
+        MethodSignature = 143,
+        MethodDeclaration = 144,
+        Constructor = 145,
+        GetAccessor = 146,
+        SetAccessor = 147,
+        CallSignature = 148,
+        ConstructSignature = 149,
+        IndexSignature = 150,
+        TypePredicate = 151,
+        TypeReference = 152,
+        FunctionType = 153,
+        ConstructorType = 154,
+        TypeQuery = 155,
+        TypeLiteral = 156,
+        ArrayType = 157,
+        TupleType = 158,
+        UnionType = 159,
+        IntersectionType = 160,
+        ParenthesizedType = 161,
+        ThisType = 162,
+        StringLiteralType = 163,
+        ObjectBindingPattern = 164,
+        ArrayBindingPattern = 165,
+        BindingElement = 166,
+        ArrayLiteralExpression = 167,
+        ObjectLiteralExpression = 168,
+        PropertyAccessExpression = 169,
+        ElementAccessExpression = 170,
+        CallExpression = 171,
+        NewExpression = 172,
+        TaggedTemplateExpression = 173,
+        TypeAssertionExpression = 174,
+        ParenthesizedExpression = 175,
+        FunctionExpression = 176,
+        ArrowFunction = 177,
+        DeleteExpression = 178,
+        TypeOfExpression = 179,
+        VoidExpression = 180,
+        AwaitExpression = 181,
+        PrefixUnaryExpression = 182,
+        PostfixUnaryExpression = 183,
+        BinaryExpression = 184,
+        ConditionalExpression = 185,
+        TemplateExpression = 186,
+        YieldExpression = 187,
+        SpreadElementExpression = 188,
+        ClassExpression = 189,
+        OmittedExpression = 190,
+        ExpressionWithTypeArguments = 191,
+        AsExpression = 192,
+        TemplateSpan = 193,
+        SemicolonClassElement = 194,
+        Block = 195,
+        VariableStatement = 196,
+        EmptyStatement = 197,
+        ExpressionStatement = 198,
+        IfStatement = 199,
+        DoStatement = 200,
+        WhileStatement = 201,
+        ForStatement = 202,
+        ForInStatement = 203,
+        ForOfStatement = 204,
+        ContinueStatement = 205,
+        BreakStatement = 206,
+        ReturnStatement = 207,
+        WithStatement = 208,
+        SwitchStatement = 209,
+        LabeledStatement = 210,
+        ThrowStatement = 211,
+        TryStatement = 212,
+        DebuggerStatement = 213,
+        VariableDeclaration = 214,
+        VariableDeclarationList = 215,
+        FunctionDeclaration = 216,
+        ClassDeclaration = 217,
+        InterfaceDeclaration = 218,
+        TypeAliasDeclaration = 219,
+        EnumDeclaration = 220,
+        ModuleDeclaration = 221,
+        ModuleBlock = 222,
+        CaseBlock = 223,
+        ImportEqualsDeclaration = 224,
+        ImportDeclaration = 225,
+        ImportClause = 226,
+        NamespaceImport = 227,
+        NamedImports = 228,
+        ImportSpecifier = 229,
+        ExportAssignment = 230,
+        ExportDeclaration = 231,
+        NamedExports = 232,
+        ExportSpecifier = 233,
+        MissingDeclaration = 234,
+        ExternalModuleReference = 235,
+        JsxElement = 236,
+        JsxSelfClosingElement = 237,
+        JsxOpeningElement = 238,
+        JsxText = 239,
+        JsxClosingElement = 240,
+        JsxAttribute = 241,
+        JsxSpreadAttribute = 242,
+        JsxExpression = 243,
+        CaseClause = 244,
+        DefaultClause = 245,
+        HeritageClause = 246,
+        CatchClause = 247,
+        PropertyAssignment = 248,
+        ShorthandPropertyAssignment = 249,
+        EnumMember = 250,
+        SourceFile = 251,
+        JSDocTypeExpression = 252,
+        JSDocAllType = 253,
+        JSDocUnknownType = 254,
+        JSDocArrayType = 255,
+        JSDocUnionType = 256,
+        JSDocTupleType = 257,
+        JSDocNullableType = 258,
+        JSDocNonNullableType = 259,
+        JSDocRecordType = 260,
+        JSDocRecordMember = 261,
+        JSDocTypeReference = 262,
+        JSDocOptionalType = 263,
+        JSDocFunctionType = 264,
+        JSDocVariadicType = 265,
+        JSDocConstructorType = 266,
+        JSDocThisType = 267,
+        JSDocComment = 268,
+        JSDocTag = 269,
+        JSDocParameterTag = 270,
+        JSDocReturnTag = 271,
+        JSDocTypeTag = 272,
+        JSDocTemplateTag = 273,
+        SyntaxList = 274,
+        Count = 275,
+        FirstAssignment = 56,
+        LastAssignment = 68,
+        FirstReservedWord = 70,
+        LastReservedWord = 105,
+        FirstKeyword = 70,
+        LastKeyword = 135,
+        FirstFutureReservedWord = 106,
+        LastFutureReservedWord = 114,
+        FirstTypeNode = 151,
+        LastTypeNode = 163,
+        FirstPunctuation = 15,
+        LastPunctuation = 68,
+        FirstToken = 0,
+        LastToken = 135,
+        FirstTriviaToken = 2,
+        LastTriviaToken = 7,
+        FirstLiteralToken = 8,
+        LastLiteralToken = 11,
+        FirstTemplateToken = 11,
+        LastTemplateToken = 14,
+        FirstBinaryOperator = 25,
+        LastBinaryOperator = 68,
+        FirstNode = 136,
+    }
+    enum NodeFlags {
+        None = 0,
+        Export = 2,
+        Ambient = 4,
+        Public = 8,
+        Private = 16,
+        Protected = 32,
+        Static = 64,
+        Abstract = 128,
+        Async = 256,
+        Default = 512,
+        MultiLine = 1024,
+        Synthetic = 2048,
+        DeclarationFile = 4096,
+        Let = 8192,
+        Const = 16384,
+        OctalLiteral = 32768,
+        Namespace = 65536,
+        ExportContext = 131072,
+        ContainsThis = 262144,
+        HasImplicitReturn = 524288,
+        HasExplicitReturn = 1048576,
+        GlobalAugmentation = 2097152,
+        HasClassExtends = 4194304,
+        HasDecorators = 8388608,
+        HasParamDecorators = 16777216,
+        HasAsyncFunctions = 33554432,
+        HasJsxSpreadAttribute = 1073741824,
+        Modifier = 1022,
+        AccessibilityModifier = 56,
+        BlockScoped = 24576,
+        ReachabilityCheckFlags = 1572864,
+        EmitHelperFlags = 62914560,
+    }
+    enum JsxFlags {
+        None = 0,
+        /** An element from a named property of the JSX.IntrinsicElements interface */
+        IntrinsicNamedElement = 1,
+        /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
+        IntrinsicIndexedElement = 2,
+        /** An element backed by a class, class-like, or function value */
+        ValueElement = 4,
+        /** Element resolution failed */
+        UnknownElement = 16,
+        IntrinsicElement = 3,
+    }
+    interface Node extends TextRange {
+        kind: SyntaxKind;
+        flags: NodeFlags;
+        decorators?: NodeArray<Decorator>;
+        modifiers?: ModifiersArray;
+        parent?: Node;
+    }
+    interface NodeArray<T> extends Array<T>, TextRange {
+        hasTrailingComma?: boolean;
+    }
+    interface ModifiersArray extends NodeArray<Modifier> {
+        flags: number;
+    }
+    interface Modifier extends Node {
+    }
+    interface Identifier extends PrimaryExpression {
+        text: string;
+        originalKeywordKind?: SyntaxKind;
+    }
+    interface QualifiedName extends Node {
+        left: EntityName;
+        right: Identifier;
+    }
+    type EntityName = Identifier | QualifiedName;
+    type PropertyName = Identifier | LiteralExpression | ComputedPropertyName;
+    type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
+    interface Declaration extends Node {
+        _declarationBrand: any;
+        name?: DeclarationName;
+    }
+    interface DeclarationStatement extends Declaration, Statement {
+        name?: Identifier;
+    }
+    interface ComputedPropertyName extends Node {
+        expression: Expression;
+    }
+    interface Decorator extends Node {
+        expression: LeftHandSideExpression;
+    }
+    interface TypeParameterDeclaration extends Declaration {
+        name: Identifier;
+        constraint?: TypeNode;
+        expression?: Expression;
+    }
+    interface SignatureDeclaration extends Declaration {
+        name?: PropertyName;
+        typeParameters?: NodeArray<TypeParameterDeclaration>;
+        parameters: NodeArray<ParameterDeclaration>;
+        type?: TypeNode;
+    }
+    interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement {
+    }
+    interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement {
+    }
+    interface VariableDeclaration extends Declaration {
+        parent?: VariableDeclarationList;
+        name: Identifier | BindingPattern;
+        type?: TypeNode;
+        initializer?: Expression;
+    }
+    interface VariableDeclarationList extends Node {
+        declarations: NodeArray<VariableDeclaration>;
+    }
+    interface ParameterDeclaration extends Declaration {
+        dotDotDotToken?: Node;
+        name: Identifier | BindingPattern;
+        questionToken?: Node;
+        type?: TypeNode;
+        initializer?: Expression;
+    }
+    interface BindingElement extends Declaration {
+        propertyName?: PropertyName;
+        dotDotDotToken?: Node;
+        name: Identifier | BindingPattern;
+        initializer?: Expression;
+    }
+    interface PropertySignature extends TypeElement {
+        name: PropertyName;
+        questionToken?: Node;
+        type?: TypeNode;
+        initializer?: Expression;
+    }
+    interface PropertyDeclaration extends ClassElement {
+        questionToken?: Node;
+        name: PropertyName;
+        type?: TypeNode;
+        initializer?: Expression;
+    }
+    interface ObjectLiteralElement extends Declaration {
+        _objectLiteralBrandBrand: any;
+        name?: PropertyName;
+    }
+    interface PropertyAssignment extends ObjectLiteralElement {
+        _propertyAssignmentBrand: any;
+        name: PropertyName;
+        questionToken?: Node;
+        initializer: Expression;
+    }
+    interface ShorthandPropertyAssignment extends ObjectLiteralElement {
+        name: Identifier;
+        questionToken?: Node;
+        equalsToken?: Node;
+        objectAssignmentInitializer?: Expression;
+    }
+    interface VariableLikeDeclaration extends Declaration {
+        propertyName?: PropertyName;
+        dotDotDotToken?: Node;
+        name: DeclarationName;
+        questionToken?: Node;
+        type?: TypeNode;
+        initializer?: Expression;
+    }
+    interface PropertyLikeDeclaration extends Declaration {
+        name: PropertyName;
+    }
+    interface BindingPattern extends Node {
+        elements: NodeArray<BindingElement>;
+    }
+    interface ObjectBindingPattern extends BindingPattern {
+    }
+    interface ArrayBindingPattern extends BindingPattern {
+    }
+    /**
+     * Several node kinds share function-like features such as a signature,
+     * a name, and a body. These nodes should extend FunctionLikeDeclaration.
+     * Examples:
+     * - FunctionDeclaration
+     * - MethodDeclaration
+     * - AccessorDeclaration
+     */
+    interface FunctionLikeDeclaration extends SignatureDeclaration {
+        _functionLikeDeclarationBrand: any;
+        asteriskToken?: Node;
+        questionToken?: Node;
+        body?: Block | Expression;
+    }
+    interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement {
+        name?: Identifier;
+        body?: FunctionBody;
+    }
+    interface MethodSignature extends SignatureDeclaration, TypeElement {
+        name: PropertyName;
+    }
+    interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
+        name: PropertyName;
+        body?: FunctionBody;
+    }
+    interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
+        body?: FunctionBody;
+    }
+    interface SemicolonClassElement extends ClassElement {
+        _semicolonClassElementBrand: any;
+    }
+    interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
+        _accessorDeclarationBrand: any;
+        name: PropertyName;
+        body: FunctionBody;
+    }
+    interface GetAccessorDeclaration extends AccessorDeclaration {
+    }
+    interface SetAccessorDeclaration extends AccessorDeclaration {
+    }
+    interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement {
+        _indexSignatureDeclarationBrand: any;
+    }
+    interface TypeNode extends Node {
+        _typeNodeBrand: any;
+    }
+    interface ThisTypeNode extends TypeNode {
+        _thisTypeNodeBrand: any;
+    }
+    interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration {
+        _functionOrConstructorTypeNodeBrand: any;
+    }
+    interface FunctionTypeNode extends FunctionOrConstructorTypeNode {
+    }
+    interface ConstructorTypeNode extends FunctionOrConstructorTypeNode {
+    }
+    interface TypeReferenceNode extends TypeNode {
+        typeName: EntityName;
+        typeArguments?: NodeArray<TypeNode>;
+    }
+    interface TypePredicateNode extends TypeNode {
+        parameterName: Identifier | ThisTypeNode;
+        type: TypeNode;
+    }
+    interface TypeQueryNode extends TypeNode {
+        exprName: EntityName;
+    }
+    interface TypeLiteralNode extends TypeNode, Declaration {
+        members: NodeArray<TypeElement>;
+    }
+    interface ArrayTypeNode extends TypeNode {
+        elementType: TypeNode;
+    }
+    interface TupleTypeNode extends TypeNode {
+        elementTypes: NodeArray<TypeNode>;
+    }
+    interface UnionOrIntersectionTypeNode extends TypeNode {
+        types: NodeArray<TypeNode>;
+    }
+    interface UnionTypeNode extends UnionOrIntersectionTypeNode {
+    }
+    interface IntersectionTypeNode extends UnionOrIntersectionTypeNode {
+    }
+    interface ParenthesizedTypeNode extends TypeNode {
+        type: TypeNode;
+    }
+    interface StringLiteralTypeNode extends LiteralLikeNode, TypeNode {
+        _stringLiteralTypeBrand: any;
+    }
+    interface StringLiteral extends LiteralExpression {
+        _stringLiteralBrand: any;
+    }
+    interface Expression extends Node {
+        _expressionBrand: any;
+        contextualType?: Type;
+    }
+    interface OmittedExpression extends Expression {
+    }
+    interface UnaryExpression extends Expression {
+        _unaryExpressionBrand: any;
+    }
+    interface IncrementExpression extends UnaryExpression {
+        _incrementExpressionBrand: any;
+    }
+    interface PrefixUnaryExpression extends IncrementExpression {
+        operator: SyntaxKind;
+        operand: UnaryExpression;
+    }
+    interface PostfixUnaryExpression extends IncrementExpression {
+        operand: LeftHandSideExpression;
+        operator: SyntaxKind;
+    }
+    interface PostfixExpression extends UnaryExpression {
+        _postfixExpressionBrand: any;
+    }
+    interface LeftHandSideExpression extends IncrementExpression {
+        _leftHandSideExpressionBrand: any;
+    }
+    interface MemberExpression extends LeftHandSideExpression {
+        _memberExpressionBrand: any;
+    }
+    interface PrimaryExpression extends MemberExpression {
+        _primaryExpressionBrand: any;
+    }
+    interface DeleteExpression extends UnaryExpression {
+        expression: UnaryExpression;
+    }
+    interface TypeOfExpression extends UnaryExpression {
+        expression: UnaryExpression;
+    }
+    interface VoidExpression extends UnaryExpression {
+        expression: UnaryExpression;
+    }
+    interface AwaitExpression extends UnaryExpression {
+        expression: UnaryExpression;
+    }
+    interface YieldExpression extends Expression {
+        asteriskToken?: Node;
+        expression?: Expression;
+    }
+    interface BinaryExpression extends Expression, Declaration {
+        left: Expression;
+        operatorToken: Node;
+        right: Expression;
+    }
+    interface ConditionalExpression extends Expression {
+        condition: Expression;
+        questionToken: Node;
+        whenTrue: Expression;
+        colonToken: Node;
+        whenFalse: Expression;
+    }
+    type FunctionBody = Block;
+    type ConciseBody = FunctionBody | Expression;
+    interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
+        name?: Identifier;
+        body: FunctionBody;
+    }
+    interface ArrowFunction extends Expression, FunctionLikeDeclaration {
+        equalsGreaterThanToken: Node;
+        body: ConciseBody;
+    }
+    interface LiteralLikeNode extends Node {
+        text: string;
+        isUnterminated?: boolean;
+        hasExtendedUnicodeEscape?: boolean;
+    }
+    interface LiteralExpression extends LiteralLikeNode, PrimaryExpression {
+        _literalExpressionBrand: any;
+    }
+    interface TemplateLiteralFragment extends LiteralLikeNode {
+        _templateLiteralFragmentBrand: any;
+    }
+    interface TemplateExpression extends PrimaryExpression {
+        head: TemplateLiteralFragment;
+        templateSpans: NodeArray<TemplateSpan>;
+    }
+    interface TemplateSpan extends Node {
+        expression: Expression;
+        literal: TemplateLiteralFragment;
+    }
+    interface ParenthesizedExpression extends PrimaryExpression {
+        expression: Expression;
+    }
+    interface ArrayLiteralExpression extends PrimaryExpression {
+        elements: NodeArray<Expression>;
+    }
+    interface SpreadElementExpression extends Expression {
+        expression: Expression;
+    }
+    interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
+        properties: NodeArray<ObjectLiteralElement>;
+    }
+    interface PropertyAccessExpression extends MemberExpression, Declaration {
+        expression: LeftHandSideExpression;
+        dotToken: Node;
+        name: Identifier;
+    }
+    interface ElementAccessExpression extends MemberExpression {
+        expression: LeftHandSideExpression;
+        argumentExpression?: Expression;
+    }
+    interface CallExpression extends LeftHandSideExpression, Declaration {
+        expression: LeftHandSideExpression;
+        typeArguments?: NodeArray<TypeNode>;
+        arguments: NodeArray<Expression>;
+    }
+    interface ExpressionWithTypeArguments extends TypeNode {
+        expression: LeftHandSideExpression;
+        typeArguments?: NodeArray<TypeNode>;
+    }
+    interface NewExpression extends CallExpression, PrimaryExpression {
+    }
+    interface TaggedTemplateExpression extends MemberExpression {
+        tag: LeftHandSideExpression;
+        template: LiteralExpression | TemplateExpression;
+    }
+    type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator;
+    interface AsExpression extends Expression {
+        expression: Expression;
+        type: TypeNode;
+    }
+    interface TypeAssertion extends UnaryExpression {
+        type: TypeNode;
+        expression: UnaryExpression;
+    }
+    type AssertionExpression = TypeAssertion | AsExpression;
+    interface JsxElement extends PrimaryExpression {
+        openingElement: JsxOpeningElement;
+        children: NodeArray<JsxChild>;
+        closingElement: JsxClosingElement;
+    }
+    interface JsxOpeningElement extends Expression {
+        _openingElementBrand?: any;
+        tagName: EntityName;
+        attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
+    }
+    interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
+        _selfClosingElementBrand?: any;
+    }
+    type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement;
+    interface JsxAttribute extends Node {
+        name: Identifier;
+        initializer?: Expression;
+    }
+    interface JsxSpreadAttribute extends Node {
+        expression: Expression;
+    }
+    interface JsxClosingElement extends Node {
+        tagName: EntityName;
+    }
+    interface JsxExpression extends Expression {
+        expression?: Expression;
+    }
+    interface JsxText extends Node {
+        _jsxTextExpressionBrand: any;
+    }
+    type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement;
+    interface Statement extends Node {
+        _statementBrand: any;
+    }
+    interface EmptyStatement extends Statement {
+    }
+    interface DebuggerStatement extends Statement {
+    }
+    interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement {
+        name?: Identifier;
+    }
+    type BlockLike = SourceFile | Block | ModuleBlock | CaseClause;
+    interface Block extends Statement {
+        statements: NodeArray<Statement>;
+    }
+    interface VariableStatement extends Statement {
+        declarationList: VariableDeclarationList;
+    }
+    interface ExpressionStatement extends Statement {
+        expression: Expression;
+    }
+    interface IfStatement extends Statement {
+        expression: Expression;
+        thenStatement: Statement;
+        elseStatement?: Statement;
+    }
+    interface IterationStatement extends Statement {
+        statement: Statement;
+    }
+    interface DoStatement extends IterationStatement {
+        expression: Expression;
+    }
+    interface WhileStatement extends IterationStatement {
+        expression: Expression;
+    }
+    interface ForStatement extends IterationStatement {
+        initializer?: VariableDeclarationList | Expression;
+        condition?: Expression;
+        incrementor?: Expression;
+    }
+    interface ForInStatement extends IterationStatement {
+        initializer: VariableDeclarationList | Expression;
+        expression: Expression;
+    }
+    interface ForOfStatement extends IterationStatement {
+        initializer: VariableDeclarationList | Expression;
+        expression: Expression;
+    }
+    interface BreakStatement extends Statement {
+        label?: Identifier;
+    }
+    interface ContinueStatement extends Statement {
+        label?: Identifier;
+    }
+    type BreakOrContinueStatement = BreakStatement | ContinueStatement;
+    interface ReturnStatement extends Statement {
+        expression?: Expression;
+    }
+    interface WithStatement extends Statement {
+        expression: Expression;
+        statement: Statement;
+    }
+    interface SwitchStatement extends Statement {
+        expression: Expression;
+        caseBlock: CaseBlock;
+    }
+    interface CaseBlock extends Node {
+        clauses: NodeArray<CaseOrDefaultClause>;
+    }
+    interface CaseClause extends Node {
+        expression: Expression;
+        statements: NodeArray<Statement>;
+    }
+    interface DefaultClause extends Node {
+        statements: NodeArray<Statement>;
+    }
+    type CaseOrDefaultClause = CaseClause | DefaultClause;
+    interface LabeledStatement extends Statement {
+        label: Identifier;
+        statement: Statement;
+    }
+    interface ThrowStatement extends Statement {
+        expression: Expression;
+    }
+    interface TryStatement extends Statement {
+        tryBlock: Block;
+        catchClause?: CatchClause;
+        finallyBlock?: Block;
+    }
+    interface CatchClause extends Node {
+        variableDeclaration: VariableDeclaration;
+        block: Block;
+    }
+    interface ClassLikeDeclaration extends Declaration {
+        name?: Identifier;
+        typeParameters?: NodeArray<TypeParameterDeclaration>;
+        heritageClauses?: NodeArray<HeritageClause>;
+        members: NodeArray<ClassElement>;
+    }
+    interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement {
+        name?: Identifier;
+    }
+    interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
+    }
+    interface ClassElement extends Declaration {
+        _classElementBrand: any;
+        name?: PropertyName;
+    }
+    interface TypeElement extends Declaration {
+        _typeElementBrand: any;
+        name?: PropertyName;
+        questionToken?: Node;
+    }
+    interface InterfaceDeclaration extends DeclarationStatement {
+        name: Identifier;
+        typeParameters?: NodeArray<TypeParameterDeclaration>;
+        heritageClauses?: NodeArray<HeritageClause>;
+        members: NodeArray<TypeElement>;
+    }
+    interface HeritageClause extends Node {
+        token: SyntaxKind;
+        types?: NodeArray<ExpressionWithTypeArguments>;
+    }
+    interface TypeAliasDeclaration extends DeclarationStatement {
+        name: Identifier;
+        typeParameters?: NodeArray<TypeParameterDeclaration>;
+        type: TypeNode;
+    }
+    interface EnumMember extends Declaration {
+        name: DeclarationName;
+        initializer?: Expression;
+    }
+    interface EnumDeclaration extends DeclarationStatement {
+        name: Identifier;
+        members: NodeArray<EnumMember>;
+    }
+    type ModuleBody = ModuleBlock | ModuleDeclaration;
+    interface ModuleDeclaration extends DeclarationStatement {
+        name: Identifier | LiteralExpression;
+        body: ModuleBlock | ModuleDeclaration;
+    }
+    interface ModuleBlock extends Node, Statement {
+        statements: NodeArray<Statement>;
+    }
+    interface ImportEqualsDeclaration extends DeclarationStatement {
+        name: Identifier;
+        moduleReference: EntityName | ExternalModuleReference;
+    }
+    interface ExternalModuleReference extends Node {
+        expression?: Expression;
+    }
+    interface ImportDeclaration extends Statement {
+        importClause?: ImportClause;
+        moduleSpecifier: Expression;
+    }
+    interface ImportClause extends Declaration {
+        name?: Identifier;
+        namedBindings?: NamespaceImport | NamedImports;
+    }
+    interface NamespaceImport extends Declaration {
+        name: Identifier;
+    }
+    interface ExportDeclaration extends DeclarationStatement {
+        exportClause?: NamedExports;
+        moduleSpecifier?: Expression;
+    }
+    interface NamedImports extends Node {
+        elements: NodeArray<ImportSpecifier>;
+    }
+    interface NamedExports extends Node {
+        elements: NodeArray<ExportSpecifier>;
+    }
+    type NamedImportsOrExports = NamedImports | NamedExports;
+    interface ImportSpecifier extends Declaration {
+        propertyName?: Identifier;
+        name: Identifier;
+    }
+    interface ExportSpecifier extends Declaration {
+        propertyName?: Identifier;
+        name: Identifier;
+    }
+    type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier;
+    interface ExportAssignment extends DeclarationStatement {
+        isExportEquals?: boolean;
+        expression: Expression;
+    }
+    interface FileReference extends TextRange {
+        fileName: string;
+    }
+    interface CommentRange extends TextRange {
+        hasTrailingNewLine?: boolean;
+        kind: SyntaxKind;
+    }
+    interface JSDocTypeExpression extends Node {
+        type: JSDocType;
+    }
+    interface JSDocType extends TypeNode {
+        _jsDocTypeBrand: any;
+    }
+    interface JSDocAllType extends JSDocType {
+        _JSDocAllTypeBrand: any;
+    }
+    interface JSDocUnknownType extends JSDocType {
+        _JSDocUnknownTypeBrand: any;
+    }
+    interface JSDocArrayType extends JSDocType {
+        elementType: JSDocType;
+    }
+    interface JSDocUnionType extends JSDocType {
+        types: NodeArray<JSDocType>;
+    }
+    interface JSDocTupleType extends JSDocType {
+        types: NodeArray<JSDocType>;
+    }
+    interface JSDocNonNullableType extends JSDocType {
+        type: JSDocType;
+    }
+    interface JSDocNullableType extends JSDocType {
+        type: JSDocType;
+    }
+    interface JSDocRecordType extends JSDocType, TypeLiteralNode {
+        members: NodeArray<JSDocRecordMember>;
+    }
+    interface JSDocTypeReference extends JSDocType {
+        name: EntityName;
+        typeArguments: NodeArray<JSDocType>;
+    }
+    interface JSDocOptionalType extends JSDocType {
+        type: JSDocType;
+    }
+    interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
+        parameters: NodeArray<ParameterDeclaration>;
+        type: JSDocType;
+    }
+    interface JSDocVariadicType extends JSDocType {
+        type: JSDocType;
+    }
+    interface JSDocConstructorType extends JSDocType {
+        type: JSDocType;
+    }
+    interface JSDocThisType extends JSDocType {
+        type: JSDocType;
+    }
+    type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
+    interface JSDocRecordMember extends PropertySignature {
+        name: Identifier | LiteralExpression;
+        type?: JSDocType;
+    }
+    interface JSDocComment extends Node {
+        tags: NodeArray<JSDocTag>;
+    }
+    interface JSDocTag extends Node {
+        atToken: Node;
+        tagName: Identifier;
+    }
+    interface JSDocTemplateTag extends JSDocTag {
+        typeParameters: NodeArray<TypeParameterDeclaration>;
+    }
+    interface JSDocReturnTag extends JSDocTag {
+        typeExpression: JSDocTypeExpression;
+    }
+    interface JSDocTypeTag extends JSDocTag {
+        typeExpression: JSDocTypeExpression;
+    }
+    interface JSDocParameterTag extends JSDocTag {
+        preParameterName?: Identifier;
+        typeExpression?: JSDocTypeExpression;
+        postParameterName?: Identifier;
+        isBracketed: boolean;
+    }
+    interface AmdDependency {
+        path: string;
+        name: string;
+    }
+    interface SourceFile extends Declaration {
+        statements: NodeArray<Statement>;
+        endOfFileToken: Node;
+        fileName: string;
+        path: Path;
+        text: string;
+        amdDependencies: AmdDependency[];
+        moduleName: string;
+        referencedFiles: FileReference[];
+        languageVariant: LanguageVariant;
+        /**
+         * lib.d.ts should have a reference comment like
+         *
+         *  /// <reference no-default-lib="true"/>
+         *
+         * If any other file has this comment, it signals not to include lib.d.ts
+         * because this containing file is intended to act as a default library.
+         */
+        hasNoDefaultLib: boolean;
+        languageVersion: ScriptTarget;
+    }
+    interface ScriptReferenceHost {
+        getCompilerOptions(): CompilerOptions;
+        getSourceFile(fileName: string): SourceFile;
+        getCurrentDirectory(): string;
+    }
+    interface ParseConfigHost {
+        readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
+    }
+    interface WriteFileCallback {
+        (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
+    }
+    class OperationCanceledException {
+    }
+    interface CancellationToken {
+        isCancellationRequested(): boolean;
+        /** @throws OperationCanceledException if isCancellationRequested is true */
+        throwIfCancellationRequested(): void;
+    }
+    interface Program extends ScriptReferenceHost {
+        /**
+         * Get a list of root file names that were passed to a 'createProgram'
+         */
+        getRootFileNames(): string[];
+        /**
+         * Get a list of files in the program
+         */
+        getSourceFiles(): SourceFile[];
+        /**
+         * Emits the JavaScript and declaration files.  If targetSourceFile is not specified, then
+         * the JavaScript and declaration files will be produced for all the files in this program.
+         * If targetSourceFile is specified, then only the JavaScript and declaration for that
+         * specific file will be generated.
+         *
+         * If writeFile is not specified then the writeFile callback from the compiler host will be
+         * used for writing the JavaScript and declaration files.  Otherwise, the writeFile parameter
+         * will be invoked when writing the JavaScript and declaration files.
+         */
+        emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
+        getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
+        getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
+        getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
+        getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
+        getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
+        /**
+         * Gets a type checker that can be used to semantically analyze source fils in the program.
+         */
+        getTypeChecker(): TypeChecker;
+    }
+    interface SourceMapSpan {
+        /** Line number in the .js file. */
+        emittedLine: number;
+        /** Column number in the .js file. */
+        emittedColumn: number;
+        /** Line number in the .ts file. */
+        sourceLine: number;
+        /** Column number in the .ts file. */
+        sourceColumn: number;
+        /** Optional name (index into names array) associated with this span. */
+        nameIndex?: number;
+        /** .ts file (index into sources array) associated with this span */
+        sourceIndex: number;
+    }
+    interface SourceMapData {
+        sourceMapFilePath: string;
+        jsSourceMappingURL: string;
+        sourceMapFile: string;
+        sourceMapSourceRoot: string;
+        sourceMapSources: string[];
+        sourceMapSourcesContent?: string[];
+        inputSourceFileNames: string[];
+        sourceMapNames?: string[];
+        sourceMapMappings: string;
+        sourceMapDecodedMappings: SourceMapSpan[];
+    }
+    /** Return code used by getEmitOutput function to indicate status of the function */
+    enum ExitStatus {
+        Success = 0,
+        DiagnosticsPresent_OutputsSkipped = 1,
+        DiagnosticsPresent_OutputsGenerated = 2,
+    }
+    interface EmitResult {
+        emitSkipped: boolean;
+        diagnostics: Diagnostic[];
+    }
+    interface TypeChecker {
+        getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
+        getDeclaredTypeOfSymbol(symbol: Symbol): Type;
+        getPropertiesOfType(type: Type): Symbol[];
+        getPropertyOfType(type: Type, propertyName: string): Symbol;
+        getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
+        getIndexTypeOfType(type: Type, kind: IndexKind): Type;
+        getBaseTypes(type: InterfaceType): ObjectType[];
+        getReturnTypeOfSignature(signature: Signature): Type;
+        getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
+        getSymbolAtLocation(node: Node): Symbol;
+        getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
+        getShorthandAssignmentValueSymbol(location: Node): Symbol;
+        getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
+        getTypeAtLocation(node: Node): Type;
+        typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
+        symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
+        getSymbolDisplayBuilder(): SymbolDisplayBuilder;
+        getFullyQualifiedName(symbol: Symbol): string;
+        getAugmentedPropertiesOfType(type: Type): Symbol[];
+        getRootSymbols(symbol: Symbol): Symbol[];
+        getContextualType(node: Expression): Type;
+        getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
+        getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
+        isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
+        isUndefinedSymbol(symbol: Symbol): boolean;
+        isArgumentsSymbol(symbol: Symbol): boolean;
+        isUnknownSymbol(symbol: Symbol): boolean;
+        getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
+        isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
+        getAliasedSymbol(symbol: Symbol): Symbol;
+        getExportsOfModule(moduleSymbol: Symbol): Symbol[];
+        getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
+        getJsxIntrinsicTagNames(): Symbol[];
+        isOptionalParameter(node: ParameterDeclaration): boolean;
+    }
+    interface SymbolDisplayBuilder {
+        buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
+        buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
+        buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+        buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
+    }
+    interface SymbolWriter {
+        writeKeyword(text: string): void;
+        writeOperator(text: string): void;
+        writePunctuation(text: string): void;
+        writeSpace(text: string): void;
+        writeStringLiteral(text: string): void;
+        writeParameter(text: string): void;
+        writeSymbol(text: string, symbol: Symbol): void;
+        writeLine(): void;
+        increaseIndent(): void;
+        decreaseIndent(): void;
+        clear(): void;
+        trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
+        reportInaccessibleThisError(): void;
+    }
+    enum TypeFormatFlags {
+        None = 0,
+        WriteArrayAsGenericType = 1,
+        UseTypeOfFunction = 2,
+        NoTruncation = 4,
+        WriteArrowStyleSignature = 8,
+        WriteOwnNameForAnyLike = 16,
+        WriteTypeArgumentsOfSignature = 32,
+        InElementType = 64,
+        UseFullyQualifiedType = 128,
+    }
+    enum SymbolFormatFlags {
+        None = 0,
+        WriteTypeParametersOrArguments = 1,
+        UseOnlyExternalAliasing = 2,
+    }
+    enum TypePredicateKind {
+        This = 0,
+        Identifier = 1,
+    }
+    interface TypePredicateBase {
+        kind: TypePredicateKind;
+        type: Type;
+    }
+    interface ThisTypePredicate extends TypePredicateBase {
+        _thisTypePredicateBrand: any;
+    }
+    interface IdentifierTypePredicate extends TypePredicateBase {
+        parameterName: string;
+        parameterIndex: number;
+    }
+    type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
+    enum SymbolFlags {
+        None = 0,
+        FunctionScopedVariable = 1,
+        BlockScopedVariable = 2,
+        Property = 4,
+        EnumMember = 8,
+        Function = 16,
+        Class = 32,
+        Interface = 64,
+        ConstEnum = 128,
+        RegularEnum = 256,
+        ValueModule = 512,
+        NamespaceModule = 1024,
+        TypeLiteral = 2048,
+        ObjectLiteral = 4096,
+        Method = 8192,
+        Constructor = 16384,
+        GetAccessor = 32768,
+        SetAccessor = 65536,
+        Signature = 131072,
+        TypeParameter = 262144,
+        TypeAlias = 524288,
+        ExportValue = 1048576,
+        ExportType = 2097152,
+        ExportNamespace = 4194304,
+        Alias = 8388608,
+        Instantiated = 16777216,
+        Merged = 33554432,
+        Transient = 67108864,
+        Prototype = 134217728,
+        SyntheticProperty = 268435456,
+        Optional = 536870912,
+        ExportStar = 1073741824,
+        Enum = 384,
+        Variable = 3,
+        Value = 107455,
+        Type = 793056,
+        Namespace = 1536,
+        Module = 1536,
+        Accessor = 98304,
+        FunctionScopedVariableExcludes = 107454,
+        BlockScopedVariableExcludes = 107455,
+        ParameterExcludes = 107455,
+        PropertyExcludes = 107455,
+        EnumMemberExcludes = 107455,
+        FunctionExcludes = 106927,
+        ClassExcludes = 899519,
+        InterfaceExcludes = 792960,
+        RegularEnumExcludes = 899327,
+        ConstEnumExcludes = 899967,
+        ValueModuleExcludes = 106639,
+        NamespaceModuleExcludes = 0,
+        MethodExcludes = 99263,
+        GetAccessorExcludes = 41919,
+        SetAccessorExcludes = 74687,
+        TypeParameterExcludes = 530912,
+        TypeAliasExcludes = 793056,
+        AliasExcludes = 8388608,
+        ModuleMember = 8914931,
+        ExportHasLocal = 944,
+        HasExports = 1952,
+        HasMembers = 6240,
+        BlockScoped = 418,
+        PropertyOrAccessor = 98308,
+        Export = 7340032,
+    }
+    interface Symbol {
+        flags: SymbolFlags;
+        name: string;
+        declarations?: Declaration[];
+        valueDeclaration?: Declaration;
+        members?: SymbolTable;
+        exports?: SymbolTable;
+    }
+    interface SymbolTable {
+        [index: string]: Symbol;
+    }
+    enum TypeFlags {
+        Any = 1,
+        String = 2,
+        Number = 4,
+        Boolean = 8,
+        Void = 16,
+        Undefined = 32,
+        Null = 64,
+        Enum = 128,
+        StringLiteral = 256,
+        TypeParameter = 512,
+        Class = 1024,
+        Interface = 2048,
+        Reference = 4096,
+        Tuple = 8192,
+        Union = 16384,
+        Intersection = 32768,
+        Anonymous = 65536,
+        Instantiated = 131072,
+        ObjectLiteral = 524288,
+        ESSymbol = 16777216,
+        ThisType = 33554432,
+        ObjectLiteralPatternWithComputedProperties = 67108864,
+        StringLike = 258,
+        NumberLike = 132,
+        ObjectType = 80896,
+        UnionOrIntersection = 49152,
+        StructuredType = 130048,
+    }
+    type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
+    interface Type {
+        flags: TypeFlags;
+        symbol?: Symbol;
+        pattern?: DestructuringPattern;
+    }
+    interface StringLiteralType extends Type {
+        text: string;
+    }
+    interface ObjectType extends Type {
+    }
+    interface InterfaceType extends ObjectType {
+        typeParameters: TypeParameter[];
+        outerTypeParameters: TypeParameter[];
+        localTypeParameters: TypeParameter[];
+        thisType: TypeParameter;
+    }
+    interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
+        declaredProperties: Symbol[];
+        declaredCallSignatures: Signature[];
+        declaredConstructSignatures: Signature[];
+        declaredStringIndexType: Type;
+        declaredNumberIndexType: Type;
+    }
+    interface TypeReference extends ObjectType {
+        target: GenericType;
+        typeArguments: Type[];
+    }
+    interface GenericType extends InterfaceType, TypeReference {
+    }
+    interface TupleType extends ObjectType {
+        elementTypes: Type[];
+    }
+    interface UnionOrIntersectionType extends Type {
+        types: Type[];
+    }
+    interface UnionType extends UnionOrIntersectionType {
+    }
+    interface IntersectionType extends UnionOrIntersectionType {
+    }
+    interface TypeParameter extends Type {
+        constraint: Type;
+    }
+    enum SignatureKind {
+        Call = 0,
+        Construct = 1,
+    }
+    interface Signature {
+        declaration: SignatureDeclaration;
+        typeParameters: TypeParameter[];
+        parameters: Symbol[];
+    }
+    enum IndexKind {
+        String = 0,
+        Number = 1,
+    }
+    interface DiagnosticMessage {
+        key: string;
+        category: DiagnosticCategory;
+        code: number;
+        message: string;
+    }
+    /**
+     * A linked list of formatted diagnostic messages to be used as part of a multiline message.
+     * It is built from the bottom up, leaving the head to be the "main" diagnostic.
+     * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
+     * the difference is that messages are all preformatted in DMC.
+     */
+    interface DiagnosticMessageChain {
+        messageText: string;
+        category: DiagnosticCategory;
+        code: number;
+        next?: DiagnosticMessageChain;
+    }
+    interface Diagnostic {
+        file: SourceFile;
+        start: number;
+        length: number;
+        messageText: string | DiagnosticMessageChain;
+        category: DiagnosticCategory;
+        code: number;
+    }
+    enum DiagnosticCategory {
+        Warning = 0,
+        Error = 1,
+        Message = 2,
+    }
+    enum ModuleResolutionKind {
+        Classic = 1,
+        NodeJs = 2,
+    }
+    interface CompilerOptions {
+        allowNonTsExtensions?: boolean;
+        charset?: string;
+        declaration?: boolean;
+        diagnostics?: boolean;
+        emitBOM?: boolean;
+        help?: boolean;
+        init?: boolean;
+        inlineSourceMap?: boolean;
+        inlineSources?: boolean;
+        jsx?: JsxEmit;
+        reactNamespace?: string;
+        listFiles?: boolean;
+        locale?: string;
+        mapRoot?: string;
+        module?: ModuleKind;
+        newLine?: NewLineKind;
+        noEmit?: boolean;
+        noEmitHelpers?: boolean;
+        noEmitOnError?: boolean;
+        noErrorTruncation?: boolean;
+        noImplicitAny?: boolean;
+        noLib?: boolean;
+        noResolve?: boolean;
+        out?: string;
+        outFile?: string;
+        outDir?: string;
+        preserveConstEnums?: boolean;
+        project?: string;
+        removeComments?: boolean;
+        rootDir?: string;
+        sourceMap?: boolean;
+        sourceRoot?: string;
+        suppressExcessPropertyErrors?: boolean;
+        suppressImplicitAnyIndexErrors?: boolean;
+        target?: ScriptTarget;
+        version?: boolean;
+        watch?: boolean;
+        isolatedModules?: boolean;
+        experimentalDecorators?: boolean;
+        emitDecoratorMetadata?: boolean;
+        moduleResolution?: ModuleResolutionKind;
+        allowUnusedLabels?: boolean;
+        allowUnreachableCode?: boolean;
+        noImplicitReturns?: boolean;
+        noFallthroughCasesInSwitch?: boolean;
+        forceConsistentCasingInFileNames?: boolean;
+        allowSyntheticDefaultImports?: boolean;
+        allowJs?: boolean;
+        noImplicitUseStrict?: boolean;
+        disableSizeLimit?: boolean;
+        [option: string]: string | number | boolean;
+    }
+    interface TypingOptions {
+        enableAutoDiscovery?: boolean;
+        include?: string[];
+        exclude?: string[];
+        [option: string]: string[] | boolean;
+    }
+    interface DiscoverTypingsInfo {
+        fileNames: string[];
+        projectRootPath: string;
+        safeListPath: string;
+        packageNameToTypingLocation: Map<string>;
+        typingOptions: TypingOptions;
+        compilerOptions: CompilerOptions;
+    }
+    enum ModuleKind {
+        None = 0,
+        CommonJS = 1,
+        AMD = 2,
+        UMD = 3,
+        System = 4,
+        ES6 = 5,
+        ES2015 = 5,
+    }
+    enum JsxEmit {
+        None = 0,
+        Preserve = 1,
+        React = 2,
+    }
+    enum NewLineKind {
+        CarriageReturnLineFeed = 0,
+        LineFeed = 1,
+    }
+    interface LineAndCharacter {
+        line: number;
+        character: number;
+    }
+    enum ScriptKind {
+        Unknown = 0,
+        JS = 1,
+        JSX = 2,
+        TS = 3,
+        TSX = 4,
+    }
+    enum ScriptTarget {
+        ES3 = 0,
+        ES5 = 1,
+        ES6 = 2,
+        ES2015 = 2,
+        Latest = 2,
+    }
+    enum LanguageVariant {
+        Standard = 0,
+        JSX = 1,
+    }
+    interface ParsedCommandLine {
+        options: CompilerOptions;
+        typingOptions?: TypingOptions;
+        fileNames: string[];
+        errors: Diagnostic[];
+    }
+    interface ModuleResolutionHost {
+        fileExists(fileName: string): boolean;
+        readFile(fileName: string): string;
+        directoryExists?(directoryName: string): boolean;
+    }
+    interface ResolvedModule {
+        resolvedFileName: string;
+        isExternalLibraryImport?: boolean;
+    }
+    interface ResolvedModuleWithFailedLookupLocations {
+        resolvedModule: ResolvedModule;
+        failedLookupLocations: string[];
+    }
+    interface CompilerHost extends ModuleResolutionHost {
+        getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
+        getCancellationToken?(): CancellationToken;
+        getDefaultLibFileName(options: CompilerOptions): string;
+        writeFile: WriteFileCallback;
+        getCurrentDirectory(): string;
+        getCanonicalFileName(fileName: string): string;
+        useCaseSensitiveFileNames(): boolean;
+        getNewLine(): string;
+        resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
+    }
+    interface TextSpan {
+        start: number;
+        length: number;
+    }
+    interface TextChangeRange {
+        span: TextSpan;
+        newLength: number;
+    }
+}
+declare namespace ts {
+    type FileWatcherCallback = (path: string, removed?: boolean) => void;
+    type DirectoryWatcherCallback = (path: string) => void;
+    interface System {
+        args: string[];
+        newLine: string;
+        useCaseSensitiveFileNames: boolean;
+        write(s: string): void;
+        readFile(path: string, encoding?: string): string;
+        writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
+        watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher;
+        watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
+        resolvePath(path: string): string;
+        fileExists(path: string): boolean;
+        directoryExists(path: string): boolean;
+        createDirectory(path: string): void;
+        getExecutingFilePath(): string;
+        getCurrentDirectory(): string;
+        readDirectory(path: string, extension?: string, exclude?: string[]): string[];
+        getMemoryUsage?(): number;
+        exit(exitCode?: number): void;
+    }
+    interface FileWatcher {
+        close(): void;
+    }
+    interface DirectoryWatcher extends FileWatcher {
+        directoryPath: Path;
+        referenceCount: number;
+    }
+    var sys: System;
+}
+declare namespace ts {
+    interface ErrorCallback {
+        (message: DiagnosticMessage, length: number): void;
+    }
+    interface Scanner {
+        getStartPos(): number;
+        getToken(): SyntaxKind;
+        getTextPos(): number;
+        getTokenPos(): number;
+        getTokenText(): string;
+        getTokenValue(): string;
+        hasExtendedUnicodeEscape(): boolean;
+        hasPrecedingLineBreak(): boolean;
+        isIdentifier(): boolean;
+        isReservedWord(): boolean;
+        isUnterminated(): boolean;
+        reScanGreaterToken(): SyntaxKind;
+        reScanSlashToken(): SyntaxKind;
+        reScanTemplateToken(): SyntaxKind;
+        scanJsxIdentifier(): SyntaxKind;
+        reScanJsxToken(): SyntaxKind;
+        scanJsxToken(): SyntaxKind;
+        scanJSDocToken(): SyntaxKind;
+        scan(): SyntaxKind;
+        setText(text: string, start?: number, length?: number): void;
+        setOnError(onError: ErrorCallback): void;
+        setScriptTarget(scriptTarget: ScriptTarget): void;
+        setLanguageVariant(variant: LanguageVariant): void;
+        setTextPos(textPos: number): void;
+        lookAhead<T>(callback: () => T): T;
+        scanRange<T>(start: number, length: number, callback: () => T): T;
+        tryScan<T>(callback: () => T): T;
+    }
+    function tokenToString(t: SyntaxKind): string;
+    function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
+    function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
+    function isWhiteSpace(ch: number): boolean;
+    function isLineBreak(ch: number): boolean;
+    function couldStartTrivia(text: string, pos: number): boolean;
+    function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
+    function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
+    /** Optionally, get the shebang */
+    function getShebang(text: string): string;
+    function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
+    function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
+    function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
+}
+declare namespace ts {
+    function getDefaultLibFileName(options: CompilerOptions): string;
+    function textSpanEnd(span: TextSpan): number;
+    function textSpanIsEmpty(span: TextSpan): boolean;
+    function textSpanContainsPosition(span: TextSpan, position: number): boolean;
+    function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
+    function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
+    function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
+    function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
+    function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
+    function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean;
+    function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
+    function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
+    function createTextSpan(start: number, length: number): TextSpan;
+    function createTextSpanFromBounds(start: number, end: number): TextSpan;
+    function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
+    function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
+    function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
+    let unchangedTextChangeRange: TextChangeRange;
+    /**
+     * Called to merge all the changes that occurred across several versions of a script snapshot
+     * into a single change.  i.e. if a user keeps making successive edits to a script we will
+     * have a text change from V1 to V2, V2 to V3, ..., Vn.
+     *
+     * This function will then merge those changes into a single change range valid between V1 and
+     * Vn.
+     */
+    function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
+    function getTypeParameterOwner(d: Declaration): Declaration;
+    function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean;
+}
+declare namespace ts {
+    function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
+    function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
+    function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
+    function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+}
+declare namespace ts {
+    const version: string;
+    function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string;
+    function resolveTripleslashReference(moduleName: string, containingFile: string): string;
+    function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+    function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+    function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
+    function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
+    function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
+    function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
+    function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
+}
+declare namespace ts {
+    function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
+    /**
+      * Read tsconfig.json file
+      * @param fileName The path to the config file
+      */
+    function readConfigFile(fileName: string, readFile: (path: string) => string): {
+        config?: any;
+        error?: Diagnostic;
+    };
+    /**
+      * Parse the text of the tsconfig.json file
+      * @param fileName The path to the config file
+      * @param jsonText The text of the config file
+      */
+    function parseConfigFileTextToJson(fileName: string, jsonText: string): {
+        config?: any;
+        error?: Diagnostic;
+    };
+    /**
+      * Parse the contents of a config file (tsconfig.json).
+      * @param json The contents of the config file to parse
+      * @param host Instance of ParseConfigHost used to enumerate files in folder.
+      * @param basePath A root directory to resolve relative path entries in the config
+      *    file to. e.g. outDir
+      */
+    function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string): ParsedCommandLine;
+    function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
+        options: CompilerOptions;
+        errors: Diagnostic[];
+    };
+}
+declare namespace ts {
+    /** The version of the language service API */
+    const servicesVersion: string;
+    interface Node {
+        getSourceFile(): SourceFile;
+        getChildCount(sourceFile?: SourceFile): number;
+        getChildAt(index: number, sourceFile?: SourceFile): Node;
+        getChildren(sourceFile?: SourceFile): Node[];
+        getStart(sourceFile?: SourceFile): number;
+        getFullStart(): number;
+        getEnd(): number;
+        getWidth(sourceFile?: SourceFile): number;
+        getFullWidth(): number;
+        getLeadingTriviaWidth(sourceFile?: SourceFile): number;
+        getFullText(sourceFile?: SourceFile): string;
+        getText(sourceFile?: SourceFile): string;
+        getFirstToken(sourceFile?: SourceFile): Node;
+        getLastToken(sourceFile?: SourceFile): Node;
+    }
+    interface Symbol {
+        getFlags(): SymbolFlags;
+        getName(): string;
+        getDeclarations(): Declaration[];
+        getDocumentationComment(): SymbolDisplayPart[];
+    }
+    interface Type {
+        getFlags(): TypeFlags;
+        getSymbol(): Symbol;
+        getProperties(): Symbol[];
+        getProperty(propertyName: string): Symbol;
+        getApparentProperties(): Symbol[];
+        getCallSignatures(): Signature[];
+        getConstructSignatures(): Signature[];
+        getStringIndexType(): Type;
+        getNumberIndexType(): Type;
+        getBaseTypes(): ObjectType[];
+    }
+    interface Signature {
+        getDeclaration(): SignatureDeclaration;
+        getTypeParameters(): Type[];
+        getParameters(): Symbol[];
+        getReturnType(): Type;
+        getDocumentationComment(): SymbolDisplayPart[];
+    }
+    interface SourceFile {
+        getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
+        getLineStarts(): number[];
+        getPositionOfLineAndCharacter(line: number, character: number): number;
+        update(newText: string, textChangeRange: TextChangeRange): SourceFile;
+    }
+    /**
+     * Represents an immutable snapshot of a script at a specified time.Once acquired, the
+     * snapshot is observably immutable. i.e. the same calls with the same parameters will return
+     * the same values.
+     */
+    interface IScriptSnapshot {
+        /** Gets a portion of the script snapshot specified by [start, end). */
+        getText(start: number, end: number): string;
+        /** Gets the length of this script snapshot. */
+        getLength(): number;
+        /**
+         * Gets the TextChangeRange that describe how the text changed between this text and
+         * an older version.  This information is used by the incremental parser to determine
+         * what sections of the script need to be re-parsed.  'undefined' can be returned if the
+         * change range cannot be determined.  However, in that case, incremental parsing will
+         * not happen and the entire document will be re - parsed.
+         */
+        getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
+        /** Releases all resources held by this script snapshot */
+        dispose?(): void;
+    }
+    namespace ScriptSnapshot {
+        function fromString(text: string): IScriptSnapshot;
+    }
+    interface PreProcessedFileInfo {
+        referencedFiles: FileReference[];
+        importedFiles: FileReference[];
+        ambientExternalModules: string[];
+        isLibFile: boolean;
+    }
+    interface HostCancellationToken {
+        isCancellationRequested(): boolean;
+    }
+    interface LanguageServiceHost {
+        getCompilationSettings(): CompilerOptions;
+        getNewLine?(): string;
+        getProjectVersion?(): string;
+        getScriptFileNames(): string[];
+        getScriptKind?(fileName: string): ScriptKind;
+        getScriptVersion(fileName: string): string;
+        getScriptSnapshot(fileName: string): IScriptSnapshot;
+        getLocalizedDiagnosticMessages?(): any;
+        getCancellationToken?(): HostCancellationToken;
+        getCurrentDirectory(): string;
+        getDefaultLibFileName(options: CompilerOptions): string;
+        log?(s: string): void;
+        trace?(s: string): void;
+        error?(s: string): void;
+        useCaseSensitiveFileNames?(): boolean;
+        resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
+        directoryExists?(directoryName: string): boolean;
+    }
+    interface LanguageService {
+        cleanupSemanticCache(): void;
+        getSyntacticDiagnostics(fileName: string): Diagnostic[];
+        getSemanticDiagnostics(fileName: string): Diagnostic[];
+        getCompilerOptionsDiagnostics(): Diagnostic[];
+        /**
+         * @deprecated Use getEncodedSyntacticClassifications instead.
+         */
+        getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
+        /**
+         * @deprecated Use getEncodedSemanticClassifications instead.
+         */
+        getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
+        getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
+        getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
+        getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
+        getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
+        getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
+        getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
+        getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
+        getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
+        getRenameInfo(fileName: string, position: number): RenameInfo;
+        findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
+        getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
+        getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
+        getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
+        findReferences(fileName: string, position: number): ReferencedSymbol[];
+        getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
+        /** @deprecated */
+        getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
+        getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
+        getNavigationBarItems(fileName: string): NavigationBarItem[];
+        getOutliningSpans(fileName: string): OutliningSpan[];
+        getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
+        getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
+        getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
+        getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
+        getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
+        getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
+        getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
+        getEmitOutput(fileName: string): EmitOutput;
+        getProgram(): Program;
+        getSourceFile(fileName: string): SourceFile;
+        dispose(): void;
+    }
+    interface Classifications {
+        spans: number[];
+        endOfLineState: EndOfLineState;
+    }
+    interface ClassifiedSpan {
+        textSpan: TextSpan;
+        classificationType: string;
+    }
+    interface NavigationBarItem {
+        text: string;
+        kind: string;
+        kindModifiers: string;
+        spans: TextSpan[];
+        childItems: NavigationBarItem[];
+        indent: number;
+        bolded: boolean;
+        grayed: boolean;
+    }
+    interface TodoCommentDescriptor {
+        text: string;
+        priority: number;
+    }
+    interface TodoComment {
+        descriptor: TodoCommentDescriptor;
+        message: string;
+        position: number;
+    }
+    class TextChange {
+        span: TextSpan;
+        newText: string;
+    }
+    interface TextInsertion {
+        newText: string;
+        /** The position in newText the caret should point to after the insertion. */
+        caretOffset: number;
+    }
+    interface RenameLocation {
+        textSpan: TextSpan;
+        fileName: string;
+    }
+    interface ReferenceEntry {
+        textSpan: TextSpan;
+        fileName: string;
+        isWriteAccess: boolean;
+    }
+    interface DocumentHighlights {
+        fileName: string;
+        highlightSpans: HighlightSpan[];
+    }
+    namespace HighlightSpanKind {
+        const none: string;
+        const definition: string;
+        const reference: string;
+        const writtenReference: string;
+    }
+    interface HighlightSpan {
+        fileName?: string;
+        textSpan: TextSpan;
+        kind: string;
+    }
+    interface NavigateToItem {
+        name: string;
+        kind: string;
+        kindModifiers: string;
+        matchKind: string;
+        isCaseSensitive: boolean;
+        fileName: string;
+        textSpan: TextSpan;
+        containerName: string;
+        containerKind: string;
+    }
+    interface EditorOptions {
+        IndentSize: number;
+        TabSize: number;
+        NewLineCharacter: string;
+        ConvertTabsToSpaces: boolean;
+        IndentStyle: IndentStyle;
+    }
+    enum IndentStyle {
+        None = 0,
+        Block = 1,
+        Smart = 2,
+    }
+    interface FormatCodeOptions extends EditorOptions {
+        InsertSpaceAfterCommaDelimiter: boolean;
+        InsertSpaceAfterSemicolonInForStatements: boolean;
+        InsertSpaceBeforeAndAfterBinaryOperators: boolean;
+        InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
+        InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
+        InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
+        InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
+        InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
+        PlaceOpenBraceOnNewLineForFunctions: boolean;
+        PlaceOpenBraceOnNewLineForControlBlocks: boolean;
+        [s: string]: boolean | number | string;
+    }
+    interface DefinitionInfo {
+        fileName: string;
+        textSpan: TextSpan;
+        kind: string;
+        name: string;
+        containerKind: string;
+        containerName: string;
+    }
+    interface ReferencedSymbol {
+        definition: DefinitionInfo;
+        references: ReferenceEntry[];
+    }
+    enum SymbolDisplayPartKind {
+        aliasName = 0,
+        className = 1,
+        enumName = 2,
+        fieldName = 3,
+        interfaceName = 4,
+        keyword = 5,
+        lineBreak = 6,
+        numericLiteral = 7,
+        stringLiteral = 8,
+        localName = 9,
+        methodName = 10,
+        moduleName = 11,
+        operator = 12,
+        parameterName = 13,
+        propertyName = 14,
+        punctuation = 15,
+        space = 16,
+        text = 17,
+        typeParameterName = 18,
+        enumMemberName = 19,
+        functionName = 20,
+        regularExpressionLiteral = 21,
+    }
+    interface SymbolDisplayPart {
+        text: string;
+        kind: string;
+    }
+    interface QuickInfo {
+        kind: string;
+        kindModifiers: string;
+        textSpan: TextSpan;
+        displayParts: SymbolDisplayPart[];
+        documentation: SymbolDisplayPart[];
+    }
+    interface RenameInfo {
+        canRename: boolean;
+        localizedErrorMessage: string;
+        displayName: string;
+        fullDisplayName: string;
+        kind: string;
+        kindModifiers: string;
+        triggerSpan: TextSpan;
+    }
+    interface SignatureHelpParameter {
+        name: string;
+        documentation: SymbolDisplayPart[];
+        displayParts: SymbolDisplayPart[];
+        isOptional: boolean;
+    }
+    /**
+     * Represents a single signature to show in signature help.
+     * The id is used for subsequent calls into the language service to ask questions about the
+     * signature help item in the context of any documents that have been updated.  i.e. after
+     * an edit has happened, while signature help is still active, the host can ask important
+     * questions like 'what parameter is the user currently contained within?'.
+     */
+    interface SignatureHelpItem {
+        isVariadic: boolean;
+        prefixDisplayParts: SymbolDisplayPart[];
+        suffixDisplayParts: SymbolDisplayPart[];
+        separatorDisplayParts: SymbolDisplayPart[];
+        parameters: SignatureHelpParameter[];
+        documentation: SymbolDisplayPart[];
+    }
+    /**
+     * Represents a set of signature help items, and the preferred item that should be selected.
+     */
+    interface SignatureHelpItems {
+        items: SignatureHelpItem[];
+        applicableSpan: TextSpan;
+        selectedItemIndex: number;
+        argumentIndex: number;
+        argumentCount: number;
+    }
+    interface CompletionInfo {
+        isMemberCompletion: boolean;
+        isNewIdentifierLocation: boolean;
+        entries: CompletionEntry[];
+    }
+    interface CompletionEntry {
+        name: string;
+        kind: string;
+        kindModifiers: string;
+        sortText: string;
+    }
+    interface CompletionEntryDetails {
+        name: string;
+        kind: string;
+        kindModifiers: string;
+        displayParts: SymbolDisplayPart[];
+        documentation: SymbolDisplayPart[];
+    }
+    interface OutliningSpan {
+        /** The span of the document to actually collapse. */
+        textSpan: TextSpan;
+        /** The span of the document to display when the user hovers over the collapsed span. */
+        hintSpan: TextSpan;
+        /** The text to display in the editor for the collapsed region. */
+        bannerText: string;
+        /**
+          * Whether or not this region should be automatically collapsed when
+          * the 'Collapse to Definitions' command is invoked.
+          */
+        autoCollapse: boolean;
+    }
+    interface EmitOutput {
+        outputFiles: OutputFile[];
+        emitSkipped: boolean;
+    }
+    enum OutputFileType {
+        JavaScript = 0,
+        SourceMap = 1,
+        Declaration = 2,
+    }
+    interface OutputFile {
+        name: string;
+        writeByteOrderMark: boolean;
+        text: string;
+    }
+    enum EndOfLineState {
+        None = 0,
+        InMultiLineCommentTrivia = 1,
+        InSingleQuoteStringLiteral = 2,
+        InDoubleQuoteStringLiteral = 3,
+        InTemplateHeadOrNoSubstitutionTemplate = 4,
+        InTemplateMiddleOrTail = 5,
+        InTemplateSubstitutionPosition = 6,
+    }
+    enum TokenClass {
+        Punctuation = 0,
+        Keyword = 1,
+        Operator = 2,
+        Comment = 3,
+        Whitespace = 4,
+        Identifier = 5,
+        NumberLiteral = 6,
+        StringLiteral = 7,
+        RegExpLiteral = 8,
+    }
+    interface ClassificationResult {
+        finalLexState: EndOfLineState;
+        entries: ClassificationInfo[];
+    }
+    interface ClassificationInfo {
+        length: number;
+        classification: TokenClass;
+    }
+    interface Classifier {
+        /**
+         * Gives lexical classifications of tokens on a line without any syntactic context.
+         * For instance, a token consisting of the text 'string' can be either an identifier
+         * named 'string' or the keyword 'string', however, because this classifier is not aware,
+         * it relies on certain heuristics to give acceptable results. For classifications where
+         * speed trumps accuracy, this function is preferable; however, for true accuracy, the
+         * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
+         * lexical, syntactic, and semantic classifiers may issue the best user experience.
+         *
+         * @param text                      The text of a line to classify.
+         * @param lexState                  The state of the lexical classifier at the end of the previous line.
+         * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
+         *                                  If there is no syntactic classifier (syntacticClassifierAbsent=true),
+         *                                  certain heuristics may be used in its place; however, if there is a
+         *                                  syntactic classifier (syntacticClassifierAbsent=false), certain
+         *                                  classifications which may be incorrectly categorized will be given
+         *                                  back as Identifiers in order to allow the syntactic classifier to
+         *                                  subsume the classification.
+         * @deprecated Use getLexicalClassifications instead.
+         */
+        getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
+        getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
+    }
+    /**
+      * The document registry represents a store of SourceFile objects that can be shared between
+      * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
+      * of files in the context.
+      * SourceFile objects account for most of the memory usage by the language service. Sharing
+      * the same DocumentRegistry instance between different instances of LanguageService allow
+      * for more efficient memory utilization since all projects will share at least the library
+      * file (lib.d.ts).
+      *
+      * A more advanced use of the document registry is to serialize sourceFile objects to disk
+      * and re-hydrate them when needed.
+      *
+      * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
+      * to all subsequent createLanguageService calls.
+      */
+    interface DocumentRegistry {
+        /**
+          * Request a stored SourceFile with a given fileName and compilationSettings.
+          * The first call to acquire will call createLanguageServiceSourceFile to generate
+          * the SourceFile if was not found in the registry.
+          *
+          * @param fileName The name of the file requested
+          * @param compilationSettings Some compilation settings like target affects the
+          * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
+          * multiple copies of the same file for different compilation settings.
+          * @parm scriptSnapshot Text of the file. Only used if the file was not found
+          * in the registry and a new one was created.
+          * @parm version Current version of the file. Only used if the file was not found
+          * in the registry and a new one was created.
+          */
+        acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+        /**
+          * Request an updated version of an already existing SourceFile with a given fileName
+          * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
+          * to get an updated SourceFile.
+          *
+          * @param fileName The name of the file requested
+          * @param compilationSettings Some compilation settings like target affects the
+          * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
+          * multiple copies of the same file for different compilation settings.
+          * @param scriptSnapshot Text of the file.
+          * @param version Current version of the file.
+          */
+        updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+        /**
+          * Informs the DocumentRegistry that a file is not needed any longer.
+          *
+          * Note: It is not allowed to call release on a SourceFile that was not acquired from
+          * this registry originally.
+          *
+          * @param fileName The name of the file to be released
+          * @param compilationSettings The compilation settings used to acquire the file
+          */
+        releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
+        reportStats(): string;
+    }
+    namespace ScriptElementKind {
+        const unknown: string;
+        const warning: string;
+        const keyword: string;
+        const scriptElement: string;
+        const moduleElement: string;
+        const classElement: string;
+        const localClassElement: string;
+        const interfaceElement: string;
+        const typeElement: string;
+        const enumElement: string;
+        const variableElement: string;
+        const localVariableElement: string;
+        const functionElement: string;
+        const localFunctionElement: string;
+        const memberFunctionElement: string;
+        const memberGetAccessorElement: string;
+        const memberSetAccessorElement: string;
+        const memberVariableElement: string;
+        const constructorImplementationElement: string;
+        const callSignatureElement: string;
+        const indexSignatureElement: string;
+        const constructSignatureElement: string;
+        const parameterElement: string;
+        const typeParameterElement: string;
+        const primitiveType: string;
+        const label: string;
+        const alias: string;
+        const constElement: string;
+        const letElement: string;
+    }
+    namespace ScriptElementKindModifier {
+        const none: string;
+        const publicMemberModifier: string;
+        const privateMemberModifier: string;
+        const protectedMemberModifier: string;
+        const exportedModifier: string;
+        const ambientModifier: string;
+        const staticModifier: string;
+        const abstractModifier: string;
+    }
+    class ClassificationTypeNames {
+        static comment: string;
+        static identifier: string;
+        static keyword: string;
+        static numericLiteral: string;
+        static operator: string;
+        static stringLiteral: string;
+        static whiteSpace: string;
+        static text: string;
+        static punctuation: string;
+        static className: string;
+        static enumName: string;
+        static interfaceName: string;
+        static moduleName: string;
+        static typeParameterName: string;
+        static typeAliasName: string;
+        static parameterName: string;
+        static docCommentTagName: string;
+        static jsxOpenTagName: string;
+        static jsxCloseTagName: string;
+        static jsxSelfClosingTagName: string;
+        static jsxAttribute: string;
+        static jsxText: string;
+        static jsxAttributeStringLiteralValue: string;
+    }
+    enum ClassificationType {
+        comment = 1,
+        identifier = 2,
+        keyword = 3,
+        numericLiteral = 4,
+        operator = 5,
+        stringLiteral = 6,
+        regularExpressionLiteral = 7,
+        whiteSpace = 8,
+        text = 9,
+        punctuation = 10,
+        className = 11,
+        enumName = 12,
+        interfaceName = 13,
+        moduleName = 14,
+        typeParameterName = 15,
+        typeAliasName = 16,
+        parameterName = 17,
+        docCommentTagName = 18,
+        jsxOpenTagName = 19,
+        jsxCloseTagName = 20,
+        jsxSelfClosingTagName = 21,
+        jsxAttribute = 22,
+        jsxText = 23,
+        jsxAttributeStringLiteralValue = 24,
+    }
+    interface DisplayPartsSymbolWriter extends SymbolWriter {
+        displayParts(): SymbolDisplayPart[];
+    }
+    function displayPartsToString(displayParts: SymbolDisplayPart[]): string;
+    function getDefaultCompilerOptions(): CompilerOptions;
+    interface TranspileOptions {
+        compilerOptions?: CompilerOptions;
+        fileName?: string;
+        reportDiagnostics?: boolean;
+        moduleName?: string;
+        renamedDependencies?: Map<string>;
+    }
+    interface TranspileOutput {
+        outputText: string;
+        diagnostics?: Diagnostic[];
+        sourceMapText?: string;
+    }
+    function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput;
+    function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
+    function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
+    let disableIncrementalParsing: boolean;
+    function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+    function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
+    function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
+    function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
+    function createClassifier(): Classifier;
+    /**
+      * Get the path of the default library files (lib.d.ts) as distributed with the typescript
+      * node package.
+      * The functionality is not supported if the ts module is consumed outside of a node module.
+      */
+    function getDefaultLibFilePath(options: CompilerOptions): string;
+}
+
+// MONACOCHANGE
+export = ts;
+// END MONACOCHANGE

File diff suppressed because it is too large
+ 3078 - 0
lib/typescriptServices.js


+ 33 - 0
package.json

@@ -0,0 +1,33 @@
+{
+  "name": "monaco-typescript",
+  "version": "0.1.0",
+  "description": "TypeScript and JavaScript language support for Monaco Editor",
+  "scripts": {
+    "test": "node_modules/.bin/mocha",
+    "watch": "node_modules/.bin/gulp watch",
+    "prepublish": "node_modules/.bin/gulp release"
+  },
+  "author": "Microsoft Corporation",
+  "license": "MIT",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/Microsoft/monaco-typescript"
+  },
+  "bugs": {
+    "url": "https://github.com/Microsoft/monaco-typescript/issues"
+  },
+  "devDependencies": {
+    "event-stream": "^3.3.2",
+    "gulp": "^3.9.1",
+    "gulp-requirejs": "^0.1.3",
+    "gulp-tsb": "^1.10.4",
+    "gulp-uglify": "^1.5.3",
+    "merge-stream": "^1.0.0",
+    "mocha": "^2.5.3",
+    "monaco-editor-core": "^0.3.1",
+    "object-assign": "^4.1.0",
+    "rimraf": "^2.5.2",
+    "typescript": "1.8.10",
+    "typescript-with-globs": "^0.1.4"
+  }
+}

+ 540 - 0
src/languageFeatures.ts

@@ -0,0 +1,540 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import {LanguageServiceDefaults} from './typescript';
+import * as ts from '../lib/typescriptServices';
+import {TypeScriptWorker} from './worker';
+
+import Uri = monaco.Uri;
+import Position = monaco.Position;
+import Range = monaco.Range;
+import Thenable = monaco.Thenable;
+import Promise = monaco.Promise;
+import CancellationToken = monaco.CancellationToken;
+import IDisposable = monaco.IDisposable;
+
+export abstract class Adapter {
+
+	constructor(protected _worker: (first:Uri, ...more:Uri[]) => Promise<TypeScriptWorker>) {
+	}
+
+	protected _positionToOffset(uri: Uri, position: monaco.IPosition): number {
+		let model = monaco.editor.getModel(uri);
+		return model.getOffsetAt(position);
+	}
+
+	protected _offsetToPosition(uri: Uri, offset: number): monaco.IPosition {
+		let model = monaco.editor.getModel(uri);
+		return model.getPositionAt(offset);
+	}
+
+	protected _textSpanToRange(uri: Uri, span: ts.TextSpan): monaco.IRange {
+		let p1 = this._offsetToPosition(uri, span.start);
+		let p2 = this._offsetToPosition(uri, span.start + span.length);
+		let {lineNumber: startLineNumber, column: startColumn} = p1;
+		let {lineNumber: endLineNumber, column: endColumn} = p2;
+		return { startLineNumber, startColumn, endLineNumber, endColumn };
+	}
+}
+
+// --- diagnostics --- ---
+
+export class DiagnostcsAdapter extends Adapter {
+
+	private _disposables: IDisposable[] = [];
+	private _listener: { [uri: string]: IDisposable } = Object.create(null);
+
+	constructor(private _defaults: LanguageServiceDefaults, private _selector: string,
+		worker: (first: Uri, ...more: Uri[]) => Promise<TypeScriptWorker>
+	) {
+		super(worker);
+
+		const onModelAdd = (model: monaco.editor.IModel): void => {
+			if (model.getModeId() !== _selector) {
+				return;
+			}
+
+			let handle: number;
+			this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
+				clearTimeout(handle);
+				handle = setTimeout(() => this._doValidate(model.uri), 500);
+			});
+
+			this._doValidate(model.uri);
+		};
+
+		const onModelRemoved = (model: monaco.editor.IModel): void => {
+			delete this._listener[model.uri.toString()];
+		};
+
+		this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
+		this._disposables.push(monaco.editor.onWillDisposeModel(onModelRemoved));
+		this._disposables.push(monaco.editor.onDidChangeModelLanguage(event => {
+			onModelRemoved(event.model);
+			onModelAdd(event.model);
+		}));
+
+		this._disposables.push({
+			dispose: () => {
+				for (let key in this._listener) {
+					this._listener[key].dispose();
+				}
+			}
+		});
+
+		monaco.editor.getModels().forEach(onModelAdd);
+	}
+
+	public dispose(): void {
+		this._disposables.forEach(d => d && d.dispose());
+		this._disposables = [];
+	}
+
+	private _doValidate(resource: Uri): void {
+		this._worker(resource).then(worker => {
+			let promises: Promise<ts.Diagnostic[]>[] = [];
+			if (!this._defaults.diagnosticsOptions.noSyntaxValidation) {
+				promises.push(worker.getSyntacticDiagnostics(resource.toString()));
+			}
+			if (!this._defaults.diagnosticsOptions.noSemanticValidation) {
+				promises.push(worker.getSemanticDiagnostics(resource.toString()));
+			}
+			return Promise.join(promises);
+		}).then(diagnostics => {
+			const markers = diagnostics
+				.reduce((p, c) => c.concat(p), [])
+				.map(d => this._convertDiagnostics(resource, d));
+
+			monaco.editor.setModelMarkers(monaco.editor.getModel(resource), this._selector, markers);
+		}).done(undefined, err => {
+			console.error(err);
+		});
+	}
+
+	private _convertDiagnostics(resource: Uri, diag: ts.Diagnostic): monaco.editor.IMarkerData {
+		const {lineNumber: startLineNumber, column: startColumn} = this._offsetToPosition(resource, diag.start);
+		const {lineNumber: endLineNumber, column: endColumn} = this._offsetToPosition(resource, diag.start + diag.length);
+
+		return {
+			severity: monaco.Severity.Error,
+			startLineNumber,
+			startColumn,
+			endLineNumber,
+			endColumn,
+			message: ts.flattenDiagnosticMessageText(diag.messageText, '\n')
+		};
+	}
+}
+
+// --- suggest ------
+
+interface MyCompletionItem extends monaco.languages.CompletionItem {
+	uri: Uri;
+	position: Position;
+}
+
+export class SuggestAdapter extends Adapter implements monaco.languages.CompletionItemProvider {
+
+	public get triggerCharacters(): string[] {
+		return ['.'];
+	}
+
+	provideCompletionItems(model:monaco.editor.IReadOnlyModel, position:Position, token:CancellationToken): Thenable<monaco.languages.CompletionItem[]> {
+		const wordInfo = model.getWordUntilPosition(position);
+		const resource = model.uri;
+		const offset = this._positionToOffset(resource, position);
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getCompletionsAtPosition(resource.toString(), offset);
+		}).then(info => {
+			if (!info) {
+				return;
+			}
+			let suggestions: MyCompletionItem[] = info.entries.map(entry => {
+				return {
+					uri: resource,
+					position: position,
+					label: entry.name,
+					sortText: entry.sortText,
+					kind: SuggestAdapter.convertKind(entry.kind)
+				};
+			});
+
+			return suggestions;
+		}));
+	}
+
+	resolveCompletionItem(item: monaco.languages.CompletionItem, token: CancellationToken): Thenable<monaco.languages.CompletionItem> {
+		let myItem = <MyCompletionItem>item;
+		const resource = myItem.uri;
+		const position = myItem.position;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getCompletionEntryDetails(resource.toString(),
+				this._positionToOffset(resource, position),
+				myItem.label);
+
+		}).then(details => {
+			if (!details) {
+				return myItem;
+			}
+			return <MyCompletionItem>{
+				uri: resource,
+				position: position,
+				label: details.name,
+				kind: SuggestAdapter.convertKind(details.kind),
+				detail: ts.displayPartsToString(details.displayParts),
+				documentation: ts.displayPartsToString(details.documentation)
+			};
+		}));
+	}
+
+	private static convertKind(kind: string): monaco.languages.CompletionItemKind {
+		switch (kind) {
+			case Kind.primitiveType:
+			case Kind.keyword:
+				return monaco.languages.CompletionItemKind.Keyword;
+			case Kind.variable:
+			case Kind.localVariable:
+				return monaco.languages.CompletionItemKind.Variable;
+			case Kind.memberVariable:
+			case Kind.memberGetAccessor:
+			case Kind.memberSetAccessor:
+				return monaco.languages.CompletionItemKind.Field;
+			case Kind.function:
+			case Kind.memberFunction:
+			case Kind.constructSignature:
+			case Kind.callSignature:
+			case Kind.indexSignature:
+				return monaco.languages.CompletionItemKind.Function;
+			case Kind.enum:
+				return monaco.languages.CompletionItemKind.Enum;
+			case Kind.module:
+				return monaco.languages.CompletionItemKind.Module;
+			case Kind.class:
+				return monaco.languages.CompletionItemKind.Class;
+			case Kind.interface:
+				return monaco.languages.CompletionItemKind.Interface;
+			case Kind.warning:
+				return monaco.languages.CompletionItemKind.File;
+		}
+
+		return monaco.languages.CompletionItemKind.Property;
+	}
+}
+
+export class SignatureHelpAdapter extends Adapter implements monaco.languages.SignatureHelpProvider {
+
+	public signatureHelpTriggerCharacters = ['(', ','];
+
+	provideSignatureHelp(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.SignatureHelp> {
+		let resource = model.uri;
+		return wireCancellationToken(token, this._worker(resource).then(worker => worker.getSignatureHelpItems(resource.toString(), this._positionToOffset(resource, position))).then(info => {
+
+			if (!info) {
+				return;
+			}
+
+			let ret:monaco.languages.SignatureHelp = {
+				activeSignature: info.selectedItemIndex,
+				activeParameter: info.argumentIndex,
+				signatures: []
+			};
+
+			info.items.forEach(item => {
+
+				let signature:monaco.languages.SignatureInformation = {
+					label: '',
+					documentation: null,
+					parameters: []
+				};
+
+				signature.label += ts.displayPartsToString(item.prefixDisplayParts);
+				item.parameters.forEach((p, i, a) => {
+					let label = ts.displayPartsToString(p.displayParts);
+					let parameter:monaco.languages.ParameterInformation = {
+						label: label,
+						documentation: ts.displayPartsToString(p.documentation)
+					};
+					signature.label += label;
+					signature.parameters.push(parameter);
+					if (i < a.length - 1) {
+						signature.label += ts.displayPartsToString(item.separatorDisplayParts);
+					}
+				});
+				signature.label += ts.displayPartsToString(item.suffixDisplayParts);
+				ret.signatures.push(signature);
+			});
+
+			return ret;
+
+		}));
+	}
+}
+
+// --- hover ------
+
+export class QuickInfoAdapter extends Adapter implements monaco.languages.HoverProvider {
+
+	provideHover(model:monaco.editor.IReadOnlyModel, position:Position, token:CancellationToken): Thenable<monaco.languages.Hover> {
+		let resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getQuickInfoAtPosition(resource.toString(), this._positionToOffset(resource, position));
+		}).then(info => {
+			if (!info) {
+				return;
+			}
+			return <monaco.languages.Hover>{
+				range: this._textSpanToRange(resource, info.textSpan),
+				htmlContent: [{ text: ts.displayPartsToString(info.displayParts) }]
+			};
+		}));
+	}
+}
+
+// --- occurrences ------
+
+export class OccurrencesAdapter extends Adapter implements monaco.languages.DocumentHighlightProvider {
+
+	public provideDocumentHighlights(model: monaco.editor.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<monaco.languages.DocumentHighlight[]> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getOccurrencesAtPosition(resource.toString(), this._positionToOffset(resource, position));
+		}).then(entries => {
+			if (!entries) {
+				return;
+			}
+			return entries.map(entry => {
+				return <monaco.languages.DocumentHighlight>{
+					range: this._textSpanToRange(resource, entry.textSpan),
+					kind: entry.isWriteAccess ? monaco.languages.DocumentHighlightKind.Write : monaco.languages.DocumentHighlightKind.Text
+				};
+			});
+		}));
+	}
+}
+
+// --- definition ------
+
+export class DefinitionAdapter extends Adapter {
+
+	public provideDefinition(model:monaco.editor.IReadOnlyModel, position:Position, token:CancellationToken): Thenable<monaco.languages.Definition> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getDefinitionAtPosition(resource.toString(), this._positionToOffset(resource, position));
+		}).then(entries => {
+			if (!entries) {
+				return;
+			}
+			const result: monaco.languages.Location[] = [];
+			for (let entry of entries) {
+				const uri = Uri.parse(entry.fileName);
+				if (monaco.editor.getModel(uri)) {
+					result.push({
+						uri: uri,
+						range: this._textSpanToRange(uri, entry.textSpan)
+					});
+				}
+			}
+			return result;
+		}));
+	}
+}
+
+// --- references ------
+
+export class ReferenceAdapter extends Adapter implements monaco.languages.ReferenceProvider {
+
+	provideReferences(model:monaco.editor.IReadOnlyModel, position:Position, context: monaco.languages.ReferenceContext, token: CancellationToken): Thenable<monaco.languages.Location[]> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getReferencesAtPosition(resource.toString(), this._positionToOffset(resource, position));
+		}).then(entries => {
+			if (!entries) {
+				return;
+			}
+			const result: monaco.languages.Location[] = [];
+			for (let entry of entries) {
+				const uri = Uri.parse(entry.fileName);
+				if (monaco.editor.getModel(uri)) {
+					result.push({
+						uri: uri,
+						range: this._textSpanToRange(uri, entry.textSpan)
+					});
+				}
+			}
+			return result;
+		}));
+	}
+}
+
+// --- outline ------
+
+export class OutlineAdapter extends Adapter implements monaco.languages.DocumentSymbolProvider {
+
+	public provideDocumentSymbols(model:monaco.editor.IReadOnlyModel, token: CancellationToken): Thenable<monaco.languages.SymbolInformation[]> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => worker.getNavigationBarItems(resource.toString())).then(items => {
+			if (!items) {
+				return;
+			}
+
+			function convert(bucket: monaco.languages.SymbolInformation[], item: ts.NavigationBarItem, containerLabel?: string): void {
+				let result: monaco.languages.SymbolInformation = {
+					name: item.text,
+					kind: outlineTypeTable[item.kind] || monaco.languages.SymbolKind.Variable,
+					location: {
+						uri: resource,
+						range: this._textSpanToRange(resource, item.spans[0])
+					},
+					containerName: containerLabel
+				};
+
+				if (item.childItems && item.childItems.length > 0) {
+					for (let child of item.childItems) {
+						convert(bucket, child, result.name);
+					}
+				}
+
+				bucket.push(result);
+			}
+
+			let result: monaco.languages.SymbolInformation[] = [];
+			items.forEach(item => convert(result, item));
+			return result;
+		}));
+	}
+}
+
+export class Kind {
+	public static unknown:string = '';
+	public static keyword:string = 'keyword';
+	public static script:string = 'script';
+	public static module:string = 'module';
+	public static class:string = 'class';
+	public static interface:string = 'interface';
+	public static type:string = 'type';
+	public static enum:string = 'enum';
+	public static variable:string = 'var';
+	public static localVariable:string = 'local var';
+	public static function:string = 'function';
+	public static localFunction:string = 'local function';
+	public static memberFunction:string = 'method';
+	public static memberGetAccessor:string = 'getter';
+	public static memberSetAccessor:string = 'setter';
+	public static memberVariable:string = 'property';
+	public static constructorImplementation:string = 'constructor';
+	public static callSignature:string = 'call';
+	public static indexSignature:string = 'index';
+	public static constructSignature:string = 'construct';
+	public static parameter:string = 'parameter';
+	public static typeParameter:string = 'type parameter';
+	public static primitiveType:string = 'primitive type';
+	public static label:string = 'label';
+	public static alias:string = 'alias';
+	public static const:string = 'const';
+	public static let:string = 'let';
+	public static warning:string = 'warning';
+}
+
+let outlineTypeTable: { [kind: string]: monaco.languages.SymbolKind } = Object.create(null);
+outlineTypeTable[Kind.module] = monaco.languages.SymbolKind.Module;
+outlineTypeTable[Kind.class] = monaco.languages.SymbolKind.Class;
+outlineTypeTable[Kind.enum] = monaco.languages.SymbolKind.Enum;
+outlineTypeTable[Kind.interface] = monaco.languages.SymbolKind.Interface;
+outlineTypeTable[Kind.memberFunction] = monaco.languages.SymbolKind.Method;
+outlineTypeTable[Kind.memberVariable] = monaco.languages.SymbolKind.Property;
+outlineTypeTable[Kind.memberGetAccessor] = monaco.languages.SymbolKind.Property;
+outlineTypeTable[Kind.memberSetAccessor] = monaco.languages.SymbolKind.Property;
+outlineTypeTable[Kind.variable] = monaco.languages.SymbolKind.Variable;
+outlineTypeTable[Kind.const] = monaco.languages.SymbolKind.Variable;
+outlineTypeTable[Kind.localVariable] = monaco.languages.SymbolKind.Variable;
+outlineTypeTable[Kind.variable] = monaco.languages.SymbolKind.Variable;
+outlineTypeTable[Kind.function] = monaco.languages.SymbolKind.Function;
+outlineTypeTable[Kind.localFunction] = monaco.languages.SymbolKind.Function;
+
+// --- formatting ----
+
+export abstract class FormatHelper extends Adapter {
+	protected static _convertOptions(options: monaco.languages.IFormattingOptions): ts.FormatCodeOptions {
+		return {
+			ConvertTabsToSpaces: options.insertSpaces,
+			TabSize: options.tabSize,
+			IndentSize: options.tabSize,
+			IndentStyle: ts.IndentStyle.Smart,
+			NewLineCharacter: '\n',
+			InsertSpaceAfterCommaDelimiter: true,
+			InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
+			InsertSpaceAfterKeywordsInControlFlowStatements: false,
+			InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: true,
+			InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: true,
+			InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: true,
+			InsertSpaceAfterSemicolonInForStatements: false,
+			InsertSpaceBeforeAndAfterBinaryOperators: true,
+			PlaceOpenBraceOnNewLineForControlBlocks: false,
+			PlaceOpenBraceOnNewLineForFunctions: false
+		};
+	}
+
+	protected _convertTextChanges(uri: Uri, change: ts.TextChange): monaco.editor.ISingleEditOperation {
+		return <monaco.editor.ISingleEditOperation>{
+			text: change.newText,
+			range: this._textSpanToRange(uri, change.span)
+		};
+	}
+}
+
+export class FormatAdapter extends FormatHelper implements monaco.languages.DocumentRangeFormattingEditProvider {
+
+	provideDocumentRangeFormattingEdits(model: monaco.editor.IReadOnlyModel, range: Range, options: monaco.languages.IFormattingOptions, token: CancellationToken): Thenable<monaco.editor.ISingleEditOperation[]> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getFormattingEditsForRange(resource.toString(),
+				this._positionToOffset(resource, { lineNumber: range.startLineNumber, column: range.startColumn }),
+				this._positionToOffset(resource, { lineNumber: range.endLineNumber, column: range.endColumn }),
+				FormatHelper._convertOptions(options));
+		}).then(edits => {
+			if (edits) {
+				return edits.map(edit => this._convertTextChanges(resource, edit));
+			}
+		}));
+	}
+}
+
+export class FormatOnTypeAdapter extends FormatHelper implements monaco.languages.OnTypeFormattingEditProvider {
+
+	get autoFormatTriggerCharacters() {
+		return [';', '}', '\n'];
+	}
+
+	provideOnTypeFormattingEdits(model: monaco.editor.IReadOnlyModel, position: Position, ch: string, options: monaco.languages.IFormattingOptions, token: CancellationToken): Thenable<monaco.editor.ISingleEditOperation[]> {
+		const resource = model.uri;
+
+		return wireCancellationToken(token, this._worker(resource).then(worker => {
+			return worker.getFormattingEditsAfterKeystroke(resource.toString(),
+				this._positionToOffset(resource, position),
+				ch, FormatHelper._convertOptions(options));
+		}).then(edits => {
+			if (edits) {
+				return edits.map(edit => this._convertTextChanges(resource, edit));
+			}
+		}));
+	}
+}
+
+/**
+ * Hook a cancellation token to a WinJS Promise
+ */
+function wireCancellationToken<T>(token: CancellationToken, promise: Promise<T>): Thenable<T> {
+	token.onCancellationRequested(() => promise.cancel());
+	return promise;
+}

+ 110 - 0
src/mode.ts

@@ -0,0 +1,110 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import {Language, createTokenizationSupport} from './tokenization';
+import {LanguageServiceDefaults, typeScriptDefaults, javaScriptDefaults, LanguageServiceMode} from './typescript';
+import {WorkerManager} from './workerManager';
+import {TypeScriptWorker} from './worker';
+import * as languageFeatures from './languageFeatures';
+
+import Promise = monaco.Promise;
+import Uri = monaco.Uri;
+import IDisposable = monaco.IDisposable;
+
+export function setupTypeScript(): void {
+	setupMode(
+		typeScriptDefaults,
+		'typescript',
+		Language.TypeScript
+	);
+}
+
+export function setupJavaScript(): void {
+	setupMode(
+		javaScriptDefaults,
+		'javascript',
+		Language.EcmaScript5
+	);
+}
+
+function setupMode(defaults:LanguageServiceDefaults, modeId:string, language:Language): void {
+
+	let disposables: IDisposable[] = [];
+
+	const client = new WorkerManager(defaults);
+	disposables.push(client);
+
+	const worker = (first: Uri, ...more: Uri[]): Promise<TypeScriptWorker> => {
+		return client.getLanguageServiceWorker(...[first].concat(more));
+	};
+
+	disposables.push(monaco.languages.registerCompletionItemProvider(modeId, new languageFeatures.SuggestAdapter(worker)));
+	disposables.push(monaco.languages.registerSignatureHelpProvider(modeId, new languageFeatures.SignatureHelpAdapter(worker)));
+	disposables.push(monaco.languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker)));
+	disposables.push(monaco.languages.registerDocumentHighlightProvider(modeId, new languageFeatures.OccurrencesAdapter(worker)));
+	disposables.push(monaco.languages.registerDefinitionProvider(modeId, new languageFeatures.DefinitionAdapter(worker)));
+	disposables.push(monaco.languages.registerReferenceProvider(modeId, new languageFeatures.ReferenceAdapter(worker)));
+	disposables.push(monaco.languages.registerDocumentSymbolProvider(modeId, new languageFeatures.OutlineAdapter(worker)));
+	disposables.push(monaco.languages.registerDocumentRangeFormattingEditProvider(modeId, new languageFeatures.FormatAdapter(worker)));
+	disposables.push(monaco.languages.registerOnTypeFormattingEditProvider(modeId, new languageFeatures.FormatOnTypeAdapter(worker)));
+	disposables.push(new languageFeatures.DiagnostcsAdapter(defaults, modeId, worker));
+	disposables.push(monaco.languages.setLanguageConfiguration(modeId, richEditConfiguration));
+	disposables.push(monaco.languages.setTokensProvider(modeId, createTokenizationSupport(language)));
+}
+
+const richEditConfiguration:monaco.languages.IRichLanguageConfiguration = {
+	wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
+
+	comments: {
+		lineComment: '//',
+		blockComment: ['/*', '*/']
+	},
+
+	brackets: [
+		['{', '}'],
+		['[', ']'],
+		['(', ')']
+	],
+
+	onEnterRules: [
+		{
+			// e.g. /** | */
+			beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
+			afterText: /^\s*\*\/$/,
+			action: { indentAction: monaco.languages.IndentAction.IndentOutdent, appendText: ' * ' }
+		},
+		{
+			// e.g. /** ...|
+			beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
+			action: { indentAction: monaco.languages.IndentAction.None, appendText: ' * ' }
+		},
+		{
+			// e.g.  * ...|
+			beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
+			action: { indentAction: monaco.languages.IndentAction.None, appendText: '* ' }
+		},
+		{
+			// e.g.  */|
+			beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
+			action: { indentAction: monaco.languages.IndentAction.None, removeText: 1 }
+		}
+	],
+
+	__electricCharacterSupport: {
+		docComment: {scope:'comment.doc', open:'/**', lineStart:' * ', close:' */'}
+	},
+
+	autoClosingPairs: [
+		{ open: '{', close: '}' },
+		{ open: '[', close: ']' },
+		{ open: '(', close: ')' },
+		{ open: '"', close: '"', notIn: ['string'] },
+		{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
+		{ open: '`', close: '`' }
+	]
+};
+
+

+ 35 - 0
src/monaco.contribution.ts

@@ -0,0 +1,35 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import * as mode from './mode';
+
+declare var require:<T>(moduleId:[string], callback:(module:T)=>void)=>void;
+
+function withMode(callback:(module:typeof mode)=>void): void {
+	require<typeof mode>(['vs/language/typescript/src/mode'], callback);
+}
+
+monaco.languages.register({
+	id: 'typescript',
+	extensions: ['.ts'],
+	aliases: ['TypeScript', 'ts', 'typescript'],
+	mimetypes: ['text/typescript']
+});
+monaco.languages.onLanguage('typescript', () => {
+	withMode((mode) => mode.setupTypeScript());
+});
+
+monaco.languages.register({
+	id: 'javascript',
+	extensions: ['.js', '.es6'],
+	firstLine: '^#!.*\\bnode',
+	filenames: ['jakefile'],
+	aliases: ['JavaScript', 'javascript', 'js'],
+	mimetypes: ['text/javascript'],
+});
+monaco.languages.onLanguage('javascript', () => {
+	withMode((mode) => mode.setupJavaScript());
+});

+ 163 - 0
src/tokenization.ts

@@ -0,0 +1,163 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import ts = require('../lib/typescriptServices');
+
+export enum Language {
+	TypeScript,
+	EcmaScript5
+}
+
+export function createTokenizationSupport(language:Language): monaco.languages.TokensProvider {
+
+	var classifier = ts.createClassifier(),
+		bracketTypeTable = language === Language.TypeScript ? tsBracketTypeTable : jsBracketTypeTable,
+		tokenTypeTable = language === Language.TypeScript ? tsTokenTypeTable : jsTokenTypeTable;
+
+	return {
+		getInitialState: () => new State(language, ts.EndOfLineState.None, false),
+		tokenize: (line, state) => tokenize(bracketTypeTable, tokenTypeTable, classifier, <State> state, line)
+	};
+}
+
+class State implements monaco.languages.IState {
+
+	public language: Language;
+	public eolState: ts.EndOfLineState;
+	public inJsDocComment: boolean;
+
+	constructor(language:Language, eolState: ts.EndOfLineState, inJsDocComment: boolean) {
+		this.language = language;
+		this.eolState = eolState;
+		this.inJsDocComment = inJsDocComment;
+	}
+
+	public clone(): State {
+		return new State(this.language, this.eolState, this.inJsDocComment);
+	}
+
+	public equals(other:monaco.languages.IState):boolean {
+		if(other === this) {
+			return true;
+		}
+		if(!other || !(other instanceof State)) {
+			return false;
+		}
+		if (this.eolState !== (<State> other).eolState) {
+			return false;
+		}
+		if(this.inJsDocComment !== (<State> other).inJsDocComment) {
+			return false;
+		}
+		return true;
+	}
+}
+
+function tokenize(bracketTypeTable: { [i: number]: string }, tokenTypeTable: { [i: number]: string },
+	classifier: ts.Classifier, state: State, text: string): monaco.languages.ILineTokens {
+
+	// Create result early and fill in tokens
+	var ret = {
+		tokens: <monaco.languages.IToken[]>[],
+		endState: new State(state.language, ts.EndOfLineState.None, false)
+	};
+
+	function appendFn(startIndex:number, type:string):void {
+		if(ret.tokens.length === 0 || ret.tokens[ret.tokens.length - 1].scopes !== type) {
+			ret.tokens.push({
+				startIndex: startIndex,
+				scopes: type
+			});
+		}
+	}
+
+	var isTypeScript = state.language === Language.TypeScript;
+
+	// shebang statement, #! /bin/node
+	if (!isTypeScript && checkSheBang(0, text, appendFn)) {
+		return ret;
+	}
+
+	var result = classifier.getClassificationsForLine(text, state.eolState, true),
+		offset = 0;
+
+	ret.endState.eolState = result.finalLexState;
+	ret.endState.inJsDocComment = result.finalLexState === ts.EndOfLineState.InMultiLineCommentTrivia && (state.inJsDocComment || /\/\*\*.*$/.test(text));
+
+	for (let entry of result.entries) {
+
+		var type: string;
+
+		if (entry.classification === ts.TokenClass.Punctuation) {
+			// punctions: check for brackets: (){}[]
+			var ch = text.charCodeAt(offset);
+			type = bracketTypeTable[ch] || tokenTypeTable[entry.classification];
+			appendFn(offset, type);
+
+		} else if (entry.classification === ts.TokenClass.Comment) {
+			// comments: check for JSDoc, block, and line comments
+			if (ret.endState.inJsDocComment || /\/\*\*.*\*\//.test(text.substr(offset, entry.length))) {
+				appendFn(offset, isTypeScript ? 'comment.doc.ts' : 'comment.doc.js');
+			} else {
+				appendFn(offset, isTypeScript ? 'comment.ts' : 'comment.js');
+			}
+		} else {
+			// everything else
+			appendFn(offset,
+				tokenTypeTable[entry.classification] || '');
+		}
+
+		offset += entry.length;
+	}
+
+	return ret;
+}
+
+interface INumberStringDictionary {
+	[idx: number]: string;
+}
+
+var tsBracketTypeTable:INumberStringDictionary = Object.create(null);
+tsBracketTypeTable['('.charCodeAt(0)] = 'delimiter.parenthesis.ts';
+tsBracketTypeTable[')'.charCodeAt(0)] = 'delimiter.parenthesis.ts';
+tsBracketTypeTable['{'.charCodeAt(0)] = 'delimiter.bracket.ts';
+tsBracketTypeTable['}'.charCodeAt(0)] = 'delimiter.bracket.ts';
+tsBracketTypeTable['['.charCodeAt(0)] = 'delimiter.array.ts';
+tsBracketTypeTable[']'.charCodeAt(0)] = 'delimiter.array.ts';
+
+var tsTokenTypeTable:INumberStringDictionary = Object.create(null);
+tsTokenTypeTable[ts.TokenClass.Identifier] = 'identifier.ts';
+tsTokenTypeTable[ts.TokenClass.Keyword] = 'keyword.ts';
+tsTokenTypeTable[ts.TokenClass.Operator] = 'delimiter.ts';
+tsTokenTypeTable[ts.TokenClass.Punctuation] = 'delimiter.ts';
+tsTokenTypeTable[ts.TokenClass.NumberLiteral] = 'number.ts';
+tsTokenTypeTable[ts.TokenClass.RegExpLiteral] = 'regexp.ts';
+tsTokenTypeTable[ts.TokenClass.StringLiteral] = 'string.ts';
+
+var jsBracketTypeTable:INumberStringDictionary = Object.create(null);
+jsBracketTypeTable['('.charCodeAt(0)] = 'delimiter.parenthesis.js';
+jsBracketTypeTable[')'.charCodeAt(0)] = 'delimiter.parenthesis.js';
+jsBracketTypeTable['{'.charCodeAt(0)] = 'delimiter.bracket.js';
+jsBracketTypeTable['}'.charCodeAt(0)] = 'delimiter.bracket.js';
+jsBracketTypeTable['['.charCodeAt(0)] = 'delimiter.array.js';
+jsBracketTypeTable[']'.charCodeAt(0)] = 'delimiter.array.js';
+
+var jsTokenTypeTable:INumberStringDictionary = Object.create(null);
+jsTokenTypeTable[ts.TokenClass.Identifier] = 'identifier.js';
+jsTokenTypeTable[ts.TokenClass.Keyword] = 'keyword.js';
+jsTokenTypeTable[ts.TokenClass.Operator] = 'delimiter.js';
+jsTokenTypeTable[ts.TokenClass.Punctuation] = 'delimiter.js';
+jsTokenTypeTable[ts.TokenClass.NumberLiteral] = 'number.js';
+jsTokenTypeTable[ts.TokenClass.RegExpLiteral] = 'regexp.js';
+jsTokenTypeTable[ts.TokenClass.StringLiteral] = 'string.js';
+
+
+function checkSheBang(deltaOffset: number, line: string, appendFn: (startIndex: number, type: string) => void): boolean {
+	if (line.indexOf('#!') === 0) {
+		appendFn(deltaOffset, 'comment.shebang');
+		return true;
+	}
+}

+ 96 - 0
src/typescript.ts

@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import * as ts from '../lib/typescriptServices';
+import {TypeScriptWorker} from './worker';
+
+import Emitter = monaco.Emitter;
+import Promise = monaco.Promise;
+import Uri = monaco.Uri;
+import IDisposable = monaco.IDisposable;
+
+// --- TypeScript configuration and defaults ---------
+
+export interface DiagnosticsOptions {
+	noSemanticValidation?: boolean;
+	noSyntaxValidation?: boolean;
+}
+
+export class LanguageServiceDefaults {
+
+	private _onDidChange = new Emitter<LanguageServiceDefaults>();
+	private _extraLibs: { [path: string]: string };
+	private _compilerOptions: ts.CompilerOptions;
+	private _diagnosticsOptions: DiagnosticsOptions;
+
+	constructor(compilerOptions: ts.CompilerOptions, diagnosticsOptions: DiagnosticsOptions) {
+		this._extraLibs = Object.create(null);
+		this.setCompilerOptions(compilerOptions);
+		this.setDiagnosticsOptions(diagnosticsOptions);
+	}
+
+	get onDidChange(): monaco.IEvent<LanguageServiceDefaults>{
+		return this._onDidChange.event;
+	}
+
+	get extraLibs(): { [path: string]: string } {
+		return Object.freeze(this._extraLibs);
+	}
+
+	addExtraLib(content: string, filePath?: string): IDisposable {
+		if (typeof filePath === 'undefined') {
+			filePath = `ts:extralib-${Date.now()}`;
+		}
+
+		if (this._extraLibs[filePath]) {
+			throw new Error(`${filePath} already a extra lib`);
+		}
+
+		this._extraLibs[filePath] = content;
+		this._onDidChange.fire(this);
+
+		return {
+			dispose: () => {
+				if (delete this._extraLibs[filePath]) {
+					this._onDidChange.fire(this);
+				}
+			}
+		};
+	}
+
+	get compilerOptions(): ts.CompilerOptions {
+		return this._compilerOptions;
+	}
+
+	setCompilerOptions(options: ts.CompilerOptions): void {
+		this._compilerOptions = options || Object.create(null);
+		this._onDidChange.fire(this);
+	}
+
+	get diagnosticsOptions(): DiagnosticsOptions {
+		return this._diagnosticsOptions;
+	}
+
+	setDiagnosticsOptions(options: DiagnosticsOptions): void {
+		this._diagnosticsOptions = options || Object.create(null);
+		this._onDidChange.fire(this);
+	}
+}
+
+export const typeScriptDefaults = new LanguageServiceDefaults(
+	{ allowNonTsExtensions: true, target: ts.ScriptTarget.Latest },
+	{ noSemanticValidation: false, noSyntaxValidation: false });
+
+export const javaScriptDefaults = new LanguageServiceDefaults(
+	{ allowNonTsExtensions: true, allowJs: true, target: ts.ScriptTarget.Latest },
+	{ noSemanticValidation: true, noSyntaxValidation: false });
+
+
+// --- TypeScript worker protocol ---------
+
+export interface LanguageServiceMode {
+	getLanguageServiceWorker(...resources: Uri[]): Promise<TypeScriptWorker>;
+}

+ 181 - 0
src/worker.ts

@@ -0,0 +1,181 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import ts = require('../lib/typescriptServices');
+import {contents as libdts} from '../lib/lib-ts';
+import {contents as libes6ts} from '../lib/lib-es6-ts';
+
+import Promise = monaco.Promise;
+
+const DEFAULT_LIB = {
+	NAME: 'defaultLib:lib.d.ts',
+	CONTENTS: libdts
+};
+
+const ES6_LIB = {
+	NAME: 'defaultLib:lib.es6.d.ts',
+	CONTENTS: libes6ts
+};
+
+export class TypeScriptWorker implements ts.LanguageServiceHost {
+
+	// --- model sync -----------------------
+
+	// private _models: { [uri: string]: MirrorModel2 } = Object.create(null);
+	private _extraLibs: { [fileName: string]: string } = Object.create(null);
+	private _languageService = ts.createLanguageService(this);
+	private _compilerOptions: ts.CompilerOptions;
+
+	// --- default ---------
+
+	acceptDefaults(options:ts.CompilerOptions, extraLibs:{ [path: string]: string }): Promise<void> {
+		this._compilerOptions = options;
+		this._extraLibs = extraLibs;
+		return;
+	}
+
+	// --- language service host ---------------
+
+	getCompilationSettings(): ts.CompilerOptions {
+		return this._compilerOptions;
+	}
+
+	getScriptFileNames(): string[] {
+		let models = monaco.worker.mirrorModels.map(model => model.uri.toString());
+		return models.concat(Object.keys(this._extraLibs));
+	}
+
+	private _getModel(fileName:string): monaco.worker.IMirrorModel {
+		let models = monaco.worker.mirrorModels;
+		for (let i = 0; i < models.length; i++) {
+			if (models[i].uri.toString() === fileName) {
+				return models[i];
+			}
+		}
+		return null;
+	}
+
+	getScriptVersion(fileName: string): string {
+		let model = this._getModel(fileName);
+		if (model) {
+			return model.version.toString();
+		} else if (this.isDefaultLibFileName(fileName) || fileName in this._extraLibs) {
+			// extra lib and default lib are static
+			return '1';
+		}
+	}
+
+	getScriptSnapshot(fileName: string): ts.IScriptSnapshot {
+		let text: string;
+		let model = this._getModel(fileName);
+		if (model) {
+			// a true editor model
+			text = model.getText();
+
+		} else if (fileName in this._extraLibs) {
+			// static extra lib
+			text = this._extraLibs[fileName];
+
+		} else if (fileName === DEFAULT_LIB.NAME) {
+			text = DEFAULT_LIB.CONTENTS;
+		} else if (fileName === ES6_LIB.NAME) {
+			text = ES6_LIB.CONTENTS;
+		} else {
+			return;
+		}
+
+		return <ts.IScriptSnapshot>{
+			getText: (start, end) => text.substring(start, end),
+			getLength: () => text.length,
+			getChangeRange: () => undefined
+		};
+	}
+
+	getCurrentDirectory(): string {
+		return '';
+	}
+
+	getDefaultLibFileName(options: ts.CompilerOptions): string {
+		// TODO@joh support lib.es7.d.ts
+		return options.target > ts.ScriptTarget.ES5 ? DEFAULT_LIB.NAME : ES6_LIB.NAME;
+	}
+
+	isDefaultLibFileName(fileName: string): boolean {
+		return fileName === this.getDefaultLibFileName(this._compilerOptions);
+	}
+
+	// --- language features
+
+	getSyntacticDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
+		const diagnostics = this._languageService.getSyntacticDiagnostics(fileName);
+		diagnostics.forEach(diag => diag.file = undefined); // diag.file cannot be JSON'yfied
+		return Promise.as(diagnostics);
+	}
+
+	getSemanticDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
+		const diagnostics = this._languageService.getSemanticDiagnostics(fileName);
+		diagnostics.forEach(diag => diag.file = undefined); // diag.file cannot be JSON'yfied
+		return Promise.as(diagnostics);
+	}
+
+	getCompilerOptionsDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
+		const diagnostics = this._languageService.getCompilerOptionsDiagnostics();
+		diagnostics.forEach(diag => diag.file = undefined); // diag.file cannot be JSON'yfied
+		return Promise.as(diagnostics);
+	}
+
+	getCompletionsAtPosition(fileName: string, position:number): Promise<ts.CompletionInfo> {
+		return Promise.as(this._languageService.getCompletionsAtPosition(fileName, position));
+	}
+
+	getCompletionEntryDetails(fileName: string, position: number, entry: string): Promise<ts.CompletionEntryDetails> {
+		return Promise.as(this._languageService.getCompletionEntryDetails(fileName, position, entry));
+	}
+
+	getSignatureHelpItems(fileName: string, position:number): Promise<ts.SignatureHelpItems> {
+		return Promise.as(this._languageService.getSignatureHelpItems(fileName, position));
+	}
+
+	getQuickInfoAtPosition(fileName: string, position: number): Promise<ts.QuickInfo> {
+		return Promise.as(this._languageService.getQuickInfoAtPosition(fileName, position));
+	}
+
+	getOccurrencesAtPosition(fileName: string, position: number): Promise<ts.ReferenceEntry[]> {
+		return Promise.as(this._languageService.getOccurrencesAtPosition(fileName, position));
+	}
+
+	getDefinitionAtPosition(fileName: string, position: number): Promise<ts.DefinitionInfo[]> {
+		return Promise.as(this._languageService.getDefinitionAtPosition(fileName, position));
+	}
+
+	getReferencesAtPosition(fileName: string, position: number): Promise<ts.ReferenceEntry[]> {
+		return Promise.as(this._languageService.getReferencesAtPosition(fileName, position));
+	}
+
+	getNavigationBarItems(fileName: string): Promise<ts.NavigationBarItem[]> {
+		return Promise.as(this._languageService.getNavigationBarItems(fileName));
+	}
+
+	getFormattingEditsForDocument(fileName: string, options: ts.FormatCodeOptions): Promise<ts.TextChange[]> {
+		return Promise.as(this._languageService.getFormattingEditsForDocument(fileName, options));
+	}
+
+	getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): Promise<ts.TextChange[]> {
+		return Promise.as(this._languageService.getFormattingEditsForRange(fileName, start, end, options));
+	}
+
+	getFormattingEditsAfterKeystroke(fileName: string, postion: number, ch: string, options: ts.FormatCodeOptions): Promise<ts.TextChange[]> {
+		return Promise.as(this._languageService.getFormattingEditsAfterKeystroke(fileName, postion, ch, options));
+	}
+
+	getEmitOutput(fileName: string): Promise<ts.EmitOutput> {
+		return Promise.as(this._languageService.getEmitOutput(fileName));
+	}
+}
+
+export function create(): TypeScriptWorker {
+	return new TypeScriptWorker();
+}

+ 104 - 0
src/workerManager.ts

@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import {LanguageServiceMode, LanguageServiceDefaults} from './typescript';
+import {TypeScriptWorker} from './worker';
+
+import Promise = monaco.Promise;
+import IDisposable = monaco.IDisposable;
+import Uri = monaco.Uri;
+
+const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
+
+export class WorkerManager {
+
+	private _defaults: LanguageServiceDefaults;
+	private _idleCheckInterval: number;
+	private _lastUsedTime: number;
+	private _configChangeListener: IDisposable;
+
+	private _worker: monaco.editor.MonacoWebWorker<TypeScriptWorker>;
+	private _client: Promise<TypeScriptWorker>;
+
+	constructor(defaults: LanguageServiceDefaults) {
+		this._defaults = defaults;
+		this._worker = null;
+		this._idleCheckInterval = setInterval(() => this._checkIfIdle(), 30 * 1000);
+		this._lastUsedTime = 0;
+		this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
+	}
+
+	private _stopWorker(): void {
+		if (this._worker) {
+			this._worker.dispose();
+			this._worker = null;
+		}
+		this._client = null;
+	}
+
+	dispose(): void {
+		clearInterval(this._idleCheckInterval);
+		this._configChangeListener.dispose();
+		this._stopWorker();
+	}
+
+	private _checkIfIdle(): void {
+		if (!this._worker) {
+			return;
+		}
+		let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
+		if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
+			this._stopWorker();
+		}
+	}
+
+	private _getClient(): Promise<TypeScriptWorker> {
+		this._lastUsedTime = Date.now();
+
+		if (!this._client) {
+			this._worker = monaco.editor.createWebWorker<TypeScriptWorker>({
+				moduleId: 'vs/language/typescript/src/worker',
+			});
+
+			let _client:TypeScriptWorker = null;
+
+			// avoid cancellation
+			this._client = toShallowCancelPromise(
+				this._worker.getProxy().then((client) => {
+					_client = client;
+				}).then(_ => {
+					const {compilerOptions, extraLibs} = this._defaults;
+					return _client.acceptDefaults(compilerOptions, extraLibs);
+				}).then(_ => _client)
+			);
+		}
+
+		return this._client;
+	}
+
+	getLanguageServiceWorker(...resources: Uri[]): Promise<TypeScriptWorker> {
+		let _client:TypeScriptWorker;
+		return this._getClient().then((client) => {
+			_client = client
+		}).then(_ => {
+			return this._worker.withSyncedResources(resources)
+		}).then(_ => _client);
+	}
+}
+
+function toShallowCancelPromise<T>(p:Promise<T>): Promise<T> {
+	let completeCallback: (value:T)=>void;
+	let errorCallback: (err:any)=>void;
+
+	let r = new Promise<T>((c, e) => {
+		completeCallback = c;
+		errorCallback = e;
+	}, () => { });
+
+	p.then(completeCallback, errorCallback);
+
+	return r;
+}

+ 12 - 0
test/all.js

@@ -0,0 +1,12 @@
+var requirejs = require("requirejs");
+
+requirejs.config({
+    baseUrl: 'out',
+    nodeRequire: require
+});
+
+ requirejs([
+     'test/tokenization.test'
+], function() {
+    run(); // We can launch the tests!
+});

+ 44 - 0
test/assert.d.ts

@@ -0,0 +1,44 @@
+declare module "assert" {
+    function internal (value: any, message?: string): void;
+    namespace internal {
+        export class AssertionError implements Error {
+            name: string;
+            message: string;
+            actual: any;
+            expected: any;
+            operator: string;
+            generatedMessage: boolean;
+
+            constructor(options?: {message?: string; actual?: any; expected?: any;
+                                  operator?: string; stackStartFunction?: Function});
+        }
+
+        export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
+        export function ok(value: any, message?: string): void;
+        export function equal(actual: any, expected: any, message?: string): void;
+        export function notEqual(actual: any, expected: any, message?: string): void;
+        export function deepEqual(actual: any, expected: any, message?: string): void;
+        export function notDeepEqual(acutal: any, expected: any, message?: string): void;
+        export function strictEqual(actual: any, expected: any, message?: string): void;
+        export function notStrictEqual(actual: any, expected: any, message?: string): void;
+        export function deepStrictEqual(actual: any, expected: any, message?: string): void;
+        export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
+        export var throws: {
+            (block: Function, message?: string): void;
+            (block: Function, error: Function, message?: string): void;
+            (block: Function, error: RegExp, message?: string): void;
+            (block: Function, error: (err: any) => boolean, message?: string): void;
+        };
+
+        export var doesNotThrow: {
+            (block: Function, message?: string): void;
+            (block: Function, error: Function, message?: string): void;
+            (block: Function, error: RegExp, message?: string): void;
+            (block: Function, error: (err: any) => boolean, message?: string): void;
+        };
+
+        export function ifError(value: any): void;
+    }
+
+    export = internal;
+}

+ 13 - 0
test/mocha.d.ts

@@ -0,0 +1,13 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+declare function run(): void;
+
+declare function suite(name: string, fn: (err?)=>void);
+declare function test(name: string, fn: (done?: (err?)=>void)=>void);
+declare function suiteSetup(fn: (done?: (err?)=>void)=>void);
+declare function suiteTeardown(fn: (done?: (err?)=>void)=>void);
+declare function setup(fn: (done?: (err?)=>void)=>void);
+declare function teardown(fn: (done?: (err?)=>void)=>void);

+ 3 - 0
test/mocha.opts

@@ -0,0 +1,3 @@
+--delay
+--ui tdd
+test/all.js

+ 502 - 0
test/tokenization.test.ts

@@ -0,0 +1,502 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import * as assert from 'assert';
+import {createTokenizationSupport, Language} from '../src/tokenization';
+
+suite('tokenization', () => {
+
+	interface ITestItem {
+		line: string;
+		tokens: monaco.languages.IToken[];
+	}
+
+	function executeTokenizationTests(tests:ITestItem[][]): void {
+		let tokenizationSupport = createTokenizationSupport(Language.EcmaScript5);
+		for (let i = 0, len = tests.length; i < len; i++) {
+			assert.ok(true, 'TEST #' + i);
+			executeTokenizationTest(tokenizationSupport, tests[i]);
+		}
+	}
+
+	function executeTokenizationTest(tokenizationSupport: monaco.languages.TokensProvider, tests:ITestItem[]): void {
+		let state = tokenizationSupport.getInitialState();
+		for (let i = 0, len = tests.length; i < len; i++) {
+			assert.ok(true, tests[i].line);
+
+			let result = tokenizationSupport.tokenize(tests[i].line, state);
+
+			if (tests[i].tokens) {
+				assert.deepEqual(result.tokens, tests[i].tokens, 'Tokenizing line ' + tests[i].line + ': ' + JSON.stringify(tests[i].tokens, null, '\t'));
+			}
+
+			state = result.endState;
+		}
+	}
+
+	test('', () => {
+		executeTokenizationTests([
+
+			// Keywords
+			[{
+			line: 'var x = function() { };',
+			tokens: [
+				{ startIndex: 0, scopes: 'keyword.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'keyword.js' },
+				{ startIndex: 16, scopes: 'delimiter.parenthesis.js' },
+				{ startIndex: 18, scopes: '' },
+				{ startIndex: 19, scopes: 'delimiter.bracket.js' },
+				{ startIndex: 20, scopes: '' },
+				{ startIndex: 21, scopes: 'delimiter.bracket.js' },
+				{ startIndex: 22, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: '    var    ',
+			tokens: [
+				{ startIndex: 0, scopes: '' },
+				{ startIndex: 4, scopes: 'keyword.js' },
+				{ startIndex: 7, scopes: '' }
+			]}],
+
+			// Comments - single line
+			[{
+			line: '//',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '    // a comment',
+			tokens: [
+				{ startIndex: 0, scopes: '' },
+				{ startIndex: 4, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '// a comment',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '// a comment /*',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '// a comment /**',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '//sticky comment',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: 'var x = 1; // my comment // is a nice one',
+			tokens: [
+				{ startIndex: 0, scopes: 'keyword.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'number.js' },
+				{ startIndex: 9, scopes: 'delimiter.js' },
+				{ startIndex: 10, scopes: '' },
+				{ startIndex: 11, scopes: 'comment.js' }
+			]}],
+
+			// Comments - range comment, single line
+			[{
+			line: '/* a simple comment */',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: 'var x = /* a simple comment */ 1;',
+			tokens: [
+				{ startIndex: 0, scopes: 'keyword.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'comment.js' },
+				{ startIndex: 30, scopes: '' },
+				{ startIndex: 31, scopes: 'number.js' },
+				{ startIndex: 32, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: 'x = /**/;',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'comment.js' },
+				{ startIndex: 8, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: 'x = /*/;',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'comment.js' }
+			]}],
+
+			// Comments - range comment, multi lines
+			[{
+			line: '/* a multiline comment',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}, {
+			line: 'can actually span',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}, {
+			line: 'multiple lines */',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: 'var x = /* start a comment',
+			tokens: [
+				{ startIndex: 0, scopes: 'keyword.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'comment.js' }
+			]}, {
+			line: ' a ',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}, {
+			line: 'and end it */ var a = 2;',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' },
+				{ startIndex: 13, scopes: '' },
+				{ startIndex: 14, scopes: 'keyword.js' },
+				{ startIndex: 17, scopes: '' },
+				{ startIndex: 18, scopes: 'identifier.js' },
+				{ startIndex: 19, scopes: '' },
+				{ startIndex: 20, scopes: 'delimiter.js' },
+				{ startIndex: 21, scopes: '' },
+				{ startIndex: 22, scopes: 'number.js' },
+				{ startIndex: 23, scopes: 'delimiter.js' }
+			]}],
+
+			// Strings
+			[{
+			line: 'var a = \'a\';',
+			tokens: [
+				{ startIndex: 0, scopes: 'keyword.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'string.js' },
+				{ startIndex: 11, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: '"use strict";',
+			tokens: [
+				{ startIndex: 0, scopes: 'string.js' },
+				{ startIndex: 12, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: 'b = a + " \'cool\'  "',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'string.js' }
+			]}],
+
+			[{
+			line: '"escaping \\"quotes\\" is cool"',
+			tokens: [
+				{ startIndex: 0, scopes: 'string.js' }
+			]}],
+
+			[{
+			line: '\'\'\'',
+			tokens: [
+				{ startIndex: 0, scopes: 'string.js' }
+			]}],
+
+			[{
+			line: '\'\\\'\'',
+			tokens: [
+				{ startIndex: 0, scopes: 'string.js' }
+			]}],
+
+			[{
+			line: '\'be careful \\not to escape\'',
+			tokens: [
+				{ startIndex: 0, scopes: 'string.js' }
+			]}],
+
+			// Numbers
+			[{
+			line: '0',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: ' 0',
+			tokens: [
+				{ startIndex: 0, scopes: '' },
+				{ startIndex: 1, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: ' 0 ',
+			tokens: [
+				{ startIndex: 0, scopes: '' },
+				{ startIndex: 1, scopes: 'number.js' },
+				{ startIndex: 2, scopes: '' }
+			]}],
+
+			[{
+			line: '0 ',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: '' }
+			]}],
+
+			[{
+			line: '0+0',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: 'delimiter.js' },
+				{ startIndex: 2, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: '100+10',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 3, scopes: 'delimiter.js' },
+				{ startIndex: 4, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: '0 + 0',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: '0123',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: '01239',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' }
+			]}],
+
+			[{
+			line: '0x',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: 'identifier.js' }
+			]}],
+
+			[{
+			line: '0x123',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' }
+			]}],
+
+			// Regular Expressions
+			[{
+			line: '//',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '/**/',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '/***/',
+			tokens: [
+				{ startIndex: 0, scopes: 'comment.doc.js' }
+			]}],
+
+			[{
+			line: '5 / 3;',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'number.js' },
+				{ startIndex: 5, scopes: 'delimiter.js' }
+			]}],
+
+			// Advanced regular expressions
+			[{
+			line: '1 / 2; /* comment',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'number.js' },
+				{ startIndex: 5, scopes: 'delimiter.js' },
+				{ startIndex: 6, scopes: '' },
+				{ startIndex: 7, scopes: 'comment.js' }
+			]}],
+
+			[{
+			line: '1 / 2 / x / b;',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'number.js' },
+				{ startIndex: 5, scopes: '' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'identifier.js' },
+				{ startIndex: 9, scopes: '' },
+				{ startIndex: 10, scopes: 'delimiter.js' },
+				{ startIndex: 11, scopes: '' },
+				{ startIndex: 12, scopes: 'identifier.js' },
+				{ startIndex: 13, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: 'a /ads/ b;',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: 'identifier.js' },
+				{ startIndex: 6, scopes: 'delimiter.js' },
+				{ startIndex: 7, scopes: '' },
+				{ startIndex: 8, scopes: 'identifier.js' },
+				{ startIndex: 9, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: '1/(2/3)/2/3;',
+			tokens: [
+				{ startIndex: 0, scopes: 'number.js' },
+				{ startIndex: 1, scopes: 'delimiter.js' },
+				{ startIndex: 2, scopes: 'delimiter.parenthesis.js' },
+				{ startIndex: 3, scopes: 'number.js' },
+				{ startIndex: 4, scopes: 'delimiter.js' },
+				{ startIndex: 5, scopes: 'number.js' },
+				{ startIndex: 6, scopes: 'delimiter.parenthesis.js' },
+				{ startIndex: 7, scopes: 'delimiter.js' },
+				{ startIndex: 8, scopes: 'number.js' },
+				{ startIndex: 9, scopes: 'delimiter.js' },
+				{ startIndex: 10, scopes: 'number.js' },
+				{ startIndex: 11, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: '{ key: 123 }',
+			tokens: [
+				{ startIndex: 0, scopes: 'delimiter.bracket.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: 'delimiter.js' },
+				{ startIndex: 6, scopes: '' },
+				{ startIndex: 7, scopes: 'number.js' },
+				{ startIndex: 10, scopes: '' },
+				{ startIndex: 11, scopes: 'delimiter.bracket.js' }
+			]}],
+
+			[{
+			line: '[1,2,3]',
+			tokens: [
+				{ startIndex: 0, scopes: 'delimiter.array.js' },
+				{ startIndex: 1, scopes: 'number.js' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: 'number.js' },
+				{ startIndex: 4, scopes: 'delimiter.js' },
+				{ startIndex: 5, scopes: 'number.js' },
+				{ startIndex: 6, scopes: 'delimiter.array.js' }
+			]}],
+
+			[{
+			line: 'foo(123);',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 3, scopes: 'delimiter.parenthesis.js' },
+				{ startIndex: 4, scopes: 'number.js' },
+				{ startIndex: 7, scopes: 'delimiter.parenthesis.js' },
+				{ startIndex: 8, scopes: 'delimiter.js' }
+			]}],
+
+			[{
+			line: '{a:{b:[]}}',
+			tokens: [
+				{ startIndex: 0, scopes: 'delimiter.bracket.js' },
+				{ startIndex: 1, scopes: 'identifier.js' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: 'delimiter.bracket.js' },
+				{ startIndex: 4, scopes: 'identifier.js' },
+				{ startIndex: 5, scopes: 'delimiter.js' },
+				{ startIndex: 6, scopes: 'delimiter.array.js' },
+				{ startIndex: 8, scopes: 'delimiter.bracket.js' }
+			]}],
+
+			[{
+			line: 'x = "[{()}]"',
+			tokens: [
+				{ startIndex: 0, scopes: 'identifier.js' },
+				{ startIndex: 1, scopes: '' },
+				{ startIndex: 2, scopes: 'delimiter.js' },
+				{ startIndex: 3, scopes: '' },
+				{ startIndex: 4, scopes: 'string.js' }
+			]}]
+		]);
+	});
+
+})

+ 29 - 0
tsconfig.json

@@ -0,0 +1,29 @@
+{
+  "compilerOptions": {
+    "module": "amd",
+    "outDir": "out",
+    "target": "es5"
+  },
+  "filesGlob": [
+    "src/*.ts",
+    "test/*.ts",
+    "lib/*.d.ts",
+    "node_modules/monaco-editor-core/monaco.d.ts"
+  ],
+  "files": [
+    "src/languageFeatures.ts",
+    "src/mode.ts",
+    "src/monaco.contribution.ts",
+    "src/tokenization.ts",
+    "src/typescript.ts",
+    "src/worker.ts",
+    "src/workerManager.ts",
+    "test/assert.d.ts",
+    "test/mocha.d.ts",
+    "test/tokenization.test.ts",
+    "lib/lib-es6-ts.d.ts",
+    "lib/lib-ts.d.ts",
+    "lib/typescriptServices.d.ts",
+    "node_modules/monaco-editor-core/monaco.d.ts"
+  ]
+}

Some files were not shown because too many files changed in this diff