diff --git a/.gitignore b/.gitignore
index c1b8bd2b3..c342f71ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,6 @@
/.ntvs_analysis.dat
/.ntvs_analysis.dat.tmp
obj/Debug/VSProj.njsproj.FileListAbsolute.txt
-./node_modules
.baseDir.ts
-node_modules/immutable/
-node_modules/react/
-node_modules
\ No newline at end of file
+node_modules/
+/typings/
diff --git a/node_modules/basarat-text-buffer/node_modules/grim/node_modules/coffeestack/node_modules/source-map/.travis.yml b/.travis.yml
similarity index 55%
rename from node_modules/basarat-text-buffer/node_modules/grim/node_modules/coffeestack/node_modules/source-map/.travis.yml
rename to .travis.yml
index ddc9c4f98..650c27d80 100644
--- a/node_modules/basarat-text-buffer/node_modules/grim/node_modules/coffeestack/node_modules/source-map/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
language: node_js
node_js:
- - 0.8
- - "0.10"
\ No newline at end of file
+ - "4.1"
+sudo: false
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5c9faa389..7ffdb9ece 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,6 +17,8 @@ apm link -l
You still have to reload atom with `ctrl+alt+r` to test your changes.
+Now you can use atom-typescript *to develop atom-typescript*. This is covered more in the workflow https://github.com/TypeStrong/atom-typescript/blob/master/CONTRIBUTING.md#workflow
+
(Note: [There is more guidance here](https://github.com/atom/atom/blob/master/docs/contributing-to-packages.md) but what we have is sufficient. `apm link -l` creates a symlink for the folder into `%HOMEPATH%\.atom\packages`)
**Optional**: If you are working on the binaries that are used if we deploy the package to NPM you can run (again from the directory that has `package.json`):
@@ -99,12 +101,6 @@ The TypeScript Language service docs: https://github.com/Microsoft/TypeScript/wi
## Showing errors in atom
Done using the `linter` plugin. If you think about it. TypeScript is really just a super powerful version of `jshint` and that is the reason to use `linter` for errors.
-
-You need to inherit from `Linter` class from the `linter`: http://atomlinter.github.io/Linter/
-```js
-var linterPath = atom.packages.getLoadedPackage("linter").path
-var Linter:LinterClass = require linterPath+"/lib/linter"
-```
Just look at `linter.ts` in our code.
## Grammar
diff --git a/Gruntfile.js b/Gruntfile.js
deleted file mode 100644
index 5f4bc4318..000000000
--- a/Gruntfile.js
+++ /dev/null
@@ -1,32 +0,0 @@
-module.exports = function (grunt) {
- 'use strict';
-
- var srcDir = 'lib';
-
- grunt.initConfig({
- ts: {
- options: {
- target: 'es5',
- module: 'commonjs',
- sourceMap: false,
- preserveConstEnums: true,
- compiler: './node_modules/ntypescript/bin/tsc'
- },
- dev: {
- src: [srcDir + '/**/*.ts'],
- watch: srcDir,
- outDir: './dist/',
- baseDir: './lib/'
- },
- build: {
- src: [srcDir + '/**/*.ts'],
- outDir: './dist/',
- baseDir: './lib/'
- },
- },
- });
-
- grunt.loadNpmTasks('grunt-ts');
- grunt.registerTask('default', ['ts:dev']);
- grunt.registerTask('build', ['ts:build']);
-};
diff --git a/README.md b/README.md
index b8aa3ceba..a4928d6ce 100644
--- a/README.md
+++ b/README.md
@@ -209,11 +209,3 @@ Look at [CONTRIBUTING.md](https://github.com/TypeStrong/atom-typescript/blob/mas
## Changelog
Breaking changes [available online](https://github.com/TypeStrong/atom-typescript/blob/master/docs/CHANGELOG.md).
-
-## Donating
-Support this project and [others by basarat][gratipay-basarat] via [gratipay][gratipay-basarat].
-
-[![Support via Gratipay][gratipay]][gratipay-basarat]
-
-[gratipay]: https://cdn.rawgit.com/gratipay/gratipay-badge/2.3.0/dist/gratipay.png
-[gratipay-basarat]: https://gratipay.com/basarat/
diff --git a/VSProj.njsproj b/VSProj.njsproj
index 0f3b609c7..2eb8214f6 100644
--- a/VSProj.njsproj
+++ b/VSProj.njsproj
@@ -39,7 +39,7 @@
-
+
@@ -93,4 +93,4 @@
-
\ No newline at end of file
+
diff --git a/dist/linter.js b/dist/linter.js
index 4c487130b..fa5ac3ab9 100644
--- a/dist/linter.js
+++ b/dist/linter.js
@@ -1,8 +1,10 @@
+"use strict";
var parent = require('./worker/parent');
var fs = require('fs');
var atom_1 = require("atom");
exports.provider = {
- grammarScopes: ['source.ts', 'source.ts.tsx'],
+ name: 'TS',
+ grammarScopes: ['source.ts', 'source.tsx'],
scope: 'file',
lintOnFly: true,
lint: function (textEditor) {
@@ -16,7 +18,7 @@ exports.provider = {
var linterErrors = resp.errors.map(function (err) { return ({
type: "Error",
filePath: filePath,
- html: " TS " + err.message.replace(/\n/g, '
'),
+ text: err.message,
range: new atom_1.Range([err.startPos.line, err.startPos.col], [err.endPos.line, err.endPos.col]),
}); });
return linterErrors;
diff --git a/dist/main/atom/atomConfig.js b/dist/main/atom/atomConfig.js
index 6cd6307a6..f8b9811fb 100644
--- a/dist/main/atom/atomConfig.js
+++ b/dist/main/atom/atomConfig.js
@@ -1,3 +1,4 @@
+"use strict";
var utils_1 = require("../lang/utils");
var packageName = 'atom-typescript';
function getConfig(nameLambda) {
@@ -68,6 +69,6 @@ var Config = (function () {
configurable: true
});
return Config;
-})();
+}());
var config = new Config();
module.exports = config;
diff --git a/dist/main/atom/atomUtils.js b/dist/main/atom/atomUtils.js
index e7b711957..f3c38b77f 100644
--- a/dist/main/atom/atomUtils.js
+++ b/dist/main/atom/atomUtils.js
@@ -1,3 +1,4 @@
+"use strict";
var path = require('path');
var fs = require('fs');
var fsu = require("../utils/fsUtil");
diff --git a/dist/main/atom/autoCompleteProvider.js b/dist/main/atom/autoCompleteProvider.js
index 4977310ea..823b5c583 100644
--- a/dist/main/atom/autoCompleteProvider.js
+++ b/dist/main/atom/autoCompleteProvider.js
@@ -1,3 +1,4 @@
+"use strict";
var parent = require('../../worker/parent');
var atomConfig = require('./atomConfig');
var fs = require('fs');
@@ -10,29 +11,10 @@ function triggerAutocompletePlus() {
explicitlyTriggered = true;
}
exports.triggerAutocompletePlus = triggerAutocompletePlus;
-var tsSnipPrefixLookup = Object.create(null);
-function loadSnippets() {
- var confPath = atom.getConfigDirPath();
- CSON.readFile(confPath + "/packages/atom-typescript/snippets/typescript-snippets.cson", function (err, snippetsRoot) {
- if (err)
- return;
- if (!snippetsRoot || !snippetsRoot['.source.ts'])
- return;
- var tsSnippets = snippetsRoot['.source.ts'];
- for (var snippetName in tsSnippets) {
- if (tsSnippets.hasOwnProperty(snippetName)) {
- tsSnipPrefixLookup[tsSnippets[snippetName].prefix] = {
- body: tsSnippets[snippetName].body,
- name: snippetName
- };
- }
- }
- });
-}
-loadSnippets();
exports.provider = {
- selector: '.source.ts',
+ selector: '.source.ts, .source.tsx',
inclusionPriority: 3,
+ suggestionPriority: 3,
excludeLowerPriority: false,
getSuggestions: function (options) {
var filePath = options.editor.getPath();
@@ -78,7 +60,8 @@ exports.provider = {
explicitlyTriggered = false;
}
else {
- if (options.prefix && options.prefix.trim() == ';') {
+ var prefix = options.prefix.trim();
+ if (prefix === '' || prefix === ';') {
return Promise.resolve([]);
}
}
@@ -114,15 +97,6 @@ exports.provider = {
};
}
});
- if (tsSnipPrefixLookup[options.prefix]) {
- var suggestion = {
- snippet: tsSnipPrefixLookup[options.prefix].body,
- replacementPrefix: options.prefix,
- rightLabelHTML: "snippet: " + options.prefix,
- type: 'snippet'
- };
- suggestions.unshift(suggestion);
- }
return suggestions;
});
return promisedSuggestions;
@@ -141,10 +115,11 @@ exports.provider = {
if (options.suggestion.atomTS_IsImport) {
options.editor.moveToBeginningOfLine();
options.editor.selectToEndOfLine();
- var groups = /^\s*import\s*(\w*)\s*=\s*require\s*\(\s*(["'])/.exec(options.editor.getSelectedText());
- var alias = groups[1];
- quote = quote || groups[2];
- options.editor.replaceSelectedText(null, function () { return "import " + alias + " = require(" + quote + options.suggestion.atomTS_IsImport.relativePath + quote + ");"; });
+ var groups = /^(\s*)import\s*(\w*)\s*=\s*require\s*\(\s*(["'])/.exec(options.editor.getSelectedText());
+ var leadingWhiteSpace = groups[1];
+ var alias = groups[2];
+ quote = quote || groups[3];
+ options.editor.replaceSelectedText(null, function () { return leadingWhiteSpace + "import " + alias + " = require(" + quote + options.suggestion.atomTS_IsImport.relativePath + quote + ");"; });
}
if (options.suggestion.atomTS_IsES6Import) {
var row = options.editor.getCursorBufferPosition().row;
diff --git a/dist/main/atom/buildView.js b/dist/main/atom/buildView.js
index 8e0dc4f71..a730293a8 100644
--- a/dist/main/atom/buildView.js
+++ b/dist/main/atom/buildView.js
@@ -1,3 +1,4 @@
+"use strict";
var mainPanelView = require('./views/mainPanelView');
var lineMessageView = require('./views/lineMessageView');
var gotoHistory = require('./gotoHistory');
diff --git a/dist/main/atom/commands/commands.js b/dist/main/atom/commands/commands.js
index bf8582db8..401b256d6 100644
--- a/dist/main/atom/commands/commands.js
+++ b/dist/main/atom/commands/commands.js
@@ -1,3 +1,4 @@
+"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
@@ -282,7 +283,7 @@ function registerCommands() {
var editor = atom.workspace.getActiveTextEditor();
if (!editor)
return false;
- if (path.extname(editor.getPath()) !== '.ts')
+ if (path.extname(editor.getPath()) !== '.ts' && path.extname(editor.getPath()) !== '.tsx')
return false;
e.abortKeyBinding();
var filePath = editor.getPath();
diff --git a/dist/main/atom/commands/json2dtsCommands.js b/dist/main/atom/commands/json2dtsCommands.js
index 0906203e5..4fd16c14a 100644
--- a/dist/main/atom/commands/json2dtsCommands.js
+++ b/dist/main/atom/commands/json2dtsCommands.js
@@ -1,3 +1,4 @@
+"use strict";
var atomUtils = require("../atomUtils");
var json2dts_1 = require("../../json2dts/json2dts");
function registerJson2dtsCommands() {
diff --git a/dist/main/atom/commands/moveFilesHandling.js b/dist/main/atom/commands/moveFilesHandling.js
index 59f87a8c9..a085ae1cc 100644
--- a/dist/main/atom/commands/moveFilesHandling.js
+++ b/dist/main/atom/commands/moveFilesHandling.js
@@ -1,3 +1,4 @@
+"use strict";
function registerRenameHandling() {
}
exports.registerRenameHandling = registerRenameHandling;
diff --git a/dist/main/atom/commands/outputFileCommands.js b/dist/main/atom/commands/outputFileCommands.js
index 6c874a64d..844f5c34b 100644
--- a/dist/main/atom/commands/outputFileCommands.js
+++ b/dist/main/atom/commands/outputFileCommands.js
@@ -1,3 +1,4 @@
+"use strict";
var atomUtils = require("../atomUtils");
var parent = require("../../../worker/parent");
var child_process_1 = require("child_process");
diff --git a/dist/main/atom/commands/reactCommands.js b/dist/main/atom/commands/reactCommands.js
index 512ca42b2..2adb4c4dc 100644
--- a/dist/main/atom/commands/reactCommands.js
+++ b/dist/main/atom/commands/reactCommands.js
@@ -1,3 +1,4 @@
+"use strict";
var atomUtils = require("../atomUtils");
var htmltotsx_1 = require("../../react/htmltotsx");
function registerReactCommands() {
diff --git a/dist/main/atom/components/componentRegistry.js b/dist/main/atom/components/componentRegistry.js
index e1ac3237c..d2905b34c 100644
--- a/dist/main/atom/components/componentRegistry.js
+++ b/dist/main/atom/components/componentRegistry.js
@@ -1,3 +1,4 @@
+"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
diff --git a/dist/main/atom/components/ts-view.js b/dist/main/atom/components/ts-view.js
index 5446d6fdc..15ee4a167 100644
--- a/dist/main/atom/components/ts-view.js
+++ b/dist/main/atom/components/ts-view.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -26,6 +27,6 @@ var TsView = (function (_super) {
this.editor.setText(text);
};
return TsView;
-})(HTMLElement);
+}(HTMLElement));
exports.TsView = TsView;
document.registerElement('ts-view', TsView);
diff --git a/dist/main/atom/debugAtomTs.js b/dist/main/atom/debugAtomTs.js
index d6acc0067..82ee36549 100644
--- a/dist/main/atom/debugAtomTs.js
+++ b/dist/main/atom/debugAtomTs.js
@@ -1,3 +1,4 @@
+"use strict";
var atomConfig = require('./atomConfig');
function runDebugCode(details) {
if (!atomConfig.debugAtomTs)
diff --git a/dist/main/atom/editorSetup.js b/dist/main/atom/editorSetup.js
index cbf507943..9e755204d 100644
--- a/dist/main/atom/editorSetup.js
+++ b/dist/main/atom/editorSetup.js
@@ -1,45 +1,4 @@
-var utils_1 = require("../lang/utils");
-var parent = require("../../worker/parent");
-var atomUtils = require("./atomUtils");
-var transformer_1 = require("../lang/transformers/transformer");
+"use strict";
function setupEditor(editor) {
- var quickFixDecoration = null;
- var quickFixMarker = null;
- function clearExistingQuickfixDecoration() {
- if (quickFixDecoration) {
- quickFixDecoration.destroy();
- quickFixDecoration = null;
- }
- if (quickFixMarker) {
- quickFixMarker.destroy();
- quickFixMarker = null;
- }
- }
- var queryForQuickFix = utils_1.debounce(function (filePathPosition) {
- parent.getQuickFixes(filePathPosition).then(function (res) {
- clearExistingQuickfixDecoration();
- if (res.fixes.length) {
- quickFixMarker = editor.markBufferRange(editor.getSelectedBufferRange());
- quickFixDecoration = editor.decorateMarker(quickFixMarker, { type: "line-number", class: "quickfix" });
- }
- });
- }, 500);
- var cursorObserver = editor.onDidChangeCursorPosition(function () {
- try {
- var pathPos = atomUtils.getFilePathPosition();
- if (transformer_1.isTransformerFile(pathPos.filePath)) {
- clearExistingQuickfixDecoration();
- return;
- }
- queryForQuickFix(pathPos);
- }
- catch (ex) {
- clearExistingQuickfixDecoration();
- }
- });
- var destroyObserver = editor.onDidDestroy(function () {
- cursorObserver.dispose();
- destroyObserver.dispose();
- });
}
exports.setupEditor = setupEditor;
diff --git a/dist/main/atom/fileStatusCache.js b/dist/main/atom/fileStatusCache.js
index f90d4e436..a92dfc0a4 100644
--- a/dist/main/atom/fileStatusCache.js
+++ b/dist/main/atom/fileStatusCache.js
@@ -1,3 +1,4 @@
+"use strict";
var fsUtil_1 = require('../utils/fsUtil');
;
var fileStatuses = {};
diff --git a/dist/main/atom/gotoHistory.js b/dist/main/atom/gotoHistory.js
index af2404bf1..acb6dbf9c 100644
--- a/dist/main/atom/gotoHistory.js
+++ b/dist/main/atom/gotoHistory.js
@@ -1,3 +1,4 @@
+"use strict";
exports.errorsInOpenFiles = { members: [] };
exports.buildOutput = { members: [] };
exports.referencesOutput = { members: [] };
diff --git a/dist/main/atom/onSaveHandler.js b/dist/main/atom/onSaveHandler.js
index eac4bf7cf..0fb427d5d 100644
--- a/dist/main/atom/onSaveHandler.js
+++ b/dist/main/atom/onSaveHandler.js
@@ -1,3 +1,4 @@
+"use strict";
var atomUtils = require("./atomUtils");
var parent = require('../../worker/parent');
var mainPanelView_1 = require("./views/mainPanelView");
diff --git a/dist/main/atom/signatureProvider.js b/dist/main/atom/signatureProvider.js
index ef89850d3..df09737c2 100644
--- a/dist/main/atom/signatureProvider.js
+++ b/dist/main/atom/signatureProvider.js
@@ -1,3 +1,4 @@
+"use strict";
function requestHandler(config) {
}
exports.requestHandler = requestHandler;
diff --git a/dist/main/atom/tooltipManager.js b/dist/main/atom/tooltipManager.js
index a844fd926..7e6d54fc8 100644
--- a/dist/main/atom/tooltipManager.js
+++ b/dist/main/atom/tooltipManager.js
@@ -1,3 +1,4 @@
+"use strict";
var atomUtils = require('./atomUtils');
var parent = require('../../worker/parent');
var path = require('path');
@@ -46,8 +47,8 @@ function attach(editorView, editor) {
if (exprTypeTooltip)
return;
var pixelPt = pixelPositionFromMouseEvent(editorView, e);
- pixelPt.top += editor.displayBuffer.getScrollTop();
- pixelPt.left += editor.displayBuffer.getScrollLeft();
+ pixelPt.top += editor.getScrollTop();
+ pixelPt.left += editor.getScrollLeft();
var screenPt = editor.screenPositionForPixelPosition(pixelPt);
var bufferPt = editor.bufferPositionForScreenPosition(screenPt);
var curCharPixelPt = rawView.pixelPositionForBufferPosition([bufferPt.row, bufferPt.column]);
diff --git a/dist/main/atom/typescriptGrammar.js b/dist/main/atom/typescriptGrammar.js
index f4c367f2f..97a4d0ecf 100644
--- a/dist/main/atom/typescriptGrammar.js
+++ b/dist/main/atom/typescriptGrammar.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -167,7 +168,7 @@ var TypeScriptSemanticGrammar = (function (_super) {
return { tokens: tokens, ruleStack: tsTokensWithRuleStack.ruleStack };
};
return TypeScriptSemanticGrammar;
-})(AtomTSBaseGrammar);
+}(AtomTSBaseGrammar));
exports.TypeScriptSemanticGrammar = TypeScriptSemanticGrammar;
function getAtomStyleForToken(token, str) {
switch (token.classification) {
diff --git a/dist/main/atom/views/astView.js b/dist/main/atom/views/astView.js
index f4a3906b2..650053db7 100644
--- a/dist/main/atom/views/astView.js
+++ b/dist/main/atom/views/astView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -47,7 +48,7 @@ var AstView = (function (_super) {
});
};
return AstView;
-})(sp.ScrollView);
+}(sp.ScrollView));
exports.AstView = AstView;
function renderTree(rootNode, _mainContent, display) {
var root = {
diff --git a/dist/main/atom/views/awesomePanelView.js b/dist/main/atom/views/awesomePanelView.js
index 109366d8c..968c720a9 100644
--- a/dist/main/atom/views/awesomePanelView.js
+++ b/dist/main/atom/views/awesomePanelView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -18,7 +19,7 @@ var AwesomePanelView = (function (_super) {
this.something.html('
tada
');
};
return AwesomePanelView;
-})(view.View);
+}(view.View));
exports.AwesomePanelView = AwesomePanelView;
function attach() {
exports.panelView = new AwesomePanelView({});
diff --git a/dist/main/atom/views/contextView.js b/dist/main/atom/views/contextView.js
index d65d7a5f4..d28535c26 100644
--- a/dist/main/atom/views/contextView.js
+++ b/dist/main/atom/views/contextView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -66,5 +67,5 @@ var ContextView = (function (_super) {
this.hide();
};
return ContextView;
-})(sp.SelectListView);
+}(sp.SelectListView));
exports.ContextView = ContextView;
diff --git a/dist/main/atom/views/dependencyView.js b/dist/main/atom/views/dependencyView.js
index f39924337..586a6b27a 100644
--- a/dist/main/atom/views/dependencyView.js
+++ b/dist/main/atom/views/dependencyView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -41,7 +42,7 @@ var DependencyView = (function (_super) {
});
};
return DependencyView;
-})(sp.ScrollView);
+}(sp.ScrollView));
exports.DependencyView = DependencyView;
var prefixes = {
circle: 'circle'
@@ -88,8 +89,8 @@ function renderGraph(dependencies, mainContent, display) {
var cycles = d3Graph.cycles();
var message = '';
var textContent = '';
- for (var _i = 0; _i < cycles.length; _i++) {
- var cycle = cycles[_i];
+ for (var _i = 0, cycles_1 = cycles; _i < cycles_1.length; _i++) {
+ var cycle = cycles_1[_i];
message += 'Cycle Found:
';
message += cycle.join('
') + '
';
textContent += '---Cycle Found---' + os.EOL;
@@ -368,7 +369,7 @@ var D3Graph = (function () {
return this.circularPaths;
};
return D3Graph;
-})();
+}());
function linkArc(d) {
var targetX = d.target.x;
var targetY = d.target.y;
diff --git a/dist/main/atom/views/documentationView.js b/dist/main/atom/views/documentationView.js
index aaa0047a0..3c6102e14 100644
--- a/dist/main/atom/views/documentationView.js
+++ b/dist/main/atom/views/documentationView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -46,7 +47,7 @@ var DocumentationView = (function (_super) {
}
};
return DocumentationView;
-})(view.View);
+}(view.View));
exports.DocumentationView = DocumentationView;
function attach() {
if (exports.docView)
diff --git a/dist/main/atom/views/fileSymbolsView.js b/dist/main/atom/views/fileSymbolsView.js
index 90c550fa2..8d21b1a2c 100644
--- a/dist/main/atom/views/fileSymbolsView.js
+++ b/dist/main/atom/views/fileSymbolsView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -49,5 +50,5 @@ var FileSymbolsView = (function (_super) {
this.hide();
};
return FileSymbolsView;
-})(sp.SelectListView);
+}(sp.SelectListView));
exports.FileSymbolsView = FileSymbolsView;
diff --git a/dist/main/atom/views/lineMessageView.js b/dist/main/atom/views/lineMessageView.js
index caa7338a0..92ad22931 100644
--- a/dist/main/atom/views/lineMessageView.js
+++ b/dist/main/atom/views/lineMessageView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -66,5 +67,5 @@ var LineMessageView = (function (_super) {
};
};
return LineMessageView;
-})(view.View);
+}(view.View));
exports.LineMessageView = LineMessageView;
diff --git a/dist/main/atom/views/mainPanelView.js b/dist/main/atom/views/mainPanelView.js
index 611d30589..ca1576dc9 100644
--- a/dist/main/atom/views/mainPanelView.js
+++ b/dist/main/atom/views/mainPanelView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -65,7 +66,7 @@ var MainPanelView = (function (_super) {
});
_this.span({
class: 'layout horizontal atomts-panel-header',
- style: 'align-items: center; flex: 1 1 auto'
+ style: 'align-items: center; flex: 1 1 auto; line-height: 24px;'
}, function () {
_this.div({
style: 'cursor: pointer;',
@@ -209,10 +210,10 @@ var MainPanelView = (function (_super) {
this.txtPendingCount.html("" + this.pendingRequests.length + "");
this.sectionPending.stop();
if (pending.length) {
- this.sectionPending.fadeIn(500);
+ this.sectionPending.animate({ opacity: 0.5 }, 500);
}
else {
- this.sectionPending.fadeOut(200);
+ this.sectionPending.animate({ opacity: 0 }, 200);
}
};
MainPanelView.prototype.errorPanelSelectedClick = function () {
@@ -295,8 +296,8 @@ var MainPanelView = (function (_super) {
var title = panelHeaders.references + " ( Found: " + references.length + " )";
this.referencesPanelBtn.html(title);
gotoHistory.referencesOutput.members = [];
- for (var _i = 0; _i < references.length; _i++) {
- var ref = references[_i];
+ for (var _i = 0, references_1 = references; _i < references_1.length; _i++) {
+ var ref = references_1[_i];
var view = new lineMessageView.LineMessageView({
goToLine: function (filePath, line, col) { return gotoHistory.gotoLine(filePath, line, col, gotoHistory.referencesOutput); },
message: '',
@@ -311,6 +312,7 @@ var MainPanelView = (function (_super) {
};
MainPanelView.prototype.clearError = function () {
this.clearedError = true;
+ this.clearSummary();
this.errorBody.empty();
};
MainPanelView.prototype.addError = function (view) {
@@ -330,13 +332,17 @@ var MainPanelView = (function (_super) {
handler(this.summary);
}
};
+ MainPanelView.prototype.clearSummary = function () {
+ this.summary.html('');
+ this.summary.off();
+ };
MainPanelView.prototype.setErrorPanelErrorCount = function (fileErrorCount, totalErrorCount) {
var title = panelHeaders.error + " ( No Errors )";
if (totalErrorCount > 0) {
title = panelHeaders.error + " (\n " + fileErrorCount + " \n file" + (fileErrorCount === 1 ? "" : "s") + " \n " + totalErrorCount + " \n error" + (totalErrorCount === 1 ? "" : "s") + " \n )";
}
else {
- this.summary.html('');
+ this.clearSummary();
this.errorBody.html('No errors in open files \u2665');
}
this.errorPanelBtn.html(title);
@@ -394,7 +400,7 @@ var MainPanelView = (function (_super) {
}
};
return MainPanelView;
-})(view.View);
+}(view.View));
exports.MainPanelView = MainPanelView;
var panel;
function attach() {
diff --git a/dist/main/atom/views/plainMessageView.js b/dist/main/atom/views/plainMessageView.js
index 43f3685e5..efa2465a9 100644
--- a/dist/main/atom/views/plainMessageView.js
+++ b/dist/main/atom/views/plainMessageView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -27,5 +28,5 @@ var PlainMessageView = (function (_super) {
};
};
return PlainMessageView;
-})(view.View);
+}(view.View));
exports.PlainMessageView = PlainMessageView;
diff --git a/dist/main/atom/views/projectSymbolsView.js b/dist/main/atom/views/projectSymbolsView.js
index 3df89e694..bd2f51d81 100644
--- a/dist/main/atom/views/projectSymbolsView.js
+++ b/dist/main/atom/views/projectSymbolsView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -59,5 +60,5 @@ var ProjectSymbolsView = (function (_super) {
this.hide();
};
return ProjectSymbolsView;
-})(sp.SelectListView);
+}(sp.SelectListView));
exports.ProjectSymbolsView = ProjectSymbolsView;
diff --git a/dist/main/atom/views/rView.js b/dist/main/atom/views/rView.js
index 332cda392..0d912ff42 100644
--- a/dist/main/atom/views/rView.js
+++ b/dist/main/atom/views/rView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -23,11 +24,11 @@ var MyComponent = (function (_super) {
});
};
MyComponent.prototype.render = function () {
- return React.createElement("div", {"onClick": this.stop}, "This is a test: ", this.state.count);
+ return React.createElement("div", {onClick: this.stop}, "This is a test: ", this.state.count);
};
MyComponent.defaultProps = { count: 0 };
return MyComponent;
-})(React.Component);
+}(React.Component));
var RView = (function (_super) {
__extends(RView, _super);
function RView(config) {
@@ -59,5 +60,5 @@ var RView = (function (_super) {
});
RView.protocol = 'atomtsview:';
return RView;
-})(sp.ScrollView);
+}(sp.ScrollView));
exports.RView = RView;
diff --git a/dist/main/atom/views/renameView.js b/dist/main/atom/views/renameView.js
index ff6f919ca..da45847a8 100644
--- a/dist/main/atom/views/renameView.js
+++ b/dist/main/atom/views/renameView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -72,7 +73,7 @@ var RenameView = (function (_super) {
};
RenameView.content = html;
return RenameView;
-})(view.View);
+}(view.View));
exports.RenameView = RenameView;
var panel;
function attach() {
diff --git a/dist/main/atom/views/semanticView.js b/dist/main/atom/views/semanticView.js
index a58ade601..bf0175e64 100644
--- a/dist/main/atom/views/semanticView.js
+++ b/dist/main/atom/views/semanticView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -75,7 +76,7 @@ var MyComponent = (function (_super) {
};
MyComponent.prototype.renderNode = function (node, indent) {
var _this = this;
- return React.createElement("div", {"className": "node", "onClick": function (event) { _this.gotoNode(node); event.stopPropagation(); }, "data-start": node.start.line, "data-end": node.end.line}, rts.indent(indent), React.createElement("span", {"className": this.getIconForKind(node.kind) + ' ' + this.isSelected(node)}, node.text), node.subNodes.map(function (sn) { return _this.renderNode(sn, indent + 1); }));
+ return React.createElement("div", {className: "node", onClick: function (event) { _this.gotoNode(node); event.stopPropagation(); }, "data-start": node.start.line, "data-end": node.end.line}, rts.indent(indent), React.createElement("span", {className: this.getIconForKind(node.kind) + ' ' + this.isSelected(node)}, node.text), node.subNodes.map(function (sn) { return _this.renderNode(sn, indent + 1); }));
};
MyComponent.prototype.getIconForKind = function (kind) {
return "icon icon-" + kind;
@@ -95,7 +96,7 @@ var MyComponent = (function (_super) {
this.state.editor.setCursorBufferPosition([gotoLine, 0]);
};
return MyComponent;
-})(React.Component);
+}(React.Component));
var SemanticView = (function (_super) {
__extends(SemanticView, _super);
function SemanticView(config) {
@@ -123,7 +124,7 @@ var SemanticView = (function (_super) {
React.render(React.createElement(MyComponent, {}), this.rootDomElement);
};
return SemanticView;
-})(sp.ScrollView);
+}(sp.ScrollView));
exports.SemanticView = SemanticView;
var panel;
function attach() {
diff --git a/dist/main/atom/views/simpleOverlaySelectionView.js b/dist/main/atom/views/simpleOverlaySelectionView.js
index 12132e3f6..1fbc08067 100644
--- a/dist/main/atom/views/simpleOverlaySelectionView.js
+++ b/dist/main/atom/views/simpleOverlaySelectionView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -62,5 +63,5 @@ var SimpleOverlaySelectListView = (function (_super) {
this.hide();
};
return SimpleOverlaySelectListView;
-})(sp.SelectListView);
+}(sp.SelectListView));
exports.SimpleOverlaySelectListView = SimpleOverlaySelectListView;
diff --git a/dist/main/atom/views/simpleSelectionView.js b/dist/main/atom/views/simpleSelectionView.js
index 67f7d4282..b466dc3fa 100644
--- a/dist/main/atom/views/simpleSelectionView.js
+++ b/dist/main/atom/views/simpleSelectionView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -66,5 +67,5 @@ var SimpleSelectListView = (function (_super) {
this.hide();
};
return SimpleSelectListView;
-})(sp.SelectListView);
+}(sp.SelectListView));
exports.SimpleSelectListView = SimpleSelectListView;
diff --git a/dist/main/atom/views/tooltipView.js b/dist/main/atom/views/tooltipView.js
index 1a21def8d..cb6949497 100644
--- a/dist/main/atom/views/tooltipView.js
+++ b/dist/main/atom/views/tooltipView.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -42,5 +43,5 @@ var TooltipView = (function (_super) {
this.$.css({ left: left, top: top, right: right });
};
return TooltipView;
-})(view.View);
+}(view.View));
exports.TooltipView = TooltipView;
diff --git a/dist/main/atom/views/view.js b/dist/main/atom/views/view.js
index 1503acf45..70f77ef1a 100644
--- a/dist/main/atom/views/view.js
+++ b/dist/main/atom/views/view.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -23,7 +24,7 @@ var View = (function (_super) {
};
View.prototype.init = function () { };
return View;
-})(sp.View);
+}(sp.View));
exports.View = View;
exports.$ = sp.$;
var ScrollView = (function (_super) {
@@ -45,5 +46,5 @@ var ScrollView = (function (_super) {
};
ScrollView.prototype.init = function () { };
return ScrollView;
-})(sp.ScrollView);
+}(sp.ScrollView));
exports.ScrollView = ScrollView;
diff --git a/dist/main/atomts.js b/dist/main/atomts.js
index 907845f24..4cc89483c 100644
--- a/dist/main/atomts.js
+++ b/dist/main/atomts.js
@@ -1,3 +1,4 @@
+"use strict";
var atomConfig = require('./atom/atomConfig');
var makeTypeScriptGlobal_1 = require("../typescript/makeTypeScriptGlobal");
makeTypeScriptGlobal_1.makeTsGlobal(atomConfig.typescriptServices);
diff --git a/dist/main/bin/atbuild.js b/dist/main/bin/atbuild.js
index fead2d79b..689bd6e78 100644
--- a/dist/main/bin/atbuild.js
+++ b/dist/main/bin/atbuild.js
@@ -1,3 +1,4 @@
+"use strict";
var makeTypeScriptGlobal_1 = require("../../typescript/makeTypeScriptGlobal");
makeTypeScriptGlobal_1.makeTsGlobal();
var tsconfig = require("../tsconfig/tsconfig");
diff --git a/dist/main/json2dts/json2dts.js b/dist/main/json2dts/json2dts.js
index 205acfe80..893efe6d7 100644
--- a/dist/main/json2dts/json2dts.js
+++ b/dist/main/json2dts/json2dts.js
@@ -1,3 +1,4 @@
+"use strict";
var JSON2DTS = require("json2dts");
var Json2dts = JSON2DTS.Json2dts;
var toValidJSON = JSON2DTS.toValidJSON;
diff --git a/dist/main/lang/core/languageServiceHost2.js b/dist/main/lang/core/languageServiceHost2.js
index ce9482f96..c3bc58cb6 100644
--- a/dist/main/lang/core/languageServiceHost2.js
+++ b/dist/main/lang/core/languageServiceHost2.js
@@ -1,3 +1,4 @@
+"use strict";
var path = require('path');
var fs = require('fs');
var textBuffer = require('basarat-text-buffer');
@@ -241,5 +242,5 @@ var LanguageServiceHost = (function () {
}
}
return LanguageServiceHost;
-})();
+}());
exports.LanguageServiceHost = LanguageServiceHost;
diff --git a/dist/main/lang/core/project.js b/dist/main/lang/core/project.js
index 32bb699c0..87f5e37f0 100644
--- a/dist/main/lang/core/project.js
+++ b/dist/main/lang/core/project.js
@@ -1,3 +1,4 @@
+"use strict";
var fs = require('fs');
exports.languageServiceHost = require('./languageServiceHost2');
var tsconfig = require('../../tsconfig/tsconfig');
@@ -33,5 +34,5 @@ var Project = (function () {
return (this.getProjectSourceFiles().filter(function (f) { return f.fileName === fileName; }).length === 1);
};
return Project;
-})();
+}());
exports.Project = Project;
diff --git a/dist/main/lang/fixmyts/astUtils.js b/dist/main/lang/fixmyts/astUtils.js
index 750ff9518..26f82a79d 100644
--- a/dist/main/lang/fixmyts/astUtils.js
+++ b/dist/main/lang/fixmyts/astUtils.js
@@ -1,3 +1,4 @@
+"use strict";
exports.forEachChild = ts.forEachChild;
function forEachChildRecursive(node, cbNode, depth) {
if (depth === void 0) { depth = 0; }
diff --git a/dist/main/lang/fixmyts/quickFix.js b/dist/main/lang/fixmyts/quickFix.js
index d87ea67de..d9b265ecf 100644
--- a/dist/main/lang/fixmyts/quickFix.js
+++ b/dist/main/lang/fixmyts/quickFix.js
@@ -1,14 +1,15 @@
+"use strict";
function getRefactoringsByFilePath(refactorings) {
var loc = {};
- for (var _i = 0; _i < refactorings.length; _i++) {
- var refac = refactorings[_i];
+ for (var _i = 0, refactorings_1 = refactorings; _i < refactorings_1.length; _i++) {
+ var refac = refactorings_1[_i];
if (!loc[refac.filePath])
loc[refac.filePath] = [];
loc[refac.filePath].push(refac);
}
for (var filePath in loc) {
- var refactorings_1 = loc[filePath];
- refactorings_1.sort(function (a, b) {
+ var refactorings_2 = loc[filePath];
+ refactorings_2.sort(function (a, b) {
return (b.span.start - a.span.start);
});
}
diff --git a/dist/main/lang/fixmyts/quickFixRegistry.js b/dist/main/lang/fixmyts/quickFixRegistry.js
index ec1ad27d7..ab1c36edb 100644
--- a/dist/main/lang/fixmyts/quickFixRegistry.js
+++ b/dist/main/lang/fixmyts/quickFixRegistry.js
@@ -1,5 +1,7 @@
+"use strict";
var addClassMember_1 = require("./quickFixes/addClassMember");
var addClassMethod_1 = require("./quickFixes/addClassMethod");
+var addImportFromStatement_1 = require("./quickFixes/addImportFromStatement");
var addImportStatement_1 = require("./quickFixes/addImportStatement");
var equalsToEquals_1 = require("./quickFixes/equalsToEquals");
var extractVariable_1 = require("./quickFixes/extractVariable");
@@ -14,6 +16,7 @@ var singleLineCommentToJsdoc_1 = require("./quickFixes/singleLineCommentToJsdoc"
exports.allQuickFixes = [
new addClassMethod_1.AddClassMethod(),
new addClassMember_1.AddClassMember(),
+ new addImportFromStatement_1.AddImportFromStatement(),
new addImportStatement_1.AddImportStatement(),
new wrapInProperty_1.WrapInProperty(),
new equalsToEquals_1.EqualsToEquals(),
diff --git a/dist/main/lang/fixmyts/quickFixes/addClassMember.js b/dist/main/lang/fixmyts/quickFixes/addClassMember.js
index 0828f8e35..409c4bbb8 100644
--- a/dist/main/lang/fixmyts/quickFixes/addClassMember.js
+++ b/dist/main/lang/fixmyts/quickFixes/addClassMember.js
@@ -1,3 +1,4 @@
+"use strict";
var ast = require("../astUtils");
var os_1 = require("os");
function getIdentifierAndClassNames(error) {
@@ -83,5 +84,5 @@ var AddClassMember = (function () {
return [refactoring];
};
return AddClassMember;
-})();
+}());
exports.AddClassMember = AddClassMember;
diff --git a/dist/main/lang/fixmyts/quickFixes/addClassMethod.js b/dist/main/lang/fixmyts/quickFixes/addClassMethod.js
index 259633092..5bc5c571a 100644
--- a/dist/main/lang/fixmyts/quickFixes/addClassMethod.js
+++ b/dist/main/lang/fixmyts/quickFixes/addClassMethod.js
@@ -1,3 +1,4 @@
+"use strict";
var ast = require("../astUtils");
var os_1 = require("os");
function getIdentifierAndClassNames(error) {
@@ -149,5 +150,5 @@ var AddClassMethod = (function () {
return [refactoring];
};
return AddClassMethod;
-})();
+}());
exports.AddClassMethod = AddClassMethod;
diff --git a/dist/main/lang/fixmyts/quickFixes/addImportFromStatement.js b/dist/main/lang/fixmyts/quickFixes/addImportFromStatement.js
new file mode 100644
index 000000000..ba7e5ba41
--- /dev/null
+++ b/dist/main/lang/fixmyts/quickFixes/addImportFromStatement.js
@@ -0,0 +1,58 @@
+"use strict";
+var os_1 = require("os");
+var displayPartsToString = ts.displayPartsToString, typeToDisplayParts = ts.typeToDisplayParts;
+var getPathCompletions_1 = require("../../modules/getPathCompletions");
+function getIdentifierAndFileNames(error, project) {
+ var errorText = error.messageText;
+ if (typeof errorText !== 'string') {
+ return undefined;
+ }
+ ;
+ var match = errorText.match(/Cannot find name \'(\w+)\'./);
+ if (!match)
+ return;
+ var identifierName = match[1];
+ var files = getPathCompletions_1.getPathCompletions({
+ project: project,
+ filePath: error.file.fileName,
+ prefix: identifierName,
+ includeExternalModules: false
+ }).files;
+ var file = files.length > 0 ? files[0].relativePath : undefined;
+ var basename = files.length > 0 ? files[0].name : undefined;
+ return { identifierName: identifierName, file: file, basename: basename };
+}
+var AddImportFromStatement = (function () {
+ function AddImportFromStatement() {
+ this.key = AddImportFromStatement.name;
+ }
+ AddImportFromStatement.prototype.canProvideFix = function (info) {
+ var relevantError = info.positionErrors.filter(function (x) { return x.code == 2304; })[0];
+ if (!relevantError)
+ return;
+ if (info.positionNode.kind !== ts.SyntaxKind.Identifier)
+ return;
+ var matches = getIdentifierAndFileNames(relevantError, info.project);
+ if (!matches)
+ return;
+ var identifierName = matches.identifierName, file = matches.file;
+ return file ? { display: "import {" + identifierName + "} from \"" + file + "\"" } : undefined;
+ };
+ AddImportFromStatement.prototype.provideFix = function (info) {
+ var relevantError = info.positionErrors.filter(function (x) { return x.code == 2304; })[0];
+ var identifier = info.positionNode;
+ var identifierName = identifier.text;
+ var fileNameforFix = getIdentifierAndFileNames(relevantError, info.project);
+ var refactorings = [{
+ span: {
+ start: 0,
+ length: 0
+ },
+ newText: "import {" + identifierName + "} from \"" + fileNameforFix.file + "\";" + os_1.EOL,
+ filePath: info.sourceFile.fileName
+ }];
+ return refactorings;
+ };
+ return AddImportFromStatement;
+}());
+exports.AddImportFromStatement = AddImportFromStatement;
diff --git a/dist/main/lang/fixmyts/quickFixes/addImportStatement.js b/dist/main/lang/fixmyts/quickFixes/addImportStatement.js
index 1c20095f8..b690f14f7 100644
--- a/dist/main/lang/fixmyts/quickFixes/addImportStatement.js
+++ b/dist/main/lang/fixmyts/quickFixes/addImportStatement.js
@@ -1,3 +1,4 @@
+"use strict";
var os_1 = require("os");
var displayPartsToString = ts.displayPartsToString, typeToDisplayParts = ts.typeToDisplayParts;
var getPathCompletions_1 = require("../../modules/getPathCompletions");
@@ -53,5 +54,5 @@ var AddImportStatement = (function () {
return refactorings;
};
return AddImportStatement;
-})();
+}());
exports.AddImportStatement = AddImportStatement;
diff --git a/dist/main/lang/fixmyts/quickFixes/equalsToEquals.js b/dist/main/lang/fixmyts/quickFixes/equalsToEquals.js
index 841dc5056..7175617fe 100644
--- a/dist/main/lang/fixmyts/quickFixes/equalsToEquals.js
+++ b/dist/main/lang/fixmyts/quickFixes/equalsToEquals.js
@@ -1,3 +1,4 @@
+"use strict";
var EqualsToEquals = (function () {
function EqualsToEquals() {
this.key = EqualsToEquals.name;
@@ -28,5 +29,5 @@ var EqualsToEquals = (function () {
return [refactoring];
};
return EqualsToEquals;
-})();
+}());
exports.EqualsToEquals = EqualsToEquals;
diff --git a/dist/main/lang/fixmyts/quickFixes/extractVariable.js b/dist/main/lang/fixmyts/quickFixes/extractVariable.js
index e6e3c2675..d16491836 100644
--- a/dist/main/lang/fixmyts/quickFixes/extractVariable.js
+++ b/dist/main/lang/fixmyts/quickFixes/extractVariable.js
@@ -1,3 +1,4 @@
+"use strict";
var os_1 = require("os");
var ExtractVariable = (function () {
function ExtractVariable() {
@@ -13,7 +14,6 @@ var ExtractVariable = (function () {
}, function () {
return { display: "Extract variable" };
});
- throw "Unexpected state in canProvideFix";
};
ExtractVariable.prototype.provideFix = function (info) {
return execute(info, function () {
@@ -23,10 +23,9 @@ var ExtractVariable = (function () {
}, function (callExpression) {
return extractVariableFromArg(info, callExpression);
});
- throw "Unexpected state in provideFix";
};
return ExtractVariable;
-})();
+}());
exports.ExtractVariable = ExtractVariable;
function execute(info, onProperty, onFuncCall, onExtractable) {
var callExpression = findLowestNode(info.positionNode, ts.SyntaxKind.CallExpression);
diff --git a/dist/main/lang/fixmyts/quickFixes/implementInterface.js b/dist/main/lang/fixmyts/quickFixes/implementInterface.js
index 83701b9da..8133aa175 100644
--- a/dist/main/lang/fixmyts/quickFixes/implementInterface.js
+++ b/dist/main/lang/fixmyts/quickFixes/implementInterface.js
@@ -1,3 +1,4 @@
+"use strict";
var ast = require("../astUtils");
var os_1 = require("os");
function getClassAndInterfaceName(error) {
@@ -42,5 +43,5 @@ var ImplementInterface = (function () {
return refactorings;
};
return ImplementInterface;
-})();
+}());
exports.ImplementInterface = ImplementInterface;
diff --git a/dist/main/lang/fixmyts/quickFixes/quoteToTemplate.js b/dist/main/lang/fixmyts/quickFixes/quoteToTemplate.js
index 80b5e0768..ad1cd7f98 100644
--- a/dist/main/lang/fixmyts/quickFixes/quoteToTemplate.js
+++ b/dist/main/lang/fixmyts/quickFixes/quoteToTemplate.js
@@ -1,3 +1,4 @@
+"use strict";
var QuoteToTemplate = (function () {
function QuoteToTemplate() {
this.key = QuoteToTemplate.name;
@@ -29,5 +30,5 @@ var QuoteToTemplate = (function () {
return [refactoring];
};
return QuoteToTemplate;
-})();
+}());
exports.QuoteToTemplate = QuoteToTemplate;
diff --git a/dist/main/lang/fixmyts/quickFixes/quotesToQuotes.js b/dist/main/lang/fixmyts/quickFixes/quotesToQuotes.js
index c6f1ba7c0..7b258d6ab 100644
--- a/dist/main/lang/fixmyts/quickFixes/quotesToQuotes.js
+++ b/dist/main/lang/fixmyts/quickFixes/quotesToQuotes.js
@@ -1,3 +1,4 @@
+"use strict";
var QuotesToQuotes = (function () {
function QuotesToQuotes() {
this.key = QuotesToQuotes.name;
@@ -34,5 +35,5 @@ var QuotesToQuotes = (function () {
return [refactoring];
};
return QuotesToQuotes;
-})();
+}());
exports.QuotesToQuotes = QuotesToQuotes;
diff --git a/dist/main/lang/fixmyts/quickFixes/singleLineCommentToJsdoc.js b/dist/main/lang/fixmyts/quickFixes/singleLineCommentToJsdoc.js
index 363c6c8a5..eadb457f7 100644
--- a/dist/main/lang/fixmyts/quickFixes/singleLineCommentToJsdoc.js
+++ b/dist/main/lang/fixmyts/quickFixes/singleLineCommentToJsdoc.js
@@ -1,3 +1,4 @@
+"use strict";
var utils = require("../../utils");
var SingleLineCommentToJsdoc = (function () {
function SingleLineCommentToJsdoc() {
@@ -39,5 +40,5 @@ var SingleLineCommentToJsdoc = (function () {
return [refactoring];
};
return SingleLineCommentToJsdoc;
-})();
+}());
exports.SingleLineCommentToJsdoc = SingleLineCommentToJsdoc;
diff --git a/dist/main/lang/fixmyts/quickFixes/stringConcatToTemplate.js b/dist/main/lang/fixmyts/quickFixes/stringConcatToTemplate.js
index 14793f213..987d69fdd 100644
--- a/dist/main/lang/fixmyts/quickFixes/stringConcatToTemplate.js
+++ b/dist/main/lang/fixmyts/quickFixes/stringConcatToTemplate.js
@@ -1,3 +1,4 @@
+"use strict";
function isBinaryAddition(node) {
return (node.kind == ts.SyntaxKind.BinaryExpression &&
node.operatorToken.kind == ts.SyntaxKind.PlusToken);
@@ -82,5 +83,5 @@ var StringConcatToTemplate = (function () {
return [refactoring];
};
return StringConcatToTemplate;
-})();
+}());
exports.StringConcatToTemplate = StringConcatToTemplate;
diff --git a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js
index 7c9bbfe85..be8213084 100644
--- a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js
+++ b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js
@@ -1,3 +1,4 @@
+"use strict";
var TypeAssertPropertyAccessToAny = (function () {
function TypeAssertPropertyAccessToAny() {
this.key = TypeAssertPropertyAccessToAny.name;
@@ -34,7 +35,7 @@ var TypeAssertPropertyAccessToAny = (function () {
return [];
};
return TypeAssertPropertyAccessToAny;
-})();
+}());
exports.TypeAssertPropertyAccessToAny = TypeAssertPropertyAccessToAny;
function getIdentifierName(errorText) {
var match = /Property \'(\w+)\' does not exist on type \.*/.exec(errorText);
diff --git a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js
index 5132c0fd4..7ddbea954 100644
--- a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js
+++ b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js
@@ -1,3 +1,4 @@
+"use strict";
var TypeAssertPropertyAccessToType = (function () {
function TypeAssertPropertyAccessToType() {
this.key = TypeAssertPropertyAccessToType.name;
@@ -35,7 +36,7 @@ var TypeAssertPropertyAccessToType = (function () {
return [];
};
return TypeAssertPropertyAccessToType;
-})();
+}());
exports.TypeAssertPropertyAccessToType = TypeAssertPropertyAccessToType;
function getIdentifierName(errorText) {
var match = /Property \'(\w+)\' does not exist on type \.*/.exec(errorText);
diff --git a/dist/main/lang/fixmyts/quickFixes/wrapInProperty.js b/dist/main/lang/fixmyts/quickFixes/wrapInProperty.js
index a01f22013..69f0134ad 100644
--- a/dist/main/lang/fixmyts/quickFixes/wrapInProperty.js
+++ b/dist/main/lang/fixmyts/quickFixes/wrapInProperty.js
@@ -1,3 +1,4 @@
+"use strict";
var os_1 = require("os");
var WrapInProperty = (function () {
function WrapInProperty() {
@@ -30,7 +31,7 @@ var WrapInProperty = (function () {
return [assignemnt, property];
};
return WrapInProperty;
-})();
+}());
exports.WrapInProperty = WrapInProperty;
function createAssignment(constructorDecl, symbolName, indentSetting, filePath) {
var indentLevel2 = createIndent(indentSetting, 2);
diff --git a/dist/main/lang/modules/astToText.js b/dist/main/lang/modules/astToText.js
index 2c9a5780e..06c4ca9f3 100644
--- a/dist/main/lang/modules/astToText.js
+++ b/dist/main/lang/modules/astToText.js
@@ -1,3 +1,4 @@
+"use strict";
var astUtils_1 = require("../fixmyts/astUtils");
function astToText(srcFile) {
var nodeIndex = 0;
diff --git a/dist/main/lang/modules/building.js b/dist/main/lang/modules/building.js
index 2d1cadadb..d49ef76ce 100644
--- a/dist/main/lang/modules/building.js
+++ b/dist/main/lang/modules/building.js
@@ -1,9 +1,12 @@
+"use strict";
var mkdirp = require('mkdirp');
var path = require('path');
var fs = require('fs');
var fsUtil_1 = require("../../utils/fsUtil");
var utils_1 = require("../utils");
-var babel;
+var findup = require('findup');
+var babels = {};
+var babelConfigs = {};
exports.Not_In_Context = "/* NotInContext */";
function diagnosticToTSError(diagnostic) {
var filePath = diagnostic.file.fileName;
@@ -37,13 +40,14 @@ function emitFile(proj, filePath) {
var sourceMapContents = {};
output.outputFiles.forEach(function (o) {
mkdirp.sync(path.dirname(o.name));
- var additionalEmits = runExternalTranspiler(filePath, sourceFile.text, o, proj, sourceMapContents);
- if (!sourceMapContents[o.name] && !proj.projectFile.project.compilerOptions.noEmit) {
- fs.writeFileSync(o.name, o.text, "utf8");
- }
- additionalEmits.forEach(function (a) {
- mkdirp.sync(path.dirname(a.name));
- fs.writeFileSync(a.name, a.text, "utf8");
+ runExternalTranspiler(filePath, sourceFile.text, o, proj, sourceMapContents).then(function (additionalEmits) {
+ if (!sourceMapContents[o.name] && !proj.projectFile.project.compilerOptions.noEmit) {
+ fs.writeFileSync(o.name, o.text, "utf8");
+ }
+ additionalEmits.forEach(function (a) {
+ mkdirp.sync(path.dirname(a.name));
+ fs.writeFileSync(a.name, a.text, "utf8");
+ });
});
});
}
@@ -75,20 +79,60 @@ function getRawOutput(proj, filePath) {
return output;
}
exports.getRawOutput = getRawOutput;
+function getBabelInstance(projectDirectory) {
+ return new Promise(function (resolve) {
+ if (!babels[projectDirectory]) {
+ findup(projectDirectory, 'node_modules/babel-core', function (err, dir) {
+ if (err) {
+ findup(projectDirectory, 'node_modules/babel', function (err, dir) {
+ if (err) {
+ babels[projectDirectory] = require('babel');
+ }
+ else {
+ babels[projectDirectory] = require(path.join(dir, 'node_modules/babel'));
+ }
+ resolve(babels[projectDirectory]);
+ });
+ }
+ else {
+ babels[projectDirectory] = require(path.join(dir, 'node_modules/babel-core'));
+ resolve(babels[projectDirectory]);
+ }
+ });
+ }
+ else {
+ resolve(babels[projectDirectory]);
+ }
+ }).then(function (babel) {
+ return new Promise(function (resolve) {
+ findup(projectDirectory, '.babelrc', function (err, dir) {
+ if (err)
+ return resolve(babel);
+ fs.readFile(path.join(dir, '.babelrc'), function (err, data) {
+ try {
+ babelConfigs[projectDirectory] = JSON.parse(data.toString());
+ }
+ catch (e) { }
+ resolve(babel);
+ });
+ });
+ });
+ });
+}
function runExternalTranspiler(sourceFileName, sourceFileText, outputFile, project, sourceMapContents) {
if (!isJSFile(outputFile.name) && !isJSSourceMapFile(outputFile.name)) {
- return [];
+ return Promise.resolve([]);
}
var settings = project.projectFile.project;
var externalTranspiler = settings.externalTranspiler;
if (!externalTranspiler) {
- return [];
+ return Promise.resolve([]);
}
if (isJSSourceMapFile(outputFile.name)) {
var sourceMapPayload = JSON.parse(outputFile.text);
var jsFileName = fsUtil_1.consistentPath(path.resolve(path.dirname(outputFile.name), sourceMapPayload.file));
sourceMapContents[outputFile.name] = { jsFileName: jsFileName, sourceMapPayload: sourceMapPayload };
- return [];
+ return Promise.resolve([]);
}
if (typeof externalTranspiler === 'string') {
externalTranspiler = {
@@ -98,43 +142,45 @@ function runExternalTranspiler(sourceFileName, sourceFileText, outputFile, proje
}
if (typeof externalTranspiler === 'object') {
if (externalTranspiler.name.toLocaleLowerCase() === "babel") {
- if (!babel) {
- babel = require("babel");
- }
- var babelOptions = utils_1.assign({}, externalTranspiler.options || {}, {
- filename: outputFile.name
- });
- var sourceMapFileName = getJSMapNameForJSFile(outputFile.name);
- if (sourceMapContents[sourceMapFileName]) {
- babelOptions.inputSourceMap = sourceMapContents[sourceMapFileName].sourceMapPayload;
- var baseName = path.basename(sourceFileName);
- babelOptions.inputSourceMap.sources = [baseName];
- babelOptions.inputSourceMap.file = baseName;
- }
- if (settings.compilerOptions.sourceMap) {
- babelOptions.sourceMaps = true;
- }
- if (settings.compilerOptions.inlineSourceMap) {
- babelOptions.sourceMaps = "inline";
- }
- if (!settings.compilerOptions.removeComments) {
- babelOptions.comments = true;
- }
- var babelResult = babel.transform(outputFile.text, babelOptions);
- outputFile.text = babelResult.code;
- if (babelResult.map && settings.compilerOptions.sourceMap) {
- var additionalEmit = {
- name: sourceMapFileName,
- text: JSON.stringify(babelResult.map),
- writeByteOrderMark: settings.compilerOptions.emitBOM
- };
- if (additionalEmit.name === "") {
- console.warn("The TypeScript language service did not yet provide a .js.map name for file " + outputFile.name);
- return [];
+ return getBabelInstance(project.projectFile.projectFileDirectory).then(function (babel) {
+ var babelOptions = utils_1.assign(babelConfigs[project.projectFile.projectFileDirectory] || {}, externalTranspiler.options || {}, {
+ filename: outputFile.name
+ });
+ var sourceMapFileName = getJSMapNameForJSFile(outputFile.name);
+ if (sourceMapContents[sourceMapFileName]) {
+ babelOptions.inputSourceMap = sourceMapContents[sourceMapFileName].sourceMapPayload;
+ var baseName = path.basename(sourceFileName);
+ babelOptions.inputSourceMap.sources = [baseName];
+ babelOptions.inputSourceMap.file = baseName;
}
- return [additionalEmit];
- }
- return [];
+ if (settings.compilerOptions.sourceMap) {
+ babelOptions.sourceMaps = true;
+ }
+ if (settings.compilerOptions.inlineSourceMap) {
+ babelOptions.sourceMaps = "inline";
+ }
+ if (!settings.compilerOptions.removeComments) {
+ babelOptions.comments = true;
+ }
+ var directory = process.cwd();
+ process.chdir(project.projectFile.projectFileDirectory);
+ var babelResult = babel.transform(outputFile.text, babelOptions);
+ process.chdir(directory);
+ outputFile.text = babelResult.code;
+ if (babelResult.map && settings.compilerOptions.sourceMap) {
+ var additionalEmit = {
+ name: sourceMapFileName,
+ text: JSON.stringify(babelResult.map),
+ writeByteOrderMark: settings.compilerOptions.emitBOM
+ };
+ if (additionalEmit.name === "") {
+ console.warn("The TypeScript language service did not yet provide a .js.map name for file " + outputFile.name);
+ return [];
+ }
+ return [additionalEmit];
+ }
+ return [];
+ });
}
}
function getJSMapNameForJSFile(jsFileName) {
diff --git a/dist/main/lang/modules/formatting.js b/dist/main/lang/modules/formatting.js
index 70567c635..ba6d5e8cc 100644
--- a/dist/main/lang/modules/formatting.js
+++ b/dist/main/lang/modules/formatting.js
@@ -1,3 +1,4 @@
+"use strict";
function formatDocument(proj, filePath) {
var textChanges = proj.languageService.getFormattingEditsForDocument(filePath, proj.projectFile.project.formatCodeOptions);
var edits = textChanges.map(function (change) {
diff --git a/dist/main/lang/modules/getPathCompletions.js b/dist/main/lang/modules/getPathCompletions.js
index 5b3663f72..0402a8991 100644
--- a/dist/main/lang/modules/getPathCompletions.js
+++ b/dist/main/lang/modules/getPathCompletions.js
@@ -1,3 +1,4 @@
+"use strict";
var path = require("path");
var tsconfig = require("../../tsconfig/tsconfig");
var utils = require("../utils");
diff --git a/dist/main/lang/modules/moveFiles.js b/dist/main/lang/modules/moveFiles.js
index af02c5b1f..daf35ba20 100644
--- a/dist/main/lang/modules/moveFiles.js
+++ b/dist/main/lang/modules/moveFiles.js
@@ -1,3 +1,4 @@
+"use strict";
var astUtils_1 = require("../fixmyts/astUtils");
var path = require("path");
var tsconfig_1 = require("../../tsconfig/tsconfig");
@@ -20,8 +21,8 @@ function getRenameFilesRefactorings(program, oldDirectoryOrFile, newDirectoryOrF
});
var matches = imports.filter(function (f) { return f.path == oldFileNoExt; });
if (matches.length) {
- for (var _i = 0; _i < matches.length; _i++) {
- var match = matches[_i];
+ for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) {
+ var match = matches_1[_i];
refactorings.push({
filePath: sourceFile.fileName,
span: {
diff --git a/dist/main/lang/modules/programDependencies.js b/dist/main/lang/modules/programDependencies.js
index 116cf2135..0fe6bdd76 100644
--- a/dist/main/lang/modules/programDependencies.js
+++ b/dist/main/lang/modules/programDependencies.js
@@ -1,3 +1,4 @@
+"use strict";
var tsconfig_1 = require("../../tsconfig/tsconfig");
var fsUtil_1 = require("../../utils/fsUtil");
var path = require("path");
@@ -19,8 +20,8 @@ function getDependencies(projectFile, program) {
}
return file;
});
- for (var _b = 0; _b < targets.length; _b++) {
- var target = targets[_b];
+ for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
+ var target = targets_1[_b];
var targetPath = fsUtil_1.consistentPath(path.relative(projectDir, fsUtil_1.consistentPath(target)));
var sourcePath = fsUtil_1.consistentPath(path.relative(projectDir, filePath));
links.push({
diff --git a/dist/main/lang/projectCache.js b/dist/main/lang/projectCache.js
index feff4f840..902bd9b36 100644
--- a/dist/main/lang/projectCache.js
+++ b/dist/main/lang/projectCache.js
@@ -1,3 +1,4 @@
+"use strict";
var fs = require("fs");
var path = require("path");
var tsconfig = require("../tsconfig/tsconfig");
diff --git a/dist/main/lang/projectService.js b/dist/main/lang/projectService.js
index cb866cb43..51f4c898b 100644
--- a/dist/main/lang/projectService.js
+++ b/dist/main/lang/projectService.js
@@ -1,3 +1,4 @@
+"use strict";
var fsu = require("../utils/fsUtil");
var fs = require('fs');
var path = require('path');
@@ -334,8 +335,8 @@ function getProjectFileDetails(query) {
exports.getProjectFileDetails = getProjectFileDetails;
function sortNavbarItemsBySpan(items) {
items.sort(function (a, b) { return a.spans[0].start - b.spans[0].start; });
- for (var _i = 0; _i < items.length; _i++) {
- var item = items[_i];
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
+ var item = items_1[_i];
if (item.childItems) {
sortNavbarItemsBySpan(item.childItems);
}
diff --git a/dist/main/lang/transformers/implementations/nullTransformer.js b/dist/main/lang/transformers/implementations/nullTransformer.js
index ea5b82f6d..e35b530cd 100644
--- a/dist/main/lang/transformers/implementations/nullTransformer.js
+++ b/dist/main/lang/transformers/implementations/nullTransformer.js
@@ -1,3 +1,4 @@
+"use strict";
var transformerRegistry_1 = require("../transformerRegistry");
var NullTransformer = (function () {
function NullTransformer() {
@@ -7,6 +8,6 @@ var NullTransformer = (function () {
return { code: code };
};
return NullTransformer;
-})();
+}());
exports.NullTransformer = NullTransformer;
transformerRegistry_1.add(new NullTransformer());
diff --git a/dist/main/lang/transformers/transformer.js b/dist/main/lang/transformers/transformer.js
index 5b96c7c76..47313d684 100644
--- a/dist/main/lang/transformers/transformer.js
+++ b/dist/main/lang/transformers/transformer.js
@@ -1,3 +1,4 @@
+"use strict";
var path = require("path");
function isTransformerFile(filePath) {
var ext = path.extname(filePath);
diff --git a/dist/main/lang/transformers/transformerRegistry.js b/dist/main/lang/transformers/transformerRegistry.js
index 3f6105304..896ba9da6 100644
--- a/dist/main/lang/transformers/transformerRegistry.js
+++ b/dist/main/lang/transformers/transformerRegistry.js
@@ -1,3 +1,4 @@
+"use strict";
var allTransformers = [];
function add(transformer) {
transformer.regex = (new RegExp("transform:" + transformer.name + "{[.\\s]*}transform:" + transformer.name, 'g'));
@@ -16,17 +17,6 @@ var transformFinderRegex = /transform:(.*){/g;
var transformEndFinderRegexGenerator = function (name) { return new RegExp("}transform:" + name); };
function getInitialTransformation(code) {
var transforms = [];
- var processedSrcUpto = 0;
- var srcCode = code;
- var destCode = '';
- var destDelta = 0;
- while (true) {
- var remainingCode = code.substr(processedSrcUpto);
- var matches = transformFinderRegex.exec(remainingCode);
- if (!matches || !matches.length || matches.length < 2)
- return { transforms: transforms };
- var nextTransformName = matches.slice[1];
- }
return { transforms: transforms };
}
exports.getInitialTransformation = getInitialTransformation;
@@ -39,8 +29,9 @@ function transform(name, code) {
return transformer.transform(code);
}
exports.transform = transform;
-var expand = require('glob-expand');
-var files = expand({ filter: 'isFile', cwd: __dirname }, [
- "./implementations/*.js"
-]);
+var glob = require('glob');
+var files = glob.sync('./implementations/*.js', {
+ nodir: true,
+ cwd: __dirname
+});
files = files.map(function (f) { return require(f); });
diff --git a/dist/main/lang/utils.js b/dist/main/lang/utils.js
index 1b0a23977..9c0b803d5 100644
--- a/dist/main/lang/utils.js
+++ b/dist/main/lang/utils.js
@@ -81,7 +81,7 @@ var Signal = (function () {
return this.listeners.length > 0;
};
return Signal;
-})();
+}());
exports.Signal = Signal;
function binarySearch(array, value) {
var low = 0;
@@ -139,7 +139,7 @@ var Dict = (function () {
return array;
};
return Dict;
-})();
+}());
exports.Dict = Dict;
function delay(seconds) {
if (seconds === void 0) { seconds = 2; }
diff --git a/dist/main/react/htmltotsx.js b/dist/main/react/htmltotsx.js
index 59347377f..12ed744a8 100644
--- a/dist/main/react/htmltotsx.js
+++ b/dist/main/react/htmltotsx.js
@@ -1,3 +1,4 @@
+"use strict";
var HTMLtoJSX = require("htmltojsx");
function convert(content, indentSize) {
var indent = Array(indentSize + 1).join(' ');
diff --git a/dist/main/tsconfig/dts-generator.js b/dist/main/tsconfig/dts-generator.js
index b3bae7d05..6cf34cd73 100644
--- a/dist/main/tsconfig/dts-generator.js
+++ b/dist/main/tsconfig/dts-generator.js
@@ -1,3 +1,4 @@
+"use strict";
var pathUtil = require("path");
var os = require("os");
var fs = require("fs");
diff --git a/dist/main/tsconfig/formatting.js b/dist/main/tsconfig/formatting.js
index 6e7de6faf..12532f7ad 100644
--- a/dist/main/tsconfig/formatting.js
+++ b/dist/main/tsconfig/formatting.js
@@ -1,3 +1,4 @@
+"use strict";
var os = require('os');
function defaultFormatCodeOptions() {
return {
@@ -5,6 +6,7 @@ function defaultFormatCodeOptions() {
TabSize: 4,
NewLineCharacter: os.EOL,
ConvertTabsToSpaces: true,
+ IndentStyle: ts.IndentStyle.Smart,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
InsertSpaceBeforeAndAfterBinaryOperators: true,
diff --git a/dist/main/tsconfig/simpleValidator.js b/dist/main/tsconfig/simpleValidator.js
index 77eba6085..a75fd158e 100644
--- a/dist/main/tsconfig/simpleValidator.js
+++ b/dist/main/tsconfig/simpleValidator.js
@@ -1,3 +1,4 @@
+"use strict";
exports.types = {
string: 'string',
boolean: 'boolean',
@@ -44,7 +45,7 @@ var SimpleValidator = (function () {
return errors;
};
return SimpleValidator;
-})();
+}());
exports.SimpleValidator = SimpleValidator;
function createMap(arr) {
return arr.reduce(function (result, key) {
diff --git a/dist/main/tsconfig/tsconfig.js b/dist/main/tsconfig/tsconfig.js
index 715c0d6f7..5c02e707b 100644
--- a/dist/main/tsconfig/tsconfig.js
+++ b/dist/main/tsconfig/tsconfig.js
@@ -1,10 +1,13 @@
+"use strict";
var fsu = require("../utils/fsUtil");
var simpleValidator = require('./simpleValidator');
-var stripBom = require('strip-bom');
var types = simpleValidator.types;
var compilerOptionsValidation = {
- allowNonTsExtensions: { type: simpleValidator.types.boolean },
- charset: { type: simpleValidator.types.string },
+ allowNonTsExtensions: { type: types.boolean },
+ allowSyntheticDefaultImports: { type: types.boolean },
+ allowUnreachableCode: { type: types.boolean },
+ allowUnusedLabels: { type: types.boolean },
+ charset: { type: types.string },
codepage: { type: types.number },
declaration: { type: types.boolean },
diagnostics: { type: types.boolean },
@@ -20,24 +23,28 @@ var compilerOptionsValidation = {
locals: { type: types.string },
listFiles: { type: types.boolean },
mapRoot: { type: types.string },
- module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd'] },
+ module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'] },
moduleResolution: { type: types.string, validValues: ['classic', 'node'] },
newLine: { type: types.string },
noEmit: { type: types.boolean },
noEmitHelpers: { type: types.boolean },
noEmitOnError: { type: types.boolean },
noErrorTruncation: { type: types.boolean },
+ noFallthroughCasesInSwitch: { type: types.boolean },
noImplicitAny: { type: types.boolean },
+ noImplicitReturns: { type: types.boolean },
noLib: { type: types.boolean },
noLibCheck: { type: types.boolean },
noResolve: { type: types.boolean },
out: { type: types.string },
+ outFile: { type: types.string },
outDir: { type: types.string },
preserveConstEnums: { type: types.boolean },
removeComments: { type: types.boolean },
rootDir: { type: types.string },
sourceMap: { type: types.boolean },
sourceRoot: { type: types.string },
+ stripInternal: { type: types.boolean },
suppressExcessPropertyErrors: { type: types.boolean },
suppressImplicitAnyIndexErrors: { type: types.boolean },
target: { type: types.string, validValues: ['es3', 'es5', 'es6'] },
@@ -46,7 +53,7 @@ var compilerOptionsValidation = {
};
var validator = new simpleValidator.SimpleValidator(compilerOptionsValidation);
exports.errors = {
- GET_PROJECT_INVALID_PATH: 'Invalid Path',
+ GET_PROJECT_INVALID_PATH: 'The path used to query for tsconfig.json does not exist',
GET_PROJECT_NO_PROJECT_FOUND: 'No Project Found',
GET_PROJECT_FAILED_TO_OPEN_PROJECT_FILE: 'Failed to fs.readFileSync the project file',
GET_PROJECT_JSON_PARSE_FAILED: 'Failed to JSON.parse the project file',
@@ -61,16 +68,17 @@ function errorWithDetails(error, details) {
}
var fs = require('fs');
var path = require('path');
-var expand = require('glob-expand');
+var tsconfig = require('tsconfig');
var os = require('os');
+var detectIndent = require('detect-indent');
var formatting = require('./formatting');
var projectFileName = 'tsconfig.json';
var defaultFilesGlob = [
- "./**/*.ts",
- "./**/*.tsx",
- "!./node_modules/**/*",
+ "**/*.ts",
+ "**/*.tsx",
+ "!node_modules/**",
];
-var invisibleFilesGlob = ["./**/*.ts", "./**/*.tsx"];
+var invisibleFilesGlob = '{**/*.ts,**/*.tsx}';
exports.defaults = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
@@ -97,8 +105,10 @@ var typescriptEnumMap = {
'none': ts.ModuleKind.None,
'commonjs': ts.ModuleKind.CommonJS,
'amd': ts.ModuleKind.AMD,
- 'system': ts.ModuleKind.System,
'umd': ts.ModuleKind.UMD,
+ 'system': ts.ModuleKind.System,
+ 'es6': ts.ModuleKind.ES6,
+ 'es2015': ts.ModuleKind.ES2015,
},
moduleResolution: {
'node': ts.ModuleResolutionKind.NodeJs,
@@ -142,6 +152,9 @@ function rawToTsCompilerOptions(jsonOptions, projectDir) {
if (compilerOptions.out !== undefined) {
compilerOptions.out = path.resolve(projectDir, compilerOptions.out);
}
+ if (compilerOptions.outFile !== undefined) {
+ compilerOptions.out = path.resolve(projectDir, compilerOptions.outFile);
+ }
return compilerOptions;
}
function tsToRawCompilerOptions(compilerOptions) {
@@ -167,7 +180,8 @@ function getDefaultInMemoryProject(srcFile) {
formatCodeOptions: formatting.defaultFormatCodeOptions(),
compileOnSave: true,
buildOnSave: false,
- scripts: {}
+ scripts: {},
+ atom: { rewriteTsconfig: true },
};
return {
projectFileDirectory: dir,
@@ -182,55 +196,36 @@ function getProjectSync(pathOrSrcFile) {
throw new Error(exports.errors.GET_PROJECT_INVALID_PATH);
}
var dir = fs.lstatSync(pathOrSrcFile).isDirectory() ? pathOrSrcFile : path.dirname(pathOrSrcFile);
- var projectFile = '';
- try {
- projectFile = travelUpTheDirectoryTreeTillYouFind(dir, projectFileName);
+ var projectFile = tsconfig.resolveSync(dir);
+ if (!projectFile) {
+ throw errorWithDetails(new Error(exports.errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: 'not found' });
}
- catch (e) {
- var err = e;
- if (err.message == "not found") {
- throw errorWithDetails(new Error(exports.errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: err.message });
- }
- }
- projectFile = path.normalize(projectFile);
var projectFileDirectory = path.dirname(projectFile) + path.sep;
var projectSpec;
+ var projectFileTextContent;
try {
- var projectFileTextContent = fs.readFileSync(projectFile, 'utf8');
+ projectFileTextContent = fs.readFileSync(projectFile, 'utf8');
}
catch (ex) {
throw new Error(exports.errors.GET_PROJECT_FAILED_TO_OPEN_PROJECT_FILE);
}
try {
- projectSpec = JSON.parse(stripBom(projectFileTextContent));
+ projectSpec = tsconfig.parseFileSync(projectFileTextContent, projectFile, { resolvePaths: false });
}
catch (ex) {
throw errorWithDetails(new Error(exports.errors.GET_PROJECT_JSON_PARSE_FAILED), { projectFilePath: fsu.consistentPath(projectFile), error: ex.message });
}
- if (!projectSpec.compilerOptions)
- projectSpec.compilerOptions = {};
- var cwdPath = path.relative(process.cwd(), path.dirname(projectFile));
- if (!projectSpec.files && !projectSpec.filesGlob) {
- var toExpand = invisibleFilesGlob;
+ if (!projectSpec.atom) {
+ projectSpec.atom = {
+ rewriteTsconfig: true,
+ };
}
if (projectSpec.filesGlob) {
- var toExpand = projectSpec.filesGlob;
- }
- if (toExpand) {
- try {
- projectSpec.files = expand({ filter: 'isFile', cwd: cwdPath }, toExpand);
- }
- catch (ex) {
- throw errorWithDetails(new Error(exports.errors.GET_PROJECT_GLOB_EXPAND_FAILED), { glob: projectSpec.filesGlob, projectFilePath: fsu.consistentPath(projectFile), errorMessage: ex.message });
- }
- }
- if (projectSpec.filesGlob) {
- var prettyJSONProjectSpec = prettyJSON(projectSpec);
- if (prettyJSONProjectSpec !== projectFileTextContent) {
- fs.writeFileSync(projectFile, prettyJSON(projectSpec));
+ var prettyJSONProjectSpec = prettyJSON(projectSpec, detectIndent(projectFileTextContent).indent);
+ if (prettyJSONProjectSpec !== projectFileTextContent && projectSpec.atom.rewriteTsconfig) {
+ fs.writeFileSync(projectFile, prettyJSONProjectSpec);
}
}
- projectSpec.files = projectSpec.files.map(function (file) { return path.resolve(projectFileDirectory, file); });
var pkg = null;
try {
var packagePath = travelUpTheDirectoryTreeTillYouFind(projectFileDirectory, 'package.json');
@@ -249,7 +244,7 @@ function getProjectSync(pathOrSrcFile) {
}
var project = {
compilerOptions: {},
- files: projectSpec.files,
+ files: projectSpec.files.map(function (x) { return path.resolve(projectFileDirectory, x); }),
filesGlob: projectSpec.filesGlob,
formatCodeOptions: formatting.makeFormatCodeOptions(projectSpec.formatCodeOptions),
compileOnSave: projectSpec.compileOnSave == undefined ? true : projectSpec.compileOnSave,
@@ -257,7 +252,8 @@ function getProjectSync(pathOrSrcFile) {
typings: [],
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
scripts: projectSpec.scripts || {},
- buildOnSave: !!projectSpec.buildOnSave
+ buildOnSave: !!projectSpec.buildOnSave,
+ atom: { rewriteTsconfig: true }
};
var validationResult = validator.validate(projectSpec.compilerOptions);
if (validationResult.errorMessage) {
@@ -290,6 +286,8 @@ function createProjectRootSync(srcFile, defaultOptions) {
var projectSpec = {};
projectSpec.compilerOptions = tsToRawCompilerOptions(defaultOptions || exports.defaults);
projectSpec.filesGlob = defaultFilesGlob;
+ projectSpec.compileOnSave = true;
+ projectSpec.buildOnSave = false;
fs.writeFileSync(projectFilePath, prettyJSON(projectSpec));
return getProjectSync(srcFile);
}
@@ -316,28 +314,32 @@ function increaseProjectForReferenceAndImports(files) {
return;
}
var preProcessedFileInfo = ts.preProcessFile(content, true), dir = path.dirname(file);
+ var extensions = ['.ts', '.d.ts', '.tsx'];
+ function getIfExists(filePathNoExt) {
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
+ var ext = extensions_1[_i];
+ if (fs.existsSync(filePathNoExt + ext)) {
+ return filePathNoExt + ext;
+ }
+ }
+ }
referenced.push(preProcessedFileInfo.referencedFiles.map(function (fileReference) {
var file = path.resolve(dir, fsu.consistentPath(fileReference.fileName));
if (fs.existsSync(file)) {
return file;
}
- if (fs.existsSync(file + '.ts')) {
- return file + '.ts';
- }
- if (fs.existsSync(file + '.d.ts')) {
- return file + '.d.ts';
- }
- return null;
+ return getIfExists(file);
}).filter(function (file) { return !!file; })
.concat(preProcessedFileInfo.importedFiles
.filter(function (fileReference) { return pathIsRelative(fileReference.fileName); })
.map(function (fileReference) {
- var file = path.resolve(dir, fileReference.fileName + '.ts');
- if (!fs.existsSync(file)) {
- file = path.resolve(dir, fileReference.fileName + '.d.ts');
+ var fileNoExt = path.resolve(dir, fileReference.fileName);
+ var file = getIfExists(fileNoExt);
+ if (!file) {
+ file = getIfExists(file + "/index");
}
return file;
- })));
+ }).filter(function (file) { return !!file; })));
});
return selectMany(referenced);
};
@@ -387,8 +389,8 @@ function getDefinitionsForNodeModules(projectDir, files) {
try {
var node_modules = travelUpTheDirectoryTreeTillYouFind(projectDir, 'node_modules', true);
var moduleDirs = getDirs(node_modules);
- for (var _i = 0; _i < moduleDirs.length; _i++) {
- var moduleDir = moduleDirs[_i];
+ for (var _i = 0, moduleDirs_1 = moduleDirs; _i < moduleDirs_1.length; _i++) {
+ var moduleDir = moduleDirs_1[_i];
try {
var package_json = JSON.parse(fs.readFileSync(moduleDir + "/package.json").toString());
packagejson.push(moduleDir + "/package.json");
@@ -422,7 +424,8 @@ function getDefinitionsForNodeModules(projectDir, files) {
.filter(function (x) { return existing[x]; });
return { implicit: implicit, ours: ours, packagejson: packagejson };
}
-function prettyJSON(object) {
+function prettyJSON(object, indent) {
+ if (indent === void 0) { indent = 4; }
var cache = [];
var value = JSON.stringify(object, function (key, value) {
if (typeof value === 'object' && value !== null) {
@@ -432,7 +435,7 @@ function prettyJSON(object) {
cache.push(value);
}
return value;
- }, 4);
+ }, indent);
value = value.split('\n').join(os.EOL) + os.EOL;
cache = null;
return value;
@@ -512,8 +515,8 @@ exports.getPotentiallyRelativeFile = getPotentiallyRelativeFile;
function getDirs(rootDir) {
var files = fs.readdirSync(rootDir);
var dirs = [];
- for (var _i = 0; _i < files.length; _i++) {
- var file = files[_i];
+ for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
+ var file = files_1[_i];
if (file[0] != '.') {
var filePath = rootDir + "/" + file;
var stat = fs.statSync(filePath);
diff --git a/dist/main/utils/fsUtil.js b/dist/main/utils/fsUtil.js
index 28deb7766..1cde4272c 100644
--- a/dist/main/utils/fsUtil.js
+++ b/dist/main/utils/fsUtil.js
@@ -1,3 +1,4 @@
+"use strict";
function consistentPath(filePath) {
return filePath.split('\\').join('/');
}
diff --git a/dist/typescript/makeTypeScriptGlobal.js b/dist/typescript/makeTypeScriptGlobal.js
index 45d9a5ad1..978443a0f 100644
--- a/dist/typescript/makeTypeScriptGlobal.js
+++ b/dist/typescript/makeTypeScriptGlobal.js
@@ -1,3 +1,4 @@
+"use strict";
var vm = require('vm');
var fs = require('fs');
global.stack = function () {
diff --git a/dist/worker/child.js b/dist/worker/child.js
index 080ea9996..df1df3c34 100644
--- a/dist/worker/child.js
+++ b/dist/worker/child.js
@@ -1,3 +1,4 @@
+"use strict";
var typescriptServices = '';
if (process.argv.length > 2) {
typescriptServices = process.argv[2];
diff --git a/dist/worker/debug.js b/dist/worker/debug.js
index ad5f2b7ee..a77b0f234 100644
--- a/dist/worker/debug.js
+++ b/dist/worker/debug.js
@@ -1,2 +1,3 @@
+"use strict";
exports.debugAll = false;
exports.debugSync = false || exports.debugAll;
diff --git a/dist/worker/lib/workerLib.js b/dist/worker/lib/workerLib.js
index 3d1677d9a..837a8ed0d 100644
--- a/dist/worker/lib/workerLib.js
+++ b/dist/worker/lib/workerLib.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
@@ -17,7 +18,6 @@ var orphanExitCode = 100;
var RequesterResponder = (function () {
function RequesterResponder() {
var _this = this;
- this.getProcess = function () { throw new Error('getProcess is abstract'); return null; };
this.currentListeners = {};
this.currentLastOfType = {};
this.pendingRequests = [];
@@ -139,7 +139,7 @@ var RequesterResponder = (function () {
.forEach(function (funcName) { return _this.addToResponders(aModule[funcName]); });
};
return RequesterResponder;
-})();
+}());
var Parent = (function (_super) {
__extends(Parent, _super);
function Parent() {
@@ -153,9 +153,15 @@ var Parent = (function (_super) {
Parent.prototype.startWorker = function (childJsPath, terminalError, customArguments) {
var _this = this;
try {
+ var spawnEnv = (process.platform === 'linux') ? Object.create(process.env) : {};
+ spawnEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
this.child = spawn(this.node, [
childJsPath
- ].concat(customArguments), { cwd: path.dirname(childJsPath), env: { ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1' }, stdio: ['ipc'] });
+ ].concat(customArguments), {
+ cwd: path.dirname(childJsPath),
+ env: spawnEnv,
+ stdio: ['ipc']
+ });
this.child.on('error', function (err) {
if (err.code === "ENOENT" && err.path === _this.node) {
_this.gotENOENTonSpawnNode = true;
@@ -207,7 +213,7 @@ var Parent = (function (_super) {
this.child = null;
};
return Parent;
-})(RequesterResponder);
+}(RequesterResponder));
exports.Parent = Parent;
var Child = (function (_super) {
__extends(Child, _super);
@@ -233,5 +239,5 @@ var Child = (function (_super) {
}, 1000);
};
return Child;
-})(RequesterResponder);
+}(RequesterResponder));
exports.Child = Child;
diff --git a/dist/worker/parent.js b/dist/worker/parent.js
index 2c5885ab8..f57feb6cd 100644
--- a/dist/worker/parent.js
+++ b/dist/worker/parent.js
@@ -1,3 +1,4 @@
+"use strict";
var debug_1 = require("./debug");
var childprocess = require('child_process');
var exec = childprocess.exec;
@@ -16,11 +17,15 @@ if (debug_1.debugSync) {
parent.sendToIpcOnlyLast = function (x) { return x; };
}
function startWorker() {
- parent.startWorker(__dirname + '/child.js', showError, atomConfig.typescriptServices ? [atomConfig.typescriptServices] : []);
+ if (!debug_1.debugSync) {
+ parent.startWorker(__dirname + '/child.js', showError, atomConfig.typescriptServices ? [atomConfig.typescriptServices] : []);
+ }
}
exports.startWorker = startWorker;
function stopWorker() {
- parent.stopWorker();
+ if (!debug_1.debugSync) {
+ parent.stopWorker();
+ }
}
exports.stopWorker = stopWorker;
function showError(error) {
diff --git a/dist/worker/queryParent.js b/dist/worker/queryParent.js
index 5816d167f..f76da632f 100644
--- a/dist/worker/queryParent.js
+++ b/dist/worker/queryParent.js
@@ -1,3 +1,4 @@
+"use strict";
var resolve = Promise.resolve.bind(Promise);
var tsconfig = require('../main/tsconfig/tsconfig');
var atomUtils;
diff --git a/docs/faq.md b/docs/faq.md
index 1ba0c31ac..03e0e0dfd 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -3,8 +3,27 @@
## I keep getting changes to tsconfig.json
This is probably because of us keeping `files` updated with the `filesGlob` option. The reason why we do this is because the official `tsconfig.json` spec does not support `filesGlob`. Therefore we keep `files` in sync with the `filesGlob` so that your team mates can use whatever editor they prefer (sublime text, visual studio etc.).
+You can now disable this behavior by setting the `rewriteTsconfig` flag to `false` in your project's `tsconfig.json` under the `atom` key.
+
+[Further Details](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#atom)
+
+## For really large projects atom-typescript gets slow
+If you have `tsconfig.json` in a folder that contains `node_modules`, atom-typescript might become slow (due to extensive file listing). Two possible fixes:
+* Move `tsconfig.json` into a sub folder e.g. `src`
+* Add a `filesGlob` that excludes `node_modules` e.g.:
+
+```ts
+"filesGlob" : [
+ "**/*.ts",
+ "**/*.tsx",
+ "!node_modules/**",
+];
+```
+
+[Further Details](https://github.com/TypeStrong/atom-typescript/issues/648).
+
## I don't want atom-typescript compiling my js
-Set `compileOnSave : false` in your tsconfig.json (https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave). Then you've got all the intellisense / refactoring goodness of atom-typescript but no generated JavaScript. Why is this useful? Well you might be using something else for your build such as [gulp-typescript](https://github.com/ivogabe/gulp-typescript) or [tsify](https://github.com/smrq/tsify).
+Set `compileOnSave : false` in your tsconfig.json (https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave). Then you've got all the intellisense / refactoring goodness of atom-typescript but no generated JavaScript. Why is this useful? Well you might be using something else for your build such as [ts-loader](https://github.com/TypeStrong/ts-loader) or [tsify](https://github.com/TypeStrong/tsify) or [gulp-typescript](https://github.com/ivogabe/gulp-typescript).
## Which version of TypeScript does atom-typescript use?
It uses [ntypescript](https://github.com/TypeStrong/ntypescript) which is just a build of Microsoft/Master. This means it's the latest and greatest of the TypeScript goodness. There is a possibility that in the future it will move to TypeScript nightlies but our current automation is working well.
@@ -35,7 +54,7 @@ You can set that in the package settings https://atom.io/docs/latest/using-atom-
You probably deleted them or added them or moved them around. We don't watch the file system as it is memory intensive and unreliable across operating systems. You can ask atom-typescript to do a rescan of your file system using the `sync` command (https://github.com/TypeStrong/atom-typescript#sync)
## Failed to Update
-This can happen particularly on windows as it is not possible to delete a file if it is executing. Close all atom instances and run the following commands:
+This can happen particularly on windows ([relevant issue](https://github.com/TypeStrong/atom-typescript/issues/195)) as it is not possible to delete a file if it is executing. Close all atom instances and run the following commands:
```
apm uninstall atom-typescript
diff --git a/docs/packages.md b/docs/packages.md
index 86d038424..4fc10a02a 100644
--- a/docs/packages.md
+++ b/docs/packages.md
@@ -2,9 +2,6 @@
## Critical
-### autocomplete-plus
-We will install this for you to give a good autocomplete experience
-
### linter
We will install this for you to give a good error highlight experience
@@ -55,4 +52,4 @@ https://atom.io/packages/pain-split a better pane splitting mechanism.
https://atom.io/packages/docblockr for easier jsdocing
### Styles
-[Here's my styles.less](https://gist.github.com/basarat/87d0a17a850b74a1cc07)
\ No newline at end of file
+[Here's my styles.less](https://gist.github.com/basarat/87d0a17a850b74a1cc07)
diff --git a/docs/tsconfig.md b/docs/tsconfig.md
index 0e8ecafd2..50e443e33 100644
--- a/docs/tsconfig.md
+++ b/docs/tsconfig.md
@@ -1,5 +1,5 @@
# `tsconfig.json`
-A unified project format for TypeScript ([see merged PR on Microsoft/TypeScript](https://github.com/Microsoft/TypeScript/pull/1692)). The TypeScript compiler (`1.5` and above) only cares about `compilerOptions` and `files`. We add additional features to this [with the typescript team's approval to extend the file as long as we don't conflict](https://github.com/Microsoft/TypeScript/issues/1955).
+A unified project format for TypeScript ([see merged PR on Microsoft/TypeScript](https://github.com/Microsoft/TypeScript/pull/1692)). The TypeScript compiler (`1.5` and above) only cares about `compilerOptions` and `files`. TypeScript `1.6` introduced the `exclude` property. We add additional features to this [with the typescript team's approval to extend the file as long as we don't conflict](https://github.com/Microsoft/TypeScript/issues/1955).
`tsconfig.json` is great for building the ["compilation context" so you **don't need to use** `/// ]|var|type|function|class|interface)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "enum-declaration":
+ name: "meta.enum.declaration.ts"
+ match: "(?:\\b(const)\\s+)?\\b(enum)\\s+([a-zA-Z_$][\\w$]*)"
+ captures:
+ "1":
+ name: "storage.modifier.ts"
+ "2":
+ name: "storage.type.ts"
+ "3":
+ name: "entity.name.class.ts"
+ "object-declaration":
+ name: "meta.declaration.object.ts"
+ begin: "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ type:
+ name: "meta.type.ts"
+ patterns: [
+ {
+ include: "#type-primitive"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#type-tuple"
+ }
+ {
+ include: "#type-object"
+ }
+ {
+ include: "#type-operator"
+ }
+ {
+ include: "#type-paren-or-function-type-parameters"
+ }
+ {
+ include: "#type-function-return-type"
+ }
+ {
+ include: "#type-name"
+ }
+ ]
+ "function-type-parameters":
+ name: "meta.function.type.parameter.ts"
+ begin: "\\("
+ beginCaptures:
+ "0":
+ name: "meta.brace.round.ts"
+ end: "\\)"
+ endCaptures:
+ "0":
+ name: "meta.brace.round.ts"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#parameter-name"
+ }
+ {
+ include: "#type-annotation"
+ }
+ {
+ include: "#variable-initializer"
+ }
+ ]
+ "type-primitive":
+ name: "meta.type.primitive.ts"
+ match: "\\b(string|number|boolean|symbol|any|void)\\b"
+ captures:
+ "1":
+ name: "storage.type.ts"
+ "type-paren-or-function-type-parameters":
+ name: "meta.type.paren.cover.ts"
+ begin: "(?:\\b(new)\\b)?\\s*\\("
+ beginCaptures:
+ "1":
+ name: "keyword.control.ts"
+ end: "\\)"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ {
+ include: "#function-type-parameters"
+ }
+ ]
+ "await-modifier":
+ name: "storage.modifier.ts"
+ match: "await"
+ "type-operator":
+ name: "keyword.operator.type.ts"
+ match: "[.|]"
+ "type-function-return-type":
+ name: "meta.type.function.return.ts"
+ begin: "=>"
+ beginCaptures:
+ "0":
+ name: "keyword.operator.ts"
+ end: "(?=\\s*[,\\)\\{=;>]|//|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "type-tuple":
+ name: "meta.type.tuple.ts"
+ begin: "\\["
+ beginCaptures:
+ "0":
+ name: "meta.brace.square.ts"
+ end: "\\]"
+ endCaptures:
+ "0":
+ name: "meta.brace.square.ts"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "type-name":
+ name: "meta.type.name.ts"
+ match: "[a-zA-Z_$][.\\w$]*"
+ captures:
+ "1":
+ name: "entity.name.type.ts"
+ "type-parameters":
+ name: "meta.type.parameters.ts"
+ begin: "([a-zA-Z_$][\\w$]*)?(<)"
+ beginCaptures:
+ "1":
+ name: "entity.name.type.ts"
+ "2":
+ name: "meta.brace.angle.ts"
+ end: "(?=$)|(>)"
+ endCaptures:
+ "2":
+ name: "meta.brace.angle.ts"
+ patterns: [
+ {
+ name: "keyword.other.ts"
+ match: "\\b(extends)\\b"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ ]
+ "variable-initializer":
+ begin: "(=)"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.ts"
+ end: "(?=$|[,);=])"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ expression:
+ name: "meta.expression.ts"
+ patterns: [
+ {
+ comment: "Match ES6 \"import from\" syntax"
+ match: "(import).*(from)\\s+((['\"`]).*\\4)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "keyword.other.ts"
+ "3":
+ name: "es6import.path.string"
+ }
+ {
+ comment: "Match import = require"
+ match: "(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*=\\s*(require)\\s*\\((.*)\\)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "variable.type.ts"
+ "3":
+ name: "keyword.other.ts"
+ "4":
+ name: "require.path.string"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match full triple slash reference comments"
+ match: "(\\/\\/\\/\\s*)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "reference.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match debugger statement"
+ match: "\\b(debugger)\\b"
+ captures:
+ "1":
+ name: "keyword.debugger.ts"
+ }
+ {
+ include: "#for-in-simple"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#regex"
+ }
+ {
+ include: "#template"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#literal"
+ }
+ {
+ include: "#paren-expression"
+ }
+ {
+ include: "#var-expr"
+ }
+ {
+ include: "#declaration"
+ }
+ {
+ include: "#cast"
+ }
+ {
+ include: "#new-expr"
+ }
+ {
+ include: "#block"
+ }
+ {
+ include: "#expression-operator"
+ }
+ {
+ include: "#relational-operator"
+ }
+ {
+ include: "#arithmetic-operator"
+ }
+ {
+ include: "#logic-operator"
+ }
+ {
+ include: "#assignment-operator"
+ }
+ {
+ include: "#storage-keyword"
+ }
+ {
+ include: "#function-call"
+ }
+ {
+ include: "#switch-case"
+ }
+ {
+ include: "#control-statement"
+ }
+ ]
+ "for-in-simple":
+ name: "forin.expr.ts"
+ match: "(?<=\\()\\s*\\b(var|let|const)\\s+([a-zA-Z_$][\\w$]*)\\s+(in|of)\\b"
+ captures:
+ "1":
+ name: "storage.type.ts"
+ "3":
+ name: "keyword.operator.ts"
+ "function-call":
+ name: "functioncall.expr.ts"
+ patterns: [
+ {
+ include: "#await-modifier"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#paren-expression"
+ }
+ ]
+ cast:
+ name: "cast.expr.ts"
+ begin: "(?:(?<=return|throw|yield|await|[=(,:>]))\\s*(<)(?!\\=)"
+ beginCaptures:
+ "1":
+ name: "meta.brace.angle.ts"
+ end: ">"
+ endCaptures:
+ "0":
+ name: "meta.brace.angle.ts"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "new-expr":
+ name: "new.expr.ts"
+ begin: "\\b(new)\\b"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.ts"
+ end: "(?=[(;]|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "object-member":
+ name: "meta.object.member.ts"
+ begin: "[a-zA-Z_$][\\w$]*\\s*:"
+ end: "(?=,|\\})"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "expression-operator":
+ name: "keyword.operator.ts"
+ match: "=>|\\b(delete|export|import|in|instanceof|module|namespace|new|typeof|void)\\b"
+ "arithmetic-operator":
+ name: "keyword.operator.arithmetic.ts"
+ match: "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%"
+ "relational-operator":
+ name: "keyword.operator.comparison.ts"
+ match: "===|==|=|!=|!==|<=|>=|<>|<|>"
+ "assignment-operator":
+ name: "keyword.operator.assignment.ts"
+ match: "<<=|>>=|>>>=|\\*=|(?]|var|type|function|class|interface)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "enum-declaration":
+ name: "meta.enum.declaration.tsx"
+ match: "(?:\\b(const)\\s+)?\\b(enum)\\s+([a-zA-Z_$][\\w$]*)"
+ captures:
+ "1":
+ name: "storage.modifier.tsx"
+ "2":
+ name: "storage.type.tsx"
+ "3":
+ name: "entity.name.class.tsx"
+ "object-declaration":
+ name: "meta.declaration.object.tsx"
+ begin: "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ type:
+ name: "meta.type.tsx"
+ patterns: [
+ {
+ include: "#type-primitive"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#type-tuple"
+ }
+ {
+ include: "#type-object"
+ }
+ {
+ include: "#type-operator"
+ }
+ {
+ include: "#type-paren-or-function-type-parameters"
+ }
+ {
+ include: "#type-function-return-type"
+ }
+ {
+ include: "#type-name"
+ }
+ ]
+ "function-type-parameters":
+ name: "meta.function.type.parameter.tsx"
+ begin: "\\("
+ beginCaptures:
+ "0":
+ name: "meta.brace.round.tsx"
+ end: "\\)"
+ endCaptures:
+ "0":
+ name: "meta.brace.round.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#parameter-name"
+ }
+ {
+ include: "#type-annotation"
+ }
+ {
+ include: "#variable-initializer"
+ }
+ ]
+ "type-primitive":
+ name: "meta.type.primitive.tsx"
+ match: "\\b(string|number|boolean|symbol|any|void)\\b"
+ captures:
+ "1":
+ name: "storage.type.tsx"
+ "type-paren-or-function-type-parameters":
+ name: "meta.type.paren.cover.tsx"
+ begin: "(?:\\b(new)\\b)?\\s*\\("
+ beginCaptures:
+ "1":
+ name: "keyword.control.tsx"
+ end: "\\)"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ {
+ include: "#function-type-parameters"
+ }
+ ]
+ "type-operator":
+ name: "keyword.operator.type.tsx"
+ match: "[.|]"
+ "type-function-return-type":
+ name: "meta.type.function.return.tsx"
+ begin: "=>"
+ beginCaptures:
+ "0":
+ name: "keyword.operator.tsx"
+ end: "(?=\\s*[,\\)\\{=;>]|//|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "type-tuple":
+ name: "meta.type.tuple.tsx"
+ begin: "\\["
+ beginCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ end: "\\]"
+ endCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "type-name":
+ name: "meta.type.name.tsx"
+ match: "[a-zA-Z_$][.\\w$]*"
+ captures:
+ "1":
+ name: "entity.name.type.tsx"
+ "type-parameters":
+ name: "meta.type.parameters.tsx"
+ begin: "([a-zA-Z_$][\\w$]*)?(<)"
+ beginCaptures:
+ "1":
+ name: "entity.name.type.tsx"
+ "2":
+ name: "meta.brace.angle.tsx"
+ end: "(?=$)|(>)"
+ endCaptures:
+ "2":
+ name: "meta.brace.angle.tsx"
+ patterns: [
+ {
+ name: "keyword.other.tsx"
+ match: "\\b(extends)\\b"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ ]
+ "variable-initializer":
+ begin: "(=)"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.tsx"
+ end: "(?=$|[,);=])"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ expression:
+ name: "meta.expression.tsx"
+ patterns: [
+ {
+ comment: "Match ES6 \"import from\" syntax"
+ match: "(import).*(from)\\s+((['\"`]).*\\4)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "keyword.other.ts"
+ "3":
+ name: "es6import.path.string"
+ }
+ {
+ comment: "Match import = require"
+ match: "(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*=\\s*(require)\\s*\\((.*)\\)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "variable.type.ts"
+ "3":
+ name: "keyword.other.ts"
+ "4":
+ name: "require.path.string"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match full triple slash reference comments"
+ match: "(\\/\\/\\/\\s*)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "reference.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match debugger statement"
+ match: "\\b(debugger)\\b"
+ captures:
+ "1":
+ name: "keyword.debugger.ts"
+ }
+ {
+ include: "#jsx"
+ }
+ {
+ include: "#for-in-simple"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#regex"
+ }
+ {
+ include: "#template"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#literal"
+ }
+ {
+ include: "#paren-expression"
+ }
{
- 'include': '#pcdata-quotes'
+ include: "#var-expr"
+ }
+ {
+ include: "#declaration"
+ }
+ {
+ include: "#new-expr"
+ }
+ {
+ include: "#block"
+ }
+ {
+ include: "#expression-operator"
+ }
+ {
+ include: "#relational-operator"
+ }
+ {
+ include: "#arithmetic-operator"
+ }
+ {
+ include: "#logic-operator"
+ }
+ {
+ include: "#assignment-operator"
+ }
+ {
+ include: "#storage-keyword"
+ }
+ {
+ include: "#function-call"
+ }
+ {
+ include: "#switch-case"
+ }
+ {
+ include: "#control-statement"
}
]
- 'pcdata-quotes':
- 'name': 'meta.other.pcdata.js'
- 'match': '\\b\\w+[\'"]\\w+\\b'
- 'jsx-tag-attributes':
- 'patterns': [
+ "for-in-simple":
+ name: "forin.expr.tsx"
+ match: "(?<=\\()\\s*\\b(var|let|const)\\s+([a-zA-Z_$][\\w$]*)\\s+(in|of)\\b"
+ captures:
+ "1":
+ name: "storage.type.tsx"
+ "3":
+ name: "keyword.operator.tsx"
+ "function-call":
+ name: "functioncall.expr.tsx"
+ patterns: [
{
- 'include': '#jsx-tag-attribute-name'
+ include: "#type-parameters"
}
{
- 'include': '#jsx-string-double-quoted'
+ include: "#paren-expression"
}
+ ]
+ "new-expr":
+ name: "new.expr.tsx"
+ begin: "\\b(new)\\b"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.tsx"
+ end: "(?=[(;]|$)"
+ patterns: [
{
- 'include': '#jsx-string-single-quoted'
- }
- {
- 'include': '#jsx-evaluated-code'
- }
- ]
- 'jsx-tag-attribute-name':
- 'name': 'meta.tag.attribute-name.js'
- 'match': '\\b([a-zA-Z0-9\\-:]+)'
- 'captures':
- '1':
- 'name': 'entity.other.attribute-name.js'
- 'jsx-string-double-quoted':
- 'begin': '"'
- 'end': '"'
- 'name': 'string.quoted.double.js'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.string.end.js'
- 'beginCaptures':
- '0':
- 'name': 'punctuation.definition.string.begin.js'
- 'patterns': [
+ include: "#type"
+ }
+ ]
+ "object-member":
+ name: "meta.object.member.tsx"
+ begin: "[a-zA-Z_$][\\w$]*\\s*:"
+ end: "(?=,|\\})"
+ patterns: [
{
- 'include': '#jsx-entities'
+ include: "#expression"
}
]
- 'jsx-string-single-quoted':
- 'begin': '\''
- 'end': '\''
- 'name': 'string.quoted.single.js'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.string.end.js'
- 'beginCaptures':
- '0':
- 'name': 'punctuation.definition.string.begin.js'
- 'patterns': [
+ "expression-operator":
+ name: "keyword.operator.tsx"
+ match: "=>|\\b(delete|export|import|in|instanceof|module|namespace|new|typeof|void|as)\\b"
+ "arithmetic-operator":
+ name: "keyword.operator.arithmetic.tsx"
+ match: "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%"
+ "relational-operator":
+ name: "keyword.operator.comparison.tsx"
+ match: "===|==|=|!=|!==|<=|>=|<>|<|>"
+ "assignment-operator":
+ name: "keyword.operator.assignment.tsx"
+ match: "<<=|>>=|>>>=|\\*=|(?)'
- 'name': 'tag.open.js'
- 'endCaptures':
- '1':
- 'name': 'punctuation.definition.tag.end.js'
- 'beginCaptures':
- '1':
- 'name': 'punctuation.definition.tag.begin.js'
- '2':
- 'name': 'entity.name.tag.js'
- 'patterns': [
+ string:
+ name: "string.tsx"
+ patterns: [
+ {
+ include: "#qstring-single"
+ }
{
- 'include': '#jsx-tag-attributes'
+ include: "#qstring-double"
}
]
- 'jsx-tag-close':
- 'match': '()([^>]+)(>)'
- 'name': 'tag.closed.js'
- 'captures':
- '1':
- 'name': 'punctuation.definition.tag.begin.js'
- '2':
- 'name': 'entity.name.tag.js'
- '3':
- 'name': 'punctuation.definition.tag.end.js'
- 'jsx-tag-invalid':
- 'name': 'invalid.illegal.tag.incomplete.js'
- 'match': '<\\s*>'
- 'jsx':
- 'name': 'meta.jsx.js'
- 'patterns': [
- {
- 'include': '#jsx-tag-open'
- }
- {
- 'include': '#jsx-tag-close'
- }
- {
- 'include': '#jsx-tag-invalid'
+ template:
+ name: "meta.template.tsx"
+ begin: "`"
+ beginCaptures:
+ "0":
+ name: "string.template.tsx"
+ end: "`"
+ endCaptures:
+ "0":
+ name: "string.template.tsx"
+ patterns: [
+ {
+ include: "#template-substitution-element"
+ }
+ {
+ include: "#template-string-contents"
+ }
+ ]
+ "template-string-contents":
+ name: "string.template.tsx"
+ begin: ".*?"
+ end: "(?=(\\$\\{|`))"
+ patterns: [
+ {
+ include: "#string-character-escape"
}
]
+ "string-character-escape":
+ name: "constant.character.escape"
+ match: "\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)"
+ "template-substitution-element":
+ name: "template.element.tsx"
+ begin: "\\$\\{"
+ beginCaptures:
+ "0":
+ name: "keyword.operator.tsx"
+ end: "\\}"
+ endCaptures:
+ "0":
+ name: "keyword.operator.tsx"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ comment:
+ name: "comment.tsx"
+ patterns: [
+ {
+ include: "#comment-block-doc"
+ }
+ {
+ include: "#comment-block"
+ }
+ {
+ include: "#comment-line"
+ }
+ ]
+ "comment-block-doc":
+ name: "comment.block.documentation.tsx"
+ begin: "/\\*\\*(?!/)"
+ end: "\\*/"
+ "comment-block":
+ name: "comment.block.tsx"
+ begin: "/\\*"
+ end: "\\*/"
+ "comment-line":
+ name: "comment.line.tsx"
+ match: "(//).*$\\n?"
+ literal:
+ name: "literal.tsx"
+ patterns: [
+ {
+ include: "#numeric-literal"
+ }
+ {
+ include: "#boolean-literal"
+ }
+ {
+ include: "#null-literal"
+ }
+ {
+ include: "#undefined-literal"
+ }
+ {
+ include: "#array-literal"
+ }
+ {
+ include: "#this-literal"
+ }
+ ]
+ "array-literal":
+ name: "meta.array.literal.tsx"
+ begin: "\\["
+ beginCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ end: "\\]"
+ endCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "numeric-literal":
+ name: "constant.numeric.tsx"
+ match: "\\b(?<=[^$])((0(x|X)[0-9a-fA-F]+)|([0-9]+(\\.[0-9]+)?))\\b"
+ "boolean-literal":
+ name: "constant.language.boolean.tsx"
+ match: "\\b(false|true)\\b"
+ "null-literal":
+ name: "constant.language.null.tsx"
+ match: "\\b(null)\\b"
+ "this-literal":
+ name: "constant.language.this.tsx"
+ match: "\\b(this)\\b"
+ "undefined-literal":
+ name: "constant.language.tsx"
+ match: "\\b(undefined)\\b"
+ "access-modifier":
+ name: "storage.modifier.tsx"
+ match: "\\b(public|protected|private)\\b"
+ "static-modifier":
+ name: "keyword.other.tsx"
+ match: "\\b(static)\\b"
+ "property-accessor":
+ name: "storage.type.property.tsx"
+ match: "\\b(get|set)\\b"
+ "jsx-tag-attributes":
+ patterns: [
+ {
+ include: "#jsx-tag-attribute-name"
+ }
+ {
+ include: "#jsx-tag-attribute-assignment"
+ }
+ {
+ include: "#jsx-string-double-quoted"
+ }
+ {
+ include: "#jsx-string-single-quoted"
+ }
+ {
+ include: "#jsx-evaluated-code"
+ }
+ ]
+ "jsx-tag-attribute-name":
+ name: "meta.tag.attribute-name.tsx"
+ match: '''
+ (?x)
+ \\s*
+ ([_$a-zA-Z][-$\\w]*)
+ (?=\\s|=|/?>|/\\*|//)
+ '''
+ captures:
+ "1":
+ name: "entity.other.attribute-name.tsx"
+ "jsx-tag-attribute-assignment":
+ name: "keyword.operator.assignment.tsx"
+ match: "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))"
+ "jsx-string-double-quoted":
+ name: "string.quoted.double.tsx"
+ begin: "\""
+ end: "\""
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.string.begin.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.string.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ "jsx-string-single-quoted":
+ name: "string.quoted.single.tsx"
+ begin: "'"
+ end: "'"
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.string.begin.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.string.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ "jsx-entities":
+ patterns: [
+ {
+ name: "constant.character.entity.tsx"
+ match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)"
+ captures:
+ "1":
+ name: "punctuation.definition.entity.tsx"
+ "3":
+ name: "punctuation.definition.entity.tsx"
+ }
+ {
+ name: "invalid.illegal.bad-ampersand.tsx"
+ match: "&"
+ }
+ ]
+ "jsx-evaluated-code":
+ name: "meta.brace.curly.tsx"
+ begin: "{"
+ end: "}"
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.brace.curly.start.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.brace.curly.end.tsx"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "jsx-tag-attributes-illegal":
+ name: "invalid.illegal.attribute.tsx"
+ match: "\\S+"
+ "jsx-tag-without-attributes":
+ name: "tag.without-attributes.tsx"
+ begin: "(<)([_$a-zA-Z][-$\\w.]*(?)"
+ end: "()([_$a-zA-Z][-$\\w.]*(?)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ "3":
+ name: "punctuation.definition.tag.end.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ "3":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-children"
+ }
+ ]
+ "jsx-tag-open":
+ name: "tag.open.tsx"
+ begin: '''
+ (?x)
+ (<)
+ ([_$a-zA-Z][-$\\w.]*(?)
+ '''
+ end: "(/?>)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#jsx-tag-attributes"
+ }
+ {
+ include: "#jsx-tag-attributes-illegal"
+ }
+ ]
+ "jsx-tag-close":
+ name: "tag.close.tsx"
+ begin: "()([_$a-zA-Z][-$\\w.]*(?)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ ]
+ "jsx-tag-invalid":
+ name: "invalid.illegal.tag.incomplete.tsx"
+ match: "<\\s*>"
+ "jsx-children":
+ patterns: [
+ {
+ include: "#jsx-tag-without-attributes"
+ }
+ {
+ include: "#jsx-tag-open"
+ }
+ {
+ include: "#jsx-tag-close"
+ }
+ {
+ include: "#jsx-tag-invalid"
+ }
+ {
+ include: "#jsx-evaluated-code"
+ }
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ jsx:
+ name: "meta.jsx.tsx"
+ patterns: [
+ {
+ include: "#jsx-tag-without-attributes"
+ }
+ {
+ include: "#jsx-tag-open"
+ }
+ {
+ include: "#jsx-tag-close"
+ }
+ {
+ include: "#jsx-tag-invalid"
+ }
+ {
+ name: "meta.jsx.children.tsx"
+ begin: "(?<=(?:'|\"|})>)"
+ end: "(?=)"
+ patterns: [
+ {
+ include: "#jsx-children"
+ }
+ ]
+ }
+ ]
\ No newline at end of file
diff --git a/grammars/typescript.cson b/grammars/typescript.cson
deleted file mode 100644
index 81fd31f47..000000000
--- a/grammars/typescript.cson
+++ /dev/null
@@ -1,1372 +0,0 @@
-'scopeName': 'source.ts'
-'comment': 'TypeScript Syntax: version 1.0'
-'fileTypes': [
- 'ts'
- 'str'
- 'tst'
-]
-'name': 'TypeScript'
-
-'patterns': [
- {
- 'comment': 'Match stuff like: namespace name {...}'
- 'match': '(?:^|(;)|\\s)(module|namespace)\\s+([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*'
- 'captures':
- '1':
- 'name': 'meta.delimiter.semicolon.js'
- '2':
- 'name': 'keyword.other.ts'
- '3':
- 'patterns': [
- {
- 'match': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*'
- 'name': 'entity.name.type.namespace.ts'
- }
- ]
- }
- {
- 'comment': 'Match types in variable definitions.'
- 'begin': '(var|const|let)\\s+'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- 'end': '(;)|\\b(in|of)\\b|(?)?)?(?:\\s+(extends|implements)\\s)?'
- 'beginCaptures':
- '1':
- 'patterns': [
- {
- 'match': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*'
- 'name': 'meta.class.ts'
- }
- {
- 'match': ','
- 'name': 'meta.delimiter.object.comma.js'
- }
- ]
- '2':
- 'name': 'storage.modifier.ts'
- 'end': '(?(?=\\()'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'match': '((?:(?:private|public|protected|static)\\s+){0,2})(?:(get|set)\\s+)?([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(?=\\()'
- 'captures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.modifier.ts'
- '3':
- 'name': 'entity.name.function.js'
- }
- {
- 'include': '#functionargumentstype'
- }
- {
- 'comment': 'Match function return type'
- 'begin': '(?<=\\))\\s*:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '((?:(?:private|public|protected|static)\\s+){0,2})([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\??)\\s*:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'entity.name.variable.ts'
- '3':
- 'name': 'keyword.operator.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'match': '((?:(?:private|public|protected|static)\\s+){0,2})([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\??)'
- 'captures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'entity.name.variable.ts'
- '3':
- 'name': 'keyword.operator.js'
- }
- {
- 'begin': '\\s*(=)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'keyword.operator.js'
- 'end': '(;)|$'
- 'endCaptures':
- '1':
- 'name': 'meta.delimiter.semicolon.js'
- 'patterns': [
- 'include': '$self'
- ]
- }
- {
- 'include': '#curlybracerecursion'
- }
- {
- 'include': '$self'
- }
- {
- 'match': ';'
- 'name': 'meta.delimiter.semicolon.js'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\.(prototype)\\.([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'support.class.js'
- '2':
- 'name': 'support.constant.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: Sound.prototype.play = function() { … }'
- 'end': '(?!\\G)'
- 'name': 'meta.function.prototype.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\.([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '0':
- 'name': 'meta.function.js'
- '1':
- 'name': 'support.class.js'
- '2':
- 'name': 'entity.name.function.js'
- '3':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: Sound.play = function() { … }'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '0':
- 'name': 'meta.function.js'
- '1':
- 'name': 'entity.name.function.js'
- '2':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: play = function() { … }'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\b([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(:)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'entity.name.function.js'
- '2':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: foobar: function() { … }'
- 'end': '(?!\\G)'
- 'name': 'meta.function.json.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '(?:((\')(.*?)(\'))|((")(.*?)(")))\\s*(:)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'string.quoted.single.js'
- '2':
- 'name': 'punctuation.definition.string.begin.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'punctuation.definition.string.end.js'
- '5':
- 'name': 'string.quoted.double.js'
- '6':
- 'name': 'punctuation.definition.string.begin.js'
- '7':
- 'name': 'entity.name.function.js'
- '8':
- 'name': 'punctuation.definition.string.end.js'
- '9':
- 'name': 'keyword.operator.js'
- 'comment': 'Attempt to match "foo": function'
- 'end': '(?!\\G)'
- 'name': 'meta.function.json.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#decorator'
- }
- {
- 'include': '#function'
- }
- {
- 'match': '(new)\\s+([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*(?:\\.[\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)*)'
- 'captures':
- '1':
- 'name': 'keyword.operator.new.js'
- '2':
- 'patterns': [
- {
- 'name': 'entity.name.type.instance.js'
- 'match': '[\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*'
- }
- ]
- 'name': 'meta.class.instance.constructor'
- }
- {
- 'begin': '(?:(?<=[\\)\\]])|\\b([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))(\\()'
- 'beginCaptures':
- '1':
- 'patterns': [
- {
- 'match': '\\b(shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|scrollByLines|scrollY|scrollTo|stop|strike|sin|sizeToContent|sidebar|signText|sort|sup|sub|substr|substring|splice|split|send|set(Milliseconds|Seconds|Minutes|Hours|Month|Year|FullYear|Date|UTC(Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|Time|Hotkeys|Cursor|Timeout|Interval|ZOptions|Active|Resizable|RequestHeader)|search|sqrt|slice|savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|cos|concat|contextual|confirm|compile|ceil|clear|clearTimeout|clearInterval|captureEvents|call|createStyleSheet|createPopup|createEventObject|to(GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|test|tan|taint|taintEnabled|isNaN|isFinite|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|untaint|unescape|unwatch|updateCommands|join|javaEnabled|pop|pow|push|plugins.refresh|paddings|parse|parseInt|parseFloat|print|prompt|preference|escape|enableExternalCapture|eval|elementFromPoint|exp|exec|execScript|execCommand|valueOf|UTC|queryCommandState|queryCommandIndeterm|queryCommandEnabled|queryCommandValue|find|file|fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|forward|floor|fromCharCode|watch|link|load|log|lastIndexOf|asin|anchor|acos|attachEvent|atob|atan|atan2|apply|alert|abs|abort|round|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|releaseCapture|releaseEvents|random|go|get(Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|Time|Date|TimezoneOffset|UTC(Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|Attention|Selection|ResponseHeader|AllResponseHeaders)|min|moveBy|moveBelow|moveTo|moveToAbsolute|moveAbove|mergeAttributes|match|margins|max|btoa|big|bold|borderWidths|blink|back)\\b'
- 'name': 'support.function.js'
- }
- {
- 'match': '\\b(substringData|submit|splitText|setNamedItem|setAttribute|setAttributeNode|select|hasChildNodes|hasFeature|namedItem|click|close|cloneNode|createComment|createCDATASection|createCaption|createTHead|createTextNode|createTFoot|createDocumentFragment|createProcessingInstruction|createEntityReference|createElement|createAttribute|tabIndex|insertRow|insertBefore|insertCell|insertData|item|open|deleteRow|deleteCell|deleteCaption|deleteTHead|deleteTFoot|deleteData|focus|write|writeln|add|appendChild|appendData|reset|replaceChild|replaceData|move|moveNamedItem|moveChild|moveAttribute|moveAttributeNode|getNamedItem|getElementsByName|getElementsByTagName|getElementById|getAttribute|getAttributeNode|blur)\\b'
- 'name': 'support.function.dom.js'
- }
- {
- 'match': '\\bsuper\\b'
- 'name': 'keyword.other.ts'
- }
- ]
- '2':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'begin': '(?=)'
- 'end': '(,)\\s*|(?=\\))'
- 'endCaptures':
- '1':
- 'include': '#comma'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Prevent built-in types from being highlighted if accessed as property'
- 'match': '(\\.)(?:Anchor|Applet|Area|Array|Boolean|Button|Checkbox|Date|document|event|FileUpload|Form|Frame|Function|Hidden|History|Image|JavaArray|JavaClass|JavaObject|JavaPackage|java|Layer|Link|Location|Math|MimeType|Number|navigator|netscape|Object|Option|Packages|Password|Plugin|Radio|RegExp|Reset|Select|String|Style|Submit|screen|sun|Text|Textarea|window|XMLHttpRequest)'
- 'captures':
- '1':
- 'name': 'meta.delimiter.method.period.js'
- }
- {
- 'comment': 'Match export, declare and constructor'
- 'match': '\\b(?:export|declare|constructor)\\b'
- 'name': 'keyword.other.ts'
- }
- {
- 'comment': 'Match stuff like: as'
- 'match': '\\b(?:as|AS)\\b'
- 'name': 'keyword.operator.ts'
- }
- {
- 'comment': 'Match type SomeType = OtherType'
- 'begin': '(type)\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.ts'
- '2':
- 'name': 'meta.class.ts'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\s*(=)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'keyword.operator.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Match types in template instantiation'
- 'begin': '(?<=[\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}])<(?=(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>\\()'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Match type assertions'
- 'begin': '(?])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>[\\p{L}\\p{Nl}$_\\(\\[\\d\\{])'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\?'
- 'beginCaptures':
- '0':
- 'name': 'keyword.operator.js'
- 'end': ':'
- 'endCaptures':
- '0':
- 'name': 'keyword.operator.js'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
- }
- {
- 'comment': 'Match debugger statement'
- 'match': '\\s*(debugger)[\\s;]+'
- 'captures':
- '1':
- 'name':'keyword.debugger.ts'
- }
- {
- 'comment': 'Match full triple slash reference comments'
- 'match': '(\\/\\/\\/\\s*)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'reference.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match import = require'
- 'match': '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)?\\s*=\\s*(require)\\s*\\((.*)\\)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'variable.type.ts'
- '3':
- 'name':'keyword.other.ts'
- '4':
- 'name':'require.path.string'
- }
- {
- 'comment': 'Match ES6 "import from" syntax'
- 'match': '(import).*(from)\\s*(.*[\'"])'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'keyword.other.ts'
- '3':
- 'name':'es6import.path.string'
- }
- {
- 'include': '#curlybracerecursion'
- }
- {
- 'comment': 'Match all [] pairs'
- 'begin': '\\['
- 'end': '\\]'
- 'captures':
- '0':
- 'name': 'meta.brace.square.js'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
- }
- {
- 'comment': 'Match all () pairs'
- 'begin': '\\('
- 'end': '\\)'
- 'captures':
- '0':
- 'name': 'meta.brace.round.js'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
- }
- {
- 'include': 'source.js'
- }
-
- # TRANSFORMS
- {
- 'comment': 'Embedded Syntaxes support'
- 'begin': '(transform):(null){'
- 'beginCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'end': '}(transform):(null)'
- 'endCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'patterns': [
- {
- 'include': 'source.ts'
- }
- ]
- }
- {
- 'comment': 'Embedded Syntax for JSX'
- 'begin': '(transform):(jsx){'
- 'beginCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'end': '}(transform):(jsx)'
- 'endCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'patterns': [
- {
- 'include': 'text.html.basic'
- }
- ]
- }
-]
-
-'repository':
- 'curlybracerecursion':
- 'comment': 'Match all {} pairs'
- 'begin': '{'
- 'end': '}'
- 'captures':
- '0':
- 'name': 'meta.brace.curly.js'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
-
- 'type':
- 'begin': '(?=)'
- 'end': '(?))'
- 'end': '\\)(?:\\[\\])*'
- 'patterns': [
- {
- 'include': '#type'
- }
- ]
- }
- {
- 'include': '#keytype'
- }
- {
- 'include': '#typetemplate'
- }
- {
- 'include': '#typenontemplate'
- }
- {
- 'include': '#functiontype'
- }
- {
- 'include': '#tuple'
- }
- {
- 'include': '#objecttype'
- }
- {
- 'match': '\\s*(\\|)\\s*'
- 'captures':
- '1':
- 'name': 'keyword.operator.union.ts'
- }
- {
- 'include': '#comments'
- }
- {
- 'match': '\\.'
- 'captures':
- '0':
- 'name': 'meta.delimiter.period.type.ts'
- }
- ]
-
- 'typeinheritedfrom':
- 'begin': '(?=)'
- 'end': '(?))'
- 'end': '\\)(?:\\[\\])*'
- 'patterns': [
- {
- 'include': '#typeinheritedfrom'
- }
- ]
- }
- {
- 'include': '#keytype'
- }
- {
- 'include': '#functiontype'
- }
- {
- 'include': '#objecttype'
- }
- {
- 'include': '#tuple'
- }
- {
- 'include': '#typetemplateinheritedfrom'
- }
- {
- 'include': '#typenontemplateinheritedfrom'
- }
- {
- 'match': '\\|'
- 'captures':
- '0':
- 'name': 'keyword.operator.union.ts'
- }
- {
- 'match': '\\.'
- 'captures':
- '0':
- 'name': 'meta.delimiter.period.type.ts'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typenontemplate':
- 'comment': 'Matches a simple type without template specification'
- 'match': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\b((?:\\[\\])*)(?!<)'
- 'captures':
- '1':
- 'name': 'support.class.ts'
-
- 'typetemplate':
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)<'
- 'beginCaptures':
- '1':
- 'name': 'support.class.template.ts'
- 'end': '>((?:\\[\\])*)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typenontemplateinheritedfrom':
- 'comment': 'Matches a simple type without template specification'
- 'match': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\b((?:\\[\\])*)(?!<)'
- 'captures':
- '1':
- 'name': 'entity.other.inherited-class.ts'
-
- 'typetemplateinheritedfrom':
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)<'
- 'beginCaptures':
- '1':
- 'name': 'entity.other.template.inherited-class.ts'
- 'end': '>((?:\\[\\])*)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'keytype':
- 'comment': 'Match key types.'
- 'match': '(number|string|boolean|any|void)(?:\\[\\])*'
- 'captures':
- '1':
- 'name': 'storage.type.variable.ts'
-
- 'functiontype':
- 'patterns': [
- {
- 'include': '#functionargumentreturntype'
- }
- {
- 'begin': '(?=<)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#functionargumentreturntype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- ]
-
- 'functionargumentreturntype':
- 'begin': '(?=\\()'
- 'end': '(?)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'functionargumentstype':
- 'comment': 'Matches the types for functions.'
- 'begin': '\\('
- 'beginCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'include': '#args'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'objecttype':
- 'comment': 'Matches anonymous object types.'
- 'begin': '{'
- 'beginCaptures':
- '0':
- 'name': 'meta.brace.curly.js'
- 'end': '(})(\\[\\])?'
- 'endCaptures':
- '1':
- 'name': 'meta.brace.curly.js'
- 'patterns': [
- {
- 'include': '#typeindexable'
- }
- {
- 'include': '#typedvariable'
- }
- {
- 'match': ';'
- 'name': 'meta.delimiter.semicolon.js'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typeindexable':
- 'begin': '\\[[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*:\\s*(string|number)\\s*\\]:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.variable.ts'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'tuple':
- 'begin': '\\['
- 'end': '\\]'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typedvariable':
- 'begin': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*\\??\\s*:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'decorator':
- 'begin': '(\\@[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\()'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.annotation.js'
- '2':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'include': '$self'
- }
- ]
-
- 'args':
- 'comment': 'Match the arguments in a function'
- 'patterns': [
- {
- 'match': '(?:\\.\\.\\.)?[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*(?=\\??\\s*[,\\)])'
- 'name': 'variable.parameter.function.ts'
- }
- {
- 'begin': '((?:\\.\\.\\.)?[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\??\\s*:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'variable.parameter.function.ts'
- 'end': '(?=\\s*[,\\)])'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'function':
- 'patterns': [
- {
- 'include': '#oldstylefunction'
- }
- {
- 'include': '#newstylefunction'
- }
- ]
-
- 'functionnolookahead':
- 'patterns': [
- {
- 'include': '#oldstylefunction'
- }
- {
- 'include': '#newstylefunctionnolookahead'
- }
- ]
-
- 'newstylefunction':
- 'patterns': [
- {
- 'include': '#newstylefunctionnontemplate'
- }
- {
- 'begin': '(?\\([^\\(].+=>)(?=<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- ]
-
- 'newstylefunctionnolookahead':
- 'patterns': [
- {
- 'begin': '(?=<)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- ]
-
- 'newstylefunctionnontemplate':
- 'begin': '(?)(?=(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>)'
- 'end': '(?!\\:)\\s*(=>)'
- 'endCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'begin': '\\:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'newstylefunctionnontemplatenolookahead':
- 'begin': '(?=\\()'
- 'end': '(?!\\:)\\s*(=>)'
- 'endCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'begin': '\\:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'oldstylefunction':
- 'begin': '(?=(?:(async)(?:\\s+))?(function))'
- 'end': '(?!\\G)(?!:)'
- 'name': 'meta.function.js'
- 'patterns': [
- {
- 'begin': '\\G(?:(async)(?:\\s+))?(function)(?:\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))?(\\*?)\\s*(\\*?)(?=\\()'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.type.function.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'storage.type.function.js'
- '5':
- 'name': 'storage.type.function.js'
- 'end': '(?<=\\))'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\G(?:(async)(?:\\s+))?(function)(?:\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))?(?=<)'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.type.function.js'
- '3':
- 'name': 'entity.name.function.js'
- 'end': '(?<=\\))'
- 'patterns': [
- {
- 'begin': '(?<=\\G)<'
- 'end': '>(?:(\\*)\\s*|\\s*(\\*)|\\s*)(?=\\()'
- 'endCaptures':
- '1':
- 'name': 'storage.type.function.js'
- '2':
- 'name': 'storage.type.function.js'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#functionargumentstype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '(?<=\\)):\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typeextend':
- 'begin': '(extends)\\s+'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.modifier.ts'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#typeinheritedfrom'
- }
- ]
-
- # Taken from JS grammar (https://github.com/atom/language-javascript/blob/897e999910fb001780286778a20b7e5c02eb59dd/grammars/javascript.cson#L631-L661)
- 'docblock':
- 'patterns': [
- {
- 'match': '(?
+///
///
// From brackets plugin
///
///
///
-///
///
///
@@ -33,14 +34,14 @@ declare module 'escape-html' {
export = escape;
}
-// courtesy @blakeembrey
-declare module 'strip-bom' {
- import Buffer = require('buffer')
-
- function stripBom(value: string): string
- function stripBom(value: Buffer): Buffer
+declare module 'detect-indent' {
+ function detectIndent (string: string): { amount: number; type?: string; indent: string };
+ export = detectIndent;
+}
- export = stripBom
+declare module 'xtend' {
+ function extend (dest: T, src: U): T & U;
+ export = extend;
}
declare module 'atom-space-pen-views' {
diff --git a/lib/linter.ts b/lib/linter.ts
index 031e406ee..9f3f2e249 100644
--- a/lib/linter.ts
+++ b/lib/linter.ts
@@ -19,7 +19,8 @@ interface LinterMessage {
}
export var provider = {
- grammarScopes: ['source.ts', 'source.ts.tsx'],
+ name: 'TS',
+ grammarScopes: ['source.ts', 'source.tsx'],
scope: 'file', // # or 'project'
lintOnFly: true, // # must be false for scope: 'project'
lint: (textEditor: AtomCore.IEditor): Promise => {
@@ -36,9 +37,7 @@ export var provider = {
var linterErrors: LinterMessage[] = resp.errors.map((err) => ({
type: "Error",
filePath,
- html: ` TS ${
- err.message.replace(/\n/g,'
')
- }`,
+ text: err.message,
range: new Range([err.startPos.line, err.startPos.col], [err.endPos.line, err.endPos.col]),
}));
return linterErrors;
diff --git a/lib/main/atom/autoCompleteProvider.ts b/lib/main/atom/autoCompleteProvider.ts
index 817877aea..d6ab9c6cf 100644
--- a/lib/main/atom/autoCompleteProvider.ts
+++ b/lib/main/atom/autoCompleteProvider.ts
@@ -53,6 +53,7 @@ declare module autocompleteplus {
export interface Provider {
inclusionPriority?: number;
excludeLowerPriority?: boolean;
+ suggestionPriority?: number;
selector: string;
disableForSelector?: string;
getSuggestions: (options: RequestOptions) => Promise;
@@ -77,45 +78,10 @@ interface SnippetsContianer {
[name: string]: SnippetDescriptor;
}
-
-// this is the structure we use to speed up the lookup by avoiding having to
-// iterate over the object properties during the requestHandler
-// this will take a little longer during load but I guess that is better than
-// taking longer at each key stroke
-interface SnippetDetail {
- body: string;
- name: string;
-}
-
-var tsSnipPrefixLookup: { [prefix: string]: SnippetDetail; } = Object.create(null);
-function loadSnippets() {
- var confPath = atom.getConfigDirPath();
- CSON.readFile(confPath + "/packages/atom-typescript/snippets/typescript-snippets.cson",
- (err, snippetsRoot) => {
- if (err) return;
- if (!snippetsRoot || !snippetsRoot['.source.ts']) return;
-
- // rearrange/invert the way this can be looked up: we want to lookup by prefix
- // this way the lookup gets faster because we dont have to iterate over the
- // properties of the object
- var tsSnippets: SnippetsContianer = snippetsRoot['.source.ts'];
- for (var snippetName in tsSnippets) {
- if (tsSnippets.hasOwnProperty(snippetName)) {
- // if the file contains a prefix multiple times only
- // the last will be active because the previous ones will be overwritten
- tsSnipPrefixLookup[tsSnippets[snippetName].prefix] = {
- body: tsSnippets[snippetName].body,
- name: snippetName
- }
- }
- }
- });
-}
-loadSnippets();
-
export var provider: autocompleteplus.Provider = {
- selector: '.source.ts',
+ selector: '.source.ts, .source.tsx',
inclusionPriority: 3,
+ suggestionPriority: 3,
excludeLowerPriority: false,
getSuggestions: (options: autocompleteplus.RequestOptions): Promise=> {
@@ -175,7 +141,9 @@ export var provider: autocompleteplus.Provider = {
explicitlyTriggered = false;
}
else { // else in special cases for automatic triggering refuse to provide completions
- if (options.prefix && options.prefix.trim() == ';') {
+ const prefix = options.prefix.trim()
+
+ if (prefix === '' || prefix === ';') {
return Promise.resolve([]);
}
}
@@ -224,21 +192,6 @@ export var provider: autocompleteplus.Provider = {
}
});
-
- // see if we have a snippet for this prefix
- if (tsSnipPrefixLookup[options.prefix]) {
- // you only get the snippet suggested after you have typed
- // the full trigger word/ prefex
- // and then it replaces a keyword/match that might also be present, e.g. "class"
- let suggestion: autocompleteplus.Suggestion = {
- snippet: tsSnipPrefixLookup[options.prefix].body,
- replacementPrefix: options.prefix,
- rightLabelHTML: "snippet: " + options.prefix,
- type: 'snippet'
- };
- suggestions.unshift(suggestion);
- }
-
return suggestions;
});
@@ -261,13 +214,14 @@ export var provider: autocompleteplus.Provider = {
if (options.suggestion.atomTS_IsImport) {
options.editor.moveToBeginningOfLine();
options.editor.selectToEndOfLine();
- var groups = /^\s*import\s*(\w*)\s*=\s*require\s*\(\s*(["'])/.exec(options.editor.getSelectedText());
- var alias = groups[1];
+ var groups = /^(\s*)import\s*(\w*)\s*=\s*require\s*\(\s*(["'])/.exec(options.editor.getSelectedText());
+ var leadingWhiteSpace = groups[1];
+ var alias = groups[2];
// Use the option if they have a preferred. Otherwise preserve
- quote = quote || groups[2];
-
- options.editor.replaceSelectedText(null, function() { return `import ${alias} = require(${quote}${options.suggestion.atomTS_IsImport.relativePath}${quote});`; });
+ quote = quote || groups[3];
+
+ options.editor.replaceSelectedText(null, function() { return `${leadingWhiteSpace}import ${alias} = require(${quote}${options.suggestion.atomTS_IsImport.relativePath}${quote});`; });
}
if (options.suggestion.atomTS_IsES6Import) {
var {row} = options.editor.getCursorBufferPosition();
diff --git a/lib/main/atom/commands/commands.ts b/lib/main/atom/commands/commands.ts
index 4f970d054..d7434c962 100644
--- a/lib/main/atom/commands/commands.ts
+++ b/lib/main/atom/commands/commands.ts
@@ -207,11 +207,11 @@ export function registerCommands() {
/*atom.commands.dispatch(
atom.views.getView(atom.workspace.getActiveTextEditor()),
'typescript:testing-r-view');*/
-
+
// atom.commands.dispatch(
// atom.views.getView(atom.workspace.getActiveTextEditor()),
// 'typescript:toggle-semantic-view');
-
+
atom.commands.dispatch(
atom.views.getView(atom.workspace.getActiveTextEditor()),
'typescript:dependency-view');
@@ -371,7 +371,7 @@ export function registerCommands() {
(e) => {
var editor = atom.workspace.getActiveTextEditor();
if (!editor) return false;
- if (path.extname(editor.getPath()) !== '.ts') return false;
+ if (path.extname(editor.getPath()) !== '.ts' && path.extname(editor.getPath()) !== '.tsx') return false;
// Abort it for others
diff --git a/lib/main/atom/editorSetup.ts b/lib/main/atom/editorSetup.ts
index 1e952ef56..87caffb45 100644
--- a/lib/main/atom/editorSetup.ts
+++ b/lib/main/atom/editorSetup.ts
@@ -7,57 +7,57 @@ import * as atomUtils from "./atomUtils";
import {isTransformerFile} from "../lang/transformers/transformer";
export function setupEditor(editor: AtomCore.IEditor) {
-
- // Quick fix decoration stuff
- var quickFixDecoration: AtomCore.Decoration = null;
- var quickFixMarker: any = null;
- function clearExistingQuickfixDecoration() {
- if (quickFixDecoration) {
- quickFixDecoration.destroy();
- quickFixDecoration = null;
- }
- if (quickFixMarker) {
- quickFixMarker.destroy();
- quickFixMarker = null;
- }
- }
- var queryForQuickFix = debounce((filePathPosition:{filePath:string;position:number}) => {
- parent.getQuickFixes(filePathPosition).then(res=> {
- clearExistingQuickfixDecoration();
- if (res.fixes.length) {
- quickFixMarker = editor.markBufferRange(editor.getSelectedBufferRange());
- quickFixDecoration = editor.decorateMarker(quickFixMarker,
- { type: "line-number", class: "quickfix" });
- }
- })
- }, 500);
- var cursorObserver = editor.onDidChangeCursorPosition(() => {
- try {
- // This line seems to throw an exception sometimes.
- // https://github.com/TypeStrong/atom-typescript/issues/325
- // https://github.com/TypeStrong/atom-typescript/issues/310
- let pathPos = atomUtils.getFilePathPosition();
-
- // TODO: implement quickfix logic for transformed files
- if (isTransformerFile(pathPos.filePath)) {
- clearExistingQuickfixDecoration();
- return;
- }
-
- queryForQuickFix(pathPos);
- }
- catch (ex) {
- clearExistingQuickfixDecoration();
- }
- });
-
-
- /**
- * On final dispose
- */
- var destroyObserver = editor.onDidDestroy(() => {
- // Clear editor observers
- cursorObserver.dispose();
- destroyObserver.dispose();
- });
+ //
+ // // Quick fix decoration stuff
+ // var quickFixDecoration: AtomCore.Decoration = null;
+ // var quickFixMarker: any = null;
+ // function clearExistingQuickfixDecoration() {
+ // if (quickFixDecoration) {
+ // quickFixDecoration.destroy();
+ // quickFixDecoration = null;
+ // }
+ // if (quickFixMarker) {
+ // quickFixMarker.destroy();
+ // quickFixMarker = null;
+ // }
+ // }
+ // var queryForQuickFix = debounce((filePathPosition:{filePath:string;position:number}) => {
+ // parent.getQuickFixes(filePathPosition).then(res=> {
+ // clearExistingQuickfixDecoration();
+ // if (res.fixes.length) {
+ // quickFixMarker = editor.markBufferRange(editor.getSelectedBufferRange());
+ // quickFixDecoration = editor.decorateMarker(quickFixMarker,
+ // { type: "line-number", class: "quickfix" });
+ // }
+ // })
+ // }, 500);
+ // var cursorObserver = editor.onDidChangeCursorPosition(() => {
+ // try {
+ // // This line seems to throw an exception sometimes.
+ // // https://github.com/TypeStrong/atom-typescript/issues/325
+ // // https://github.com/TypeStrong/atom-typescript/issues/310
+ // let pathPos = atomUtils.getFilePathPosition();
+ //
+ // // TODO: implement quickfix logic for transformed files
+ // if (isTransformerFile(pathPos.filePath)) {
+ // clearExistingQuickfixDecoration();
+ // return;
+ // }
+ //
+ // queryForQuickFix(pathPos);
+ // }
+ // catch (ex) {
+ // clearExistingQuickfixDecoration();
+ // }
+ // });
+ //
+ //
+ // /**
+ // * On final dispose
+ // */
+ // var destroyObserver = editor.onDidDestroy(() => {
+ // // Clear editor observers
+ // cursorObserver.dispose();
+ // destroyObserver.dispose();
+ // });
}
diff --git a/lib/main/atom/tooltipManager.ts b/lib/main/atom/tooltipManager.ts
index e6b3afed7..69101174a 100644
--- a/lib/main/atom/tooltipManager.ts
+++ b/lib/main/atom/tooltipManager.ts
@@ -69,8 +69,8 @@ export function attach(editorView: JQuery, editor: AtomCore.IEditor) {
if (exprTypeTooltip) return;
var pixelPt = pixelPositionFromMouseEvent(editorView, e);
- pixelPt.top += editor.displayBuffer.getScrollTop();
- pixelPt.left += editor.displayBuffer.getScrollLeft();
+ pixelPt.top += editor.getScrollTop();
+ pixelPt.left += editor.getScrollLeft();
var screenPt = editor.screenPositionForPixelPosition(pixelPt);
var bufferPt = editor.bufferPositionForScreenPosition(screenPt);
var curCharPixelPt = rawView.pixelPositionForBufferPosition([bufferPt.row, bufferPt.column]);
diff --git a/lib/main/atom/views/mainPanelView.ts b/lib/main/atom/views/mainPanelView.ts
index ea6a5c43c..eb2584ae9 100644
--- a/lib/main/atom/views/mainPanelView.ts
+++ b/lib/main/atom/views/mainPanelView.ts
@@ -78,7 +78,7 @@ export class MainPanelView extends view.View {
this.span({
class: 'layout horizontal atomts-panel-header',
- style: 'align-items: center; flex: 1 1 auto'
+ style: 'align-items: center; flex: 1 1 auto; line-height: 24px;' // Line height is equal to height of github loading icon
}, () => {
this.div({
style: 'cursor: pointer;',
@@ -241,10 +241,10 @@ export class MainPanelView extends view.View {
this.sectionPending.stop();
if (pending.length) {
- this.sectionPending.fadeIn(500);
+ this.sectionPending.animate({opacity: 0.5}, 500);
}
else {
- this.sectionPending.fadeOut(200);
+ this.sectionPending.animate({opacity: 0}, 200);
}
}
@@ -365,6 +365,7 @@ export class MainPanelView extends view.View {
private clearedError = true;
clearError() {
this.clearedError = true;
+ this.clearSummary();
this.errorBody.empty();
}
@@ -396,6 +397,11 @@ export class MainPanelView extends view.View {
}
}
+ clearSummary() {
+ this.summary.html('');
+ this.summary.off();
+ }
+
setErrorPanelErrorCount(fileErrorCount: number, totalErrorCount: number) {
var title = `${panelHeaders.error} ( No Errors )`;
if (totalErrorCount > 0) {
@@ -407,7 +413,7 @@ export class MainPanelView extends view.View {
)`;
}
else {
- this.summary.html('');
+ this.clearSummary();
this.errorBody.html('No errors in open files \u2665');
}
diff --git a/lib/main/lang/fixmyts/quickFixRegistry.ts b/lib/main/lang/fixmyts/quickFixRegistry.ts
index eb2f04f56..d81ec89f6 100644
--- a/lib/main/lang/fixmyts/quickFixRegistry.ts
+++ b/lib/main/lang/fixmyts/quickFixRegistry.ts
@@ -4,6 +4,7 @@ import {QuickFix} from "./quickFix";
*/
import {AddClassMember} from "./quickFixes/addClassMember";
import {AddClassMethod} from "./quickFixes/addClassMethod";
+import {AddImportFromStatement} from "./quickFixes/addImportFromStatement";
import {AddImportStatement} from "./quickFixes/addImportStatement";
import {EqualsToEquals} from "./quickFixes/equalsToEquals";
import {ExtractVariable} from "./quickFixes/extractVariable";
@@ -18,6 +19,7 @@ import {SingleLineCommentToJsdoc} from "./quickFixes/singleLineCommentToJsdoc";
export var allQuickFixes: QuickFix[] = [
new AddClassMethod(),
new AddClassMember(),
+ new AddImportFromStatement(),
new AddImportStatement(),
new WrapInProperty(),
new EqualsToEquals(),
diff --git a/lib/main/lang/fixmyts/quickFixes/addImportFromStatement.ts b/lib/main/lang/fixmyts/quickFixes/addImportFromStatement.ts
new file mode 100644
index 000000000..b9ce35671
--- /dev/null
+++ b/lib/main/lang/fixmyts/quickFixes/addImportFromStatement.ts
@@ -0,0 +1,84 @@
+import {QuickFix, QuickFixQueryInformation, Refactoring, CanProvideFixResponse} from "../quickFix";
+import * as ast from "../astUtils";
+import {EOL } from "os";
+var { displayPartsToString, typeToDisplayParts } = ts;
+import path = require('path');
+import {Project} from "../../core/project";
+
+import {getPathCompletions} from "../../modules/getPathCompletions";
+
+function getIdentifierAndFileNames(error: ts.Diagnostic, project: Project) {
+
+ var errorText: string = error.messageText;
+
+ // We don't support error chains yet
+ if (typeof errorText !== 'string') {
+ return undefined;
+ };
+
+ var match = errorText.match(/Cannot find name \'(\w+)\'./);
+
+ // If for whatever reason the error message doesn't match
+ if (!match) return;
+
+ var [, identifierName] = match;
+ var {files} = getPathCompletions({
+ project,
+ filePath: error.file.fileName,
+ prefix: identifierName,
+ includeExternalModules: false
+ });
+ var file = files.length > 0 ? files[0].relativePath : undefined;
+ var basename = files.length > 0 ? files[0].name : undefined;
+ return { identifierName, file, basename };
+}
+
+export class AddImportFromStatement implements QuickFix {
+ key = AddImportFromStatement.name;
+
+ canProvideFix(info: QuickFixQueryInformation): CanProvideFixResponse {
+ var relevantError = info.positionErrors.filter(x=> x.code == 2304)[0];
+ if (!relevantError) return;
+ if (info.positionNode.kind !== ts.SyntaxKind.Identifier) return;
+ var matches = getIdentifierAndFileNames(relevantError, info.project);
+ if (!matches) return;
+
+ var { identifierName, file} = matches;
+ return file ? { display: `import {${identifierName}} from \"${file}\"` } : undefined;
+ }
+
+ provideFix(info: QuickFixQueryInformation): Refactoring[] {
+ var relevantError = info.positionErrors.filter(x=> x.code == 2304)[0];
+ var identifier = info.positionNode;
+
+ var identifierName = identifier.text;
+ var fileNameforFix = getIdentifierAndFileNames(relevantError, info.project);
+
+ // Add stuff at the top of the file
+ let refactorings: Refactoring[] = [{
+ span: {
+ start: 0,
+ length: 0
+ },
+ newText: `import {${identifierName}} from \"${fileNameforFix.file}\";${EOL}`,
+ filePath: info.sourceFile.fileName
+ }];
+
+ // Also refactor the variable name to match the file name
+ // TODO: the following code only takes into account location
+ // There may be other locations where this is used.
+ // Better that they trigger a *rename* explicitly later if they want to rename the variable
+ // if (identifierName !== fileNameforFix.basename) {
+ // refactorings.push({
+ // span: {
+ // start: identifier.getStart(),
+ // length: identifier.end - identifier.getStart()
+ // },
+ // newText: fileNameforFix.basename,
+ // filePath: info.srcFile.fileName
+ // })
+ // }
+
+ return refactorings;
+ }
+}
diff --git a/lib/main/lang/fixmyts/quickFixes/extractVariable.ts b/lib/main/lang/fixmyts/quickFixes/extractVariable.ts
index 0e0b99165..7d473d411 100644
--- a/lib/main/lang/fixmyts/quickFixes/extractVariable.ts
+++ b/lib/main/lang/fixmyts/quickFixes/extractVariable.ts
@@ -19,9 +19,6 @@ export class ExtractVariable implements QuickFix {
() => {
return { display: `Extract variable` };
});
-
- throw "Unexpected state in canProvideFix";
-
}
provideFix(info: QuickFixQueryInformation): Refactoring[] {
@@ -36,8 +33,6 @@ export class ExtractVariable implements QuickFix {
(callExpression) => {
return extractVariableFromArg(info, callExpression);
});
-
- throw "Unexpected state in provideFix";
}
}
diff --git a/lib/main/lang/modules/building.ts b/lib/main/lang/modules/building.ts
index fa1e3ab3c..1681706fc 100644
--- a/lib/main/lang/modules/building.ts
+++ b/lib/main/lang/modules/building.ts
@@ -5,9 +5,12 @@ import fs = require('fs');
import {pathIsRelative, makeRelativePath} from "../../tsconfig/tsconfig";
import {consistentPath} from "../../utils/fsUtil";
import {createMap, assign} from "../utils";
+var findup = require('findup');
/** Lazy loaded babel tanspiler */
-let babel: any;
+let babels: { [key: string]: any } = {};
+/** Store babel configurations from .babelrc */
+let babelConfigs: { [key: string]: any } = {};
/** If we get a compile request for a ts file that is not in project. We return a js file with the following content */
export const Not_In_Context = "/* NotInContext */";
@@ -54,23 +57,23 @@ export function emitFile(proj: project.Project, filePath: string): EmitOutput {
let sourceMapContents: { [index: string]: any } = {};
output.outputFiles.forEach(o => {
mkdirp.sync(path.dirname(o.name));
- let additionalEmits = runExternalTranspiler(
+ runExternalTranspiler(
filePath,
sourceFile.text,
o,
proj,
sourceMapContents
- );
-
- if (!sourceMapContents[o.name] && !proj.projectFile.project.compilerOptions.noEmit) {
- // .js.map files will be written as an "additional emit" later.
- fs.writeFileSync(o.name, o.text, "utf8");
- }
+ ).then((additionalEmits) => {
+ if (!sourceMapContents[o.name] && !proj.projectFile.project.compilerOptions.noEmit) {
+ // .js.map files will be written as an "additional emit" later.
+ fs.writeFileSync(o.name, o.text, "utf8");
+ }
- additionalEmits.forEach(a => {
- mkdirp.sync(path.dirname(a.name));
- fs.writeFileSync(a.name, a.text, "utf8");
- })
+ additionalEmits.forEach(a => {
+ mkdirp.sync(path.dirname(a.name));
+ fs.writeFileSync(a.name, a.text, "utf8");
+ });
+ });
});
}
@@ -103,27 +106,66 @@ export function getRawOutput(proj: project.Project, filePath: string): ts.EmitOu
return output;
}
+function getBabelInstance(projectDirectory: string) {
+ return new Promise(resolve => {
+ if (!babels[projectDirectory]) {
+ findup(projectDirectory, 'node_modules/babel-core', function(err: any, dir: string) {
+ if (err) {
+ findup(projectDirectory, 'node_modules/babel', function(err: any, dir: string) {
+ if (err) {
+ babels[projectDirectory] = require('babel');
+ } else {
+ babels[projectDirectory] = require(path.join(dir, 'node_modules/babel'));
+ }
+
+ resolve(babels[projectDirectory]);
+ });
+ } else {
+ babels[projectDirectory] = require(path.join(dir, 'node_modules/babel-core'));
+ resolve(babels[projectDirectory]);
+ }
+ });
+ } else {
+ resolve(babels[projectDirectory]);
+ }
+ }).then(babel => {
+ return new Promise(resolve => {
+ findup(projectDirectory, '.babelrc', function(err: any, dir) {
+ if (err) return resolve(babel);
+
+ fs.readFile(path.join(dir, '.babelrc'), function(err, data) {
+ try {
+ babelConfigs[projectDirectory] = JSON.parse(data.toString());
+ } catch (e) { }
+
+ resolve(babel);
+ });
+ });
+ });
+ });
+}
+
function runExternalTranspiler(sourceFileName: string,
sourceFileText: string,
outputFile: ts.OutputFile,
project: project.Project,
- sourceMapContents: { [index: string]: any }): ts.OutputFile[] {
+ sourceMapContents: { [index: string]: any }): Promise {
if (!isJSFile(outputFile.name) && !isJSSourceMapFile(outputFile.name)) {
- return [];
+ return Promise.resolve([]);
}
let settings = project.projectFile.project;
let externalTranspiler = settings.externalTranspiler;
if (!externalTranspiler) {
- return [];
+ return Promise.resolve([]);
}
if (isJSSourceMapFile(outputFile.name)) {
let sourceMapPayload = JSON.parse(outputFile.text);
let jsFileName = consistentPath(path.resolve(path.dirname(outputFile.name), sourceMapPayload.file));
sourceMapContents[outputFile.name] = { jsFileName: jsFileName, sourceMapPayload };
- return [];
+ return Promise.resolve([]);
}
if (typeof externalTranspiler === 'string') {
@@ -136,54 +178,56 @@ function runExternalTranspiler(sourceFileName: string,
// We need this type guard to narrow externalTranspiler's type
if (typeof externalTranspiler === 'object') {
if (externalTranspiler.name.toLocaleLowerCase() === "babel") {
- if (!babel) {
- babel = require("babel")
- }
+ return getBabelInstance(project.projectFile.projectFileDirectory).then((babel) => {
- let babelOptions: any = assign({}, externalTranspiler.options || {}, {
- filename: outputFile.name
- });
-
- let sourceMapFileName = getJSMapNameForJSFile(outputFile.name);
+ let babelOptions: any = assign(babelConfigs[project.projectFile.projectFileDirectory] || {}, externalTranspiler.options || {}, {
+ filename: outputFile.name
+ });
- if (sourceMapContents[sourceMapFileName]) {
- babelOptions.inputSourceMap = sourceMapContents[sourceMapFileName].sourceMapPayload;
- let baseName = path.basename(sourceFileName);
- // NOTE: Babel generates invalid source map without consistent `sources` and `file`.
- babelOptions.inputSourceMap.sources = [baseName];
- babelOptions.inputSourceMap.file = baseName;
- }
- if (settings.compilerOptions.sourceMap) {
- babelOptions.sourceMaps = true;
- }
- if (settings.compilerOptions.inlineSourceMap) {
- babelOptions.sourceMaps = "inline";
- }
- if (!settings.compilerOptions.removeComments) {
- babelOptions.comments = true;
- }
+ let sourceMapFileName = getJSMapNameForJSFile(outputFile.name);
- let babelResult = babel.transform(outputFile.text, babelOptions);
- outputFile.text = babelResult.code;
-
- if (babelResult.map && settings.compilerOptions.sourceMap) {
- let additionalEmit: ts.OutputFile = {
- name: sourceMapFileName,
- text: JSON.stringify(babelResult.map),
- writeByteOrderMark: settings.compilerOptions.emitBOM
- };
-
- if (additionalEmit.name === "") {
- // can't emit a blank file name - this should only be reached if the TypeScript
- // language service returns the .js file before the .js.map file.
- console.warn(`The TypeScript language service did not yet provide a .js.map name for file ${outputFile.name}`);
- return [];
+ if (sourceMapContents[sourceMapFileName]) {
+ babelOptions.inputSourceMap = sourceMapContents[sourceMapFileName].sourceMapPayload;
+ let baseName = path.basename(sourceFileName);
+ // NOTE: Babel generates invalid source map without consistent `sources` and `file`.
+ babelOptions.inputSourceMap.sources = [baseName];
+ babelOptions.inputSourceMap.file = baseName;
+ }
+ if (settings.compilerOptions.sourceMap) {
+ babelOptions.sourceMaps = true;
+ }
+ if (settings.compilerOptions.inlineSourceMap) {
+ babelOptions.sourceMaps = "inline";
+ }
+ if (!settings.compilerOptions.removeComments) {
+ babelOptions.comments = true;
}
- return [additionalEmit];
- }
+ var directory = process.cwd();
+ process.chdir(project.projectFile.projectFileDirectory);
+ let babelResult = babel.transform(outputFile.text, babelOptions);
+ process.chdir(directory);
+ outputFile.text = babelResult.code;
+
+ if (babelResult.map && settings.compilerOptions.sourceMap) {
+ let additionalEmit: ts.OutputFile = {
+ name: sourceMapFileName,
+ text: JSON.stringify(babelResult.map),
+ writeByteOrderMark: settings.compilerOptions.emitBOM
+ };
+
+ if (additionalEmit.name === "") {
+ // can't emit a blank file name - this should only be reached if the TypeScript
+ // language service returns the .js file before the .js.map file.
+ console.warn(`The TypeScript language service did not yet provide a .js.map name for file ${outputFile.name}`);
+ return [];
+ }
+
+ return [additionalEmit];
+ }
- return [];
+ return [];
+ });
}
}
diff --git a/lib/main/lang/projectService.ts b/lib/main/lang/projectService.ts
index 7b1e45c0b..4d4ab90f9 100644
--- a/lib/main/lang/projectService.ts
+++ b/lib/main/lang/projectService.ts
@@ -124,7 +124,7 @@ export function build(query: BuildQuery): Promise {
return output;
});
- // Also optionally emit a root dts:
+ // Also optionally emit a root dts:
building.emitDts(proj);
// If there is a post build script to run ... run it
@@ -138,7 +138,7 @@ export function build(query: BuildQuery): Promise {
}
});
}
-
+
let tsFilesWithInvalidEmit = outputs
.filter((o) => o.emitError)
.map((o) => o.sourceFileName);
diff --git a/lib/main/lang/transformers/transformerRegistry.ts b/lib/main/lang/transformers/transformerRegistry.ts
index 3ee4c72da..f4cc21c46 100644
--- a/lib/main/lang/transformers/transformerRegistry.ts
+++ b/lib/main/lang/transformers/transformerRegistry.ts
@@ -2,7 +2,7 @@ import utils = require("../utils");
import {Transformer, TransformerDelimiter, FileTransformationDetails} from "./transformer";
/**
- * Transformers should push themeselves into this registry.
+ * Transformers should push themeselves into this registry.
* This is so that the registry does not depend on the transformers
* As that will cause a circular reference
*/
@@ -30,27 +30,28 @@ export function getInitialTransformation(code: string): FileTransformationDetail
var transforms: TransformerDelimiter[] = [];
- var processedSrcUpto = 0;
- var srcCode = code;
- var destCode = '';
- var destDelta = 0;
-
- while (true) {
- let remainingCode = code.substr(processedSrcUpto);
- // Get the next transform that exist in this file:
- var matches = transformFinderRegex.exec(remainingCode);
- // No more transforms:
- if (!matches || !matches.length || matches.length < 2) return { transforms };
- // Found one!
- var nextTransformName = matches.slice[1];
- // Update the processedUpto
- }
-
- /**
- * TODO: for each transform we note down the src start and src end
- * Then we transform the src code. This gives a dest start (initially same as src start) and dest end (more or less)
- * we use this to additionally compute a running (delta) in dest. This delta is used in the next (dest start).
- */
+ // var processedSrcUpto = 0;
+ // var srcCode = code;
+ // var destCode = '';
+ // var destDelta = 0;
+ //
+ // while (true) {
+ // let remainingCode = code.substr(processedSrcUpto);
+ // // Get the next transform that exist in this file:
+ // var matches = transformFinderRegex.exec(remainingCode);
+ // // No more transforms:
+ // if (!matches || !matches.length || matches.length < 2) return { transforms };
+ // // Found one!
+ // var nextTransformName = matches.slice[1];
+ // // Update the processedUpto
+ // break;
+ // }
+ //
+ // /**
+ // * TODO: for each transform we note down the src start and src end
+ // * Then we transform the src code. This gives a dest start (initially same as src start) and dest end (more or less)
+ // * we use this to additionally compute a running (delta) in dest. This delta is used in the next (dest start).
+ // */
return { transforms };
@@ -67,12 +68,13 @@ export function transform(name: string, code: string): { code: string } {
return transformer.transform(code);
}
-// Ensure that all the transformers are loaded:
+// Ensure that all the transformers are loaded:
// Since nothing depends on these explicitly (don't want a circular ref)
// We need to load them manually:
import * as path from "path";
-var expand = require('glob-expand');
-let files: string[] = expand({ filter: 'isFile', cwd: __dirname }, [
- "./implementations/*.js"
-]);
-files = files.map(f=> require(f));
\ No newline at end of file
+var glob = require('glob');
+let files: string[] = glob.sync('./implementations/*.js', {
+ nodir: true,
+ cwd: __dirname
+});
+files = files.map(f=> require(f));
diff --git a/lib/main/tsconfig/formatting.ts b/lib/main/tsconfig/formatting.ts
index 7bf19f2dc..b0dcc10f6 100644
--- a/lib/main/tsconfig/formatting.ts
+++ b/lib/main/tsconfig/formatting.ts
@@ -26,6 +26,7 @@ export function defaultFormatCodeOptions(): ts.FormatCodeOptions {
TabSize: 4,
NewLineCharacter: os.EOL,
ConvertTabsToSpaces: true,
+ IndentStyle: ts.IndentStyle.Smart,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
InsertSpaceBeforeAndAfterBinaryOperators: true,
diff --git a/lib/main/tsconfig/tsconfig.ts b/lib/main/tsconfig/tsconfig.ts
index f582c0c81..ab1baebbd 100644
--- a/lib/main/tsconfig/tsconfig.ts
+++ b/lib/main/tsconfig/tsconfig.ts
@@ -1,7 +1,6 @@
import * as fsu from "../utils/fsUtil";
import simpleValidator = require('./simpleValidator');
-import stripBom = require('strip-bom');
var types = simpleValidator.types;
// Most compiler options come from require('typescript').CompilerOptions, but
@@ -18,6 +17,9 @@ var types = simpleValidator.types;
*/
interface CompilerOptions {
allowNonTsExtensions?: boolean;
+ allowSyntheticDefaultImports?: boolean;
+ allowUnreachableCode?: boolean;
+ allowUnusedLabels?: boolean;
charset?: string;
codepage?: number;
declaration?: boolean;
@@ -41,17 +43,21 @@ interface CompilerOptions {
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
+ noFallthroughCasesInSwitch?: boolean;
noImplicitAny?: boolean; // Error on inferred `any` type
+ noImplicitReturns?: boolean;
noLib?: boolean;
noLibCheck?: boolean;
noResolve?: boolean;
out?: string;
+ outFile?: string; // new name for out
outDir?: string; // Redirect output structure to this directory
preserveConstEnums?: boolean;
removeComments?: boolean; // Do not emit comments in output
rootDir?: string;
sourceMap?: boolean; // Generates SourceMaps (.map files)
sourceRoot?: string; // Optionally specifies the location where debugger should locate TypeScript source files after deployment
+ stripInternal?: boolean;
suppressExcessPropertyErrors?: boolean; // Optionally disable strict object literal assignment checking
suppressImplicitAnyIndexErrors?: boolean;
target?: string; // 'es3'|'es5' (default)|'es6'
@@ -60,8 +66,11 @@ interface CompilerOptions {
}
var compilerOptionsValidation: simpleValidator.ValidationInfo = {
- allowNonTsExtensions: { type: simpleValidator.types.boolean },
- charset: { type: simpleValidator.types.string },
+ allowNonTsExtensions: { type: types.boolean },
+ allowSyntheticDefaultImports: { type: types.boolean },
+ allowUnreachableCode: { type: types.boolean },
+ allowUnusedLabels: { type: types.boolean },
+ charset: { type: types.string },
codepage: { type: types.number },
declaration: { type: types.boolean },
diagnostics: { type: types.boolean },
@@ -77,24 +86,28 @@ var compilerOptionsValidation: simpleValidator.ValidationInfo = {
locals: { type: types.string },
listFiles: { type: types.boolean },
mapRoot: { type: types.string },
- module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd'] },
+ module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'] },
moduleResolution: { type: types.string, validValues: ['classic', 'node'] },
newLine: { type: types.string },
noEmit: { type: types.boolean },
noEmitHelpers: { type: types.boolean },
noEmitOnError: { type: types.boolean },
noErrorTruncation: { type: types.boolean },
+ noFallthroughCasesInSwitch: { type: types.boolean },
noImplicitAny: { type: types.boolean },
+ noImplicitReturns: { type: types.boolean },
noLib: { type: types.boolean },
noLibCheck: { type: types.boolean },
noResolve: { type: types.boolean },
out: { type: types.string },
+ outFile: { type: types.string },
outDir: { type: types.string },
preserveConstEnums: { type: types.boolean },
removeComments: { type: types.boolean },
rootDir: { type: types.string },
sourceMap: { type: types.boolean },
sourceRoot: { type: types.string },
+ stripInternal: { type: types.boolean },
suppressExcessPropertyErrors: { type: types.boolean },
suppressImplicitAnyIndexErrors: { type: types.boolean },
target: { type: types.string, validValues: ['es3', 'es5', 'es6'] },
@@ -118,6 +131,7 @@ interface UsefulFromPackageJson {
*/
interface TypeScriptProjectRawSpecification {
compilerOptions?: CompilerOptions;
+ exclude?: string[]; // optional: An array of 'glob / minimatch / RegExp' patterns to specify directories / files to exclude
files?: string[]; // optional: paths to files
filesGlob?: string[]; // optional: An array of 'glob / minimatch / RegExp' patterns to specify source files
formatCodeOptions?: formatting.FormatCodeOptions; // optional: formatting options
@@ -125,6 +139,7 @@ interface TypeScriptProjectRawSpecification {
buildOnSave?: boolean;
externalTranspiler?: string | { name: string; options?: any };
scripts?: { postbuild?: string };
+ atom?: { rewriteTsconfig?: boolean };
}
/**
@@ -142,6 +157,7 @@ export interface TypeScriptProjectSpecification {
package?: UsefulFromPackageJson;
externalTranspiler?: string | { name: string; options?: any };
scripts: { postbuild?: string };
+ atom: { rewriteTsconfig: boolean };
}
///////// FOR USE WITH THE API /////////////
@@ -159,7 +175,7 @@ export interface TypeScriptProjectFileDetails {
//////////////////////////////////////////////////////////////////////
export var errors = {
- GET_PROJECT_INVALID_PATH: 'Invalid Path',
+ GET_PROJECT_INVALID_PATH: 'The path used to query for tsconfig.json does not exist',
GET_PROJECT_NO_PROJECT_FOUND: 'No Project Found',
GET_PROJECT_FAILED_TO_OPEN_PROJECT_FILE: 'Failed to fs.readFileSync the project file',
GET_PROJECT_JSON_PARSE_FAILED: 'Failed to JSON.parse the project file',
@@ -193,23 +209,26 @@ function errorWithDetails(error: Error, details: T): Error {
import fs = require('fs');
import path = require('path');
-import expand = require('glob-expand');
+import tsconfig = require('tsconfig');
import os = require('os');
+import detectIndent = require('detect-indent');
+import extend = require('xtend');
import formatting = require('./formatting');
var projectFileName = 'tsconfig.json';
+
/**
* This is what we write to new files
*/
var defaultFilesGlob = [
- "./**/*.ts",
- "./**/*.tsx",
- "!./node_modules/**/*",
+ "**/*.ts",
+ "**/*.tsx",
+ "!node_modules/**",
];
/**
* This is what we use when the user doens't specify a files / filesGlob
*/
-var invisibleFilesGlob = ["./**/*.ts", "./**/*.tsx"];
+var invisibleFilesGlob = '{**/*.ts,**/*.tsx}';
export var defaults: ts.CompilerOptions = {
target: ts.ScriptTarget.ES5,
@@ -238,8 +257,10 @@ var typescriptEnumMap = {
'none': ts.ModuleKind.None,
'commonjs': ts.ModuleKind.CommonJS,
'amd': ts.ModuleKind.AMD,
- 'system': ts.ModuleKind.System,
'umd': ts.ModuleKind.UMD,
+ 'system': ts.ModuleKind.System,
+ 'es6': ts.ModuleKind.ES6,
+ 'es2015': ts.ModuleKind.ES2015,
},
moduleResolution: {
'node': ts.ModuleResolutionKind.NodeJs,
@@ -291,6 +312,11 @@ function rawToTsCompilerOptions(jsonOptions: CompilerOptions, projectDir: string
compilerOptions.out = path.resolve(projectDir, compilerOptions.out);
}
+ if (compilerOptions.outFile !== undefined) {
+ // Till out is removed. Support outFile by just copying it to `out`
+ compilerOptions.out = path.resolve(projectDir, compilerOptions.outFile);
+ }
+
return compilerOptions;
}
@@ -323,7 +349,8 @@ export function getDefaultInMemoryProject(srcFile: string): TypeScriptProjectFil
formatCodeOptions: formatting.defaultFormatCodeOptions(),
compileOnSave: true,
buildOnSave: false,
- scripts: {}
+ scripts: {},
+ atom: { rewriteTsconfig: true },
};
return {
@@ -344,70 +371,48 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
throw new Error(errors.GET_PROJECT_INVALID_PATH);
}
- // Get the path directory
var dir = fs.lstatSync(pathOrSrcFile).isDirectory() ? pathOrSrcFile : path.dirname(pathOrSrcFile);
+ var projectFile = tsconfig.resolveSync(dir);
- // Keep going up till we find the project file
- var projectFile = '';
- try {
- projectFile = travelUpTheDirectoryTreeTillYouFind(dir, projectFileName);
+ if (!projectFile) {
+ throw errorWithDetails(
+ new Error(errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: 'not found' });
}
- catch (e) {
- let err: Error = e;
- if (err.message == "not found") {
- throw errorWithDetails(
- new Error(errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: err.message });
- }
- }
- projectFile = path.normalize(projectFile);
+
var projectFileDirectory = path.dirname(projectFile) + path.sep;
// We now have a valid projectFile. Parse it:
var projectSpec: TypeScriptProjectRawSpecification;
+ var projectFileTextContent: string;
+
try {
- var projectFileTextContent = fs.readFileSync(projectFile, 'utf8');
+ projectFileTextContent = fs.readFileSync(projectFile, 'utf8');
} catch (ex) {
throw new Error(errors.GET_PROJECT_FAILED_TO_OPEN_PROJECT_FILE);
}
+
try {
- projectSpec = JSON.parse(stripBom(projectFileTextContent));
+ projectSpec = tsconfig.parseFileSync(projectFileTextContent, projectFile, { resolvePaths: false });
} catch (ex) {
throw errorWithDetails(
new Error(errors.GET_PROJECT_JSON_PARSE_FAILED), { projectFilePath: fsu.consistentPath(projectFile), error: ex.message });
}
- // Setup default project options
- if (!projectSpec.compilerOptions) projectSpec.compilerOptions = {};
-
- // Our customizations for "tsconfig.json"
- // Use grunt.file.expand type of logic
- var cwdPath = path.relative(process.cwd(), path.dirname(projectFile));
- if (!projectSpec.files && !projectSpec.filesGlob) { // If there is no files and no filesGlob, we create an invisible one.
- var toExpand = invisibleFilesGlob;
- }
- if (projectSpec.filesGlob) { // If there is a files glob we will use that
- var toExpand = projectSpec.filesGlob
- }
- if (toExpand) { // Expand whatever needs expanding
- try {
- projectSpec.files = expand({ filter: 'isFile', cwd: cwdPath }, toExpand);
- }
- catch (ex) {
- throw errorWithDetails(
- new Error(errors.GET_PROJECT_GLOB_EXPAND_FAILED),
- { glob: projectSpec.filesGlob, projectFilePath: fsu.consistentPath(projectFile), errorMessage: ex.message });
+ /** Setup defaults for atom key */
+ if (!projectSpec.atom) {
+ projectSpec.atom = {
+ rewriteTsconfig: true,
}
}
+
if (projectSpec.filesGlob) { // for filesGlob we keep the files in sync
- var prettyJSONProjectSpec = prettyJSON(projectSpec);
- if (prettyJSONProjectSpec !== projectFileTextContent) {
- fs.writeFileSync(projectFile, prettyJSON(projectSpec));
+ var prettyJSONProjectSpec = prettyJSON(projectSpec, detectIndent(projectFileTextContent).indent);
+
+ if (prettyJSONProjectSpec !== projectFileTextContent && projectSpec.atom.rewriteTsconfig) {
+ fs.writeFileSync(projectFile, prettyJSONProjectSpec);
}
}
- // Remove all relativeness
- projectSpec.files = projectSpec.files.map((file) => path.resolve(projectFileDirectory, file));
-
var pkg: UsefulFromPackageJson = null;
try {
var packagePath = travelUpTheDirectoryTreeTillYouFind(projectFileDirectory, 'package.json');
@@ -428,7 +433,7 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
var project: TypeScriptProjectSpecification = {
compilerOptions: {},
- files: projectSpec.files,
+ files: projectSpec.files.map(x => path.resolve(projectFileDirectory, x)),
filesGlob: projectSpec.filesGlob,
formatCodeOptions: formatting.makeFormatCodeOptions(projectSpec.formatCodeOptions),
compileOnSave: projectSpec.compileOnSave == undefined ? true : projectSpec.compileOnSave,
@@ -436,7 +441,8 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
typings: [],
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
scripts: projectSpec.scripts || {},
- buildOnSave: !!projectSpec.buildOnSave
+ buildOnSave: !!projectSpec.buildOnSave,
+ atom: { rewriteTsconfig: true }
};
// Validate the raw compiler options before converting them to TS compiler options
@@ -491,6 +497,8 @@ export function createProjectRootSync(srcFile: string, defaultOptions?: ts.Compi
var projectSpec: TypeScriptProjectRawSpecification = {};
projectSpec.compilerOptions = tsToRawCompilerOptions(defaultOptions || defaults);
projectSpec.filesGlob = defaultFilesGlob;
+ projectSpec.compileOnSave = true;
+ projectSpec.buildOnSave = false;
fs.writeFileSync(projectFilePath, prettyJSON(projectSpec));
return getProjectSync(srcFile);
@@ -527,32 +535,36 @@ function increaseProjectForReferenceAndImports(files: string[]): string[] {
var preProcessedFileInfo = ts.preProcessFile(content, true),
dir = path.dirname(file);
+ let extensions = ['.ts', '.d.ts', '.tsx'];
+ function getIfExists(filePathNoExt: string) {
+ for (let ext of extensions) {
+ if (fs.existsSync(filePathNoExt + ext)) {
+ return filePathNoExt + ext;
+ }
+ }
+ }
+
referenced.push(
preProcessedFileInfo.referencedFiles.map(fileReference => {
// We assume reference paths are always relative
var file = path.resolve(dir, fsu.consistentPath(fileReference.fileName));
- // Try all three, by itself, .ts, .d.ts
+ // Try by itself then with extensions
if (fs.existsSync(file)) {
return file;
}
- if (fs.existsSync(file + '.ts')) {
- return file + '.ts';
- }
- if (fs.existsSync(file + '.d.ts')) {
- return file + '.d.ts';
- }
- return null;
+ return getIfExists(file);
}).filter(file=> !!file)
.concat(
preProcessedFileInfo.importedFiles
.filter((fileReference) => pathIsRelative(fileReference.fileName))
.map(fileReference => {
- var file = path.resolve(dir, fileReference.fileName + '.ts');
- if (!fs.existsSync(file)) {
- file = path.resolve(dir, fileReference.fileName + '.d.ts');
+ let fileNoExt = path.resolve(dir, fileReference.fileName);
+ let file = getIfExists(fileNoExt);
+ if (!file) {
+ file = getIfExists(`${file}/index`);
}
return file;
- })
+ }).filter(file=> !!file)
)
);
});
@@ -688,9 +700,10 @@ function getDefinitionsForNodeModules(projectDir: string, files: string[]): { ou
return { implicit, ours, packagejson };
}
-export function prettyJSON(object: any): string {
+export function prettyJSON(object: any, indent: string | number = 4): string {
var cache = [];
- var value = JSON.stringify(object,
+ var value = JSON.stringify(
+ object,
// fixup circular reference
function(key, value) {
if (typeof value === 'object' && value !== null) {
@@ -703,8 +716,8 @@ export function prettyJSON(object: any): string {
}
return value;
},
- // indent 4 spaces
- 4);
+ indent
+ );
value = value.split('\n').join(os.EOL) + os.EOL;
cache = null;
return value;
diff --git a/lib/tsconfig.json b/lib/tsconfig.json
index 7aac82c90..bc01d87bd 100644
--- a/lib/tsconfig.json
+++ b/lib/tsconfig.json
@@ -17,6 +17,7 @@
"filesGlob": [
"./**/*.ts",
"./**/*.tsx",
+ "../typings/main.d.ts",
"!node_modules/**/*.ts",
"!node_modules/**/*.tsx"
],
@@ -65,20 +66,21 @@
"./main/lang/core/project.ts",
"./main/lang/fixmyts/astUtils.ts",
"./main/lang/fixmyts/quickFix.ts",
- "./main/lang/fixmyts/quickFixRegistry.ts",
"./main/lang/fixmyts/quickFixes/addClassMember.ts",
"./main/lang/fixmyts/quickFixes/addClassMethod.ts",
+ "./main/lang/fixmyts/quickFixes/addImportFromStatement.ts",
"./main/lang/fixmyts/quickFixes/addImportStatement.ts",
"./main/lang/fixmyts/quickFixes/equalsToEquals.ts",
"./main/lang/fixmyts/quickFixes/extractVariable.ts",
"./main/lang/fixmyts/quickFixes/implementInterface.ts",
- "./main/lang/fixmyts/quickFixes/quoteToTemplate.ts",
"./main/lang/fixmyts/quickFixes/quotesToQuotes.ts",
+ "./main/lang/fixmyts/quickFixes/quoteToTemplate.ts",
"./main/lang/fixmyts/quickFixes/singleLineCommentToJsdoc.ts",
"./main/lang/fixmyts/quickFixes/stringConcatToTemplate.ts",
"./main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.ts",
"./main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.ts",
"./main/lang/fixmyts/quickFixes/wrapInProperty.ts",
+ "./main/lang/fixmyts/quickFixRegistry.ts",
"./main/lang/modules/astToText.ts",
"./main/lang/modules/building.ts",
"./main/lang/modules/formatting.ts",
@@ -105,10 +107,10 @@
"./typings/codemirror.d.ts",
"./typings/d3/d3.d.ts",
"./typings/emissary/emissary.d.ts",
- "./typings/glob-expand/glob-expand.d.ts",
+ "./typings/glob/glob.d.ts",
"./typings/htmltojsx/htmltojsx.d.ts",
"./typings/jquery/jquery.d.ts",
- "./typings/minimatch.d.ts",
+ "./typings/minimatch/minimatch.d.ts",
"./typings/mixto/mixto.d.ts",
"./typings/mkdirp/mkdirp.d.ts",
"./typings/mustache.d.ts",
@@ -117,7 +119,6 @@
"./typings/q/Q.d.ts",
"./typings/react/react-jsx.d.ts",
"./typings/react/react.d.ts",
- "./typings/source-map/source-map.d.ts",
"./typings/space-pen/space-pen.d.ts",
"./typings/status-bar/status-bar.d.ts",
"./typings/text-buffer/text-buffer.d.ts",
@@ -128,6 +129,11 @@
"./worker/parent.ts",
"./worker/queryParent.ts",
"./main/atom/views/rView.tsx",
- "./main/atom/views/semanticView.tsx"
- ]
+ "./main/atom/views/semanticView.tsx",
+ "../typings/main.d.ts"
+ ],
+ "exclude": [],
+ "atom": {
+ "rewriteTsconfig": true
+ }
}
diff --git a/lib/tsd.json b/lib/tsd.json
index 028c42bfd..04d8a827f 100644
--- a/lib/tsd.json
+++ b/lib/tsd.json
@@ -30,7 +30,7 @@
"commit": "69bdfb0884020e41f17a1dd80ad4c77de2636874"
},
"node/node.d.ts": {
- "commit": "69bdfb0884020e41f17a1dd80ad4c77de2636874"
+ "commit": "66f88ec51858bb21bc375fa91a963c04bc09401e"
},
"q/Q.d.ts": {
"commit": "69bdfb0884020e41f17a1dd80ad4c77de2636874"
@@ -41,9 +41,6 @@
"d3/d3.d.ts": {
"commit": "2520bce9a8a71b66e67487cbd5b33fec880b0c55"
},
- "source-map/source-map.d.ts": {
- "commit": "70737c2a2496f7a13c4da63eb00081cad94d19f1"
- },
"react/react.d.ts": {
"commit": "6f04d25ad38982d372cc3cda62fa4c0eef9e24d7"
},
@@ -52,6 +49,12 @@
},
"htmltojsx/htmltojsx.d.ts": {
"commit": "1632606f82cfbaf89d4b96b8dccacfaf2a6ae2f3"
+ },
+ "glob/glob.d.ts": {
+ "commit": "66f88ec51858bb21bc375fa91a963c04bc09401e"
+ },
+ "minimatch/minimatch.d.ts": {
+ "commit": "66f88ec51858bb21bc375fa91a963c04bc09401e"
}
}
}
diff --git a/lib/typings/atompromise.d.ts b/lib/typings/atompromise.d.ts
index 2aaf30bdc..98bad30e6 100644
--- a/lib/typings/atompromise.d.ts
+++ b/lib/typings/atompromise.d.ts
@@ -33,7 +33,7 @@ interface PromiseConstructor {
* and a reject callback used to reject the promise with a provided reason or error.
*/
new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise;
-
+
(init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise;
/**
@@ -96,3 +96,7 @@ interface PromiseDeferred {
}
declare var Promise: PromiseConstructor;
+
+declare module 'pinkie-promise'{
+ export = Promise;
+}
diff --git a/lib/typings/glob-expand/glob-expand.d.ts b/lib/typings/glob-expand/glob-expand.d.ts
deleted file mode 100644
index b020a1bdc..000000000
--- a/lib/typings/glob-expand/glob-expand.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare module "glob-expand" {
- var foo;
- export = foo;
-}
diff --git a/lib/typings/glob/glob.d.ts b/lib/typings/glob/glob.d.ts
new file mode 100644
index 000000000..6e9714375
--- /dev/null
+++ b/lib/typings/glob/glob.d.ts
@@ -0,0 +1,112 @@
+// Type definitions for Glob 5.0.10
+// Project: https://github.com/isaacs/node-glob
+// Definitions by: vvakame
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+
+declare module "glob" {
+
+ import events = require("events");
+ import fs = require('fs');
+ import minimatch = require("minimatch");
+
+ function G(pattern: string, cb: (err: Error, matches: string[]) => void): void;
+ function G(pattern: string, options: G.IOptions, cb: (err: Error, matches: string[]) => void): void;
+
+ module G {
+ function sync(pattern: string, options?: IOptions): string[];
+
+ function hasMagic(pattern: string, options?: IOptions): boolean;
+
+ var Glob: IGlobStatic;
+ var GlobSync: IGlobSyncStatic;
+
+ interface IOptions extends minimatch.IOptions {
+ cwd?: string;
+ root?: string;
+ dot?: boolean;
+ nomount?: boolean;
+ mark?: boolean;
+ nosort?: boolean;
+ stat?: boolean;
+ silent?: boolean;
+ strict?: boolean;
+ cache?: { [path: string]: any /* boolean | string | string[] */ };
+ statCache?: { [path: string]: fs.Stats };
+ symlinks?: any;
+ sync?: boolean;
+ nounique?: boolean;
+ nonull?: boolean;
+ debug?: boolean;
+ nobrace?: boolean;
+ noglobstar?: boolean;
+ noext?: boolean;
+ nocase?: boolean;
+ matchBase?: any;
+ nodir?: boolean;
+ ignore?: any; /* string | string[] */
+ follow?: boolean;
+ realpath?: boolean;
+ nonegate?: boolean;
+ nocomment?: boolean;
+
+ /** Deprecated. */
+ globDebug?: boolean;
+ }
+
+ interface IGlobStatic extends events.EventEmitter {
+ new (pattern: string, cb?: (err: Error, matches: string[]) => void): IGlob;
+ new (pattern: string, options: IOptions, cb?: (err: Error, matches: string[]) => void): IGlob;
+ prototype: IGlob;
+ }
+
+ interface IGlobSyncStatic {
+ new (pattern: string, options?: IOptions): IGlobBase
+ prototype: IGlobBase;
+ }
+
+ interface IGlobBase {
+ minimatch: minimatch.IMinimatch;
+ options: IOptions;
+ aborted: boolean;
+ cache: { [path: string]: any /* boolean | string | string[] */ };
+ statCache: { [path: string]: fs.Stats };
+ symlinks: { [path: string]: boolean };
+ realpathCache: { [path: string]: string };
+ found: string[];
+ }
+
+ interface IGlob extends IGlobBase, events.EventEmitter {
+ pause(): void;
+ resume(): void;
+ abort(): void;
+
+ /** Deprecated. */
+ EOF: any;
+ /** Deprecated. */
+ paused: boolean;
+ /** Deprecated. */
+ maxDepth: number;
+ /** Deprecated. */
+ maxLength: number;
+ /** Deprecated. */
+ changedCwd: boolean;
+ /** Deprecated. */
+ cwd: string;
+ /** Deprecated. */
+ root: string;
+ /** Deprecated. */
+ error: any;
+ /** Deprecated. */
+ matches: string[];
+ /** Deprecated. */
+ log(...args: any[]): void;
+ /** Deprecated. */
+ emitMatch(m: any): void;
+ }
+ }
+
+ export = G;
+}
diff --git a/lib/typings/minimatch.d.ts b/lib/typings/minimatch.d.ts
deleted file mode 100644
index 684e0a0bf..000000000
--- a/lib/typings/minimatch.d.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2013-2014 François de Campredon
-//
-// 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
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * All options are false by default.
- */
-interface MiniMatchOptions {
-
- /**
- * Dump a ton of stuff to stderr.
- */
- debug?: boolean;
-
- /**
- * Do not expand {a,b} and {1..3} brace sets.
- */
- nobrace?: boolean;
-
- /**
- * Disable ** matching against multiple folder names.
- */
- noglobstar?: boolean;
-
- /**
- * Allow patterns to match filenames starting with a period, even if the pattern does not explicitly have a period in that spot.
- * Note that by default, a/** /b will not match a/.d/b, unless dot is set.
- */
- dot?: boolean;
-
- /**
- * Disable "extglob" style patterns like +(a|b).
- */
- noext?: boolean;
-
- /**
- * Perform a case-insensitive match.
- */
- nocase?: boolean;
-
-
- /**
- * When a match is not found by minimatch.match, return a list containing the pattern itself.
- * When set, an empty list is returned if there are no matches.
- */
- nonull?: boolean;
-
-
- /**
- * If set, then patterns without slashes will be matched against the basename of the path if it contains slashes.
- * For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123.
- */
- matchBase?: boolean;
-
-
- /**
- * Suppress the behavior of treating # at the start of a pattern as a comment.
- */
- nocomment?: boolean;
-
-
- /**
- * Suppress the behavior of treating a leading ! character as negation.
- */
- nonegate?: boolean;
-
-
- /**
- * Returns from negate expressions the same as if they were not negated. (Ie, true on a hit, false on a miss.)
- */
- flipNegate?: boolean;
-}
-
-
-interface MiniMatchStatic {
- (path: string, pattern: string, options?: MiniMatchOptions): boolean;
- filter(pattern: string, options?: MiniMatchOptions): { (path: string): boolean };
-}
-
-declare module 'minimatch' {
- var minimatch: MiniMatchStatic;
- export = minimatch;
-}
-
-
diff --git a/lib/typings/minimatch/minimatch.d.ts b/lib/typings/minimatch/minimatch.d.ts
new file mode 100644
index 000000000..a79c6ff11
--- /dev/null
+++ b/lib/typings/minimatch/minimatch.d.ts
@@ -0,0 +1,64 @@
+// Type definitions for Minimatch 2.0.8
+// Project: https://github.com/isaacs/minimatch
+// Definitions by: vvakame
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module "minimatch" {
+
+ function M(target: string, pattern: string, options?: M.IOptions): boolean;
+
+ module M {
+ function match(list: string[], pattern: string, options?: IOptions): string[];
+ function filter(pattern: string, options?: IOptions): (element: string, indexed: number, array: string[]) => boolean;
+ function makeRe(pattern: string, options?: IOptions): RegExp;
+
+ var Minimatch: IMinimatchStatic;
+
+ interface IOptions {
+ debug?: boolean;
+ nobrace?: boolean;
+ noglobstar?: boolean;
+ dot?: boolean;
+ noext?: boolean;
+ nocase?: boolean;
+ nonull?: boolean;
+ matchBase?: boolean;
+ nocomment?: boolean;
+ nonegate?: boolean;
+ flipNegate?: boolean;
+ }
+
+ interface IMinimatchStatic {
+ new (pattern: string, options?: IOptions): IMinimatch;
+ prototype: IMinimatch;
+ }
+
+ interface IMinimatch {
+ pattern: string;
+ options: IOptions;
+ /** 2-dimensional array of regexp or string expressions. */
+ set: any[][]; // (RegExp | string)[][]
+ regexp: RegExp;
+ negate: boolean;
+ comment: boolean;
+ empty: boolean;
+
+ makeRe(): RegExp; // regexp or boolean
+ match(fname: string): boolean;
+ matchOne(files: string[], pattern: string[], partial: boolean): boolean;
+
+ /** Deprecated. For internal use. */
+ debug(): void;
+ /** Deprecated. For internal use. */
+ make(): void;
+ /** Deprecated. For internal use. */
+ parseNegate(): void;
+ /** Deprecated. For internal use. */
+ braceExpand(pattern: string, options: IOptions): void;
+ /** Deprecated. For internal use. */
+ parse(pattern: string, isSub?: boolean): void;
+ }
+ }
+
+ export = M;
+}
diff --git a/lib/typings/node/node.d.ts b/lib/typings/node/node.d.ts
index 7bd8ca118..e90a4a146 100644
--- a/lib/typings/node/node.d.ts
+++ b/lib/typings/node/node.d.ts
@@ -9,6 +9,19 @@
* *
************************************************/
+interface Error {
+ stack?: string;
+}
+
+
+// compat for TypeScript 1.5.3
+// if you use with --target es3 or --target es5 and use below definitions,
+// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3.
+interface MapConstructor {}
+interface WeakMapConstructor {}
+interface SetConstructor {}
+interface WeakSetConstructor {}
+
/************************************************
* *
* GLOBAL *
@@ -27,23 +40,30 @@ declare function clearInterval(intervalId: NodeJS.Timer): void;
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
declare function clearImmediate(immediateId: any): void;
-declare var require: {
+interface NodeRequireFunction {
(id: string): any;
+}
+
+interface NodeRequire extends NodeRequireFunction {
resolve(id:string): string;
cache: any;
extensions: any;
main: any;
-};
+}
+
+declare var require: NodeRequire;
-declare var module: {
+interface NodeModule {
exports: any;
- require(id: string): any;
+ require: NodeRequireFunction;
id: string;
filename: string;
loaded: boolean;
parent: any;
children: any[];
-};
+}
+
+declare var module: NodeModule;
// Same as module.exports
declare var exports: any;
@@ -61,15 +81,76 @@ declare var SlowBuffer: {
// Buffer class
interface Buffer extends NodeBuffer {}
+
+/**
+ * Raw data is stored in instances of the Buffer class.
+ * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
+ * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
+ */
declare var Buffer: {
+ /**
+ * Allocates a new buffer containing the given {str}.
+ *
+ * @param str String to store in buffer.
+ * @param encoding encoding to use, optional. Default is 'utf8'
+ */
new (str: string, encoding?: string): Buffer;
+ /**
+ * Allocates a new buffer of {size} octets.
+ *
+ * @param size count of octets to allocate.
+ */
new (size: number): Buffer;
- new (size: Uint8Array): Buffer;
+ /**
+ * Allocates a new buffer containing the given {array} of octets.
+ *
+ * @param array The octets to store.
+ */
+ new (array: Uint8Array): Buffer;
+ /**
+ * Allocates a new buffer containing the given {array} of octets.
+ *
+ * @param array The octets to store.
+ */
new (array: any[]): Buffer;
prototype: Buffer;
+ /**
+ * Returns true if {obj} is a Buffer
+ *
+ * @param obj object to test.
+ */
isBuffer(obj: any): boolean;
+ /**
+ * Returns true if {encoding} is a valid encoding argument.
+ * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
+ *
+ * @param encoding string to test.
+ */
+ isEncoding(encoding: string): boolean;
+ /**
+ * Gives the actual byte length of a string. encoding defaults to 'utf8'.
+ * This is not the same as String.prototype.length since that returns the number of characters in a string.
+ *
+ * @param string string to test.
+ * @param encoding encoding used to evaluate (defaults to 'utf8')
+ */
byteLength(string: string, encoding?: string): number;
+ /**
+ * Returns a buffer which is the result of concatenating all the buffers in the list together.
+ *
+ * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
+ * If the list has exactly one item, then the first item of the list is returned.
+ * If the list has more than one item, then a new Buffer is created.
+ *
+ * @param list An array of Buffer objects to concatenate
+ * @param totalLength Total length of the buffers when concatenated.
+ * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
+ */
concat(list: Buffer[], totalLength?: number): Buffer;
+ /**
+ * The same as buf1.compare(buf2).
+ */
+ compare(buf1: Buffer, buf2: Buffer): number;
};
/************************************************
@@ -79,10 +160,11 @@ declare var Buffer: {
************************************************/
declare module NodeJS {
export interface ErrnoException extends Error {
- errno?: any;
+ errno?: number;
code?: string;
path?: string;
syscall?: string;
+ stack?: string;
}
export interface EventEmitter {
@@ -98,7 +180,7 @@ declare module NodeJS {
export interface ReadableStream extends EventEmitter {
readable: boolean;
- read(size?: number): any;
+ read(size?: number): string|Buffer;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
@@ -111,8 +193,7 @@ declare module NodeJS {
export interface WritableStream extends EventEmitter {
writable: boolean;
- write(buffer: Buffer, cb?: Function): boolean;
- write(str: string, cb?: Function): boolean;
+ write(buffer: Buffer|string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
@@ -190,6 +271,71 @@ declare module NodeJS {
send?(message: any, sendHandle?: any): void;
}
+ export interface Global {
+ Array: typeof Array;
+ ArrayBuffer: typeof ArrayBuffer;
+ Boolean: typeof Boolean;
+ Buffer: typeof Buffer;
+ DataView: typeof DataView;
+ Date: typeof Date;
+ Error: typeof Error;
+ EvalError: typeof EvalError;
+ Float32Array: typeof Float32Array;
+ Float64Array: typeof Float64Array;
+ Function: typeof Function;
+ GLOBAL: Global;
+ Infinity: typeof Infinity;
+ Int16Array: typeof Int16Array;
+ Int32Array: typeof Int32Array;
+ Int8Array: typeof Int8Array;
+ Intl: typeof Intl;
+ JSON: typeof JSON;
+ Map: MapConstructor;
+ Math: typeof Math;
+ NaN: typeof NaN;
+ Number: typeof Number;
+ Object: typeof Object;
+ Promise: Function;
+ RangeError: typeof RangeError;
+ ReferenceError: typeof ReferenceError;
+ RegExp: typeof RegExp;
+ Set: SetConstructor;
+ String: typeof String;
+ Symbol: Function;
+ SyntaxError: typeof SyntaxError;
+ TypeError: typeof TypeError;
+ URIError: typeof URIError;
+ Uint16Array: typeof Uint16Array;
+ Uint32Array: typeof Uint32Array;
+ Uint8Array: typeof Uint8Array;
+ Uint8ClampedArray: Function;
+ WeakMap: WeakMapConstructor;
+ WeakSet: WeakSetConstructor;
+ clearImmediate: (immediateId: any) => void;
+ clearInterval: (intervalId: NodeJS.Timer) => void;
+ clearTimeout: (timeoutId: NodeJS.Timer) => void;
+ console: typeof console;
+ decodeURI: typeof decodeURI;
+ decodeURIComponent: typeof decodeURIComponent;
+ encodeURI: typeof encodeURI;
+ encodeURIComponent: typeof encodeURIComponent;
+ escape: (str: string) => string;
+ eval: typeof eval;
+ global: Global;
+ isFinite: typeof isFinite;
+ isNaN: typeof isNaN;
+ parseFloat: typeof parseFloat;
+ parseInt: typeof parseInt;
+ process: Process;
+ root: Global;
+ setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
+ setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
+ setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
+ undefined: typeof undefined;
+ unescape: (str: string) => string;
+ gc: () => void;
+ }
+
export interface Timer {
ref() : void;
unref() : void;
@@ -205,8 +351,18 @@ interface NodeBuffer {
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): any;
length: number;
+ equals(otherBuffer: Buffer): boolean;
+ compare(otherBuffer: Buffer): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
+ writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+ writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+ writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+ writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+ readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
+ readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
+ readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
+ readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAsset?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
@@ -270,27 +426,23 @@ declare module "events" {
}
declare module "http" {
- import events = require("events");
- import net = require("net");
- import stream = require("stream");
+ import * as events from "events";
+ import * as net from "net";
+ import * as stream from "stream";
export interface Server extends events.EventEmitter {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
+ listen(port: number, hostname?: string, callback?: Function): Server;
listen(path: string, callback?: Function): Server;
listen(handle: any, listeningListener?: Function): Server;
close(cb?: any): Server;
address(): { port: number; family: string; address: string; };
maxHeadersCount: number;
}
- export interface ServerRequest extends events.EventEmitter, stream.Readable {
- method: string;
- url: string;
- headers: any;
- trailers: string;
- httpVersion: string;
- setEncoding(encoding?: string): void;
- pause(): void;
- resume(): void;
+ /**
+ * @deprecated Use IncomingMessage
+ */
+ export interface ServerRequest extends IncomingMessage {
connection: net.Socket;
}
export interface ServerResponse extends events.EventEmitter, stream.Writable {
@@ -305,6 +457,7 @@ declare module "http" {
writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
writeHead(statusCode: number, headers?: any): void;
statusCode: number;
+ statusMessage: string;
setHeader(name: string, value: string): void;
sendDate: boolean;
getHeader(name: string): string;
@@ -340,15 +493,35 @@ declare module "http" {
end(str: string, encoding?: string, cb?: Function): void;
end(data?: any, encoding?: string): void;
}
- export interface ClientResponse extends events.EventEmitter, stream.Readable {
- statusCode: number;
+ export interface IncomingMessage extends events.EventEmitter, stream.Readable {
httpVersion: string;
headers: any;
+ rawHeaders: string[];
trailers: any;
- setEncoding(encoding?: string): void;
- pause(): void;
- resume(): void;
+ rawTrailers: any;
+ setTimeout(msecs: number, callback: Function): NodeJS.Timer;
+ /**
+ * Only valid for request obtained from http.Server.
+ */
+ method?: string;
+ /**
+ * Only valid for request obtained from http.Server.
+ */
+ url?: string;
+ /**
+ * Only valid for response obtained from http.ClientRequest.
+ */
+ statusCode?: number;
+ /**
+ * Only valid for response obtained from http.ClientRequest.
+ */
+ statusMessage?: string;
+ socket: net.Socket;
}
+ /**
+ * @deprecated Use IncomingMessage
+ */
+ export interface ClientResponse extends IncomingMessage { }
export interface AgentOptions {
/**
@@ -386,20 +559,22 @@ declare module "http" {
destroy(): void;
}
+ export var METHODS: string[];
+
export var STATUS_CODES: {
[errorCode: number]: string;
[errorCode: string]: string;
};
- export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server;
+ export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server;
export function createClient(port?: number, host?: string): any;
- export function request(options: any, callback?: Function): ClientRequest;
- export function get(options: any, callback?: Function): ClientRequest;
+ export function request(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
+ export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
export var globalAgent: Agent;
}
declare module "cluster" {
- import child = require("child_process");
- import events = require("events");
+ import * as child from "child_process";
+ import * as events from "events";
export interface ClusterSettings {
exec?: string;
@@ -438,7 +613,7 @@ declare module "cluster" {
}
declare module "zlib" {
- import stream = require("stream");
+ import * as stream from "stream";
export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
export interface Gzip extends stream.Transform { }
@@ -458,12 +633,19 @@ declare module "zlib" {
export function createUnzip(options?: ZlibOptions): Unzip;
export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function deflateSync(buf: Buffer, options?: ZlibOptions): any;
export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any;
export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function gzipSync(buf: Buffer, options?: ZlibOptions): any;
export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function gunzipSync(buf: Buffer, options?: ZlibOptions): any;
export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function inflateSync(buf: Buffer, options?: ZlibOptions): any;
export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any;
export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
+ export function unzipSync(buf: Buffer, options?: ZlibOptions): any;
// Constants
export var Z_NO_FLUSH: number;
@@ -516,9 +698,9 @@ declare module "os" {
}
declare module "https" {
- import tls = require("tls");
- import events = require("events");
- import http = require("http");
+ import * as tls from "tls";
+ import * as events from "events";
+ import * as http from "http";
export interface ServerOptions {
pfx?: any;
@@ -563,8 +745,8 @@ declare module "https" {
};
export interface Server extends tls.Server { }
export function createServer(options: ServerOptions, requestListener?: Function): Server;
- export function request(options: RequestOptions, callback?: (res: http.ClientResponse) =>void ): http.ClientRequest;
- export function get(options: RequestOptions, callback?: (res: http.ClientResponse) =>void ): http.ClientRequest;
+ export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
+ export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
export var globalAgent: Agent;
}
@@ -582,8 +764,8 @@ declare module "punycode" {
}
declare module "repl" {
- import stream = require("stream");
- import events = require("events");
+ import * as stream from "stream";
+ import * as events from "events";
export interface ReplOptions {
prompt?: string;
@@ -600,11 +782,11 @@ declare module "repl" {
}
declare module "readline" {
- import events = require("events");
- import stream = require("stream");
+ import * as events from "events";
+ import * as stream from "stream";
export interface ReadLine extends events.EventEmitter {
- setPrompt(prompt: string, length: number): void;
+ setPrompt(prompt: string): void;
prompt(preserveCursor?: boolean): void;
question(query: string, callback: Function): void;
pause(): void;
@@ -635,8 +817,8 @@ declare module "vm" {
}
declare module "child_process" {
- import events = require("events");
- import stream = require("stream");
+ import * as events from "events";
+ import * as stream from "stream";
export interface ChildProcess extends events.EventEmitter {
stdin: stream.Writable;
@@ -646,6 +828,7 @@ declare module "child_process" {
kill(signal?: string): void;
send(message: any, sendHandle?: any): void;
disconnect(): void;
+ unref(): void;
}
export function spawn(command: string, args?: string[], options?: {
@@ -664,8 +847,8 @@ declare module "child_process" {
timeout?: number;
maxBuffer?: number;
killSignal?: string;
- }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
- export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
+ }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
+ export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
export function execFile(file: string,
callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
export function execFile(file: string, args?: string[],
@@ -697,6 +880,18 @@ declare module "child_process" {
killSignal?: string;
encoding?: string;
}): ChildProcess;
+ export function execFileSync(command: string, args?: string[], options?: {
+ cwd?: string;
+ input?: string|Buffer;
+ stdio?: any;
+ env?: any;
+ uid?: number;
+ gid?: number;
+ timeout?: number;
+ maxBuffer?: number;
+ killSignal?: string;
+ encoding?: string;
+ }): ChildProcess;
}
declare module "url" {
@@ -749,7 +944,7 @@ declare module "dns" {
}
declare module "net" {
- import stream = require("stream");
+ import * as stream from "stream";
export interface Socket extends stream.Duplex {
// Extended base methods
@@ -775,7 +970,10 @@ declare module "net" {
ref(): void;
remoteAddress: string;
+ remoteFamily: string;
remotePort: number;
+ localAddress: string;
+ localPort: number;
bytesRead: number;
bytesWritten: number;
@@ -814,7 +1012,7 @@ declare module "net" {
}
declare module "dgram" {
- import events = require("events");
+ import * as events from "events";
interface RemoteInfo {
address: string;
@@ -844,8 +1042,8 @@ declare module "dgram" {
}
declare module "fs" {
- import stream = require("stream");
- import events = require("events");
+ import * as stream from "stream";
+ import * as events from "events";
interface Stats {
isFile(): boolean;
@@ -868,6 +1066,7 @@ declare module "fs" {
atime: Date;
mtime: Date;
ctime: Date;
+ birthtime: Date;
}
interface FSWatcher extends events.EventEmitter {
@@ -879,9 +1078,21 @@ declare module "fs" {
}
export interface WriteStream extends stream.Writable {
close(): void;
+ bytesWritten: number;
}
+ /**
+ * Asynchronous rename.
+ * @param oldPath
+ * @param newPath
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /**
+ * Synchronous rename
+ * @param oldPath
+ * @param newPath
+ */
export function renameSync(oldPath: string, newPath: string): void;
export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
@@ -921,15 +1132,71 @@ declare module "fs" {
export function readlinkSync(path: string): string;
export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void;
- export function realpathSync(path: string, cache?: {[path: string]: string}): string;
+ export function realpathSync(path: string, cache?: { [path: string]: string }): string;
+ /*
+ * Asynchronous unlink - deletes the file specified in {path}
+ *
+ * @param path
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /*
+ * Synchronous unlink - deletes the file specified in {path}
+ *
+ * @param path
+ */
export function unlinkSync(path: string): void;
+ /*
+ * Asynchronous rmdir - removes the directory specified in {path}
+ *
+ * @param path
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /*
+ * Synchronous rmdir - removes the directory specified in {path}
+ *
+ * @param path
+ */
export function rmdirSync(path: string): void;
+ /*
+ * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
+ *
+ * @param path
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /*
+ * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
+ *
+ * @param path
+ * @param mode
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /*
+ * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
+ *
+ * @param path
+ * @param mode
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
+ /*
+ * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
+ *
+ * @param path
+ * @param mode
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function mkdirSync(path: string, mode?: number): void;
+ /*
+ * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
+ *
+ * @param path
+ * @param mode
+ * @param callback No arguments other than a possible exception are given to the completion callback.
+ */
export function mkdirSync(path: string, mode?: string): void;
export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
export function readdirSync(path: string): string[];
@@ -951,15 +1218,64 @@ declare module "fs" {
export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function fsyncSync(fd: number): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
+ export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
+ export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
+ export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
+ export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
+ /*
+ * Asynchronous readFile - Asynchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param encoding
+ * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
+ */
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
+ /*
+ * Asynchronous readFile - Asynchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
+ * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
+ */
export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
+ /*
+ * Asynchronous readFile - Asynchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
+ * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
+ */
export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
- export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void ): void;
+ /*
+ * Asynchronous readFile - Asynchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
+ */
+ export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
+ /*
+ * Synchronous readFile - Synchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param encoding
+ */
export function readFileSync(filename: string, encoding: string): string;
+ /*
+ * Synchronous readFile - Synchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
+ */
export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
+ /*
+ * Synchronous readFile - Synchronously reads the entire contents of a file.
+ *
+ * @param fileName
+ * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
+ */
export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
@@ -978,49 +1294,178 @@ declare module "fs" {
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
export function exists(path: string, callback?: (exists: boolean) => void): void;
export function existsSync(path: string): boolean;
+ /** Constant for fs.access(). File is visible to the calling process. */
+ export var F_OK: number;
+ /** Constant for fs.access(). File can be read by the calling process. */
+ export var R_OK: number;
+ /** Constant for fs.access(). File can be written by the calling process. */
+ export var W_OK: number;
+ /** Constant for fs.access(). File can be executed by the calling process. */
+ export var X_OK: number;
+ /** Tests a user's permissions for the file specified by path. */
+ export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void;
+ export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
+ /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
+ export function accessSync(path: string, mode ?: number): void;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
- fd?: string;
+ fd?: number;
mode?: number;
- bufferSize?: number;
- }): ReadStream;
- export function createReadStream(path: string, options?: {
- flags?: string;
- encoding?: string;
- fd?: string;
- mode?: string;
- bufferSize?: number;
+ autoClose?: boolean;
}): ReadStream;
export function createWriteStream(path: string, options?: {
flags?: string;
encoding?: string;
- string?: string;
+ fd?: number;
+ mode?: number;
}): WriteStream;
}
declare module "path" {
+ /**
+ * A parsed path object generated by path.parse() or consumed by path.format().
+ */
export interface ParsedPath {
+ /**
+ * The root of the path such as '/' or 'c:\'
+ */
root: string;
+ /**
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
+ */
dir: string;
+ /**
+ * The file name including extension (if any) such as 'index.html'
+ */
base: string;
+ /**
+ * The file extension (if any) such as '.html'
+ */
ext: string;
+ /**
+ * The file name without extension (if any) such as 'index'
+ */
name: string;
}
+ /**
+ * Normalize a string path, reducing '..' and '.' parts.
+ * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
+ *
+ * @param p string path to normalize.
+ */
export function normalize(p: string): string;
+ /**
+ * Join all arguments together and normalize the resulting path.
+ * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
+ *
+ * @param paths string paths to join.
+ */
export function join(...paths: any[]): string;
+ /**
+ * Join all arguments together and normalize the resulting path.
+ * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
+ *
+ * @param paths string paths to join.
+ */
+ export function join(...paths: string[]): string;
+ /**
+ * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
+ *
+ * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
+ *
+ * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
+ *
+ * @param pathSegments string paths to join. Non-string arguments are ignored.
+ */
export function resolve(...pathSegments: any[]): string;
- export function isAbsolute(p: string): boolean;
+ /**
+ * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
+ *
+ * @param path path to test.
+ */
+ export function isAbsolute(path: string): boolean;
+ /**
+ * Solve the relative path from {from} to {to}.
+ * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
+ *
+ * @param from
+ * @param to
+ */
export function relative(from: string, to: string): string;
+ /**
+ * Return the directory name of a path. Similar to the Unix dirname command.
+ *
+ * @param p the path to evaluate.
+ */
export function dirname(p: string): string;
+ /**
+ * Return the last portion of a path. Similar to the Unix basename command.
+ * Often used to extract the file name from a fully qualified path.
+ *
+ * @param p the path to evaluate.
+ * @param ext optionally, an extension to remove from the result.
+ */
export function basename(p: string, ext?: string): string;
+ /**
+ * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
+ * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
+ *
+ * @param p the path to evaluate.
+ */
export function extname(p: string): string;
+ /**
+ * The platform-specific file separator. '\\' or '/'.
+ */
export var sep: string;
+ /**
+ * The platform-specific file delimiter. ';' or ':'.
+ */
export var delimiter: string;
- export function parse(p: string): ParsedPath;
- export function format(pP: ParsedPath): string;
+ /**
+ * Returns an object from a path string - the opposite of format().
+ *
+ * @param pathString path to evaluate.
+ */
+ export function parse(pathString: string): ParsedPath;
+ /**
+ * Returns a path string from an object - the opposite of parse().
+ *
+ * @param pathString path to evaluate.
+ */
+ export function format(pathObject: ParsedPath): string;
+
+ export module posix {
+ export function normalize(p: string): string;
+ export function join(...paths: any[]): string;
+ export function resolve(...pathSegments: any[]): string;
+ export function isAbsolute(p: string): boolean;
+ export function relative(from: string, to: string): string;
+ export function dirname(p: string): string;
+ export function basename(p: string, ext?: string): string;
+ export function extname(p: string): string;
+ export var sep: string;
+ export var delimiter: string;
+ export function parse(p: string): ParsedPath;
+ export function format(pP: ParsedPath): string;
+ }
+
+ export module win32 {
+ export function normalize(p: string): string;
+ export function join(...paths: any[]): string;
+ export function resolve(...pathSegments: any[]): string;
+ export function isAbsolute(p: string): boolean;
+ export function relative(from: string, to: string): string;
+ export function dirname(p: string): string;
+ export function basename(p: string, ext?: string): string;
+ export function extname(p: string): string;
+ export var sep: string;
+ export var delimiter: string;
+ export function parse(p: string): ParsedPath;
+ export function format(pP: ParsedPath): string;
+ }
}
declare module "string_decoder" {
@@ -1034,9 +1479,9 @@ declare module "string_decoder" {
}
declare module "tls" {
- import crypto = require("crypto");
- import net = require("net");
- import stream = require("stream");
+ import * as crypto from "crypto";
+ import * as net from "net";
+ import * as stream from "stream";
var CLIENT_RENEG_LIMIT: number;
var CLIENT_RENEG_WINDOW: number;
@@ -1110,11 +1555,27 @@ declare module "tls" {
cleartext: any;
}
+ export interface SecureContextOptions {
+ pfx?: any; //string | buffer
+ key?: any; //string | buffer
+ passphrase?: string;
+ cert?: any; // string | buffer
+ ca?: any; // string | buffer
+ crl?: any; // string | string[]
+ ciphers?: string;
+ honorCipherOrder?: boolean;
+ }
+
+ export interface SecureContext {
+ context: any;
+ }
+
export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server;
export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream;
export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
+ export function createSecureContext(details: SecureContextOptions): SecureContext;
}
declare module "crypto" {
@@ -1163,12 +1624,12 @@ declare module "crypto" {
setAutoPadding(auto_padding: boolean): void;
}
export function createSign(algorithm: string): Signer;
- interface Signer {
+ interface Signer extends NodeJS.WritableStream {
update(data: any): void;
sign(private_key: string, output_format: string): string;
}
export function createVerify(algorith: string): Verify;
- interface Verify {
+ interface Verify extends NodeJS.WritableStream {
update(data: any): void;
verify(object: string, signature: string, signature_format?: string): boolean;
}
@@ -1186,7 +1647,9 @@ declare module "crypto" {
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
+ export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
+ export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer;
export function randomBytes(size: number): Buffer;
export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
export function pseudoRandomBytes(size: number): Buffer;
@@ -1194,7 +1657,7 @@ declare module "crypto" {
}
declare module "stream" {
- import events = require("events");
+ import * as events from "events";
export interface Stream extends events.EventEmitter {
pipe(destination: T, options?: { end?: boolean; }): T;
@@ -1216,8 +1679,7 @@ declare module "stream" {
resume(): void;
pipe(destination: T, options?: { end?: boolean; }): T;
unpipe(destination?: T): void;
- unshift(chunk: string): void;
- unshift(chunk: Buffer): void;
+ unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
}
@@ -1225,20 +1687,18 @@ declare module "stream" {
export interface WritableOptions {
highWaterMark?: number;
decodeStrings?: boolean;
+ objectMode?: boolean;
}
export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
writable: boolean;
constructor(opts?: WritableOptions);
- _write(data: Buffer, encoding: string, callback: Function): void;
- _write(data: string, encoding: string, callback: Function): void;
- write(buffer: Buffer, cb?: Function): boolean;
- write(str: string, cb?: Function): boolean;
- write(str: string, encoding?: string, cb?: Function): boolean;
+ _write(chunk: any, encoding: string, callback: Function): void;
+ write(chunk: any, cb?: Function): boolean;
+ write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
- end(buffer: Buffer, cb?: Function): void;
- end(str: string, cb?: Function): void;
- end(str: string, encoding?: string, cb?: Function): void;
+ end(chunk: any, cb?: Function): void;
+ end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface DuplexOptions extends ReadableOptions, WritableOptions {
@@ -1249,15 +1709,12 @@ declare module "stream" {
export class Duplex extends Readable implements NodeJS.ReadWriteStream {
writable: boolean;
constructor(opts?: DuplexOptions);
- _write(data: Buffer, encoding: string, callback: Function): void;
- _write(data: string, encoding: string, callback: Function): void;
- write(buffer: Buffer, cb?: Function): boolean;
- write(str: string, cb?: Function): boolean;
- write(str: string, encoding?: string, cb?: Function): boolean;
+ _write(chunk: any, encoding: string, callback: Function): void;
+ write(chunk: any, cb?: Function): boolean;
+ write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
- end(buffer: Buffer, cb?: Function): void;
- end(str: string, cb?: Function): void;
- end(str: string, encoding?: string, cb?: Function): void;
+ end(chunk: any, cb?: Function): void;
+ end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface TransformOptions extends ReadableOptions, WritableOptions {}
@@ -1267,8 +1724,7 @@ declare module "stream" {
readable: boolean;
writable: boolean;
constructor(opts?: TransformOptions);
- _transform(chunk: Buffer, encoding: string, callback: Function): void;
- _transform(chunk: string, encoding: string, callback: Function): void;
+ _transform(chunk: any, encoding: string, callback: Function): void;
_flush(callback: Function): void;
read(size?: number): any;
setEncoding(encoding: string): void;
@@ -1276,17 +1732,14 @@ declare module "stream" {
resume(): void;
pipe(destination: T, options?: { end?: boolean; }): T;
unpipe(destination?: T): void;
- unshift(chunk: string): void;
- unshift(chunk: Buffer): void;
+ unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
- write(buffer: Buffer, cb?: Function): boolean;
- write(str: string, cb?: Function): boolean;
- write(str: string, encoding?: string, cb?: Function): boolean;
+ write(chunk: any, cb?: Function): boolean;
+ write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
- end(buffer: Buffer, cb?: Function): void;
- end(str: string, cb?: Function): void;
- end(str: string, encoding?: string, cb?: Function): void;
+ end(chunk: any, cb?: Function): void;
+ end(chunk: any, encoding?: string, cb?: Function): void;
}
export class PassThrough extends Transform {}
@@ -1313,6 +1766,7 @@ declare module "util" {
export function isDate(object: any): boolean;
export function isError(object: any): boolean;
export function inherits(constructor: any, superConstructor: any): void;
+ export function debuglog(key:string): (msg:string,...param: any[])=>void;
}
declare module "assert" {
@@ -1359,7 +1813,7 @@ declare module "assert" {
}
declare module "tty" {
- import net = require("net");
+ import * as net from "net";
export function isatty(fd: number): boolean;
export interface ReadStream extends net.Socket {
@@ -1373,7 +1827,7 @@ declare module "tty" {
}
declare module "domain" {
- import events = require("events");
+ import * as events from "events";
export class Domain extends events.EventEmitter {
run(fn: Function): void;
@@ -1392,3 +1846,227 @@ declare module "domain" {
export function create(): Domain;
}
+
+declare module "constants" {
+ export var E2BIG: number;
+ export var EACCES: number;
+ export var EADDRINUSE: number;
+ export var EADDRNOTAVAIL: number;
+ export var EAFNOSUPPORT: number;
+ export var EAGAIN: number;
+ export var EALREADY: number;
+ export var EBADF: number;
+ export var EBADMSG: number;
+ export var EBUSY: number;
+ export var ECANCELED: number;
+ export var ECHILD: number;
+ export var ECONNABORTED: number;
+ export var ECONNREFUSED: number;
+ export var ECONNRESET: number;
+ export var EDEADLK: number;
+ export var EDESTADDRREQ: number;
+ export var EDOM: number;
+ export var EEXIST: number;
+ export var EFAULT: number;
+ export var EFBIG: number;
+ export var EHOSTUNREACH: number;
+ export var EIDRM: number;
+ export var EILSEQ: number;
+ export var EINPROGRESS: number;
+ export var EINTR: number;
+ export var EINVAL: number;
+ export var EIO: number;
+ export var EISCONN: number;
+ export var EISDIR: number;
+ export var ELOOP: number;
+ export var EMFILE: number;
+ export var EMLINK: number;
+ export var EMSGSIZE: number;
+ export var ENAMETOOLONG: number;
+ export var ENETDOWN: number;
+ export var ENETRESET: number;
+ export var ENETUNREACH: number;
+ export var ENFILE: number;
+ export var ENOBUFS: number;
+ export var ENODATA: number;
+ export var ENODEV: number;
+ export var ENOENT: number;
+ export var ENOEXEC: number;
+ export var ENOLCK: number;
+ export var ENOLINK: number;
+ export var ENOMEM: number;
+ export var ENOMSG: number;
+ export var ENOPROTOOPT: number;
+ export var ENOSPC: number;
+ export var ENOSR: number;
+ export var ENOSTR: number;
+ export var ENOSYS: number;
+ export var ENOTCONN: number;
+ export var ENOTDIR: number;
+ export var ENOTEMPTY: number;
+ export var ENOTSOCK: number;
+ export var ENOTSUP: number;
+ export var ENOTTY: number;
+ export var ENXIO: number;
+ export var EOPNOTSUPP: number;
+ export var EOVERFLOW: number;
+ export var EPERM: number;
+ export var EPIPE: number;
+ export var EPROTO: number;
+ export var EPROTONOSUPPORT: number;
+ export var EPROTOTYPE: number;
+ export var ERANGE: number;
+ export var EROFS: number;
+ export var ESPIPE: number;
+ export var ESRCH: number;
+ export var ETIME: number;
+ export var ETIMEDOUT: number;
+ export var ETXTBSY: number;
+ export var EWOULDBLOCK: number;
+ export var EXDEV: number;
+ export var WSAEINTR: number;
+ export var WSAEBADF: number;
+ export var WSAEACCES: number;
+ export var WSAEFAULT: number;
+ export var WSAEINVAL: number;
+ export var WSAEMFILE: number;
+ export var WSAEWOULDBLOCK: number;
+ export var WSAEINPROGRESS: number;
+ export var WSAEALREADY: number;
+ export var WSAENOTSOCK: number;
+ export var WSAEDESTADDRREQ: number;
+ export var WSAEMSGSIZE: number;
+ export var WSAEPROTOTYPE: number;
+ export var WSAENOPROTOOPT: number;
+ export var WSAEPROTONOSUPPORT: number;
+ export var WSAESOCKTNOSUPPORT: number;
+ export var WSAEOPNOTSUPP: number;
+ export var WSAEPFNOSUPPORT: number;
+ export var WSAEAFNOSUPPORT: number;
+ export var WSAEADDRINUSE: number;
+ export var WSAEADDRNOTAVAIL: number;
+ export var WSAENETDOWN: number;
+ export var WSAENETUNREACH: number;
+ export var WSAENETRESET: number;
+ export var WSAECONNABORTED: number;
+ export var WSAECONNRESET: number;
+ export var WSAENOBUFS: number;
+ export var WSAEISCONN: number;
+ export var WSAENOTCONN: number;
+ export var WSAESHUTDOWN: number;
+ export var WSAETOOMANYREFS: number;
+ export var WSAETIMEDOUT: number;
+ export var WSAECONNREFUSED: number;
+ export var WSAELOOP: number;
+ export var WSAENAMETOOLONG: number;
+ export var WSAEHOSTDOWN: number;
+ export var WSAEHOSTUNREACH: number;
+ export var WSAENOTEMPTY: number;
+ export var WSAEPROCLIM: number;
+ export var WSAEUSERS: number;
+ export var WSAEDQUOT: number;
+ export var WSAESTALE: number;
+ export var WSAEREMOTE: number;
+ export var WSASYSNOTREADY: number;
+ export var WSAVERNOTSUPPORTED: number;
+ export var WSANOTINITIALISED: number;
+ export var WSAEDISCON: number;
+ export var WSAENOMORE: number;
+ export var WSAECANCELLED: number;
+ export var WSAEINVALIDPROCTABLE: number;
+ export var WSAEINVALIDPROVIDER: number;
+ export var WSAEPROVIDERFAILEDINIT: number;
+ export var WSASYSCALLFAILURE: number;
+ export var WSASERVICE_NOT_FOUND: number;
+ export var WSATYPE_NOT_FOUND: number;
+ export var WSA_E_NO_MORE: number;
+ export var WSA_E_CANCELLED: number;
+ export var WSAEREFUSED: number;
+ export var SIGHUP: number;
+ export var SIGINT: number;
+ export var SIGILL: number;
+ export var SIGABRT: number;
+ export var SIGFPE: number;
+ export var SIGKILL: number;
+ export var SIGSEGV: number;
+ export var SIGTERM: number;
+ export var SIGBREAK: number;
+ export var SIGWINCH: number;
+ export var SSL_OP_ALL: number;
+ export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
+ export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
+ export var SSL_OP_CISCO_ANYCONNECT: number;
+ export var SSL_OP_COOKIE_EXCHANGE: number;
+ export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
+ export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
+ export var SSL_OP_EPHEMERAL_RSA: number;
+ export var SSL_OP_LEGACY_SERVER_CONNECT: number;
+ export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
+ export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
+ export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
+ export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
+ export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
+ export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
+ export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
+ export var SSL_OP_NO_COMPRESSION: number;
+ export var SSL_OP_NO_QUERY_MTU: number;
+ export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
+ export var SSL_OP_NO_SSLv2: number;
+ export var SSL_OP_NO_SSLv3: number;
+ export var SSL_OP_NO_TICKET: number;
+ export var SSL_OP_NO_TLSv1: number;
+ export var SSL_OP_NO_TLSv1_1: number;
+ export var SSL_OP_NO_TLSv1_2: number;
+ export var SSL_OP_PKCS1_CHECK_1: number;
+ export var SSL_OP_PKCS1_CHECK_2: number;
+ export var SSL_OP_SINGLE_DH_USE: number;
+ export var SSL_OP_SINGLE_ECDH_USE: number;
+ export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
+ export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
+ export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
+ export var SSL_OP_TLS_D5_BUG: number;
+ export var SSL_OP_TLS_ROLLBACK_BUG: number;
+ export var ENGINE_METHOD_DSA: number;
+ export var ENGINE_METHOD_DH: number;
+ export var ENGINE_METHOD_RAND: number;
+ export var ENGINE_METHOD_ECDH: number;
+ export var ENGINE_METHOD_ECDSA: number;
+ export var ENGINE_METHOD_CIPHERS: number;
+ export var ENGINE_METHOD_DIGESTS: number;
+ export var ENGINE_METHOD_STORE: number;
+ export var ENGINE_METHOD_PKEY_METHS: number;
+ export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
+ export var ENGINE_METHOD_ALL: number;
+ export var ENGINE_METHOD_NONE: number;
+ export var DH_CHECK_P_NOT_SAFE_PRIME: number;
+ export var DH_CHECK_P_NOT_PRIME: number;
+ export var DH_UNABLE_TO_CHECK_GENERATOR: number;
+ export var DH_NOT_SUITABLE_GENERATOR: number;
+ export var NPN_ENABLED: number;
+ export var RSA_PKCS1_PADDING: number;
+ export var RSA_SSLV23_PADDING: number;
+ export var RSA_NO_PADDING: number;
+ export var RSA_PKCS1_OAEP_PADDING: number;
+ export var RSA_X931_PADDING: number;
+ export var RSA_PKCS1_PSS_PADDING: number;
+ export var POINT_CONVERSION_COMPRESSED: number;
+ export var POINT_CONVERSION_UNCOMPRESSED: number;
+ export var POINT_CONVERSION_HYBRID: number;
+ export var O_RDONLY: number;
+ export var O_WRONLY: number;
+ export var O_RDWR: number;
+ export var S_IFMT: number;
+ export var S_IFREG: number;
+ export var S_IFDIR: number;
+ export var S_IFCHR: number;
+ export var S_IFLNK: number;
+ export var O_CREAT: number;
+ export var O_EXCL: number;
+ export var O_TRUNC: number;
+ export var O_APPEND: number;
+ export var F_OK: number;
+ export var R_OK: number;
+ export var W_OK: number;
+ export var X_OK: number;
+ export var UV_UDP_REUSEADDR: number;
+}
diff --git a/lib/typings/q/Q.d.ts b/lib/typings/q/Q.d.ts
index 590fd92ad..bd5a6f4bf 100644
--- a/lib/typings/q/Q.d.ts
+++ b/lib/typings/q/Q.d.ts
@@ -1,317 +1,317 @@
-// Type definitions for Q
-// Project: https://github.com/kriskowal/q
-// Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-/**
- * If value is a Q promise, returns the promise.
- * If value is a promise from another library it is coerced into a Q promise (where possible).
- */
-declare function Q(promise: Q.IPromise): Q.Promise;
-/**
- * If value is not a promise, returns a promise that is fulfilled with value.
- */
-declare function Q(value: T): Q.Promise;
-
-declare module Q {
- interface IPromise {
- then(onFulfill?: (value: T) => U | IPromise, onReject?: (error: any) => U | IPromise): IPromise;
- }
-
- interface Deferred {
- promise: Promise;
- resolve(value: T): void;
- reject(reason: any): void;
- notify(value: any): void;
- makeNodeResolver(): (reason: any, value: T) => void;
- }
-
- interface Promise {
- /**
- * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
-
- * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
- */
- fin(finallyCallback: () => any): Promise;
- /**
- * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
-
- * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
- */
- finally(finallyCallback: () => any): Promise;
-
- /**
- * The then method from the Promises/A+ specification, with an additional progress handler.
- */
- then(onFulfill?: (value: T) => U | IPromise, onReject?: (error: any) => U | IPromise, onProgress?: Function): Promise;
-
- /**
- * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
- *
- * This is especially useful in conjunction with all
- */
- spread(onFulfilled: Function, onRejected?: Function): Promise;
-
- fail(onRejected: (reason: any) => U | IPromise): Promise;
-
- /**
- * A sugar method, equivalent to promise.then(undefined, onRejected).
- */
- catch(onRejected: (reason: any) => U | IPromise): Promise;
-
- /**
- * A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
- */
- progress(onProgress: (progress: any) => any): Promise;
-
- /**
- * Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
- *
- * This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
- *
- * Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
- *
- * The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
- */
- done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void;
-
- /**
- * If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise.
- */
- nodeify(callback: (reason: any, value: any) => void): Promise;
-
- /**
- * Returns a promise to get the named property of an object. Essentially equivalent to
- *
- * promise.then(function (o) {
- * return o[propertyName];
- * });
- */
- get(propertyName: String): Promise;
- set(propertyName: String, value: any): Promise;
- delete(propertyName: String): Promise;
- /**
- * Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
- *
- * promise.then(function (o) {
- * return o[methodName].apply(o, args);
- * });
- */
- post(methodName: String, args: any[]): Promise;
- /**
- * Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
- */
- invoke(methodName: String, ...args: any[]): Promise;
- fapply(args: any[]): Promise;
- fcall(...args: any[]): Promise;
-
- /**
- * Returns a promise for an array of the property names of an object. Essentially equivalent to
- *
- * promise.then(function (o) {
- * return Object.keys(o);
- * });
- */
- keys(): Promise;
-
- /**
- * A sugar method, equivalent to promise.then(function () { return value; }).
- */
- thenResolve(value: U): Promise;
- /**
- * A sugar method, equivalent to promise.then(function () { throw reason; }).
- */
- thenReject(reason: any): Promise;
- timeout(ms: number, message?: string): Promise;
- /**
- * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
- */
- delay(ms: number): Promise;
-
- /**
- * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
- */
- isFulfilled(): boolean;
- /**
- * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
- */
- isRejected(): boolean;
- /**
- * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
- */
- isPending(): boolean;
-
- valueOf(): any;
-
- /**
- * Returns a "state snapshot" object, which will be in one of three forms:
- *
- * - { state: "pending" }
- * - { state: "fulfilled", value: }
- * - { state: "rejected", reason: }
- */
- inspect(): PromiseState;
- }
-
- interface PromiseState {
- /**
- * "fulfilled", "rejected", "pending"
- */
- state: string;
- value?: T;
- reason?: any;
- }
-
- // If no value provided, returned promise will be of void type
- export function when(): Promise;
-
- // if no fulfill, reject, or progress provided, returned promise will be of same type
- export function when(value: T | IPromise): Promise;
-
- // If a non-promise value is provided, it will not reject or progress
- export function when(value: T | IPromise, onFulfilled: (val: T) => U | IPromise, onRejected?: (reason: any) => U | IPromise, onProgress?: (progress: any) => any): Promise;
-
- /**
- * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now.
- * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it.
- */
- // export function try(method: Function, ...args: any[]): Promise;
-
- export function fbind(method: (...args: any[]) => T | IPromise, ...args: any[]): (...args: any[]) => Promise;
-
- export function fcall(method: (...args: any[]) => T, ...args: any[]): Promise;
-
- export function send(obj: any, functionName: string, ...args: any[]): Promise;
- export function invoke(obj: any, functionName: string, ...args: any[]): Promise;
- export function mcall(obj: any, functionName: string, ...args: any[]): Promise;
-
- export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise;
- export function nbind(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise;
- export function nfbind(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise;
- export function nfcall(nodeFunction: Function, ...args: any[]): Promise;
- export function nfapply(nodeFunction: Function, args: any[]): Promise;
-
- export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise;
- export function npost(nodeModule: any, functionName: string, args: any[]): Promise;
- export function nsend(nodeModule: any, functionName: string, ...args: any[]): Promise;
- export function nmcall(nodeModule: any, functionName: string, ...args: any[]): Promise;
-
- /**
- * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
- */
- export function all(promises: IPromise[]): Promise;
-
- /**
- * Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
- */
- export function allSettled(promises: IPromise[]): Promise[]>;
-
- export function allResolved(promises: IPromise[]): Promise[]>;
-
- /**
- * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
- * This is especially useful in conjunction with all.
- */
- export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U | IPromise, onRejected?: (reason: any) => U | IPromise): Promise;
-
- /**
- * Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms".
- */
- export function timeout(promise: Promise, ms: number, message?: string): Promise;
-
- /**
- * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
- */
- export function delay(promise: Promise, ms: number): Promise;
- /**
- * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
- */
- export function delay(value: T, ms: number): Promise;
- /**
- * Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed.
- */
- export function delay(ms: number): Promise ;
- /**
- * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
- */
- export function isFulfilled(promise: Promise): boolean;
- /**
- * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
- */
- export function isRejected(promise: Promise): boolean;
- /**
- * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
- */
- export function isPending(promise: Promise): boolean;
-
- /**
- * Returns a "deferred" object with a:
- * promise property
- * resolve(value) method
- * reject(reason) method
- * notify(value) method
- * makeNodeResolver() method
- */
- export function defer(): Deferred;
-
- /**
- * Returns a promise that is rejected with reason.
- */
- export function reject(reason?: any): Promise;
-
- export function Promise(resolver: (resolve: (val: T | IPromise) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise;
-
- /**
- * Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
- *
- * This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions.
- */
- export function promised(callback: (...args: any[]) => T): (...args: any[]) => Promise;
-
- /**
- * Returns whether the given value is a Q promise.
- */
- export function isPromise(object: any): boolean;
- /**
- * Returns whether the given value is a promise (i.e. it's an object with a then function).
- */
- export function isPromiseAlike(object: any): boolean;
- /**
- * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
- */
- export function isPending(object: any): boolean;
-
- /**
- * This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield.
- */
- export function async(generatorFunction: any): (...args: any[]) => Promise;
- export function nextTick(callback: Function): void;
-
- /**
- * A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror.
- */
- export var onerror: (reason: any) => void;
- /**
- * A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced.
- */
- export var longStackSupport: boolean;
-
- /**
- * Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
- * Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
- * Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
- * Calling resolve with a non-promise value causes promise to be fulfilled with that value.
- */
- export function resolve(object: IPromise): Promise;
- /**
- * Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
- * Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
- * Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
- * Calling resolve with a non-promise value causes promise to be fulfilled with that value.
- */
- export function resolve(object: T): Promise;
-}
-
-declare module "q" {
- export = Q;
-}
+// Type definitions for Q
+// Project: https://github.com/kriskowal/q
+// Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+/**
+ * If value is a Q promise, returns the promise.
+ * If value is a promise from another library it is coerced into a Q promise (where possible).
+ */
+declare function Q(promise: Q.IPromise): Q.Promise;
+/**
+ * If value is not a promise, returns a promise that is fulfilled with value.
+ */
+declare function Q(value: T): Q.Promise;
+
+declare module Q {
+ interface IPromise {
+ then(onFulfill?: (value: T) => U | IPromise, onReject?: (error: any) => U | IPromise): IPromise;
+ }
+
+ interface Deferred {
+ promise: Promise;
+ resolve(value: T): void;
+ reject(reason: any): void;
+ notify(value: any): void;
+ makeNodeResolver(): (reason: any, value: T) => void;
+ }
+
+ interface Promise {
+ /**
+ * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
+
+ * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
+ */
+ fin(finallyCallback: () => any): Promise;
+ /**
+ * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
+
+ * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
+ */
+ finally(finallyCallback: () => any): Promise;
+
+ /**
+ * The then method from the Promises/A+ specification, with an additional progress handler.
+ */
+ then(onFulfill?: (value: T) => U | IPromise, onReject?: (error: any) => U | IPromise, onProgress?: Function): Promise;
+
+ /**
+ * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
+ *
+ * This is especially useful in conjunction with all
+ */
+ spread(onFulfilled: Function, onRejected?: Function): Promise;
+
+ fail(onRejected: (reason: any) => U | IPromise): Promise;
+
+ /**
+ * A sugar method, equivalent to promise.then(undefined, onRejected).
+ */
+ catch(onRejected: (reason: any) => U | IPromise): Promise;
+
+ /**
+ * A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
+ */
+ progress(onProgress: (progress: any) => any): Promise;
+
+ /**
+ * Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
+ *
+ * This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
+ *
+ * Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
+ *
+ * The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
+ */
+ done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void;
+
+ /**
+ * If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise.
+ */
+ nodeify(callback: (reason: any, value: any) => void): Promise;
+
+ /**
+ * Returns a promise to get the named property of an object. Essentially equivalent to
+ *
+ * promise.then(function (o) {
+ * return o[propertyName];
+ * });
+ */
+ get(propertyName: String): Promise;
+ set(propertyName: String, value: any): Promise;
+ delete(propertyName: String): Promise;
+ /**
+ * Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
+ *
+ * promise.then(function (o) {
+ * return o[methodName].apply(o, args);
+ * });
+ */
+ post(methodName: String, args: any[]): Promise;
+ /**
+ * Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
+ */
+ invoke(methodName: String, ...args: any[]): Promise;
+ fapply(args: any[]): Promise;
+ fcall(...args: any[]): Promise;
+
+ /**
+ * Returns a promise for an array of the property names of an object. Essentially equivalent to
+ *
+ * promise.then(function (o) {
+ * return Object.keys(o);
+ * });
+ */
+ keys(): Promise;
+
+ /**
+ * A sugar method, equivalent to promise.then(function () { return value; }).
+ */
+ thenResolve(value: U): Promise;
+ /**
+ * A sugar method, equivalent to promise.then(function () { throw reason; }).
+ */
+ thenReject(reason: any): Promise;
+ timeout(ms: number, message?: string): Promise;
+ /**
+ * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
+ */
+ delay(ms: number): Promise;
+
+ /**
+ * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
+ */
+ isFulfilled(): boolean;
+ /**
+ * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
+ */
+ isRejected(): boolean;
+ /**
+ * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
+ */
+ isPending(): boolean;
+
+ valueOf(): any;
+
+ /**
+ * Returns a "state snapshot" object, which will be in one of three forms:
+ *
+ * - { state: "pending" }
+ * - { state: "fulfilled", value: }
+ * - { state: "rejected", reason: }
+ */
+ inspect(): PromiseState;
+ }
+
+ interface PromiseState {
+ /**
+ * "fulfilled", "rejected", "pending"
+ */
+ state: string;
+ value?: T;
+ reason?: any;
+ }
+
+ // If no value provided, returned promise will be of void type
+ export function when(): Promise;
+
+ // if no fulfill, reject, or progress provided, returned promise will be of same type
+ export function when(value: T | IPromise): Promise;
+
+ // If a non-promise value is provided, it will not reject or progress
+ export function when(value: T | IPromise, onFulfilled: (val: T) => U | IPromise, onRejected?: (reason: any) => U | IPromise, onProgress?: (progress: any) => any): Promise;
+
+ /**
+ * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now.
+ * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it.
+ */
+ // export function try(method: Function, ...args: any[]): Promise;
+
+ export function fbind(method: (...args: any[]) => T | IPromise, ...args: any[]): (...args: any[]) => Promise;
+
+ export function fcall(method: (...args: any[]) => T, ...args: any[]): Promise;
+
+ export function send(obj: any, functionName: string, ...args: any[]): Promise;
+ export function invoke(obj: any, functionName: string, ...args: any[]): Promise;
+ export function mcall(obj: any, functionName: string, ...args: any[]): Promise;
+
+ export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise;
+ export function nbind(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise;
+ export function nfbind(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise;
+ export function nfcall(nodeFunction: Function, ...args: any[]): Promise