26439 lines
1.5 MiB
26439 lines
1.5 MiB
"use strict";
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
"use strict";
|
|
/*@internal*/
|
|
var ts;
|
|
(function (ts) {
|
|
/** Gets a timestamp with (at least) ms resolution */
|
|
ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); };
|
|
})(ts || (ts = {}));
|
|
/*@internal*/
|
|
/** Performance measurements for the compiler. */
|
|
(function (ts) {
|
|
var performance;
|
|
(function (performance) {
|
|
// NOTE: cannot use ts.noop as core.ts loads after this
|
|
var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : function () { };
|
|
var enabled = false;
|
|
var profilerStart = 0;
|
|
var counts;
|
|
var marks;
|
|
var measures;
|
|
/**
|
|
* Marks a performance event.
|
|
*
|
|
* @param markName The name of the mark.
|
|
*/
|
|
function mark(markName) {
|
|
if (enabled) {
|
|
marks.set(markName, ts.timestamp());
|
|
counts.set(markName, (counts.get(markName) || 0) + 1);
|
|
profilerEvent(markName);
|
|
}
|
|
}
|
|
performance.mark = mark;
|
|
/**
|
|
* Adds a performance measurement with the specified name.
|
|
*
|
|
* @param measureName The name of the performance measurement.
|
|
* @param startMarkName The name of the starting mark. If not supplied, the point at which the
|
|
* profiler was enabled is used.
|
|
* @param endMarkName The name of the ending mark. If not supplied, the current timestamp is
|
|
* used.
|
|
*/
|
|
function measure(measureName, startMarkName, endMarkName) {
|
|
if (enabled) {
|
|
var end = endMarkName && marks.get(endMarkName) || ts.timestamp();
|
|
var start = startMarkName && marks.get(startMarkName) || profilerStart;
|
|
measures.set(measureName, (measures.get(measureName) || 0) + (end - start));
|
|
}
|
|
}
|
|
performance.measure = measure;
|
|
/**
|
|
* Gets the number of times a marker was encountered.
|
|
*
|
|
* @param markName The name of the mark.
|
|
*/
|
|
function getCount(markName) {
|
|
return counts && counts.get(markName) || 0;
|
|
}
|
|
performance.getCount = getCount;
|
|
/**
|
|
* Gets the total duration of all measurements with the supplied name.
|
|
*
|
|
* @param measureName The name of the measure whose durations should be accumulated.
|
|
*/
|
|
function getDuration(measureName) {
|
|
return measures && measures.get(measureName) || 0;
|
|
}
|
|
performance.getDuration = getDuration;
|
|
/**
|
|
* Iterate over each measure, performing some action
|
|
*
|
|
* @param cb The action to perform for each measure
|
|
*/
|
|
function forEachMeasure(cb) {
|
|
measures.forEach(function (measure, key) {
|
|
cb(key, measure);
|
|
});
|
|
}
|
|
performance.forEachMeasure = forEachMeasure;
|
|
/** Enables (and resets) performance measurements for the compiler. */
|
|
function enable() {
|
|
counts = ts.createMap();
|
|
marks = ts.createMap();
|
|
measures = ts.createMap();
|
|
enabled = true;
|
|
profilerStart = ts.timestamp();
|
|
}
|
|
performance.enable = enable;
|
|
/** Disables performance measurements for the compiler. */
|
|
function disable() {
|
|
enabled = false;
|
|
}
|
|
performance.disable = disable;
|
|
})(performance = ts.performance || (ts.performance = {}));
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
// WARNING: The script `configureNightly.ts` uses a regexp to parse out these values.
|
|
// If changing the text in this section, be sure to test `configureNightly` too.
|
|
ts.versionMajorMinor = "3.0";
|
|
/** The version of the TypeScript compiler release */
|
|
ts.version = ts.versionMajorMinor + ".0-dev";
|
|
})(ts || (ts = {}));
|
|
/* @internal */
|
|
(function (ts) {
|
|
var Comparison;
|
|
(function (Comparison) {
|
|
Comparison[Comparison["LessThan"] = -1] = "LessThan";
|
|
Comparison[Comparison["EqualTo"] = 0] = "EqualTo";
|
|
Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan";
|
|
})(Comparison = ts.Comparison || (ts.Comparison = {}));
|
|
/** Create a MapLike with good performance. */
|
|
function createDictionaryObject() {
|
|
var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword
|
|
// Using 'delete' on an object causes V8 to put the object in dictionary mode.
|
|
// This disables creation of hidden classes, which are expensive when an object is
|
|
// constantly changing shape.
|
|
map.__ = undefined;
|
|
delete map.__;
|
|
return map;
|
|
}
|
|
/** Create a new map. If a template object is provided, the map will copy entries from it. */
|
|
function createMap() {
|
|
return new ts.MapCtr();
|
|
}
|
|
ts.createMap = createMap;
|
|
function createMapFromEntries(entries) {
|
|
var map = createMap();
|
|
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
var _a = entries_1[_i], key = _a[0], value = _a[1];
|
|
map.set(key, value);
|
|
}
|
|
return map;
|
|
}
|
|
ts.createMapFromEntries = createMapFromEntries;
|
|
function createMapFromTemplate(template) {
|
|
var map = new ts.MapCtr();
|
|
// Copies keys/values from template. Note that for..in will not throw if
|
|
// template is undefined, and instead will just exit the loop.
|
|
for (var key in template) {
|
|
if (hasOwnProperty.call(template, key)) {
|
|
map.set(key, template[key]);
|
|
}
|
|
}
|
|
return map;
|
|
}
|
|
ts.createMapFromTemplate = createMapFromTemplate;
|
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
// tslint:disable-next-line no-in-operator variable-name
|
|
ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap();
|
|
// Keep the class inside a function so it doesn't get compiled if it's not used.
|
|
function shimMap() {
|
|
var MapIterator = /** @class */ (function () {
|
|
function MapIterator(data, selector) {
|
|
this.index = 0;
|
|
this.data = data;
|
|
this.selector = selector;
|
|
this.keys = Object.keys(data);
|
|
}
|
|
MapIterator.prototype.next = function () {
|
|
var index = this.index;
|
|
if (index < this.keys.length) {
|
|
this.index++;
|
|
return { value: this.selector(this.data, this.keys[index]), done: false };
|
|
}
|
|
return { value: undefined, done: true };
|
|
};
|
|
return MapIterator;
|
|
}());
|
|
return /** @class */ (function () {
|
|
function class_1() {
|
|
this.data = createDictionaryObject();
|
|
this.size = 0;
|
|
}
|
|
class_1.prototype.get = function (key) {
|
|
return this.data[key];
|
|
};
|
|
class_1.prototype.set = function (key, value) {
|
|
if (!this.has(key)) {
|
|
this.size++;
|
|
}
|
|
this.data[key] = value;
|
|
return this;
|
|
};
|
|
class_1.prototype.has = function (key) {
|
|
// tslint:disable-next-line:no-in-operator
|
|
return key in this.data;
|
|
};
|
|
class_1.prototype.delete = function (key) {
|
|
if (this.has(key)) {
|
|
this.size--;
|
|
delete this.data[key];
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
class_1.prototype.clear = function () {
|
|
this.data = createDictionaryObject();
|
|
this.size = 0;
|
|
};
|
|
class_1.prototype.keys = function () {
|
|
return new MapIterator(this.data, function (_data, key) { return key; });
|
|
};
|
|
class_1.prototype.values = function () {
|
|
return new MapIterator(this.data, function (data, key) { return data[key]; });
|
|
};
|
|
class_1.prototype.entries = function () {
|
|
return new MapIterator(this.data, function (data, key) { return [key, data[key]]; });
|
|
};
|
|
class_1.prototype.forEach = function (action) {
|
|
for (var key in this.data) {
|
|
action(this.data[key], key);
|
|
}
|
|
};
|
|
return class_1;
|
|
}());
|
|
}
|
|
function length(array) {
|
|
return array ? array.length : 0;
|
|
}
|
|
ts.length = length;
|
|
/**
|
|
* Iterates through 'array' by index and performs the callback on each element of array until the callback
|
|
* returns a truthy value, then returns that value.
|
|
* If no such value is found, the callback is applied to each element of array and undefined is returned.
|
|
*/
|
|
function forEach(array, callback) {
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var result = callback(array[i], i);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.forEach = forEach;
|
|
/** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */
|
|
function firstDefined(array, callback) {
|
|
if (array === undefined) {
|
|
return undefined;
|
|
}
|
|
for (var i = 0; i < array.length; i++) {
|
|
var result = callback(array[i], i);
|
|
if (result !== undefined) {
|
|
return result;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.firstDefined = firstDefined;
|
|
function firstDefinedIterator(iter, callback) {
|
|
while (true) {
|
|
var _a = iter.next(), value = _a.value, done = _a.done;
|
|
if (done) {
|
|
return undefined;
|
|
}
|
|
var result = callback(value);
|
|
if (result !== undefined) {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
ts.firstDefinedIterator = firstDefinedIterator;
|
|
function zipWith(arrayA, arrayB, callback) {
|
|
var result = [];
|
|
Debug.assertEqual(arrayA.length, arrayB.length);
|
|
for (var i = 0; i < arrayA.length; i++) {
|
|
result.push(callback(arrayA[i], arrayB[i], i));
|
|
}
|
|
return result;
|
|
}
|
|
ts.zipWith = zipWith;
|
|
function zipToIterator(arrayA, arrayB) {
|
|
Debug.assertEqual(arrayA.length, arrayB.length);
|
|
var i = 0;
|
|
return {
|
|
next: function () {
|
|
if (i === arrayA.length) {
|
|
return { value: undefined, done: true };
|
|
}
|
|
i++;
|
|
return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };
|
|
}
|
|
};
|
|
}
|
|
ts.zipToIterator = zipToIterator;
|
|
function zipToMap(keys, values) {
|
|
Debug.assert(keys.length === values.length);
|
|
var map = createMap();
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
map.set(keys[i], values[i]);
|
|
}
|
|
return map;
|
|
}
|
|
ts.zipToMap = zipToMap;
|
|
/**
|
|
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
|
* returns a falsey value, then returns false.
|
|
* If no such value is found, the callback is applied to each element of array and `true` is returned.
|
|
*/
|
|
function every(array, callback) {
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
if (!callback(array[i], i)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.every = every;
|
|
function find(array, predicate) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var value = array[i];
|
|
if (predicate(value, i)) {
|
|
return value;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.find = find;
|
|
function findLast(array, predicate) {
|
|
for (var i = array.length - 1; i >= 0; i--) {
|
|
var value = array[i];
|
|
if (predicate(value, i)) {
|
|
return value;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.findLast = findLast;
|
|
/** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */
|
|
function findIndex(array, predicate, startIndex) {
|
|
for (var i = startIndex || 0; i < array.length; i++) {
|
|
if (predicate(array[i], i)) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
ts.findIndex = findIndex;
|
|
function findLastIndex(array, predicate, startIndex) {
|
|
for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
|
|
if (predicate(array[i], i)) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
ts.findLastIndex = findLastIndex;
|
|
/**
|
|
* Returns the first truthy result of `callback`, or else fails.
|
|
* This is like `forEach`, but never returns undefined.
|
|
*/
|
|
function findMap(array, callback) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var result = callback(array[i], i);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
return Debug.fail();
|
|
}
|
|
ts.findMap = findMap;
|
|
function contains(array, value, equalityComparer) {
|
|
if (equalityComparer === void 0) { equalityComparer = equateValues; }
|
|
if (array) {
|
|
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
var v = array_1[_i];
|
|
if (equalityComparer(v, value)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.contains = contains;
|
|
function arraysEqual(a, b, equalityComparer) {
|
|
if (equalityComparer === void 0) { equalityComparer = equateValues; }
|
|
return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });
|
|
}
|
|
ts.arraysEqual = arraysEqual;
|
|
function indexOfAnyCharCode(text, charCodes, start) {
|
|
for (var i = start || 0; i < text.length; i++) {
|
|
if (contains(charCodes, text.charCodeAt(i))) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
ts.indexOfAnyCharCode = indexOfAnyCharCode;
|
|
function countWhere(array, predicate) {
|
|
var count = 0;
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var v = array[i];
|
|
if (predicate(v, i)) {
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
ts.countWhere = countWhere;
|
|
function filter(array, f) {
|
|
if (array) {
|
|
var len = array.length;
|
|
var i = 0;
|
|
while (i < len && f(array[i]))
|
|
i++;
|
|
if (i < len) {
|
|
var result = array.slice(0, i);
|
|
i++;
|
|
while (i < len) {
|
|
var item = array[i];
|
|
if (f(item)) {
|
|
result.push(item);
|
|
}
|
|
i++;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
ts.filter = filter;
|
|
function filterMutate(array, f) {
|
|
var outIndex = 0;
|
|
for (var i = 0; i < array.length; i++) {
|
|
if (f(array[i], i, array)) {
|
|
array[outIndex] = array[i];
|
|
outIndex++;
|
|
}
|
|
}
|
|
array.length = outIndex;
|
|
}
|
|
ts.filterMutate = filterMutate;
|
|
function clear(array) {
|
|
array.length = 0;
|
|
}
|
|
ts.clear = clear;
|
|
function map(array, f) {
|
|
var result;
|
|
if (array) {
|
|
result = [];
|
|
for (var i = 0; i < array.length; i++) {
|
|
result.push(f(array[i], i));
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.map = map;
|
|
function mapIterator(iter, mapFn) {
|
|
return {
|
|
next: function () {
|
|
var iterRes = iter.next();
|
|
return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };
|
|
}
|
|
};
|
|
}
|
|
ts.mapIterator = mapIterator;
|
|
function sameMap(array, f) {
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var item = array[i];
|
|
var mapped = f(item, i);
|
|
if (item !== mapped) {
|
|
var result = array.slice(0, i);
|
|
result.push(mapped);
|
|
for (i++; i < array.length; i++) {
|
|
result.push(f(array[i], i));
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
ts.sameMap = sameMap;
|
|
function flatten(array) {
|
|
var result;
|
|
if (array) {
|
|
result = [];
|
|
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
|
|
var v = array_2[_i];
|
|
if (v) {
|
|
if (isArray(v)) {
|
|
addRange(result, v);
|
|
}
|
|
else {
|
|
result.push(v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.flatten = flatten;
|
|
function flatMap(array, mapfn) {
|
|
var result;
|
|
if (array) {
|
|
result = [];
|
|
for (var i = 0; i < array.length; i++) {
|
|
var v = mapfn(array[i], i);
|
|
if (v) {
|
|
if (isArray(v)) {
|
|
addRange(result, v);
|
|
}
|
|
else {
|
|
result.push(v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.flatMap = flatMap;
|
|
function flatMapIterator(iter, mapfn) {
|
|
var first = iter.next();
|
|
if (first.done) {
|
|
return ts.emptyIterator;
|
|
}
|
|
var currentIter = getIterator(first.value);
|
|
return {
|
|
next: function () {
|
|
while (true) {
|
|
var currentRes = currentIter.next();
|
|
if (!currentRes.done) {
|
|
return currentRes;
|
|
}
|
|
var iterRes = iter.next();
|
|
if (iterRes.done) {
|
|
return iterRes;
|
|
}
|
|
currentIter = getIterator(iterRes.value);
|
|
}
|
|
},
|
|
};
|
|
function getIterator(x) {
|
|
var res = mapfn(x);
|
|
return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;
|
|
}
|
|
}
|
|
ts.flatMapIterator = flatMapIterator;
|
|
function sameFlatMap(array, mapfn) {
|
|
var result;
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var item = array[i];
|
|
var mapped = mapfn(item, i);
|
|
if (result || item !== mapped || isArray(mapped)) {
|
|
if (!result) {
|
|
result = array.slice(0, i);
|
|
}
|
|
if (isArray(mapped)) {
|
|
addRange(result, mapped);
|
|
}
|
|
else {
|
|
result.push(mapped);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result || array;
|
|
}
|
|
ts.sameFlatMap = sameFlatMap;
|
|
function mapAllOrFail(array, mapFn) {
|
|
var result = [];
|
|
for (var i = 0; i < array.length; i++) {
|
|
var mapped = mapFn(array[i], i);
|
|
if (mapped === undefined) {
|
|
return undefined;
|
|
}
|
|
result.push(mapped);
|
|
}
|
|
return result;
|
|
}
|
|
ts.mapAllOrFail = mapAllOrFail;
|
|
function mapDefined(array, mapFn) {
|
|
var result = [];
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var mapped = mapFn(array[i], i);
|
|
if (mapped !== undefined) {
|
|
result.push(mapped);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.mapDefined = mapDefined;
|
|
function mapDefinedIterator(iter, mapFn) {
|
|
return {
|
|
next: function () {
|
|
while (true) {
|
|
var res = iter.next();
|
|
if (res.done) {
|
|
return res;
|
|
}
|
|
var value = mapFn(res.value);
|
|
if (value !== undefined) {
|
|
return { value: value, done: false };
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
ts.mapDefinedIterator = mapDefinedIterator;
|
|
ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };
|
|
function singleIterator(value) {
|
|
var done = false;
|
|
return {
|
|
next: function () {
|
|
var wasDone = done;
|
|
done = true;
|
|
return wasDone ? { value: undefined, done: true } : { value: value, done: false };
|
|
}
|
|
};
|
|
}
|
|
ts.singleIterator = singleIterator;
|
|
function spanMap(array, keyfn, mapfn) {
|
|
var result;
|
|
if (array) {
|
|
result = [];
|
|
var len = array.length;
|
|
var previousKey = void 0;
|
|
var key = void 0;
|
|
var start = 0;
|
|
var pos = 0;
|
|
while (start < len) {
|
|
while (pos < len) {
|
|
var value = array[pos];
|
|
key = keyfn(value, pos);
|
|
if (pos === 0) {
|
|
previousKey = key;
|
|
}
|
|
else if (key !== previousKey) {
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
if (start < pos) {
|
|
var v = mapfn(array.slice(start, pos), previousKey, start, pos);
|
|
if (v) {
|
|
result.push(v);
|
|
}
|
|
start = pos;
|
|
}
|
|
previousKey = key;
|
|
pos++;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.spanMap = spanMap;
|
|
function mapEntries(map, f) {
|
|
if (!map) {
|
|
return undefined;
|
|
}
|
|
var result = createMap();
|
|
map.forEach(function (value, key) {
|
|
var _a = f(key, value), newKey = _a[0], newValue = _a[1];
|
|
result.set(newKey, newValue);
|
|
});
|
|
return result;
|
|
}
|
|
ts.mapEntries = mapEntries;
|
|
function some(array, predicate) {
|
|
if (array) {
|
|
if (predicate) {
|
|
for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
|
|
var v = array_3[_i];
|
|
if (predicate(v)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
return array.length > 0;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.some = some;
|
|
/** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */
|
|
function getRangesWhere(arr, pred, cb) {
|
|
var start;
|
|
for (var i = 0; i < arr.length; i++) {
|
|
if (pred(arr[i])) {
|
|
start = start === undefined ? i : start;
|
|
}
|
|
else {
|
|
if (start !== undefined) {
|
|
cb(start, i);
|
|
start = undefined;
|
|
}
|
|
}
|
|
}
|
|
if (start !== undefined)
|
|
cb(start, arr.length);
|
|
}
|
|
ts.getRangesWhere = getRangesWhere;
|
|
function concatenate(array1, array2) {
|
|
if (!some(array2))
|
|
return array1;
|
|
if (!some(array1))
|
|
return array2;
|
|
return array1.concat(array2);
|
|
}
|
|
ts.concatenate = concatenate;
|
|
function deduplicateRelational(array, equalityComparer, comparer) {
|
|
// Perform a stable sort of the array. This ensures the first entry in a list of
|
|
// duplicates remains the first entry in the result.
|
|
var indices = array.map(function (_, i) { return i; });
|
|
stableSortIndices(array, indices, comparer);
|
|
var last = array[indices[0]];
|
|
var deduplicated = [indices[0]];
|
|
for (var i = 1; i < indices.length; i++) {
|
|
var index = indices[i];
|
|
var item = array[index];
|
|
if (!equalityComparer(last, item)) {
|
|
deduplicated.push(index);
|
|
last = item;
|
|
}
|
|
}
|
|
// restore original order
|
|
deduplicated.sort();
|
|
return deduplicated.map(function (i) { return array[i]; });
|
|
}
|
|
function deduplicateEquality(array, equalityComparer) {
|
|
var result = [];
|
|
for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
|
|
var item = array_4[_i];
|
|
pushIfUnique(result, item, equalityComparer);
|
|
}
|
|
return result;
|
|
}
|
|
function deduplicate(array, equalityComparer, comparer) {
|
|
return !array ? undefined :
|
|
array.length === 0 ? [] :
|
|
array.length === 1 ? array.slice() :
|
|
comparer ? deduplicateRelational(array, equalityComparer, comparer) :
|
|
deduplicateEquality(array, equalityComparer);
|
|
}
|
|
ts.deduplicate = deduplicate;
|
|
function deduplicateSorted(array, comparer) {
|
|
if (!array)
|
|
return undefined;
|
|
if (array.length === 0)
|
|
return [];
|
|
var last = array[0];
|
|
var deduplicated = [last];
|
|
for (var i = 1; i < array.length; i++) {
|
|
var next = array[i];
|
|
switch (comparer(next, last)) {
|
|
// equality comparison
|
|
case true:
|
|
// relational comparison
|
|
case 0 /* EqualTo */:
|
|
continue;
|
|
case -1 /* LessThan */:
|
|
// If `array` is sorted, `next` should **never** be less than `last`.
|
|
return Debug.fail("Array is unsorted.");
|
|
}
|
|
deduplicated.push(last = next);
|
|
}
|
|
return deduplicated;
|
|
}
|
|
function insertSorted(array, insert, compare) {
|
|
if (array.length === 0) {
|
|
array.push(insert);
|
|
return;
|
|
}
|
|
var insertIndex = binarySearch(array, insert, identity, compare);
|
|
if (insertIndex < 0) {
|
|
array.splice(~insertIndex, 0, insert);
|
|
}
|
|
}
|
|
ts.insertSorted = insertSorted;
|
|
function sortAndDeduplicate(array, comparer, equalityComparer) {
|
|
return deduplicateSorted(sort(array, comparer), equalityComparer || comparer);
|
|
}
|
|
ts.sortAndDeduplicate = sortAndDeduplicate;
|
|
function arrayIsEqualTo(array1, array2, equalityComparer) {
|
|
if (equalityComparer === void 0) { equalityComparer = equateValues; }
|
|
if (!array1 || !array2) {
|
|
return array1 === array2;
|
|
}
|
|
if (array1.length !== array2.length) {
|
|
return false;
|
|
}
|
|
for (var i = 0; i < array1.length; i++) {
|
|
if (!equalityComparer(array1[i], array2[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.arrayIsEqualTo = arrayIsEqualTo;
|
|
function compact(array) {
|
|
var result;
|
|
if (array) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
var v = array[i];
|
|
if (result || !v) {
|
|
if (!result) {
|
|
result = array.slice(0, i);
|
|
}
|
|
if (v) {
|
|
result.push(v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result || array;
|
|
}
|
|
ts.compact = compact;
|
|
/**
|
|
* Gets the relative complement of `arrayA` with respect to `arrayB`, returning the elements that
|
|
* are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted
|
|
* based on the provided comparer.
|
|
*/
|
|
function relativeComplement(arrayA, arrayB, comparer) {
|
|
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
|
|
return arrayB;
|
|
var result = [];
|
|
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
|
|
if (offsetB > 0) {
|
|
// Ensure `arrayB` is properly sorted.
|
|
Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
|
|
}
|
|
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
|
|
if (offsetA > startA) {
|
|
// Ensure `arrayA` is properly sorted. We only need to perform this check if
|
|
// `offsetA` has changed since we entered the loop.
|
|
Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
|
|
}
|
|
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
|
|
case -1 /* LessThan */:
|
|
// If B is less than A, B does not exist in arrayA. Add B to the result and
|
|
// move to the next element in arrayB without changing the current position
|
|
// in arrayA.
|
|
result.push(arrayB[offsetB]);
|
|
continue loopB;
|
|
case 0 /* EqualTo */:
|
|
// If B is equal to A, B exists in arrayA. Move to the next element in
|
|
// arrayB without adding B to the result or changing the current position
|
|
// in arrayA.
|
|
continue loopB;
|
|
case 1 /* GreaterThan */:
|
|
// If B is greater than A, we need to keep looking for B in arrayA. Move to
|
|
// the next element in arrayA and recheck.
|
|
continue loopA;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.relativeComplement = relativeComplement;
|
|
function sum(array, prop) {
|
|
var result = 0;
|
|
for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
|
|
var v = array_5[_i];
|
|
result += v[prop];
|
|
}
|
|
return result;
|
|
}
|
|
ts.sum = sum;
|
|
function append(to, value) {
|
|
if (value === undefined)
|
|
return to;
|
|
if (to === undefined)
|
|
return [value];
|
|
to.push(value);
|
|
return to;
|
|
}
|
|
ts.append = append;
|
|
/**
|
|
* Gets the actual offset into an array for a relative offset. Negative offsets indicate a
|
|
* position offset from the end of the array.
|
|
*/
|
|
function toOffset(array, offset) {
|
|
return offset < 0 ? array.length + offset : offset;
|
|
}
|
|
function addRange(to, from, start, end) {
|
|
if (from === undefined || from.length === 0)
|
|
return to;
|
|
if (to === undefined)
|
|
return from.slice(start, end);
|
|
start = start === undefined ? 0 : toOffset(from, start);
|
|
end = end === undefined ? from.length : toOffset(from, end);
|
|
for (var i = start; i < end && i < from.length; i++) {
|
|
if (from[i] !== undefined) {
|
|
to.push(from[i]);
|
|
}
|
|
}
|
|
return to;
|
|
}
|
|
ts.addRange = addRange;
|
|
/**
|
|
* @return Whether the value was added.
|
|
*/
|
|
function pushIfUnique(array, toAdd, equalityComparer) {
|
|
if (contains(array, toAdd, equalityComparer)) {
|
|
return false;
|
|
}
|
|
else {
|
|
array.push(toAdd);
|
|
return true;
|
|
}
|
|
}
|
|
ts.pushIfUnique = pushIfUnique;
|
|
/**
|
|
* Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array.
|
|
*/
|
|
function appendIfUnique(array, toAdd, equalityComparer) {
|
|
if (array) {
|
|
pushIfUnique(array, toAdd, equalityComparer);
|
|
return array;
|
|
}
|
|
else {
|
|
return [toAdd];
|
|
}
|
|
}
|
|
ts.appendIfUnique = appendIfUnique;
|
|
function stableSortIndices(array, indices, comparer) {
|
|
// sort indices by value then position
|
|
indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });
|
|
}
|
|
/**
|
|
* Returns a new sorted array.
|
|
*/
|
|
function sort(array, comparer) {
|
|
return array.slice().sort(comparer);
|
|
}
|
|
ts.sort = sort;
|
|
function best(iter, isBetter) {
|
|
var x = iter.next();
|
|
if (x.done) {
|
|
return undefined;
|
|
}
|
|
var best = x.value;
|
|
while (true) {
|
|
var _a = iter.next(), value = _a.value, done = _a.done;
|
|
if (done) {
|
|
return best;
|
|
}
|
|
if (isBetter(value, best)) {
|
|
best = value;
|
|
}
|
|
}
|
|
}
|
|
ts.best = best;
|
|
function arrayIterator(array) {
|
|
var i = 0;
|
|
return { next: function () {
|
|
if (i === array.length) {
|
|
return { value: undefined, done: true };
|
|
}
|
|
else {
|
|
i++;
|
|
return { value: array[i - 1], done: false };
|
|
}
|
|
} };
|
|
}
|
|
ts.arrayIterator = arrayIterator;
|
|
/**
|
|
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
|
|
*/
|
|
function stableSort(array, comparer) {
|
|
var indices = array.map(function (_, i) { return i; });
|
|
stableSortIndices(array, indices, comparer);
|
|
return indices.map(function (i) { return array[i]; });
|
|
}
|
|
ts.stableSort = stableSort;
|
|
function rangeEquals(array1, array2, pos, end) {
|
|
while (pos < end) {
|
|
if (array1[pos] !== array2[pos]) {
|
|
return false;
|
|
}
|
|
pos++;
|
|
}
|
|
return true;
|
|
}
|
|
ts.rangeEquals = rangeEquals;
|
|
/**
|
|
* Returns the element at a specific offset in an array if non-empty, `undefined` otherwise.
|
|
* A negative offset indicates the element should be retrieved from the end of the array.
|
|
*/
|
|
function elementAt(array, offset) {
|
|
if (array) {
|
|
offset = toOffset(array, offset);
|
|
if (offset < array.length) {
|
|
return array[offset];
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.elementAt = elementAt;
|
|
/**
|
|
* Returns the first element of an array if non-empty, `undefined` otherwise.
|
|
*/
|
|
function firstOrUndefined(array) {
|
|
return array.length === 0 ? undefined : array[0];
|
|
}
|
|
ts.firstOrUndefined = firstOrUndefined;
|
|
function first(array) {
|
|
Debug.assert(array.length !== 0);
|
|
return array[0];
|
|
}
|
|
ts.first = first;
|
|
/**
|
|
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
|
*/
|
|
function lastOrUndefined(array) {
|
|
return array.length === 0 ? undefined : array[array.length - 1];
|
|
}
|
|
ts.lastOrUndefined = lastOrUndefined;
|
|
function last(array) {
|
|
Debug.assert(array.length !== 0);
|
|
return array[array.length - 1];
|
|
}
|
|
ts.last = last;
|
|
/**
|
|
* Returns the only element of an array if it contains only one element, `undefined` otherwise.
|
|
*/
|
|
function singleOrUndefined(array) {
|
|
return array && array.length === 1
|
|
? array[0]
|
|
: undefined;
|
|
}
|
|
ts.singleOrUndefined = singleOrUndefined;
|
|
function singleOrMany(array) {
|
|
return array && array.length === 1
|
|
? array[0]
|
|
: array;
|
|
}
|
|
ts.singleOrMany = singleOrMany;
|
|
function replaceElement(array, index, value) {
|
|
var result = array.slice(0);
|
|
result[index] = value;
|
|
return result;
|
|
}
|
|
ts.replaceElement = replaceElement;
|
|
/**
|
|
* Performs a binary search, finding the index at which `value` occurs in `array`.
|
|
* If no such index is found, returns the 2's-complement of first index at which
|
|
* `array[index]` exceeds `value`.
|
|
* @param array A sorted array whose first element must be no larger than number
|
|
* @param value The value to be searched for in the array.
|
|
* @param keySelector A callback used to select the search key from `value` and each element of
|
|
* `array`.
|
|
* @param keyComparer A callback used to compare two keys in a sorted array.
|
|
* @param offset An offset into `array` at which to start the search.
|
|
*/
|
|
function binarySearch(array, value, keySelector, keyComparer, offset) {
|
|
if (!array || array.length === 0) {
|
|
return -1;
|
|
}
|
|
var low = offset || 0;
|
|
var high = array.length - 1;
|
|
var key = keySelector(value);
|
|
while (low <= high) {
|
|
var middle = low + ((high - low) >> 1);
|
|
var midKey = keySelector(array[middle]);
|
|
switch (keyComparer(midKey, key)) {
|
|
case -1 /* LessThan */:
|
|
low = middle + 1;
|
|
break;
|
|
case 0 /* EqualTo */:
|
|
return middle;
|
|
case 1 /* GreaterThan */:
|
|
high = middle - 1;
|
|
break;
|
|
}
|
|
}
|
|
return ~low;
|
|
}
|
|
ts.binarySearch = binarySearch;
|
|
function reduceLeft(array, f, initial, start, count) {
|
|
if (array && array.length > 0) {
|
|
var size = array.length;
|
|
if (size > 0) {
|
|
var pos = start === undefined || start < 0 ? 0 : start;
|
|
var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
|
|
var result = void 0;
|
|
if (arguments.length <= 2) {
|
|
result = array[pos];
|
|
pos++;
|
|
}
|
|
else {
|
|
result = initial;
|
|
}
|
|
while (pos <= end) {
|
|
result = f(result, array[pos], pos);
|
|
pos++;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
return initial;
|
|
}
|
|
ts.reduceLeft = reduceLeft;
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
/**
|
|
* Indicates whether a map-like contains an own property with the specified key.
|
|
*
|
|
* @param map A map-like.
|
|
* @param key A property key.
|
|
*/
|
|
function hasProperty(map, key) {
|
|
return hasOwnProperty.call(map, key);
|
|
}
|
|
ts.hasProperty = hasProperty;
|
|
/**
|
|
* Gets the value of an owned property in a map-like.
|
|
*
|
|
* @param map A map-like.
|
|
* @param key A property key.
|
|
*/
|
|
function getProperty(map, key) {
|
|
return hasOwnProperty.call(map, key) ? map[key] : undefined;
|
|
}
|
|
ts.getProperty = getProperty;
|
|
/**
|
|
* Gets the owned, enumerable property keys of a map-like.
|
|
*/
|
|
function getOwnKeys(map) {
|
|
var keys = [];
|
|
for (var key in map) {
|
|
if (hasOwnProperty.call(map, key)) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
return keys;
|
|
}
|
|
ts.getOwnKeys = getOwnKeys;
|
|
function getOwnValues(sparseArray) {
|
|
var values = [];
|
|
for (var key in sparseArray) {
|
|
if (hasOwnProperty.call(sparseArray, key)) {
|
|
values.push(sparseArray[key]);
|
|
}
|
|
}
|
|
return values;
|
|
}
|
|
ts.getOwnValues = getOwnValues;
|
|
function arrayFrom(iterator, map) {
|
|
var _a;
|
|
var result = [];
|
|
for (var _b = iterator.next(), value = _b.value, done = _b.done; !done; _a = iterator.next(), value = _a.value, done = _a.done, _a) {
|
|
result.push(map ? map(value) : value);
|
|
}
|
|
return result;
|
|
}
|
|
ts.arrayFrom = arrayFrom;
|
|
function assign(t) {
|
|
var args = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
args[_i - 1] = arguments[_i];
|
|
}
|
|
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|
var arg = args_1[_a];
|
|
for (var p in arg) {
|
|
if (hasProperty(arg, p)) {
|
|
t[p] = arg[p]; // TODO: GH#23368
|
|
}
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
ts.assign = assign;
|
|
/**
|
|
* Performs a shallow equality comparison of the contents of two map-likes.
|
|
*
|
|
* @param left A map-like whose properties should be compared.
|
|
* @param right A map-like whose properties should be compared.
|
|
*/
|
|
function equalOwnProperties(left, right, equalityComparer) {
|
|
if (equalityComparer === void 0) { equalityComparer = equateValues; }
|
|
if (left === right)
|
|
return true;
|
|
if (!left || !right)
|
|
return false;
|
|
for (var key in left) {
|
|
if (hasOwnProperty.call(left, key)) {
|
|
if (!hasOwnProperty.call(right, key) === undefined)
|
|
return false;
|
|
if (!equalityComparer(left[key], right[key]))
|
|
return false;
|
|
}
|
|
}
|
|
for (var key in right) {
|
|
if (hasOwnProperty.call(right, key)) {
|
|
if (!hasOwnProperty.call(left, key))
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.equalOwnProperties = equalOwnProperties;
|
|
function arrayToMap(array, makeKey, makeValue) {
|
|
if (makeValue === void 0) { makeValue = identity; }
|
|
var result = createMap();
|
|
for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
|
|
var value = array_6[_i];
|
|
var key = makeKey(value);
|
|
if (key !== undefined)
|
|
result.set(key, makeValue(value));
|
|
}
|
|
return result;
|
|
}
|
|
ts.arrayToMap = arrayToMap;
|
|
function arrayToNumericMap(array, makeKey, makeValue) {
|
|
if (makeValue === void 0) { makeValue = identity; }
|
|
var result = [];
|
|
for (var _i = 0, array_7 = array; _i < array_7.length; _i++) {
|
|
var value = array_7[_i];
|
|
result[makeKey(value)] = makeValue(value);
|
|
}
|
|
return result;
|
|
}
|
|
ts.arrayToNumericMap = arrayToNumericMap;
|
|
function arrayToMultiMap(values, makeKey, makeValue) {
|
|
if (makeValue === void 0) { makeValue = identity; }
|
|
var result = createMultiMap();
|
|
for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
|
|
var value = values_1[_i];
|
|
result.add(makeKey(value), makeValue(value));
|
|
}
|
|
return result;
|
|
}
|
|
ts.arrayToMultiMap = arrayToMultiMap;
|
|
function group(values, getGroupId) {
|
|
return arrayFrom(arrayToMultiMap(values, getGroupId).values());
|
|
}
|
|
ts.group = group;
|
|
function clone(object) {
|
|
var result = {};
|
|
for (var id in object) {
|
|
if (hasOwnProperty.call(object, id)) {
|
|
result[id] = object[id];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.clone = clone;
|
|
function extend(first, second) {
|
|
var result = {};
|
|
for (var id in second) {
|
|
if (hasOwnProperty.call(second, id)) {
|
|
result[id] = second[id];
|
|
}
|
|
}
|
|
for (var id in first) {
|
|
if (hasOwnProperty.call(first, id)) {
|
|
result[id] = first[id];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.extend = extend;
|
|
function createMultiMap() {
|
|
var map = createMap();
|
|
map.add = multiMapAdd;
|
|
map.remove = multiMapRemove;
|
|
return map;
|
|
}
|
|
ts.createMultiMap = createMultiMap;
|
|
function multiMapAdd(key, value) {
|
|
var values = this.get(key);
|
|
if (values) {
|
|
values.push(value);
|
|
}
|
|
else {
|
|
this.set(key, values = [value]);
|
|
}
|
|
return values;
|
|
}
|
|
function multiMapRemove(key, value) {
|
|
var values = this.get(key);
|
|
if (values) {
|
|
unorderedRemoveItem(values, value);
|
|
if (!values.length) {
|
|
this.delete(key);
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Tests whether a value is an array.
|
|
*/
|
|
function isArray(value) {
|
|
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
|
}
|
|
ts.isArray = isArray;
|
|
function toArray(value) {
|
|
return isArray(value) ? value : [value];
|
|
}
|
|
ts.toArray = toArray;
|
|
/**
|
|
* Tests whether a value is string
|
|
*/
|
|
function isString(text) {
|
|
return typeof text === "string";
|
|
}
|
|
ts.isString = isString;
|
|
function tryCast(value, test) {
|
|
return value !== undefined && test(value) ? value : undefined;
|
|
}
|
|
ts.tryCast = tryCast;
|
|
function cast(value, test) {
|
|
if (value !== undefined && test(value))
|
|
return value;
|
|
return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
|
|
}
|
|
ts.cast = cast;
|
|
/** Does nothing. */
|
|
function noop(_) { } // tslint:disable-line no-empty
|
|
ts.noop = noop;
|
|
/** Do nothing and return false */
|
|
function returnFalse() { return false; }
|
|
ts.returnFalse = returnFalse;
|
|
/** Do nothing and return true */
|
|
function returnTrue() { return true; }
|
|
ts.returnTrue = returnTrue;
|
|
/** Returns its argument. */
|
|
function identity(x) { return x; }
|
|
ts.identity = identity;
|
|
/** Returns lower case string */
|
|
function toLowerCase(x) { return x.toLowerCase(); }
|
|
ts.toLowerCase = toLowerCase;
|
|
/** Throws an error because a function is not implemented. */
|
|
function notImplemented() {
|
|
throw new Error("Not implemented");
|
|
}
|
|
ts.notImplemented = notImplemented;
|
|
function memoize(callback) {
|
|
var value;
|
|
return function () {
|
|
if (callback) {
|
|
value = callback();
|
|
callback = undefined;
|
|
}
|
|
return value;
|
|
};
|
|
}
|
|
ts.memoize = memoize;
|
|
function chain(a, b, c, d, e) {
|
|
if (e) {
|
|
var args_2 = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
args_2[i] = arguments[i];
|
|
}
|
|
return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); };
|
|
}
|
|
else if (d) {
|
|
return function (t) { return compose(a(t), b(t), c(t), d(t)); };
|
|
}
|
|
else if (c) {
|
|
return function (t) { return compose(a(t), b(t), c(t)); };
|
|
}
|
|
else if (b) {
|
|
return function (t) { return compose(a(t), b(t)); };
|
|
}
|
|
else if (a) {
|
|
return function (t) { return compose(a(t)); };
|
|
}
|
|
else {
|
|
return function (_) { return function (u) { return u; }; };
|
|
}
|
|
}
|
|
ts.chain = chain;
|
|
function compose(a, b, c, d, e) {
|
|
if (e) {
|
|
var args_3 = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
args_3[i] = arguments[i];
|
|
}
|
|
return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); };
|
|
}
|
|
else if (d) {
|
|
return function (t) { return d(c(b(a(t)))); };
|
|
}
|
|
else if (c) {
|
|
return function (t) { return c(b(a(t))); };
|
|
}
|
|
else if (b) {
|
|
return function (t) { return b(a(t)); };
|
|
}
|
|
else if (a) {
|
|
return function (t) { return a(t); };
|
|
}
|
|
else {
|
|
return function (t) { return t; };
|
|
}
|
|
}
|
|
ts.compose = compose;
|
|
var AssertionLevel;
|
|
(function (AssertionLevel) {
|
|
AssertionLevel[AssertionLevel["None"] = 0] = "None";
|
|
AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal";
|
|
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
|
|
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
|
|
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
|
|
var Debug;
|
|
(function (Debug) {
|
|
Debug.currentAssertionLevel = 0 /* None */;
|
|
Debug.isDebugging = false;
|
|
function shouldAssert(level) {
|
|
return Debug.currentAssertionLevel >= level;
|
|
}
|
|
Debug.shouldAssert = shouldAssert;
|
|
function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
|
|
if (!expression) {
|
|
if (verboseDebugInfo) {
|
|
message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
|
|
}
|
|
fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
|
|
}
|
|
}
|
|
Debug.assert = assert;
|
|
function assertEqual(a, b, msg, msg2) {
|
|
if (a !== b) {
|
|
var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
|
|
fail("Expected " + a + " === " + b + ". " + message);
|
|
}
|
|
}
|
|
Debug.assertEqual = assertEqual;
|
|
function assertLessThan(a, b, msg) {
|
|
if (a >= b) {
|
|
fail("Expected " + a + " < " + b + ". " + (msg || ""));
|
|
}
|
|
}
|
|
Debug.assertLessThan = assertLessThan;
|
|
function assertLessThanOrEqual(a, b) {
|
|
if (a > b) {
|
|
fail("Expected " + a + " <= " + b);
|
|
}
|
|
}
|
|
Debug.assertLessThanOrEqual = assertLessThanOrEqual;
|
|
function assertGreaterThanOrEqual(a, b) {
|
|
if (a < b) {
|
|
fail("Expected " + a + " >= " + b);
|
|
}
|
|
}
|
|
Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
|
|
function fail(message, stackCrawlMark) {
|
|
debugger;
|
|
var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(e, stackCrawlMark || fail);
|
|
}
|
|
throw e;
|
|
}
|
|
Debug.fail = fail;
|
|
function assertDefined(value, message) {
|
|
if (value === undefined || value === null)
|
|
return fail(message);
|
|
return value;
|
|
}
|
|
Debug.assertDefined = assertDefined;
|
|
function assertEachDefined(value, message) {
|
|
for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
|
|
var v = value_1[_i];
|
|
assertDefined(v, message);
|
|
}
|
|
return value;
|
|
}
|
|
Debug.assertEachDefined = assertEachDefined;
|
|
function assertNever(member, message, stackCrawlMark) {
|
|
return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever);
|
|
}
|
|
Debug.assertNever = assertNever;
|
|
function getFunctionName(func) {
|
|
if (typeof func !== "function") {
|
|
return "";
|
|
}
|
|
else if (func.hasOwnProperty("name")) {
|
|
return func.name;
|
|
}
|
|
else {
|
|
var text = Function.prototype.toString.call(func);
|
|
var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
|
|
return match ? match[1] : "";
|
|
}
|
|
}
|
|
Debug.getFunctionName = getFunctionName;
|
|
})(Debug = ts.Debug || (ts.Debug = {}));
|
|
function equateValues(a, b) {
|
|
return a === b;
|
|
}
|
|
ts.equateValues = equateValues;
|
|
/**
|
|
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
*
|
|
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
*/
|
|
function equateStringsCaseInsensitive(a, b) {
|
|
return a === b
|
|
|| a !== undefined
|
|
&& b !== undefined
|
|
&& a.toUpperCase() === b.toUpperCase();
|
|
}
|
|
ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
|
|
/**
|
|
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
*
|
|
* Case-sensitive comparisons compare both strings one code-point at a time using the
|
|
* integer value of each code-point.
|
|
*/
|
|
function equateStringsCaseSensitive(a, b) {
|
|
return equateValues(a, b);
|
|
}
|
|
ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
|
|
function compareComparableValues(a, b) {
|
|
return a === b ? 0 /* EqualTo */ :
|
|
a === undefined ? -1 /* LessThan */ :
|
|
b === undefined ? 1 /* GreaterThan */ :
|
|
a < b ? -1 /* LessThan */ :
|
|
1 /* GreaterThan */;
|
|
}
|
|
/**
|
|
* Compare two numeric values for their order relative to each other.
|
|
* To compare strings, use any of the `compareStrings` functions.
|
|
*/
|
|
function compareValues(a, b) {
|
|
return compareComparableValues(a, b);
|
|
}
|
|
ts.compareValues = compareValues;
|
|
function min(a, b, compare) {
|
|
return compare(a, b) === -1 /* LessThan */ ? a : b;
|
|
}
|
|
ts.min = min;
|
|
/**
|
|
* Compare two strings using a case-insensitive ordinal comparison.
|
|
*
|
|
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
* comparisons provide predictable ordering, but place "a" after "B".
|
|
*
|
|
* Case-insensitive comparisons compare both strings one code-point at a time using the integer
|
|
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
*/
|
|
function compareStringsCaseInsensitive(a, b) {
|
|
if (a === b)
|
|
return 0 /* EqualTo */;
|
|
if (a === undefined)
|
|
return -1 /* LessThan */;
|
|
if (b === undefined)
|
|
return 1 /* GreaterThan */;
|
|
a = a.toUpperCase();
|
|
b = b.toUpperCase();
|
|
return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
|
|
}
|
|
ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
|
|
/**
|
|
* Compare two strings using a case-sensitive ordinal comparison.
|
|
*
|
|
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
* comparisons provide predictable ordering, but place "a" after "B".
|
|
*
|
|
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
* value of each code-point.
|
|
*/
|
|
function compareStringsCaseSensitive(a, b) {
|
|
return compareComparableValues(a, b);
|
|
}
|
|
ts.compareStringsCaseSensitive = compareStringsCaseSensitive;
|
|
function getStringComparer(ignoreCase) {
|
|
return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
|
|
}
|
|
ts.getStringComparer = getStringComparer;
|
|
/**
|
|
* Creates a string comparer for use with string collation in the UI.
|
|
*/
|
|
var createUIStringComparer = (function () {
|
|
var defaultComparer;
|
|
var enUSComparer;
|
|
var stringComparerFactory = getStringComparerFactory();
|
|
return createStringComparer;
|
|
function compareWithCallback(a, b, comparer) {
|
|
if (a === b)
|
|
return 0 /* EqualTo */;
|
|
if (a === undefined)
|
|
return -1 /* LessThan */;
|
|
if (b === undefined)
|
|
return 1 /* GreaterThan */;
|
|
var value = comparer(a, b);
|
|
return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
|
|
}
|
|
function createIntlCollatorStringComparer(locale) {
|
|
// Intl.Collator.prototype.compare is bound to the collator. See NOTE in
|
|
// http://www.ecma-international.org/ecma-402/2.0/#sec-Intl.Collator.prototype.compare
|
|
var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
|
|
return function (a, b) { return compareWithCallback(a, b, comparer); };
|
|
}
|
|
function createLocaleCompareStringComparer(locale) {
|
|
// if the locale is not the default locale (`undefined`), use the fallback comparer.
|
|
if (locale !== undefined)
|
|
return createFallbackStringComparer();
|
|
return function (a, b) { return compareWithCallback(a, b, compareStrings); };
|
|
function compareStrings(a, b) {
|
|
return a.localeCompare(b);
|
|
}
|
|
}
|
|
function createFallbackStringComparer() {
|
|
// An ordinal comparison puts "A" after "b", but for the UI we want "A" before "b".
|
|
// We first sort case insensitively. So "Aaa" will come before "baa".
|
|
// Then we sort case sensitively, so "aaa" will come before "Aaa".
|
|
//
|
|
// For case insensitive comparisons we always map both strings to their
|
|
// upper-case form as some unicode characters do not properly round-trip to
|
|
// lowercase (such as `ẞ` (German sharp capital s)).
|
|
return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); };
|
|
function compareDictionaryOrder(a, b) {
|
|
return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
|
|
}
|
|
function compareStrings(a, b) {
|
|
return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
|
|
}
|
|
}
|
|
function getStringComparerFactory() {
|
|
// If the host supports Intl, we use it for comparisons using the default locale.
|
|
if (typeof Intl === "object" && typeof Intl.Collator === "function") {
|
|
return createIntlCollatorStringComparer;
|
|
}
|
|
// If the host does not support Intl, we fall back to localeCompare.
|
|
// localeCompare in Node v0.10 is just an ordinal comparison, so don't use it.
|
|
if (typeof String.prototype.localeCompare === "function" &&
|
|
typeof String.prototype.toLocaleUpperCase === "function" &&
|
|
"a".localeCompare("B") < 0) {
|
|
return createLocaleCompareStringComparer;
|
|
}
|
|
// Otherwise, fall back to ordinal comparison:
|
|
return createFallbackStringComparer;
|
|
}
|
|
function createStringComparer(locale) {
|
|
// Hold onto common string comparers. This avoids constantly reallocating comparers during
|
|
// tests.
|
|
if (locale === undefined) {
|
|
return defaultComparer || (defaultComparer = stringComparerFactory(locale));
|
|
}
|
|
else if (locale === "en-US") {
|
|
return enUSComparer || (enUSComparer = stringComparerFactory(locale));
|
|
}
|
|
else {
|
|
return stringComparerFactory(locale);
|
|
}
|
|
}
|
|
})();
|
|
var uiComparerCaseSensitive;
|
|
var uiLocale;
|
|
function getUILocale() {
|
|
return uiLocale;
|
|
}
|
|
ts.getUILocale = getUILocale;
|
|
function setUILocale(value) {
|
|
if (uiLocale !== value) {
|
|
uiLocale = value;
|
|
uiComparerCaseSensitive = undefined;
|
|
}
|
|
}
|
|
ts.setUILocale = setUILocale;
|
|
/**
|
|
* Compare two strings in a using the case-sensitive sort behavior of the UI locale.
|
|
*
|
|
* Ordering is not predictable between different host locales, but is best for displaying
|
|
* ordered data for UI presentation. Characters with multiple unicode representations may
|
|
* be considered equal.
|
|
*
|
|
* Case-sensitive comparisons compare strings that differ in base characters, or
|
|
* accents/diacritic marks, or case as unequal.
|
|
*/
|
|
function compareStringsCaseSensitiveUI(a, b) {
|
|
var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
|
|
return comparer(a, b);
|
|
}
|
|
ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
|
|
function compareProperties(a, b, key, comparer) {
|
|
return a === b ? 0 /* EqualTo */ :
|
|
a === undefined ? -1 /* LessThan */ :
|
|
b === undefined ? 1 /* GreaterThan */ :
|
|
comparer(a[key], b[key]);
|
|
}
|
|
ts.compareProperties = compareProperties;
|
|
/** True is greater than false. */
|
|
function compareBooleans(a, b) {
|
|
return compareValues(a ? 1 : 0, b ? 1 : 0);
|
|
}
|
|
ts.compareBooleans = compareBooleans;
|
|
/**
|
|
* Given a name and a list of names that are *not* equal to the name, return a spelling suggestion if there is one that is close enough.
|
|
* Names less than length 3 only check for case-insensitive equality, not Levenshtein distance.
|
|
*
|
|
* If there is a candidate that's the same except for case, return that.
|
|
* If there is a candidate that's within one edit of the name, return that.
|
|
* Otherwise, return the candidate with the smallest Levenshtein distance,
|
|
* except for candidates:
|
|
* * With no name
|
|
* * Whose length differs from the target name by more than 0.34 of the length of the name.
|
|
* * Whose levenshtein distance is more than 0.4 of the length of the name
|
|
* (0.4 allows 1 substitution/transposition for every 5 characters,
|
|
* and 1 insertion/deletion at 3 characters)
|
|
*/
|
|
function getSpellingSuggestion(name, candidates, getName) {
|
|
var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
|
|
var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result isn't better than this, don't bother.
|
|
var bestCandidate;
|
|
var justCheckExactMatches = false;
|
|
var nameLowerCase = name.toLowerCase();
|
|
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
var candidate = candidates_1[_i];
|
|
var candidateName = getName(candidate);
|
|
if (candidateName !== undefined && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference) {
|
|
var candidateNameLowerCase = candidateName.toLowerCase();
|
|
if (candidateNameLowerCase === nameLowerCase) {
|
|
return candidate;
|
|
}
|
|
if (justCheckExactMatches) {
|
|
continue;
|
|
}
|
|
if (candidateName.length < 3) {
|
|
// Don't bother, user would have noticed a 2-character name having an extra character
|
|
continue;
|
|
}
|
|
// Only care about a result better than the best so far.
|
|
var distance = levenshteinWithMax(nameLowerCase, candidateNameLowerCase, bestDistance - 1);
|
|
if (distance === undefined) {
|
|
continue;
|
|
}
|
|
if (distance < 3) {
|
|
justCheckExactMatches = true;
|
|
bestCandidate = candidate;
|
|
}
|
|
else {
|
|
Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
|
|
bestDistance = distance;
|
|
bestCandidate = candidate;
|
|
}
|
|
}
|
|
}
|
|
return bestCandidate;
|
|
}
|
|
ts.getSpellingSuggestion = getSpellingSuggestion;
|
|
function levenshteinWithMax(s1, s2, max) {
|
|
var previous = new Array(s2.length + 1);
|
|
var current = new Array(s2.length + 1);
|
|
/** Represents any value > max. We don't care about the particular value. */
|
|
var big = max + 1;
|
|
for (var i = 0; i <= s2.length; i++) {
|
|
previous[i] = i;
|
|
}
|
|
for (var i = 1; i <= s1.length; i++) {
|
|
var c1 = s1.charCodeAt(i - 1);
|
|
var minJ = i > max ? i - max : 1;
|
|
var maxJ = s2.length > max + i ? max + i : s2.length;
|
|
current[0] = i;
|
|
/** Smallest value of the matrix in the ith column. */
|
|
var colMin = i;
|
|
for (var j = 1; j < minJ; j++) {
|
|
current[j] = big;
|
|
}
|
|
for (var j = minJ; j <= maxJ; j++) {
|
|
var dist = c1 === s2.charCodeAt(j - 1)
|
|
? previous[j - 1]
|
|
: Math.min(/*delete*/ previous[j] + 1, /*insert*/ current[j - 1] + 1, /*substitute*/ previous[j - 1] + 2);
|
|
current[j] = dist;
|
|
colMin = Math.min(colMin, dist);
|
|
}
|
|
for (var j = maxJ + 1; j <= s2.length; j++) {
|
|
current[j] = big;
|
|
}
|
|
if (colMin > max) {
|
|
// Give up -- everything in this column is > max and it can't get better in future columns.
|
|
return undefined;
|
|
}
|
|
var temp = previous;
|
|
previous = current;
|
|
current = temp;
|
|
}
|
|
var res = previous[s2.length];
|
|
return res > max ? undefined : res;
|
|
}
|
|
function endsWith(str, suffix) {
|
|
var expectedPos = str.length - suffix.length;
|
|
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
|
}
|
|
ts.endsWith = endsWith;
|
|
function removeSuffix(str, suffix) {
|
|
return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
|
|
}
|
|
ts.removeSuffix = removeSuffix;
|
|
function tryRemoveSuffix(str, suffix) {
|
|
return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined;
|
|
}
|
|
ts.tryRemoveSuffix = tryRemoveSuffix;
|
|
function stringContains(str, substring) {
|
|
return str.indexOf(substring) !== -1;
|
|
}
|
|
ts.stringContains = stringContains;
|
|
function fileExtensionIs(path, extension) {
|
|
return path.length > extension.length && endsWith(path, extension);
|
|
}
|
|
ts.fileExtensionIs = fileExtensionIs;
|
|
function fileExtensionIsOneOf(path, extensions) {
|
|
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
var extension = extensions_1[_i];
|
|
if (fileExtensionIs(path, extension)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
/**
|
|
* Takes a string like "jquery-min.4.2.3" and returns "jquery"
|
|
*/
|
|
function removeMinAndVersionNumbers(fileName) {
|
|
// Match a "." or "-" followed by a version number or 'min' at the end of the name
|
|
var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
|
|
// The "min" or version may both be present, in either order, so try applying the above twice.
|
|
return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
|
|
}
|
|
ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers;
|
|
/** Remove an item from an array, moving everything to its right one space left. */
|
|
function orderedRemoveItem(array, item) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
if (array[i] === item) {
|
|
orderedRemoveItemAt(array, i);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.orderedRemoveItem = orderedRemoveItem;
|
|
/** Remove an item by index from an array, moving everything to its right one space left. */
|
|
function orderedRemoveItemAt(array, index) {
|
|
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
|
|
for (var i = index; i < array.length - 1; i++) {
|
|
array[i] = array[i + 1];
|
|
}
|
|
array.pop();
|
|
}
|
|
ts.orderedRemoveItemAt = orderedRemoveItemAt;
|
|
function unorderedRemoveItemAt(array, index) {
|
|
// Fill in the "hole" left at `index`.
|
|
array[index] = array[array.length - 1];
|
|
array.pop();
|
|
}
|
|
ts.unorderedRemoveItemAt = unorderedRemoveItemAt;
|
|
/** Remove the *first* occurrence of `item` from the array. */
|
|
function unorderedRemoveItem(array, item) {
|
|
return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; });
|
|
}
|
|
ts.unorderedRemoveItem = unorderedRemoveItem;
|
|
/** Remove the *first* element satisfying `predicate`. */
|
|
function unorderedRemoveFirstItemWhere(array, predicate) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
if (predicate(array[i])) {
|
|
unorderedRemoveItemAt(array, i);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function createGetCanonicalFileName(useCaseSensitiveFileNames) {
|
|
return useCaseSensitiveFileNames ? identity : toLowerCase;
|
|
}
|
|
ts.createGetCanonicalFileName = createGetCanonicalFileName;
|
|
function patternText(_a) {
|
|
var prefix = _a.prefix, suffix = _a.suffix;
|
|
return prefix + "*" + suffix;
|
|
}
|
|
ts.patternText = patternText;
|
|
/**
|
|
* Given that candidate matches pattern, returns the text matching the '*'.
|
|
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
|
|
*/
|
|
function matchedText(pattern, candidate) {
|
|
Debug.assert(isPatternMatch(pattern, candidate));
|
|
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
|
|
}
|
|
ts.matchedText = matchedText;
|
|
/** Return the object corresponding to the best pattern to match `candidate`. */
|
|
function findBestPatternMatch(values, getPattern, candidate) {
|
|
var matchedValue;
|
|
// use length of prefix as betterness criteria
|
|
var longestMatchPrefixLength = -1;
|
|
for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
|
|
var v = values_2[_i];
|
|
var pattern = getPattern(v);
|
|
if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
|
|
longestMatchPrefixLength = pattern.prefix.length;
|
|
matchedValue = v;
|
|
}
|
|
}
|
|
return matchedValue;
|
|
}
|
|
ts.findBestPatternMatch = findBestPatternMatch;
|
|
function startsWith(str, prefix) {
|
|
return str.lastIndexOf(prefix, 0) === 0;
|
|
}
|
|
ts.startsWith = startsWith;
|
|
function removePrefix(str, prefix) {
|
|
return startsWith(str, prefix) ? str.substr(prefix.length) : str;
|
|
}
|
|
ts.removePrefix = removePrefix;
|
|
function tryRemovePrefix(str, prefix) {
|
|
return startsWith(str, prefix) ? str.substring(prefix.length) : undefined;
|
|
}
|
|
ts.tryRemovePrefix = tryRemovePrefix;
|
|
function isPatternMatch(_a, candidate) {
|
|
var prefix = _a.prefix, suffix = _a.suffix;
|
|
return candidate.length >= prefix.length + suffix.length &&
|
|
startsWith(candidate, prefix) &&
|
|
endsWith(candidate, suffix);
|
|
}
|
|
function and(f, g) {
|
|
return function (arg) { return f(arg) && g(arg); };
|
|
}
|
|
ts.and = and;
|
|
function or(f, g) {
|
|
return function (arg) { return f(arg) || g(arg); };
|
|
}
|
|
ts.or = or;
|
|
function assertTypeIsNever(_) { } // tslint:disable-line no-empty
|
|
ts.assertTypeIsNever = assertTypeIsNever;
|
|
function singleElementArray(t) {
|
|
return t === undefined ? undefined : [t];
|
|
}
|
|
ts.singleElementArray = singleElementArray;
|
|
function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
|
|
unchanged = unchanged || noop;
|
|
var newIndex = 0;
|
|
var oldIndex = 0;
|
|
var newLen = newItems.length;
|
|
var oldLen = oldItems.length;
|
|
while (newIndex < newLen && oldIndex < oldLen) {
|
|
var newItem = newItems[newIndex];
|
|
var oldItem = oldItems[oldIndex];
|
|
var compareResult = comparer(newItem, oldItem);
|
|
if (compareResult === -1 /* LessThan */) {
|
|
inserted(newItem);
|
|
newIndex++;
|
|
}
|
|
else if (compareResult === 1 /* GreaterThan */) {
|
|
deleted(oldItem);
|
|
oldIndex++;
|
|
}
|
|
else {
|
|
unchanged(oldItem, newItem);
|
|
newIndex++;
|
|
oldIndex++;
|
|
}
|
|
}
|
|
while (newIndex < newLen) {
|
|
inserted(newItems[newIndex++]);
|
|
}
|
|
while (oldIndex < oldLen) {
|
|
deleted(oldItems[oldIndex++]);
|
|
}
|
|
}
|
|
ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes;
|
|
})(ts || (ts = {}));
|
|
//# sourceMappingURL=core.js.map
|
|
"use strict";
|
|
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
var ts;
|
|
(function (ts) {
|
|
// token > SyntaxKind.Identifier => token is a keyword
|
|
// Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync
|
|
var SyntaxKind;
|
|
(function (SyntaxKind) {
|
|
SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown";
|
|
SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken";
|
|
SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia";
|
|
SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia";
|
|
SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia";
|
|
SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia";
|
|
// We detect and preserve #! on the first line
|
|
SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia";
|
|
// We detect and provide better error recovery when we encounter a git merge marker. This
|
|
// allows us to edit files with git-conflict markers in them in a much more pleasant manner.
|
|
SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia";
|
|
// Literals
|
|
SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral";
|
|
SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral";
|
|
SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText";
|
|
SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces";
|
|
SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral";
|
|
SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral";
|
|
// Pseudo-literals
|
|
SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead";
|
|
SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle";
|
|
SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail";
|
|
// Punctuation
|
|
SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken";
|
|
SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken";
|
|
SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken";
|
|
SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken";
|
|
SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken";
|
|
SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken";
|
|
SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken";
|
|
SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken";
|
|
SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken";
|
|
SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken";
|
|
SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken";
|
|
SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken";
|
|
SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken";
|
|
SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken";
|
|
SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken";
|
|
SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken";
|
|
SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken";
|
|
SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken";
|
|
SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken";
|
|
SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken";
|
|
SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken";
|
|
SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken";
|
|
SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken";
|
|
SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken";
|
|
SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken";
|
|
SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken";
|
|
SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken";
|
|
SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken";
|
|
SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken";
|
|
SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken";
|
|
SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken";
|
|
SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken";
|
|
SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken";
|
|
SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken";
|
|
SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken";
|
|
SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken";
|
|
SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken";
|
|
// Assignments
|
|
SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken";
|
|
SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken";
|
|
SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken";
|
|
SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken";
|
|
SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken";
|
|
SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken";
|
|
SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken";
|
|
SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken";
|
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken";
|
|
SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken";
|
|
SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken";
|
|
SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken";
|
|
// Identifiers
|
|
SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier";
|
|
// Reserved words
|
|
SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword";
|
|
SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword";
|
|
SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword";
|
|
SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword";
|
|
SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword";
|
|
SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword";
|
|
SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword";
|
|
SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword";
|
|
SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword";
|
|
SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword";
|
|
SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword";
|
|
SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword";
|
|
SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword";
|
|
SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword";
|
|
SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword";
|
|
SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword";
|
|
SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword";
|
|
SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword";
|
|
SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword";
|
|
SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword";
|
|
SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword";
|
|
SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword";
|
|
SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword";
|
|
SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword";
|
|
SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword";
|
|
SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword";
|
|
SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword";
|
|
SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword";
|
|
SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword";
|
|
SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword";
|
|
SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword";
|
|
SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword";
|
|
SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword";
|
|
SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword";
|
|
SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword";
|
|
SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword";
|
|
// Strict mode reserved words
|
|
SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword";
|
|
SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword";
|
|
SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword";
|
|
SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword";
|
|
SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword";
|
|
SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword";
|
|
SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword";
|
|
SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword";
|
|
SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword";
|
|
// Contextual keywords
|
|
SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword";
|
|
SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword";
|
|
SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword";
|
|
SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword";
|
|
SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword";
|
|
SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword";
|
|
SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword";
|
|
SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword";
|
|
SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword";
|
|
SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword";
|
|
SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword";
|
|
SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword";
|
|
SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword";
|
|
SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword";
|
|
SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword";
|
|
SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword";
|
|
SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword";
|
|
SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword";
|
|
SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword";
|
|
SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword";
|
|
SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword";
|
|
SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword";
|
|
SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword";
|
|
SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword";
|
|
SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword";
|
|
SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword";
|
|
SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword";
|
|
SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword";
|
|
SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword";
|
|
// Parse tree nodes
|
|
// Names
|
|
SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName";
|
|
SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName";
|
|
// Signature elements
|
|
SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter";
|
|
SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter";
|
|
SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator";
|
|
// TypeMember
|
|
SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature";
|
|
SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration";
|
|
SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature";
|
|
SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration";
|
|
SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor";
|
|
SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor";
|
|
SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor";
|
|
SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature";
|
|
SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature";
|
|
SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature";
|
|
// Type
|
|
SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate";
|
|
SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference";
|
|
SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType";
|
|
SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType";
|
|
SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery";
|
|
SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral";
|
|
SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType";
|
|
SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType";
|
|
SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType";
|
|
SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType";
|
|
SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType";
|
|
SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType";
|
|
SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType";
|
|
SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType";
|
|
SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator";
|
|
SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType";
|
|
SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType";
|
|
SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType";
|
|
SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType";
|
|
// Binding patterns
|
|
SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern";
|
|
SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern";
|
|
SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement";
|
|
// Expression
|
|
SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression";
|
|
SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression";
|
|
SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression";
|
|
SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression";
|
|
SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression";
|
|
SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression";
|
|
SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression";
|
|
SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression";
|
|
SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression";
|
|
SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression";
|
|
SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction";
|
|
SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression";
|
|
SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression";
|
|
SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression";
|
|
SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression";
|
|
SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression";
|
|
SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression";
|
|
SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression";
|
|
SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression";
|
|
SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression";
|
|
SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression";
|
|
SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement";
|
|
SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression";
|
|
SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression";
|
|
SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments";
|
|
SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression";
|
|
SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression";
|
|
SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty";
|
|
// Misc
|
|
SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan";
|
|
SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement";
|
|
// Element
|
|
SyntaxKind[SyntaxKind["Block"] = 213] = "Block";
|
|
SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement";
|
|
SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement";
|
|
SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement";
|
|
SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement";
|
|
SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement";
|
|
SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement";
|
|
SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement";
|
|
SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement";
|
|
SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement";
|
|
SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement";
|
|
SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement";
|
|
SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement";
|
|
SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement";
|
|
SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement";
|
|
SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement";
|
|
SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement";
|
|
SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement";
|
|
SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement";
|
|
SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration";
|
|
SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList";
|
|
SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration";
|
|
SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration";
|
|
SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration";
|
|
SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration";
|
|
SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration";
|
|
SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration";
|
|
SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock";
|
|
SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock";
|
|
SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration";
|
|
SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration";
|
|
SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration";
|
|
SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause";
|
|
SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport";
|
|
SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports";
|
|
SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier";
|
|
SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment";
|
|
SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration";
|
|
SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports";
|
|
SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier";
|
|
SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration";
|
|
// Module references
|
|
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference";
|
|
// JSX
|
|
SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement";
|
|
SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement";
|
|
SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement";
|
|
SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement";
|
|
SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment";
|
|
SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment";
|
|
SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment";
|
|
SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute";
|
|
SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes";
|
|
SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute";
|
|
SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression";
|
|
// Clauses
|
|
SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause";
|
|
SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause";
|
|
SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause";
|
|
SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause";
|
|
// Property assignments
|
|
SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment";
|
|
SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment";
|
|
SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment";
|
|
// Enum
|
|
SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember";
|
|
// Top-level nodes
|
|
SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile";
|
|
SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle";
|
|
SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource";
|
|
SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles";
|
|
// JSDoc nodes
|
|
SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression";
|
|
// The * type
|
|
SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType";
|
|
// The ? type
|
|
SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType";
|
|
SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType";
|
|
SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType";
|
|
SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType";
|
|
SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType";
|
|
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType";
|
|
SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment";
|
|
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral";
|
|
SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature";
|
|
SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag";
|
|
SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag";
|
|
SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag";
|
|
SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag";
|
|
SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag";
|
|
SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag";
|
|
SyntaxKind[SyntaxKind["JSDocTypeTag"] = 295] = "JSDocTypeTag";
|
|
SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 296] = "JSDocTemplateTag";
|
|
SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 297] = "JSDocTypedefTag";
|
|
SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 298] = "JSDocPropertyTag";
|
|
// Synthesized list
|
|
SyntaxKind[SyntaxKind["SyntaxList"] = 299] = "SyntaxList";
|
|
// Transformation nodes
|
|
SyntaxKind[SyntaxKind["NotEmittedStatement"] = 300] = "NotEmittedStatement";
|
|
SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 301] = "PartiallyEmittedExpression";
|
|
SyntaxKind[SyntaxKind["CommaListExpression"] = 302] = "CommaListExpression";
|
|
SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 303] = "MergeDeclarationMarker";
|
|
SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 304] = "EndOfDeclarationMarker";
|
|
// Enum value count
|
|
SyntaxKind[SyntaxKind["Count"] = 305] = "Count";
|
|
// Markers
|
|
SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment";
|
|
SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment";
|
|
SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment";
|
|
SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment";
|
|
SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord";
|
|
SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord";
|
|
SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword";
|
|
SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword";
|
|
SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord";
|
|
SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord";
|
|
SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode";
|
|
SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode";
|
|
SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation";
|
|
SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation";
|
|
SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken";
|
|
SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken";
|
|
SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken";
|
|
SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken";
|
|
SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken";
|
|
SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken";
|
|
SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken";
|
|
SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken";
|
|
SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator";
|
|
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator";
|
|
SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode";
|
|
SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode";
|
|
SyntaxKind[SyntaxKind["LastJSDocNode"] = 298] = "LastJSDocNode";
|
|
SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode";
|
|
SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 298] = "LastJSDocTagNode";
|
|
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword";
|
|
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword";
|
|
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
|
|
var NodeFlags;
|
|
(function (NodeFlags) {
|
|
NodeFlags[NodeFlags["None"] = 0] = "None";
|
|
NodeFlags[NodeFlags["Let"] = 1] = "Let";
|
|
NodeFlags[NodeFlags["Const"] = 2] = "Const";
|
|
NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace";
|
|
NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized";
|
|
NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace";
|
|
NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext";
|
|
NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis";
|
|
NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn";
|
|
NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn";
|
|
NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation";
|
|
NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions";
|
|
NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext";
|
|
NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext";
|
|
NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext";
|
|
NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext";
|
|
NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError";
|
|
NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile";
|
|
NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError";
|
|
NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData";
|
|
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
|
// walking the tree if the flags are not set. However, these flags are just a approximation
|
|
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
|
// During editing, if a dynamic import is removed, incremental parsing will *NOT* clear this flag.
|
|
// This means that the tree will always be traversed during module resolution, or when looking for external module indicators.
|
|
// However, the removal operation should not occur often and in the case of the
|
|
// removal, it is likely that users will add the import anyway.
|
|
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
|
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
|
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport";
|
|
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta";
|
|
NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc";
|
|
/* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient";
|
|
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement";
|
|
NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile";
|
|
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
|
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags";
|
|
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags";
|
|
// Parsing context flags
|
|
NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags";
|
|
// Exclude these flags when parsing a Type
|
|
NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags";
|
|
// Represents all flags that are potentially set once and
|
|
// never cleared on SourceFiles which get re-used in between incremental parses.
|
|
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
|
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags";
|
|
})(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
|
|
var ModifierFlags;
|
|
(function (ModifierFlags) {
|
|
ModifierFlags[ModifierFlags["None"] = 0] = "None";
|
|
ModifierFlags[ModifierFlags["Export"] = 1] = "Export";
|
|
ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient";
|
|
ModifierFlags[ModifierFlags["Public"] = 4] = "Public";
|
|
ModifierFlags[ModifierFlags["Private"] = 8] = "Private";
|
|
ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected";
|
|
ModifierFlags[ModifierFlags["Static"] = 32] = "Static";
|
|
ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly";
|
|
ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract";
|
|
ModifierFlags[ModifierFlags["Async"] = 256] = "Async";
|
|
ModifierFlags[ModifierFlags["Default"] = 512] = "Default";
|
|
ModifierFlags[ModifierFlags["Const"] = 2048] = "Const";
|
|
ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
|
|
ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier";
|
|
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
|
|
ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier";
|
|
ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier";
|
|
ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier";
|
|
ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault";
|
|
ModifierFlags[ModifierFlags["All"] = 3071] = "All";
|
|
})(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {}));
|
|
var JsxFlags;
|
|
(function (JsxFlags) {
|
|
JsxFlags[JsxFlags["None"] = 0] = "None";
|
|
/** An element from a named property of the JSX.IntrinsicElements interface */
|
|
JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement";
|
|
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
|
|
JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement";
|
|
JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement";
|
|
})(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {}));
|
|
/* @internal */
|
|
var RelationComparisonResult;
|
|
(function (RelationComparisonResult) {
|
|
RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded";
|
|
RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed";
|
|
RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported";
|
|
})(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {}));
|
|
/*@internal*/
|
|
var GeneratedIdentifierFlags;
|
|
(function (GeneratedIdentifierFlags) {
|
|
// Kinds
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["None"] = 0] = "None";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["Auto"] = 1] = "Auto";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["Loop"] = 2] = "Loop";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["Unique"] = 3] = "Unique";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["Node"] = 4] = "Node";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["KindMask"] = 7] = "KindMask";
|
|
// Flags
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["ReservedInNestedScopes"] = 8] = "ReservedInNestedScopes";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["Optimistic"] = 16] = "Optimistic";
|
|
GeneratedIdentifierFlags[GeneratedIdentifierFlags["FileLevel"] = 32] = "FileLevel";
|
|
})(GeneratedIdentifierFlags = ts.GeneratedIdentifierFlags || (ts.GeneratedIdentifierFlags = {}));
|
|
/* @internal */
|
|
var TokenFlags;
|
|
(function (TokenFlags) {
|
|
TokenFlags[TokenFlags["None"] = 0] = "None";
|
|
TokenFlags[TokenFlags["PrecedingLineBreak"] = 1] = "PrecedingLineBreak";
|
|
TokenFlags[TokenFlags["PrecedingJSDocComment"] = 2] = "PrecedingJSDocComment";
|
|
TokenFlags[TokenFlags["Unterminated"] = 4] = "Unterminated";
|
|
TokenFlags[TokenFlags["ExtendedUnicodeEscape"] = 8] = "ExtendedUnicodeEscape";
|
|
TokenFlags[TokenFlags["Scientific"] = 16] = "Scientific";
|
|
TokenFlags[TokenFlags["Octal"] = 32] = "Octal";
|
|
TokenFlags[TokenFlags["HexSpecifier"] = 64] = "HexSpecifier";
|
|
TokenFlags[TokenFlags["BinarySpecifier"] = 128] = "BinarySpecifier";
|
|
TokenFlags[TokenFlags["OctalSpecifier"] = 256] = "OctalSpecifier";
|
|
TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator";
|
|
TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier";
|
|
TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags";
|
|
})(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {}));
|
|
var FlowFlags;
|
|
(function (FlowFlags) {
|
|
FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable";
|
|
FlowFlags[FlowFlags["Start"] = 2] = "Start";
|
|
FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel";
|
|
FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel";
|
|
FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment";
|
|
FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition";
|
|
FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition";
|
|
FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause";
|
|
FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation";
|
|
FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced";
|
|
FlowFlags[FlowFlags["Shared"] = 1024] = "Shared";
|
|
FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally";
|
|
FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally";
|
|
FlowFlags[FlowFlags["Label"] = 12] = "Label";
|
|
FlowFlags[FlowFlags["Condition"] = 96] = "Condition";
|
|
})(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {}));
|
|
var OperationCanceledException = /** @class */ (function () {
|
|
function OperationCanceledException() {
|
|
}
|
|
return OperationCanceledException;
|
|
}());
|
|
ts.OperationCanceledException = OperationCanceledException;
|
|
/* @internal */
|
|
var StructureIsReused;
|
|
(function (StructureIsReused) {
|
|
StructureIsReused[StructureIsReused["Not"] = 0] = "Not";
|
|
StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules";
|
|
StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely";
|
|
})(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {}));
|
|
/** Return code used by getEmitOutput function to indicate status of the function */
|
|
var ExitStatus;
|
|
(function (ExitStatus) {
|
|
// Compiler ran successfully. Either this was a simple do-nothing compilation (for example,
|
|
// when -version or -help was provided, or this was a normal compilation, no diagnostics
|
|
// were produced, and all outputs were generated successfully.
|
|
ExitStatus[ExitStatus["Success"] = 0] = "Success";
|
|
// Diagnostics were produced and because of them no code was generated.
|
|
ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
|
|
// Diagnostics were produced and outputs were generated in spite of them.
|
|
ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
|
|
})(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
|
|
/* @internal */
|
|
var UnionReduction;
|
|
(function (UnionReduction) {
|
|
UnionReduction[UnionReduction["None"] = 0] = "None";
|
|
UnionReduction[UnionReduction["Literal"] = 1] = "Literal";
|
|
UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype";
|
|
})(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {}));
|
|
var NodeBuilderFlags;
|
|
(function (NodeBuilderFlags) {
|
|
NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None";
|
|
// Options
|
|
NodeBuilderFlags[NodeBuilderFlags["NoTruncation"] = 1] = "NoTruncation";
|
|
NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
|
|
NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
|
|
NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
|
|
NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences";
|
|
NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
|
|
NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
|
|
NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing";
|
|
NodeBuilderFlags[NodeBuilderFlags["SuppressAnyReturnType"] = 256] = "SuppressAnyReturnType";
|
|
NodeBuilderFlags[NodeBuilderFlags["WriteTypeParametersInQualifiedName"] = 512] = "WriteTypeParametersInQualifiedName";
|
|
NodeBuilderFlags[NodeBuilderFlags["MultilineObjectLiterals"] = 1024] = "MultilineObjectLiterals";
|
|
NodeBuilderFlags[NodeBuilderFlags["WriteClassExpressionAsTypeLiteral"] = 2048] = "WriteClassExpressionAsTypeLiteral";
|
|
NodeBuilderFlags[NodeBuilderFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction";
|
|
NodeBuilderFlags[NodeBuilderFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers";
|
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
// Error handling
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowEmptyTuple"] = 524288] = "AllowEmptyTuple";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
NodeBuilderFlags[NodeBuilderFlags["AllowEmptyIndexInfoType"] = 2097152] = "AllowEmptyIndexInfoType";
|
|
NodeBuilderFlags[NodeBuilderFlags["IgnoreErrors"] = 3112960] = "IgnoreErrors";
|
|
// State
|
|
NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral";
|
|
NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName";
|
|
NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType";
|
|
})(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {}));
|
|
// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment
|
|
var TypeFormatFlags;
|
|
(function (TypeFormatFlags) {
|
|
TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None";
|
|
TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 1] = "NoTruncation";
|
|
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
|
|
// hole because there's a hole in node builder flags
|
|
TypeFormatFlags[TypeFormatFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
|
|
// hole because there's a hole in node builder flags
|
|
TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
|
|
TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
|
|
// hole because `UseOnlyExternalAliasing` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` instead
|
|
TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 256] = "SuppressAnyReturnType";
|
|
// hole because `WriteTypeParametersInQualifiedName` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` for this instead
|
|
TypeFormatFlags[TypeFormatFlags["MultilineObjectLiterals"] = 1024] = "MultilineObjectLiterals";
|
|
TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 2048] = "WriteClassExpressionAsTypeLiteral";
|
|
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction";
|
|
TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers";
|
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
// even though `T` can't be accessed in the current scope.
|
|
// Error Handling
|
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
// TypeFormatFlags exclusive
|
|
TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 131072] = "AddUndefined";
|
|
TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 262144] = "WriteArrowStyleSignature";
|
|
// State
|
|
TypeFormatFlags[TypeFormatFlags["InArrayType"] = 524288] = "InArrayType";
|
|
TypeFormatFlags[TypeFormatFlags["InElementType"] = 2097152] = "InElementType";
|
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 9469291] = "NodeBuilderFlagsMask";
|
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
var SymbolFormatFlags;
|
|
(function (SymbolFormatFlags) {
|
|
SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None";
|
|
// Write symbols's type argument if it is instantiated symbol
|
|
// eg. class C<T> { p: T } <-- Show p as C<T>.p here
|
|
// var a: C<number>;
|
|
// var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p
|
|
SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments";
|
|
// Use only external alias information to get the symbol name in the given context
|
|
// eg. module m { export class c { } } import x = m.c;
|
|
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x
|
|
SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing";
|
|
// Build symbol name using any nodes needed, instead of just components of an entity name
|
|
SymbolFormatFlags[SymbolFormatFlags["AllowAnyNodeKind"] = 4] = "AllowAnyNodeKind";
|
|
// Prefer aliases which are not directly visible
|
|
SymbolFormatFlags[SymbolFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 8] = "UseAliasDefinedOutsideCurrentScope";
|
|
})(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {}));
|
|
/* @internal */
|
|
var SymbolAccessibility;
|
|
(function (SymbolAccessibility) {
|
|
SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible";
|
|
SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible";
|
|
SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed";
|
|
})(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {}));
|
|
/* @internal */
|
|
var SyntheticSymbolKind;
|
|
(function (SyntheticSymbolKind) {
|
|
SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection";
|
|
SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread";
|
|
})(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {}));
|
|
var TypePredicateKind;
|
|
(function (TypePredicateKind) {
|
|
TypePredicateKind[TypePredicateKind["This"] = 0] = "This";
|
|
TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier";
|
|
})(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {}));
|
|
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */
|
|
/* @internal */
|
|
var TypeReferenceSerializationKind;
|
|
(function (TypeReferenceSerializationKind) {
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
|
|
// should be emitted using a safe fallback.
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
|
|
// function that can be reached at runtime (e.g. a `class`
|
|
// declaration or a `var` declaration for the static side
|
|
// of a type, such as the global `Promise` type in lib.d.ts).
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise";
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature";
|
|
// with call signatures.
|
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType";
|
|
})(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
|
|
var SymbolFlags;
|
|
(function (SymbolFlags) {
|
|
SymbolFlags[SymbolFlags["None"] = 0] = "None";
|
|
SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable";
|
|
SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable";
|
|
SymbolFlags[SymbolFlags["Property"] = 4] = "Property";
|
|
SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember";
|
|
SymbolFlags[SymbolFlags["Function"] = 16] = "Function";
|
|
SymbolFlags[SymbolFlags["Class"] = 32] = "Class";
|
|
SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface";
|
|
SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum";
|
|
SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum";
|
|
SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule";
|
|
SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule";
|
|
SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral";
|
|
SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral";
|
|
SymbolFlags[SymbolFlags["Method"] = 8192] = "Method";
|
|
SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor";
|
|
SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor";
|
|
SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor";
|
|
SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature";
|
|
SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter";
|
|
SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias";
|
|
SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue";
|
|
SymbolFlags[SymbolFlags["Alias"] = 2097152] = "Alias";
|
|
SymbolFlags[SymbolFlags["Prototype"] = 4194304] = "Prototype";
|
|
SymbolFlags[SymbolFlags["ExportStar"] = 8388608] = "ExportStar";
|
|
SymbolFlags[SymbolFlags["Optional"] = 16777216] = "Optional";
|
|
SymbolFlags[SymbolFlags["Transient"] = 33554432] = "Transient";
|
|
SymbolFlags[SymbolFlags["JSContainer"] = 67108864] = "JSContainer";
|
|
/* @internal */
|
|
SymbolFlags[SymbolFlags["All"] = 67108863] = "All";
|
|
SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum";
|
|
SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable";
|
|
SymbolFlags[SymbolFlags["Value"] = 67216319] = "Value";
|
|
SymbolFlags[SymbolFlags["Type"] = 67901928] = "Type";
|
|
SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace";
|
|
SymbolFlags[SymbolFlags["Module"] = 1536] = "Module";
|
|
SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor";
|
|
// Variables can be redeclared, but can not redeclare a block-scoped declaration with the
|
|
// same name, or any other value that is not a variable, e.g. ValueModule or Class
|
|
SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67216318] = "FunctionScopedVariableExcludes";
|
|
// Block-scoped declarations are not allowed to be re-declared
|
|
// they can not merge with anything in the value space
|
|
SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67216319] = "BlockScopedVariableExcludes";
|
|
SymbolFlags[SymbolFlags["ParameterExcludes"] = 67216319] = "ParameterExcludes";
|
|
SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes";
|
|
SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes";
|
|
SymbolFlags[SymbolFlags["FunctionExcludes"] = 67215791] = "FunctionExcludes";
|
|
SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes";
|
|
SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67901832] = "InterfaceExcludes";
|
|
SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes";
|
|
SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes";
|
|
SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 67215503] = "ValueModuleExcludes";
|
|
SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes";
|
|
SymbolFlags[SymbolFlags["MethodExcludes"] = 67208127] = "MethodExcludes";
|
|
SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67150783] = "GetAccessorExcludes";
|
|
SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67183551] = "SetAccessorExcludes";
|
|
SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67639784] = "TypeParameterExcludes";
|
|
SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67901928] = "TypeAliasExcludes";
|
|
SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes";
|
|
SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember";
|
|
SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal";
|
|
SymbolFlags[SymbolFlags["HasExports"] = 1955] = "HasExports";
|
|
SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers";
|
|
SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped";
|
|
SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor";
|
|
SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember";
|
|
/* @internal */
|
|
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
|
// classification.
|
|
SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable";
|
|
/* @internal */
|
|
SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer";
|
|
})(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {}));
|
|
/* @internal */
|
|
var EnumKind;
|
|
(function (EnumKind) {
|
|
EnumKind[EnumKind["Numeric"] = 0] = "Numeric";
|
|
EnumKind[EnumKind["Literal"] = 1] = "Literal"; // Literal enum (each member has a TypeFlags.EnumLiteral type)
|
|
})(EnumKind = ts.EnumKind || (ts.EnumKind = {}));
|
|
/* @internal */
|
|
var CheckFlags;
|
|
(function (CheckFlags) {
|
|
CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated";
|
|
CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty";
|
|
CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod";
|
|
CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly";
|
|
CheckFlags[CheckFlags["Partial"] = 16] = "Partial";
|
|
CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType";
|
|
CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic";
|
|
CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected";
|
|
CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate";
|
|
CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic";
|
|
CheckFlags[CheckFlags["Late"] = 1024] = "Late";
|
|
CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped";
|
|
CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
|
|
})(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {}));
|
|
var InternalSymbolName;
|
|
(function (InternalSymbolName) {
|
|
InternalSymbolName["Call"] = "__call";
|
|
InternalSymbolName["Constructor"] = "__constructor";
|
|
InternalSymbolName["New"] = "__new";
|
|
InternalSymbolName["Index"] = "__index";
|
|
InternalSymbolName["ExportStar"] = "__export";
|
|
InternalSymbolName["Global"] = "__global";
|
|
InternalSymbolName["Missing"] = "__missing";
|
|
InternalSymbolName["Type"] = "__type";
|
|
InternalSymbolName["Object"] = "__object";
|
|
InternalSymbolName["JSXAttributes"] = "__jsxAttributes";
|
|
InternalSymbolName["Class"] = "__class";
|
|
InternalSymbolName["Function"] = "__function";
|
|
InternalSymbolName["Computed"] = "__computed";
|
|
InternalSymbolName["Resolving"] = "__resolving__";
|
|
InternalSymbolName["ExportEquals"] = "export=";
|
|
InternalSymbolName["Default"] = "default";
|
|
})(InternalSymbolName = ts.InternalSymbolName || (ts.InternalSymbolName = {}));
|
|
/* @internal */
|
|
var NodeCheckFlags;
|
|
(function (NodeCheckFlags) {
|
|
NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked";
|
|
NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis";
|
|
NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis";
|
|
NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget";
|
|
NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
|
|
NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
|
|
NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
|
|
NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
|
|
NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
|
|
NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
|
|
NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
|
|
NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
|
|
NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding";
|
|
NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding";
|
|
NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop";
|
|
NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding";
|
|
NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding";
|
|
NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter";
|
|
NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked";
|
|
NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference";
|
|
NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass";
|
|
})(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {}));
|
|
var TypeFlags;
|
|
(function (TypeFlags) {
|
|
TypeFlags[TypeFlags["Any"] = 1] = "Any";
|
|
TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown";
|
|
TypeFlags[TypeFlags["String"] = 4] = "String";
|
|
TypeFlags[TypeFlags["Number"] = 8] = "Number";
|
|
TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean";
|
|
TypeFlags[TypeFlags["Enum"] = 32] = "Enum";
|
|
TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral";
|
|
TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral";
|
|
TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral";
|
|
TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral";
|
|
TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol";
|
|
TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol";
|
|
TypeFlags[TypeFlags["Void"] = 4096] = "Void";
|
|
TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined";
|
|
TypeFlags[TypeFlags["Null"] = 16384] = "Null";
|
|
TypeFlags[TypeFlags["Never"] = 32768] = "Never";
|
|
TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter";
|
|
TypeFlags[TypeFlags["Object"] = 131072] = "Object";
|
|
TypeFlags[TypeFlags["Union"] = 262144] = "Union";
|
|
TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection";
|
|
TypeFlags[TypeFlags["Index"] = 1048576] = "Index";
|
|
TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess";
|
|
TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional";
|
|
TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution";
|
|
TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["UnionOfUnitTypes"] = 67108864] = "UnionOfUnitTypes";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["ContainsObjectLiteral"] = 268435456] = "ContainsObjectLiteral";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 536870912] = "ContainsAnyFunctionType";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable";
|
|
TypeFlags[TypeFlags["Literal"] = 448] = "Literal";
|
|
TypeFlags[TypeFlags["Unit"] = 27072] = "Unit";
|
|
TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy";
|
|
TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive";
|
|
TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike";
|
|
TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike";
|
|
TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike";
|
|
TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike";
|
|
TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike";
|
|
TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains";
|
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection";
|
|
TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType";
|
|
TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable";
|
|
TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive";
|
|
TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive";
|
|
TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable";
|
|
TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable";
|
|
// 'Narrowable' types are types where narrowing actually narrows.
|
|
// This *should* be every type other than null, undefined, void, and never
|
|
TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable";
|
|
TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["NotUnit"] = 16749629] = "NotUnit";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["PropagatingFlags"] = 939524096] = "PropagatingFlags";
|
|
// The following flags are used for different purposes during union and intersection type construction
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["NonWideningType"] = 134217728] = "NonWideningType";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["Wildcard"] = 268435456] = "Wildcard";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["EmptyObject"] = 536870912] = "EmptyObject";
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["ConstructionFlags"] = 939524096] = "ConstructionFlags";
|
|
// The following flag is used for different purposes by maybeTypeOfKind
|
|
/* @internal */
|
|
TypeFlags[TypeFlags["GenericMappedType"] = 134217728] = "GenericMappedType";
|
|
})(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {}));
|
|
var ObjectFlags;
|
|
(function (ObjectFlags) {
|
|
ObjectFlags[ObjectFlags["Class"] = 1] = "Class";
|
|
ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface";
|
|
ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference";
|
|
ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple";
|
|
ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous";
|
|
ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped";
|
|
ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated";
|
|
ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral";
|
|
ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray";
|
|
ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties";
|
|
ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread";
|
|
ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped";
|
|
ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes";
|
|
ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType";
|
|
ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface";
|
|
})(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {}));
|
|
/* @internal */
|
|
var Variance;
|
|
(function (Variance) {
|
|
Variance[Variance["Invariant"] = 0] = "Invariant";
|
|
Variance[Variance["Covariant"] = 1] = "Covariant";
|
|
Variance[Variance["Contravariant"] = 2] = "Contravariant";
|
|
Variance[Variance["Bivariant"] = 3] = "Bivariant";
|
|
Variance[Variance["Independent"] = 4] = "Independent";
|
|
})(Variance = ts.Variance || (ts.Variance = {}));
|
|
var SignatureKind;
|
|
(function (SignatureKind) {
|
|
SignatureKind[SignatureKind["Call"] = 0] = "Call";
|
|
SignatureKind[SignatureKind["Construct"] = 1] = "Construct";
|
|
})(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {}));
|
|
var IndexKind;
|
|
(function (IndexKind) {
|
|
IndexKind[IndexKind["String"] = 0] = "String";
|
|
IndexKind[IndexKind["Number"] = 1] = "Number";
|
|
})(IndexKind = ts.IndexKind || (ts.IndexKind = {}));
|
|
var InferencePriority;
|
|
(function (InferencePriority) {
|
|
InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable";
|
|
InferencePriority[InferencePriority["HomomorphicMappedType"] = 2] = "HomomorphicMappedType";
|
|
InferencePriority[InferencePriority["MappedTypeConstraint"] = 4] = "MappedTypeConstraint";
|
|
InferencePriority[InferencePriority["ReturnType"] = 8] = "ReturnType";
|
|
InferencePriority[InferencePriority["LiteralKeyof"] = 16] = "LiteralKeyof";
|
|
InferencePriority[InferencePriority["NoConstraints"] = 32] = "NoConstraints";
|
|
InferencePriority[InferencePriority["AlwaysStrict"] = 64] = "AlwaysStrict";
|
|
InferencePriority[InferencePriority["PriorityImpliesCombination"] = 28] = "PriorityImpliesCombination";
|
|
})(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {}));
|
|
/* @internal */
|
|
var InferenceFlags;
|
|
(function (InferenceFlags) {
|
|
InferenceFlags[InferenceFlags["None"] = 0] = "None";
|
|
InferenceFlags[InferenceFlags["InferUnionTypes"] = 1] = "InferUnionTypes";
|
|
InferenceFlags[InferenceFlags["NoDefault"] = 2] = "NoDefault";
|
|
InferenceFlags[InferenceFlags["AnyDefault"] = 4] = "AnyDefault";
|
|
})(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {}));
|
|
/**
|
|
* Ternary values are defined such that
|
|
* x & y is False if either x or y is False.
|
|
* x & y is Maybe if either x or y is Maybe, but neither x or y is False.
|
|
* x & y is True if both x and y are True.
|
|
* x | y is False if both x and y are False.
|
|
* x | y is Maybe if either x or y is Maybe, but neither x or y is True.
|
|
* x | y is True if either x or y is True.
|
|
*/
|
|
/* @internal */
|
|
var Ternary;
|
|
(function (Ternary) {
|
|
Ternary[Ternary["False"] = 0] = "False";
|
|
Ternary[Ternary["Maybe"] = 1] = "Maybe";
|
|
Ternary[Ternary["True"] = -1] = "True";
|
|
})(Ternary = ts.Ternary || (ts.Ternary = {}));
|
|
/* @internal */
|
|
var SpecialPropertyAssignmentKind;
|
|
(function (SpecialPropertyAssignmentKind) {
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None";
|
|
/// exports.name = expr
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty";
|
|
/// module.exports = expr
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports";
|
|
/// className.prototype.name = expr
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty";
|
|
/// this.name = expr
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty";
|
|
// F.name = expr
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property";
|
|
// F.prototype = { ... }
|
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Prototype"] = 6] = "Prototype";
|
|
})(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {}));
|
|
var DiagnosticCategory;
|
|
(function (DiagnosticCategory) {
|
|
DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
|
|
DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
|
|
DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
|
|
DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
|
|
})(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
|
|
/* @internal */
|
|
function diagnosticCategoryName(d, lowerCase) {
|
|
if (lowerCase === void 0) { lowerCase = true; }
|
|
var name = DiagnosticCategory[d.category];
|
|
return lowerCase ? name.toLowerCase() : name;
|
|
}
|
|
ts.diagnosticCategoryName = diagnosticCategoryName;
|
|
var ModuleResolutionKind;
|
|
(function (ModuleResolutionKind) {
|
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
|
|
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
|
|
var ModuleKind;
|
|
(function (ModuleKind) {
|
|
ModuleKind[ModuleKind["None"] = 0] = "None";
|
|
ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
|
|
ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
|
|
ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
|
|
ModuleKind[ModuleKind["System"] = 4] = "System";
|
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext";
|
|
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
|
|
var JsxEmit;
|
|
(function (JsxEmit) {
|
|
JsxEmit[JsxEmit["None"] = 0] = "None";
|
|
JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve";
|
|
JsxEmit[JsxEmit["React"] = 2] = "React";
|
|
JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative";
|
|
})(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {}));
|
|
var NewLineKind;
|
|
(function (NewLineKind) {
|
|
NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed";
|
|
NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed";
|
|
})(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {}));
|
|
var ScriptKind;
|
|
(function (ScriptKind) {
|
|
ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown";
|
|
ScriptKind[ScriptKind["JS"] = 1] = "JS";
|
|
ScriptKind[ScriptKind["JSX"] = 2] = "JSX";
|
|
ScriptKind[ScriptKind["TS"] = 3] = "TS";
|
|
ScriptKind[ScriptKind["TSX"] = 4] = "TSX";
|
|
ScriptKind[ScriptKind["External"] = 5] = "External";
|
|
ScriptKind[ScriptKind["JSON"] = 6] = "JSON";
|
|
/**
|
|
* Used on extensions that doesn't define the ScriptKind but the content defines it.
|
|
* Deferred extensions are going to be included in all project contexts.
|
|
*/
|
|
ScriptKind[ScriptKind["Deferred"] = 7] = "Deferred";
|
|
})(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {}));
|
|
var ScriptTarget;
|
|
(function (ScriptTarget) {
|
|
ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3";
|
|
ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5";
|
|
ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015";
|
|
ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016";
|
|
ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017";
|
|
ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018";
|
|
ScriptTarget[ScriptTarget["ESNext"] = 6] = "ESNext";
|
|
ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON";
|
|
ScriptTarget[ScriptTarget["Latest"] = 6] = "Latest";
|
|
})(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {}));
|
|
var LanguageVariant;
|
|
(function (LanguageVariant) {
|
|
LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard";
|
|
LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX";
|
|
})(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {}));
|
|
var WatchDirectoryFlags;
|
|
(function (WatchDirectoryFlags) {
|
|
WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None";
|
|
WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive";
|
|
})(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {}));
|
|
/* @internal */
|
|
var CharacterCodes;
|
|
(function (CharacterCodes) {
|
|
CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter";
|
|
CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter";
|
|
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
|
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
|
CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator";
|
|
CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator";
|
|
CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine";
|
|
// Unicode 3.0 space characters
|
|
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
|
CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace";
|
|
CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad";
|
|
CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad";
|
|
CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace";
|
|
CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace";
|
|
CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace";
|
|
CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace";
|
|
CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace";
|
|
CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace";
|
|
CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace";
|
|
CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace";
|
|
CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace";
|
|
CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace";
|
|
CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace";
|
|
CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace";
|
|
CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace";
|
|
CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham";
|
|
CharacterCodes[CharacterCodes["_"] = 95] = "_";
|
|
CharacterCodes[CharacterCodes["$"] = 36] = "$";
|
|
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
|
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
|
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
|
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
|
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
|
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
|
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
|
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
|
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
|
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
|
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
|
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
|
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
|
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
|
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
|
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
|
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
|
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
|
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
|
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
|
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
|
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
|
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
|
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
|
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
|
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
|
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
|
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
|
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
|
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
|
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
|
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
|
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
|
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
|
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
|
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
|
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
|
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
|
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
|
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
|
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
|
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
|
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
|
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
|
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
|
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
|
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
|
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
|
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
|
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
|
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
|
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
|
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
|
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
|
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
|
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
|
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
|
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
|
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
|
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
|
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
|
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
|
CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand";
|
|
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
|
CharacterCodes[CharacterCodes["at"] = 64] = "at";
|
|
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
|
CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick";
|
|
CharacterCodes[CharacterCodes["bar"] = 124] = "bar";
|
|
CharacterCodes[CharacterCodes["caret"] = 94] = "caret";
|
|
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
|
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
|
CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen";
|
|
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
|
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
|
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
|
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
|
CharacterCodes[CharacterCodes["equals"] = 61] = "equals";
|
|
CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation";
|
|
CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan";
|
|
CharacterCodes[CharacterCodes["hash"] = 35] = "hash";
|
|
CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan";
|
|
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
|
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
|
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
|
CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen";
|
|
CharacterCodes[CharacterCodes["percent"] = 37] = "percent";
|
|
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
|
CharacterCodes[CharacterCodes["question"] = 63] = "question";
|
|
CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon";
|
|
CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote";
|
|
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
|
CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde";
|
|
CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace";
|
|
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
|
CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark";
|
|
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
|
CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab";
|
|
})(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {}));
|
|
var Extension;
|
|
(function (Extension) {
|
|
Extension["Ts"] = ".ts";
|
|
Extension["Tsx"] = ".tsx";
|
|
Extension["Dts"] = ".d.ts";
|
|
Extension["Js"] = ".js";
|
|
Extension["Jsx"] = ".jsx";
|
|
Extension["Json"] = ".json";
|
|
})(Extension = ts.Extension || (ts.Extension = {}));
|
|
/* @internal */
|
|
var TransformFlags;
|
|
(function (TransformFlags) {
|
|
TransformFlags[TransformFlags["None"] = 0] = "None";
|
|
// Facts
|
|
// - Flags used to indicate that a node or subtree contains syntax that requires transformation.
|
|
TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript";
|
|
TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript";
|
|
TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx";
|
|
TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext";
|
|
TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017";
|
|
TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016";
|
|
TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015";
|
|
TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015";
|
|
TransformFlags[TransformFlags["Generator"] = 256] = "Generator";
|
|
TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator";
|
|
TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment";
|
|
TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment";
|
|
// Markers
|
|
// - Flags used to indicate that a subtree contains a specific transformation.
|
|
TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators";
|
|
TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer";
|
|
TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
|
|
TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis";
|
|
TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName";
|
|
TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments";
|
|
TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments";
|
|
TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread";
|
|
TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread";
|
|
TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest";
|
|
TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest";
|
|
TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName";
|
|
TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding";
|
|
TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern";
|
|
TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield";
|
|
TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion";
|
|
TransformFlags[TransformFlags["ContainsDynamicImport"] = 67108864] = "ContainsDynamicImport";
|
|
TransformFlags[TransformFlags["Super"] = 134217728] = "Super";
|
|
TransformFlags[TransformFlags["ContainsSuper"] = 268435456] = "ContainsSuper";
|
|
// Please leave this as 1 << 29.
|
|
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
|
|
// It is a good reminder of how much room we have left
|
|
TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
|
|
// Assertions
|
|
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
|
|
TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript";
|
|
TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx";
|
|
TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext";
|
|
TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017";
|
|
TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016";
|
|
TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015";
|
|
TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator";
|
|
TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment";
|
|
// Scope Exclusions
|
|
// - Bitmasks that exclude flags from propagating out of a specific context
|
|
// into the subtree flags of their container.
|
|
TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536872257] = "OuterExpressionExcludes";
|
|
TransformFlags[TransformFlags["PropertyAccessExcludes"] = 671089985] = "PropertyAccessExcludes";
|
|
TransformFlags[TransformFlags["NodeExcludes"] = 939525441] = "NodeExcludes";
|
|
TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 1003902273] = "ArrowFunctionExcludes";
|
|
TransformFlags[TransformFlags["FunctionExcludes"] = 1003935041] = "FunctionExcludes";
|
|
TransformFlags[TransformFlags["ConstructorExcludes"] = 1003668801] = "ConstructorExcludes";
|
|
TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 1003668801] = "MethodOrAccessorExcludes";
|
|
TransformFlags[TransformFlags["ClassExcludes"] = 942011713] = "ClassExcludes";
|
|
TransformFlags[TransformFlags["ModuleExcludes"] = 977327425] = "ModuleExcludes";
|
|
TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes";
|
|
TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 942740801] = "ObjectLiteralExcludes";
|
|
TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 940049729] = "ArrayLiteralOrCallOrNewExcludes";
|
|
TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 948962625] = "VariableDeclarationListExcludes";
|
|
TransformFlags[TransformFlags["ParameterExcludes"] = 939525441] = "ParameterExcludes";
|
|
TransformFlags[TransformFlags["CatchClauseExcludes"] = 940574017] = "CatchClauseExcludes";
|
|
TransformFlags[TransformFlags["BindingPatternExcludes"] = 940049729] = "BindingPatternExcludes";
|
|
// Masks
|
|
// - Additional bitmasks
|
|
TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask";
|
|
TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask";
|
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
var EmitFlags;
|
|
(function (EmitFlags) {
|
|
EmitFlags[EmitFlags["None"] = 0] = "None";
|
|
EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine";
|
|
EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode";
|
|
EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution";
|
|
EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis";
|
|
EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap";
|
|
EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap";
|
|
EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap";
|
|
EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps";
|
|
EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps";
|
|
EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps";
|
|
EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps";
|
|
EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments";
|
|
EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments";
|
|
EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments";
|
|
EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments";
|
|
EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName";
|
|
EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName";
|
|
EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName";
|
|
EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName";
|
|
EmitFlags[EmitFlags["Indented"] = 65536] = "Indented";
|
|
EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation";
|
|
EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody";
|
|
EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope";
|
|
EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue";
|
|
EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting";
|
|
EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker";
|
|
EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator";
|
|
EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping";
|
|
/*@internal*/ EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper";
|
|
/*@internal*/ EmitFlags[EmitFlags["NeverApplyImportHelper"] = 67108864] = "NeverApplyImportHelper";
|
|
})(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {}));
|
|
/**
|
|
* Used by the checker, this enum keeps track of external emit helpers that should be type
|
|
* checked.
|
|
*/
|
|
/* @internal */
|
|
var ExternalEmitHelpers;
|
|
(function (ExternalEmitHelpers) {
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["Await"] = 2048] = "Await";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 4096] = "AsyncGenerator";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 8192] = "AsyncDelegator";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 16384] = "AsyncValues";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["ExportStar"] = 32768] = "ExportStar";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 65536] = "MakeTemplateObject";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper";
|
|
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 65536] = "LastEmitHelper";
|
|
// Helpers included by ES2015 for..of
|
|
ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes";
|
|
// Helpers included by ES2017 for..await..of
|
|
ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 16384] = "ForAwaitOfIncludes";
|
|
// Helpers included by ES2017 async generators
|
|
ExternalEmitHelpers[ExternalEmitHelpers["AsyncGeneratorIncludes"] = 6144] = "AsyncGeneratorIncludes";
|
|
// Helpers included by yield* in ES2017 async generators
|
|
ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegatorIncludes"] = 26624] = "AsyncDelegatorIncludes";
|
|
// Helpers included by ES2015 spread
|
|
ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes";
|
|
})(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {}));
|
|
var EmitHint;
|
|
(function (EmitHint) {
|
|
EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile";
|
|
EmitHint[EmitHint["Expression"] = 1] = "Expression";
|
|
EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName";
|
|
EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter";
|
|
EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified";
|
|
})(EmitHint = ts.EmitHint || (ts.EmitHint = {}));
|
|
var ListFormat;
|
|
(function (ListFormat) {
|
|
ListFormat[ListFormat["None"] = 0] = "None";
|
|
// Line separators
|
|
ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine";
|
|
ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine";
|
|
ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines";
|
|
ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask";
|
|
// Delimiters
|
|
ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited";
|
|
ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited";
|
|
ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited";
|
|
ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited";
|
|
ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask";
|
|
ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma";
|
|
// Whitespace
|
|
ListFormat[ListFormat["Indented"] = 64] = "Indented";
|
|
ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces";
|
|
ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings";
|
|
// Brackets/Braces
|
|
ListFormat[ListFormat["Braces"] = 512] = "Braces";
|
|
ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis";
|
|
ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets";
|
|
ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets";
|
|
ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask";
|
|
ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined";
|
|
ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty";
|
|
ListFormat[ListFormat["Optional"] = 24576] = "Optional";
|
|
// Other
|
|
ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine";
|
|
ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine";
|
|
ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments";
|
|
ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty";
|
|
ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement";
|
|
// Precomputed Formats
|
|
ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers";
|
|
ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses";
|
|
ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers";
|
|
ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers";
|
|
ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements";
|
|
ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents";
|
|
ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents";
|
|
ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements";
|
|
ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements";
|
|
ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties";
|
|
ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements";
|
|
ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements";
|
|
ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments";
|
|
ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments";
|
|
ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans";
|
|
ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements";
|
|
ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements";
|
|
ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList";
|
|
ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements";
|
|
ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements";
|
|
ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses";
|
|
ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers";
|
|
ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers";
|
|
ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers";
|
|
ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses";
|
|
ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements";
|
|
ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren";
|
|
ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes";
|
|
ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements";
|
|
ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes";
|
|
ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements";
|
|
ListFormat[ListFormat["Decorators"] = 24577] = "Decorators";
|
|
ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments";
|
|
ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters";
|
|
ListFormat[ListFormat["Parameters"] = 1296] = "Parameters";
|
|
ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters";
|
|
})(ListFormat = ts.ListFormat || (ts.ListFormat = {}));
|
|
/* @internal */
|
|
var PragmaKindFlags;
|
|
(function (PragmaKindFlags) {
|
|
PragmaKindFlags[PragmaKindFlags["None"] = 0] = "None";
|
|
/**
|
|
* Triple slash comment of the form
|
|
* /// <pragma-name argname="value" />
|
|
*/
|
|
PragmaKindFlags[PragmaKindFlags["TripleSlashXML"] = 1] = "TripleSlashXML";
|
|
/**
|
|
* Single line comment of the form
|
|
* // @pragma-name argval1 argval2
|
|
* or
|
|
* /// @pragma-name argval1 argval2
|
|
*/
|
|
PragmaKindFlags[PragmaKindFlags["SingleLine"] = 2] = "SingleLine";
|
|
/**
|
|
* Multiline non-jsdoc pragma of the form
|
|
* /* @pragma-name argval1 argval2 * /
|
|
*/
|
|
PragmaKindFlags[PragmaKindFlags["MultiLine"] = 4] = "MultiLine";
|
|
PragmaKindFlags[PragmaKindFlags["All"] = 7] = "All";
|
|
PragmaKindFlags[PragmaKindFlags["Default"] = 7] = "Default";
|
|
})(PragmaKindFlags = ts.PragmaKindFlags || (ts.PragmaKindFlags = {}));
|
|
/**
|
|
* This function only exists to cause exact types to be inferred for all the literals within `commentPragmas`
|
|
*/
|
|
/* @internal */
|
|
function _contextuallyTypePragmas(args) {
|
|
return args;
|
|
}
|
|
// While not strictly a type, this is here because `PragmaMap` needs to be here to be used with `SourceFile`, and we don't
|
|
// fancy effectively defining it twice, once in value-space and once in type-space
|
|
/* @internal */
|
|
ts.commentPragmas = _contextuallyTypePragmas({
|
|
"reference": {
|
|
args: [
|
|
{ name: "types", optional: true, captureSpan: true },
|
|
{ name: "lib", optional: true, captureSpan: true },
|
|
{ name: "path", optional: true, captureSpan: true },
|
|
{ name: "no-default-lib", optional: true }
|
|
],
|
|
kind: 1 /* TripleSlashXML */
|
|
},
|
|
"amd-dependency": {
|
|
args: [{ name: "path" }, { name: "name", optional: true }],
|
|
kind: 1 /* TripleSlashXML */
|
|
},
|
|
"amd-module": {
|
|
args: [{ name: "name" }],
|
|
kind: 1 /* TripleSlashXML */
|
|
},
|
|
"ts-check": {
|
|
kind: 2 /* SingleLine */
|
|
},
|
|
"ts-nocheck": {
|
|
kind: 2 /* SingleLine */
|
|
},
|
|
"jsx": {
|
|
args: [{ name: "factory" }],
|
|
kind: 4 /* MultiLine */
|
|
},
|
|
});
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
/**
|
|
* Set a high stack trace limit to provide more information in case of an error.
|
|
* Called for command-line and server use cases.
|
|
* Not called if TypeScript is used as a library.
|
|
*/
|
|
/* @internal */
|
|
function setStackTraceLimit() {
|
|
if (Error.stackTraceLimit < 100) { // Also tests that we won't set the property if it doesn't exist.
|
|
Error.stackTraceLimit = 100;
|
|
}
|
|
}
|
|
ts.setStackTraceLimit = setStackTraceLimit;
|
|
var FileWatcherEventKind;
|
|
(function (FileWatcherEventKind) {
|
|
FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
|
|
FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
|
|
FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
|
|
})(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
|
|
/* @internal */
|
|
var PollingInterval;
|
|
(function (PollingInterval) {
|
|
PollingInterval[PollingInterval["High"] = 2000] = "High";
|
|
PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
|
|
PollingInterval[PollingInterval["Low"] = 250] = "Low";
|
|
})(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
|
|
function getPriorityValues(highPriorityValue) {
|
|
var mediumPriorityValue = highPriorityValue * 2;
|
|
var lowPriorityValue = mediumPriorityValue * 4;
|
|
return [highPriorityValue, mediumPriorityValue, lowPriorityValue];
|
|
}
|
|
function pollingInterval(watchPriority) {
|
|
return pollingIntervalsForPriority[watchPriority];
|
|
}
|
|
var pollingIntervalsForPriority = getPriorityValues(250);
|
|
/* @internal */
|
|
function watchFileUsingPriorityPollingInterval(host, fileName, callback, watchPriority) {
|
|
return host.watchFile(fileName, callback, pollingInterval(watchPriority));
|
|
}
|
|
ts.watchFileUsingPriorityPollingInterval = watchFileUsingPriorityPollingInterval;
|
|
/* @internal */
|
|
ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time
|
|
function createPollingIntervalBasedLevels(levels) {
|
|
var _a;
|
|
return _a = {},
|
|
_a[PollingInterval.Low] = levels.Low,
|
|
_a[PollingInterval.Medium] = levels.Medium,
|
|
_a[PollingInterval.High] = levels.High,
|
|
_a;
|
|
}
|
|
var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
|
|
var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
|
|
/* @internal */
|
|
ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
|
|
/* @internal */
|
|
function setCustomPollingValues(system) {
|
|
if (!system.getEnvironmentVariable) {
|
|
return;
|
|
}
|
|
var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
|
|
pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
|
|
ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
|
|
function getLevel(envVar, level) {
|
|
return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
|
|
}
|
|
function getCustomLevels(baseVariable) {
|
|
var customLevels;
|
|
setCustomLevel("Low");
|
|
setCustomLevel("Medium");
|
|
setCustomLevel("High");
|
|
return customLevels;
|
|
function setCustomLevel(level) {
|
|
var customLevel = getLevel(baseVariable, level);
|
|
if (customLevel) {
|
|
(customLevels || (customLevels = {}))[level] = Number(customLevel);
|
|
}
|
|
}
|
|
}
|
|
function setCustomLevels(baseVariable, levels) {
|
|
var customLevels = getCustomLevels(baseVariable);
|
|
if (customLevels) {
|
|
setLevel("Low");
|
|
setLevel("Medium");
|
|
setLevel("High");
|
|
return true;
|
|
}
|
|
return false;
|
|
function setLevel(level) {
|
|
levels[level] = customLevels[level] || levels[level];
|
|
}
|
|
}
|
|
function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
|
|
var customLevels = getCustomLevels(baseVariable);
|
|
return (pollingIntervalChanged || customLevels) &&
|
|
createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels);
|
|
}
|
|
}
|
|
ts.setCustomPollingValues = setCustomPollingValues;
|
|
/* @internal */
|
|
function createDynamicPriorityPollingWatchFile(host) {
|
|
var watchedFiles = [];
|
|
var changedFilesInLastPoll = [];
|
|
var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
|
|
var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
|
|
var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
|
|
return watchFile;
|
|
function watchFile(fileName, callback, defaultPollingInterval) {
|
|
var file = {
|
|
fileName: fileName,
|
|
callback: callback,
|
|
unchangedPolls: 0,
|
|
mtime: getModifiedTime(fileName)
|
|
};
|
|
watchedFiles.push(file);
|
|
addToPollingIntervalQueue(file, defaultPollingInterval);
|
|
return {
|
|
close: function () {
|
|
file.isClosed = true;
|
|
// Remove from watchedFiles
|
|
ts.unorderedRemoveItem(watchedFiles, file);
|
|
// Do not update polling interval queue since that will happen as part of polling
|
|
}
|
|
};
|
|
}
|
|
function createPollingIntervalQueue(pollingInterval) {
|
|
var queue = [];
|
|
queue.pollingInterval = pollingInterval;
|
|
queue.pollIndex = 0;
|
|
queue.pollScheduled = false;
|
|
return queue;
|
|
}
|
|
function pollPollingIntervalQueue(queue) {
|
|
queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
|
|
// Set the next polling index and timeout
|
|
if (queue.length) {
|
|
scheduleNextPoll(queue.pollingInterval);
|
|
}
|
|
else {
|
|
ts.Debug.assert(queue.pollIndex === 0);
|
|
queue.pollScheduled = false;
|
|
}
|
|
}
|
|
function pollLowPollingIntervalQueue(queue) {
|
|
// Always poll complete list of changedFilesInLastPoll
|
|
pollQueue(changedFilesInLastPoll, PollingInterval.Low, /*pollIndex*/ 0, changedFilesInLastPoll.length);
|
|
// Finally do the actual polling of the queue
|
|
pollPollingIntervalQueue(queue);
|
|
// Schedule poll if there are files in changedFilesInLastPoll but no files in the actual queue
|
|
// as pollPollingIntervalQueue wont schedule for next poll
|
|
if (!queue.pollScheduled && changedFilesInLastPoll.length) {
|
|
scheduleNextPoll(PollingInterval.Low);
|
|
}
|
|
}
|
|
function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
|
|
// Max visit would be all elements of the queue
|
|
var needsVisit = queue.length;
|
|
var definedValueCopyToIndex = pollIndex;
|
|
for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
|
|
var watchedFile = queue[pollIndex];
|
|
if (!watchedFile) {
|
|
continue;
|
|
}
|
|
else if (watchedFile.isClosed) {
|
|
queue[pollIndex] = undefined;
|
|
continue;
|
|
}
|
|
polled++;
|
|
var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
|
|
if (watchedFile.isClosed) {
|
|
// Closed watcher as part of callback
|
|
queue[pollIndex] = undefined;
|
|
}
|
|
else if (fileChanged) {
|
|
watchedFile.unchangedPolls = 0;
|
|
// Changed files go to changedFilesInLastPoll queue
|
|
if (queue !== changedFilesInLastPoll) {
|
|
queue[pollIndex] = undefined;
|
|
addChangedFileToLowPollingIntervalQueue(watchedFile);
|
|
}
|
|
}
|
|
else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
|
|
watchedFile.unchangedPolls++;
|
|
}
|
|
else if (queue === changedFilesInLastPoll) {
|
|
// Restart unchangedPollCount for unchanged file and move to low polling interval queue
|
|
watchedFile.unchangedPolls = 1;
|
|
queue[pollIndex] = undefined;
|
|
addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
|
|
}
|
|
else if (pollingInterval !== PollingInterval.High) {
|
|
watchedFile.unchangedPolls++;
|
|
queue[pollIndex] = undefined;
|
|
addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
|
|
}
|
|
if (queue[pollIndex]) {
|
|
// Copy this file to the non hole location
|
|
if (definedValueCopyToIndex < pollIndex) {
|
|
queue[definedValueCopyToIndex] = watchedFile;
|
|
queue[pollIndex] = undefined;
|
|
}
|
|
definedValueCopyToIndex++;
|
|
}
|
|
}
|
|
// Return next poll index
|
|
return pollIndex;
|
|
function nextPollIndex() {
|
|
pollIndex++;
|
|
if (pollIndex === queue.length) {
|
|
if (definedValueCopyToIndex < pollIndex) {
|
|
// There are holes from nextDefinedValueIndex to end of queue, change queue size
|
|
queue.length = definedValueCopyToIndex;
|
|
}
|
|
pollIndex = 0;
|
|
definedValueCopyToIndex = 0;
|
|
}
|
|
}
|
|
}
|
|
function pollingIntervalQueue(pollingInterval) {
|
|
switch (pollingInterval) {
|
|
case PollingInterval.Low:
|
|
return lowPollingIntervalQueue;
|
|
case PollingInterval.Medium:
|
|
return mediumPollingIntervalQueue;
|
|
case PollingInterval.High:
|
|
return highPollingIntervalQueue;
|
|
}
|
|
}
|
|
function addToPollingIntervalQueue(file, pollingInterval) {
|
|
pollingIntervalQueue(pollingInterval).push(file);
|
|
scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
|
|
}
|
|
function addChangedFileToLowPollingIntervalQueue(file) {
|
|
changedFilesInLastPoll.push(file);
|
|
scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
|
|
}
|
|
function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
|
|
if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
|
|
scheduleNextPoll(pollingInterval);
|
|
}
|
|
}
|
|
function scheduleNextPoll(pollingInterval) {
|
|
pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
|
|
}
|
|
function getModifiedTime(fileName) {
|
|
return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
|
|
}
|
|
}
|
|
ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
|
|
/**
|
|
* Returns true if file status changed
|
|
*/
|
|
/*@internal*/
|
|
function onWatchedFileStat(watchedFile, modifiedTime) {
|
|
var oldTime = watchedFile.mtime.getTime();
|
|
var newTime = modifiedTime.getTime();
|
|
if (oldTime !== newTime) {
|
|
watchedFile.mtime = modifiedTime;
|
|
var eventKind = oldTime === 0
|
|
? FileWatcherEventKind.Created
|
|
: newTime === 0
|
|
? FileWatcherEventKind.Deleted
|
|
: FileWatcherEventKind.Changed;
|
|
watchedFile.callback(watchedFile.fileName, eventKind);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.onWatchedFileStat = onWatchedFileStat;
|
|
/**
|
|
* Watch the directory recursively using host provided method to watch child directories
|
|
* that means if this is recursive watcher, watch the children directories as well
|
|
* (eg on OS that dont support recursive watch using fs.watch use fs.watchFile)
|
|
*/
|
|
/*@internal*/
|
|
function createRecursiveDirectoryWatcher(host) {
|
|
return createDirectoryWatcher;
|
|
/**
|
|
* Create the directory watcher for the dirPath.
|
|
*/
|
|
function createDirectoryWatcher(dirName, callback) {
|
|
var watcher = host.watchDirectory(dirName, function (fileName) {
|
|
// Call the actual callback
|
|
callback(fileName);
|
|
// Iterate through existing children and update the watches if needed
|
|
updateChildWatches(result, callback);
|
|
});
|
|
var result = {
|
|
close: function () {
|
|
watcher.close();
|
|
result.childWatches.forEach(ts.closeFileWatcher);
|
|
result = undefined;
|
|
},
|
|
dirName: dirName,
|
|
childWatches: ts.emptyArray
|
|
};
|
|
updateChildWatches(result, callback);
|
|
return result;
|
|
}
|
|
function updateChildWatches(watcher, callback) {
|
|
// Iterate through existing children and update the watches if needed
|
|
if (watcher) {
|
|
watcher.childWatches = watchChildDirectories(watcher.dirName, watcher.childWatches, callback);
|
|
}
|
|
}
|
|
/**
|
|
* Watch the directories in the parentDir
|
|
*/
|
|
function watchChildDirectories(parentDir, existingChildWatches, callback) {
|
|
var newChildWatches;
|
|
ts.enumerateInsertsAndDeletes(host.directoryExists(parentDir) ? ts.mapDefined(host.getAccessibleSortedChildDirectories(parentDir), function (child) {
|
|
var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
|
|
// Filter our the symbolic link directories since those arent included in recursive watch
|
|
// which is same behaviour when recursive: true is passed to fs.watch
|
|
return host.filePathComparer(childFullName, host.realpath(childFullName)) === 0 /* EqualTo */ ? childFullName : undefined;
|
|
}) : ts.emptyArray, existingChildWatches, function (child, childWatcher) { return host.filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
|
|
return newChildWatches || ts.emptyArray;
|
|
/**
|
|
* Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list
|
|
*/
|
|
function createAndAddChildDirectoryWatcher(childName) {
|
|
var result = createDirectoryWatcher(childName, callback);
|
|
addChildDirectoryWatcher(result);
|
|
}
|
|
/**
|
|
* Add child directory watcher to the new ChildDirectoryWatcher list
|
|
*/
|
|
function addChildDirectoryWatcher(childWatcher) {
|
|
(newChildWatches || (newChildWatches = [])).push(childWatcher);
|
|
}
|
|
}
|
|
}
|
|
ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher;
|
|
function getNodeMajorVersion() {
|
|
if (typeof process === "undefined") {
|
|
return undefined;
|
|
}
|
|
var version = process.version;
|
|
if (!version) {
|
|
return undefined;
|
|
}
|
|
var dot = version.indexOf(".");
|
|
if (dot === -1) {
|
|
return undefined;
|
|
}
|
|
return parseInt(version.substring(1, dot));
|
|
}
|
|
ts.getNodeMajorVersion = getNodeMajorVersion;
|
|
// TODO: this is used as if it's certainly defined in many places.
|
|
ts.sys = (function () {
|
|
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
|
|
// byte order mark from the specified encoding. Using any other byte order mark does
|
|
// not actually work.
|
|
var byteOrderMarkIndicator = "\uFEFF";
|
|
function getNodeSystem() {
|
|
var _fs = require("fs");
|
|
var _path = require("path");
|
|
var _os = require("os");
|
|
// crypto can be absent on reduced node installations
|
|
var _crypto;
|
|
try {
|
|
_crypto = require("crypto");
|
|
}
|
|
catch (_a) {
|
|
_crypto = undefined;
|
|
}
|
|
var Buffer = require("buffer").Buffer;
|
|
var nodeVersion = getNodeMajorVersion();
|
|
var isNode4OrLater = nodeVersion >= 4;
|
|
var platform = _os.platform();
|
|
var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
|
var FileSystemEntryKind;
|
|
(function (FileSystemEntryKind) {
|
|
FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File";
|
|
FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory";
|
|
})(FileSystemEntryKind || (FileSystemEntryKind = {}));
|
|
var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER;
|
|
var tscWatchFile = process.env.TSC_WATCHFILE;
|
|
var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY;
|
|
var dynamicPollingWatchFile;
|
|
var nodeSystem = {
|
|
args: process.argv.slice(2),
|
|
newLine: _os.EOL,
|
|
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
|
write: function (s) {
|
|
process.stdout.write(s);
|
|
},
|
|
writeOutputIsTTY: function () {
|
|
return process.stdout.isTTY;
|
|
},
|
|
readFile: readFile,
|
|
writeFile: writeFile,
|
|
watchFile: getWatchFile(),
|
|
watchDirectory: getWatchDirectory(),
|
|
resolvePath: function (path) { return _path.resolve(path); },
|
|
fileExists: fileExists,
|
|
directoryExists: directoryExists,
|
|
createDirectory: function (directoryName) {
|
|
if (!nodeSystem.directoryExists(directoryName)) {
|
|
_fs.mkdirSync(directoryName);
|
|
}
|
|
},
|
|
getExecutingFilePath: function () {
|
|
return __filename;
|
|
},
|
|
getCurrentDirectory: function () {
|
|
return process.cwd();
|
|
},
|
|
getDirectories: getDirectories,
|
|
getEnvironmentVariable: function (name) {
|
|
return process.env[name] || "";
|
|
},
|
|
readDirectory: readDirectory,
|
|
getModifiedTime: getModifiedTime,
|
|
setModifiedTime: setModifiedTime,
|
|
deleteFile: deleteFile,
|
|
createHash: _crypto ? createMD5HashUsingNativeCrypto : generateDjb2Hash,
|
|
createSHA256Hash: _crypto ? createSHA256Hash : undefined,
|
|
getMemoryUsage: function () {
|
|
if (global.gc) {
|
|
global.gc();
|
|
}
|
|
return process.memoryUsage().heapUsed;
|
|
},
|
|
getFileSize: function (path) {
|
|
try {
|
|
var stat = _fs.statSync(path);
|
|
if (stat.isFile()) {
|
|
return stat.size;
|
|
}
|
|
}
|
|
catch ( /*ignore*/_a) { /*ignore*/ }
|
|
return 0;
|
|
},
|
|
exit: function (exitCode) {
|
|
process.exit(exitCode);
|
|
},
|
|
realpath: realpath,
|
|
debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
|
|
tryEnableSourceMapsForHost: function () {
|
|
try {
|
|
require("source-map-support").install();
|
|
}
|
|
catch (_a) {
|
|
// Could not enable source maps.
|
|
}
|
|
},
|
|
setTimeout: setTimeout,
|
|
clearTimeout: clearTimeout,
|
|
clearScreen: function () {
|
|
process.stdout.write("\x1Bc");
|
|
},
|
|
setBlocking: function () {
|
|
if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
|
|
process.stdout._handle.setBlocking(true);
|
|
}
|
|
},
|
|
base64decode: Buffer.from ? function (input) {
|
|
return Buffer.from(input, "base64").toString("utf8");
|
|
} : function (input) {
|
|
return new Buffer(input, "base64").toString("utf8");
|
|
},
|
|
base64encode: Buffer.from ? function (input) {
|
|
return Buffer.from(input).toString("base64");
|
|
} : function (input) {
|
|
return new Buffer(input).toString("base64");
|
|
}
|
|
};
|
|
return nodeSystem;
|
|
function isFileSystemCaseSensitive() {
|
|
// win32\win64 are case insensitive platforms
|
|
if (platform === "win32" || platform === "win64") {
|
|
return false;
|
|
}
|
|
// If this file exists under a different case, we must be case-insensitve.
|
|
return !fileExists(swapCase(__filename));
|
|
}
|
|
/** Convert all lowercase chars to uppercase, and vice-versa */
|
|
function swapCase(s) {
|
|
return s.replace(/\w/g, function (ch) {
|
|
var up = ch.toUpperCase();
|
|
return ch === up ? ch.toLowerCase() : up;
|
|
});
|
|
}
|
|
function getWatchFile() {
|
|
switch (tscWatchFile) {
|
|
case "PriorityPollingInterval":
|
|
// Use polling interval based on priority when create watch using host.watchFile
|
|
return fsWatchFile;
|
|
case "DynamicPriorityPolling":
|
|
// Use polling interval but change the interval depending on file changes and their default polling interval
|
|
return createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout });
|
|
case "UseFsEvents":
|
|
// Use notifications from FS to watch with falling back to fs.watchFile
|
|
return watchFileUsingFsWatch;
|
|
case "UseFsEventsWithFallbackDynamicPolling":
|
|
// Use notifications from FS to watch with falling back to dynamic watch file
|
|
dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout });
|
|
return createWatchFileUsingDynamicWatchFile(dynamicPollingWatchFile);
|
|
case "UseFsEventsOnParentDirectory":
|
|
// Use notifications from FS to watch with falling back to fs.watchFile
|
|
return createNonPollingWatchFile();
|
|
}
|
|
return useNonPollingWatchers ?
|
|
createNonPollingWatchFile() :
|
|
// Default to do not use polling interval as it is before this experiment branch
|
|
function (fileName, callback) { return fsWatchFile(fileName, callback); };
|
|
}
|
|
function getWatchDirectory() {
|
|
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
|
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
|
var fsSupportsRecursive = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
|
|
if (fsSupportsRecursive) {
|
|
return watchDirectoryUsingFsWatch;
|
|
}
|
|
var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ?
|
|
createWatchDirectoryUsing(fsWatchFile) :
|
|
tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ?
|
|
createWatchDirectoryUsing(dynamicPollingWatchFile || createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })) :
|
|
watchDirectoryUsingFsWatch;
|
|
var watchDirectoryRecursively = createRecursiveDirectoryWatcher({
|
|
filePathComparer: ts.getStringComparer(!useCaseSensitiveFileNames),
|
|
directoryExists: directoryExists,
|
|
getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
|
|
watchDirectory: watchDirectory,
|
|
realpath: realpath
|
|
});
|
|
return function (directoryName, callback, recursive) {
|
|
if (recursive) {
|
|
return watchDirectoryRecursively(directoryName, callback);
|
|
}
|
|
watchDirectory(directoryName, callback);
|
|
return undefined; // TODO: GH#18217
|
|
};
|
|
}
|
|
function createNonPollingWatchFile() {
|
|
// One file can have multiple watchers
|
|
var fileWatcherCallbacks = ts.createMultiMap();
|
|
var dirWatchers = ts.createMap();
|
|
var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
|
|
return nonPollingWatchFile;
|
|
function nonPollingWatchFile(fileName, callback) {
|
|
var filePath = toCanonicalName(fileName);
|
|
fileWatcherCallbacks.add(filePath, callback);
|
|
var dirPath = ts.getDirectoryPath(filePath) || ".";
|
|
var watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath);
|
|
watcher.referenceCount++;
|
|
return {
|
|
close: function () {
|
|
if (watcher.referenceCount === 1) {
|
|
watcher.close();
|
|
dirWatchers.delete(dirPath);
|
|
}
|
|
else {
|
|
watcher.referenceCount--;
|
|
}
|
|
fileWatcherCallbacks.remove(filePath, callback);
|
|
}
|
|
};
|
|
}
|
|
function createDirectoryWatcher(dirName, dirPath) {
|
|
var watcher = fsWatchDirectory(dirName, function (_eventName, relativeFileName) {
|
|
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
|
|
var fileName = !ts.isString(relativeFileName)
|
|
? undefined // TODO: GH#18217
|
|
: ts.getNormalizedAbsolutePath(relativeFileName, dirName);
|
|
// Some applications save a working file via rename operations
|
|
var callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName));
|
|
if (callbacks) {
|
|
for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
|
|
var fileCallback = callbacks_1[_i];
|
|
fileCallback(fileName, FileWatcherEventKind.Changed);
|
|
}
|
|
}
|
|
});
|
|
watcher.referenceCount = 0;
|
|
dirWatchers.set(dirPath, watcher);
|
|
return watcher;
|
|
}
|
|
}
|
|
function fsWatchFile(fileName, callback, pollingInterval) {
|
|
_fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged);
|
|
var eventKind;
|
|
return {
|
|
close: function () { return _fs.unwatchFile(fileName, fileChanged); }
|
|
};
|
|
function fileChanged(curr, prev) {
|
|
// previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears)
|
|
// In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation
|
|
var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
|
|
if (+curr.mtime === 0) {
|
|
if (isPreviouslyDeleted) {
|
|
// Already deleted file, no need to callback again
|
|
return;
|
|
}
|
|
eventKind = FileWatcherEventKind.Deleted;
|
|
}
|
|
else if (isPreviouslyDeleted) {
|
|
eventKind = FileWatcherEventKind.Created;
|
|
}
|
|
// If there is no change in modified time, ignore the event
|
|
else if (+curr.mtime === +prev.mtime) {
|
|
return;
|
|
}
|
|
else {
|
|
// File changed
|
|
eventKind = FileWatcherEventKind.Changed;
|
|
}
|
|
callback(fileName, eventKind);
|
|
}
|
|
}
|
|
function createFileWatcherCallback(callback) {
|
|
return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
|
|
}
|
|
function createFsWatchCallbackForFileWatcherCallback(fileName, callback) {
|
|
return function (eventName) {
|
|
if (eventName === "rename") {
|
|
callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
|
|
}
|
|
else {
|
|
// Change
|
|
callback(fileName, FileWatcherEventKind.Changed);
|
|
}
|
|
};
|
|
}
|
|
function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback) {
|
|
return function (eventName, relativeFileName) {
|
|
// In watchDirectory we only care about adding and removing files (when event name is
|
|
// "rename"); changes made within files are handled by corresponding fileWatchers (when
|
|
// event name is "change")
|
|
if (eventName === "rename") {
|
|
// When deleting a file, the passed baseFileName is null
|
|
callback(!relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName)));
|
|
}
|
|
};
|
|
}
|
|
function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) {
|
|
var options;
|
|
/** Watcher for the file system entry depending on whether it is missing or present */
|
|
var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
|
watchMissingFileSystemEntry() :
|
|
watchPresentFileSystemEntry();
|
|
return {
|
|
close: function () {
|
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
watcher.close();
|
|
watcher = undefined;
|
|
}
|
|
};
|
|
/**
|
|
* Invoke the callback with rename and update the watcher if not closed
|
|
* @param createWatcher
|
|
*/
|
|
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
|
// Call the callback for current directory
|
|
callback("rename", "");
|
|
// If watcher is not closed, update it
|
|
if (watcher) {
|
|
watcher.close();
|
|
watcher = createWatcher();
|
|
}
|
|
}
|
|
/**
|
|
* Watch the file or directory that is currently present
|
|
* and when the watched file or directory is deleted, switch to missing file system entry watcher
|
|
*/
|
|
function watchPresentFileSystemEntry() {
|
|
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
|
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
|
if (options === undefined) {
|
|
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
|
|
options = { persistent: true, recursive: !!recursive };
|
|
}
|
|
else {
|
|
options = { persistent: true };
|
|
}
|
|
}
|
|
try {
|
|
var presentWatcher = _fs.watch(fileOrDirectory, options, callback);
|
|
// Watch the missing file or directory or error
|
|
presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
|
|
return presentWatcher;
|
|
}
|
|
catch (e) {
|
|
// Catch the exception and use polling instead
|
|
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
// so instead of throwing error, use fs.watchFile
|
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
}
|
|
}
|
|
/**
|
|
* Watch the file or directory using fs.watchFile since fs.watch threw exception
|
|
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
*/
|
|
function watchPresentFileSystemEntryWithFsWatchFile() {
|
|
return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval);
|
|
}
|
|
/**
|
|
* Watch the file or directory that is missing
|
|
* and switch to existing file or directory when the missing filesystem entry is created
|
|
*/
|
|
function watchMissingFileSystemEntry() {
|
|
return fallbackPollingWatchFile(fileOrDirectory, function (_fileName, eventKind) {
|
|
if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
// Call the callback for current file or directory
|
|
// For now it could be callback for the inner directory creation,
|
|
// but just return current directory, better than current no-op
|
|
invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
|
|
}
|
|
}, pollingInterval);
|
|
}
|
|
}
|
|
function watchFileUsingFsWatch(fileName, callback, pollingInterval) {
|
|
return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback), /*recursive*/ false, fsWatchFile, pollingInterval);
|
|
}
|
|
function createWatchFileUsingDynamicWatchFile(watchFile) {
|
|
return function (fileName, callback, pollingInterval) { return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback), /*recursive*/ false, watchFile, pollingInterval); };
|
|
}
|
|
function fsWatchDirectory(directoryName, callback, recursive) {
|
|
return fsWatch(directoryName, 1 /* Directory */, callback, !!recursive, fsWatchFile);
|
|
}
|
|
function watchDirectoryUsingFsWatch(directoryName, callback, recursive) {
|
|
return fsWatchDirectory(directoryName, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive);
|
|
}
|
|
function createWatchDirectoryUsing(fsWatchFile) {
|
|
return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); };
|
|
}
|
|
function readFile(fileName, _encoding) {
|
|
if (!fileExists(fileName)) {
|
|
return undefined;
|
|
}
|
|
var buffer = _fs.readFileSync(fileName);
|
|
var len = buffer.length;
|
|
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
|
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
|
// flip all byte pairs and treat as little endian.
|
|
len &= ~1; // Round down to a multiple of 2
|
|
for (var i = 0; i < len; i += 2) {
|
|
var temp = buffer[i];
|
|
buffer[i] = buffer[i + 1];
|
|
buffer[i + 1] = temp;
|
|
}
|
|
return buffer.toString("utf16le", 2);
|
|
}
|
|
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
|
// Little endian UTF-16 byte order mark detected
|
|
return buffer.toString("utf16le", 2);
|
|
}
|
|
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
|
// UTF-8 byte order mark detected
|
|
return buffer.toString("utf8", 3);
|
|
}
|
|
// Default is UTF-8 with no byte order mark
|
|
return buffer.toString("utf8");
|
|
}
|
|
function writeFile(fileName, data, writeByteOrderMark) {
|
|
// If a BOM is required, emit one
|
|
if (writeByteOrderMark) {
|
|
data = byteOrderMarkIndicator + data;
|
|
}
|
|
var fd;
|
|
try {
|
|
fd = _fs.openSync(fileName, "w");
|
|
_fs.writeSync(fd, data, /*position*/ undefined, "utf8");
|
|
}
|
|
finally {
|
|
if (fd !== undefined) {
|
|
_fs.closeSync(fd);
|
|
}
|
|
}
|
|
}
|
|
function getAccessibleFileSystemEntries(path) {
|
|
try {
|
|
var entries = _fs.readdirSync(path || ".").sort();
|
|
var files = [];
|
|
var directories = [];
|
|
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
var entry = entries_1[_i];
|
|
// This is necessary because on some file system node fails to exclude
|
|
// "." and "..". See https://github.com/nodejs/node/issues/4002
|
|
if (entry === "." || entry === "..") {
|
|
continue;
|
|
}
|
|
var name = ts.combinePaths(path, entry);
|
|
var stat = void 0;
|
|
try {
|
|
stat = _fs.statSync(name);
|
|
}
|
|
catch (e) {
|
|
continue;
|
|
}
|
|
if (stat.isFile()) {
|
|
files.push(entry);
|
|
}
|
|
else if (stat.isDirectory()) {
|
|
directories.push(entry);
|
|
}
|
|
}
|
|
return { files: files, directories: directories };
|
|
}
|
|
catch (e) {
|
|
return ts.emptyFileSystemEntries;
|
|
}
|
|
}
|
|
function readDirectory(path, extensions, excludes, includes, depth) {
|
|
return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries);
|
|
}
|
|
function fileSystemEntryExists(path, entryKind) {
|
|
try {
|
|
var stat = _fs.statSync(path);
|
|
switch (entryKind) {
|
|
case 0 /* File */: return stat.isFile();
|
|
case 1 /* Directory */: return stat.isDirectory();
|
|
default: return false;
|
|
}
|
|
}
|
|
catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
function fileExists(path) {
|
|
return fileSystemEntryExists(path, 0 /* File */);
|
|
}
|
|
function directoryExists(path) {
|
|
return fileSystemEntryExists(path, 1 /* Directory */);
|
|
}
|
|
function getDirectories(path) {
|
|
return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); });
|
|
}
|
|
function realpath(path) {
|
|
try {
|
|
return _fs.realpathSync(path);
|
|
}
|
|
catch (_a) {
|
|
return path;
|
|
}
|
|
}
|
|
function getModifiedTime(path) {
|
|
try {
|
|
return _fs.statSync(path).mtime;
|
|
}
|
|
catch (e) {
|
|
return undefined;
|
|
}
|
|
}
|
|
function setModifiedTime(path, time) {
|
|
try {
|
|
_fs.utimesSync(path, time, time);
|
|
}
|
|
catch (e) {
|
|
return;
|
|
}
|
|
}
|
|
function deleteFile(path) {
|
|
try {
|
|
return _fs.unlinkSync(path);
|
|
}
|
|
catch (e) {
|
|
return;
|
|
}
|
|
}
|
|
/**
|
|
* djb2 hashing algorithm
|
|
* http://www.cse.yorku.ca/~oz/hash.html
|
|
*/
|
|
function generateDjb2Hash(data) {
|
|
var chars = data.split("").map(function (str) { return str.charCodeAt(0); });
|
|
return "" + chars.reduce(function (prev, curr) { return ((prev << 5) + prev) + curr; }, 5381);
|
|
}
|
|
function createMD5HashUsingNativeCrypto(data) {
|
|
var hash = _crypto.createHash("md5");
|
|
hash.update(data);
|
|
return hash.digest("hex");
|
|
}
|
|
function createSHA256Hash(data) {
|
|
var hash = _crypto.createHash("sha256");
|
|
hash.update(data);
|
|
return hash.digest("hex");
|
|
}
|
|
}
|
|
function getChakraSystem() {
|
|
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
|
|
return {
|
|
newLine: ChakraHost.newLine || "\r\n",
|
|
args: ChakraHost.args,
|
|
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames,
|
|
write: ChakraHost.echo,
|
|
readFile: function (path, _encoding) {
|
|
// encoding is automatically handled by the implementation in ChakraHost
|
|
return ChakraHost.readFile(path);
|
|
},
|
|
writeFile: function (path, data, writeByteOrderMark) {
|
|
// If a BOM is required, emit one
|
|
if (writeByteOrderMark) {
|
|
data = byteOrderMarkIndicator + data;
|
|
}
|
|
ChakraHost.writeFile(path, data);
|
|
},
|
|
resolvePath: ChakraHost.resolvePath,
|
|
fileExists: ChakraHost.fileExists,
|
|
directoryExists: ChakraHost.directoryExists,
|
|
createDirectory: ChakraHost.createDirectory,
|
|
getExecutingFilePath: function () { return ChakraHost.executingFile; },
|
|
getCurrentDirectory: function () { return ChakraHost.currentDirectory; },
|
|
getDirectories: ChakraHost.getDirectories,
|
|
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }),
|
|
readDirectory: function (path, extensions, excludes, includes, _depth) {
|
|
var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
|
|
return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern);
|
|
},
|
|
exit: ChakraHost.quit,
|
|
realpath: realpath
|
|
};
|
|
}
|
|
function recursiveCreateDirectory(directoryPath, sys) {
|
|
var basePath = ts.getDirectoryPath(directoryPath);
|
|
var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath);
|
|
if (shouldCreateParent) {
|
|
recursiveCreateDirectory(basePath, sys);
|
|
}
|
|
if (shouldCreateParent || !sys.directoryExists(directoryPath)) {
|
|
sys.createDirectory(directoryPath);
|
|
}
|
|
}
|
|
var sys;
|
|
if (typeof ChakraHost !== "undefined") {
|
|
sys = getChakraSystem();
|
|
}
|
|
else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
|
|
// process and process.nextTick checks if current environment is node-like
|
|
// process.browser check excludes webpack and browserify
|
|
sys = getNodeSystem();
|
|
}
|
|
if (sys) {
|
|
// patch writefile to create folder before writing the file
|
|
var originalWriteFile_1 = sys.writeFile;
|
|
sys.writeFile = function (path, data, writeBom) {
|
|
var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path));
|
|
if (directoryPath && !sys.directoryExists(directoryPath)) {
|
|
recursiveCreateDirectory(directoryPath, sys);
|
|
}
|
|
originalWriteFile_1.call(sys, path, data, writeBom);
|
|
};
|
|
}
|
|
return sys;
|
|
})();
|
|
if (ts.sys && ts.sys.getEnvironmentVariable) {
|
|
setCustomPollingValues(ts.sys);
|
|
ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
|
|
? 1 /* Normal */
|
|
: 0 /* None */;
|
|
}
|
|
if (ts.sys && ts.sys.debugMode) {
|
|
ts.Debug.isDebugging = true;
|
|
}
|
|
})(ts || (ts = {}));
|
|
// <auto-generated />
|
|
// generated from './diagnosticInformationMap.generated.ts' by 'src\parser'
|
|
/* @internal */
|
|
var ts;
|
|
(function (ts) {
|
|
function diag(code, category, key, message, reportsUnnecessary) {
|
|
return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary };
|
|
}
|
|
// tslint:disable-next-line variable-name
|
|
ts.Diagnostics = {
|
|
Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
|
|
Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
|
|
_0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
|
|
A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
|
|
Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
|
|
Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
|
|
An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
|
|
Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
|
|
A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."),
|
|
A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."),
|
|
Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."),
|
|
A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."),
|
|
An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."),
|
|
An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."),
|
|
An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."),
|
|
An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."),
|
|
An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."),
|
|
An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."),
|
|
An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."),
|
|
readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."),
|
|
Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
|
|
_0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
|
|
_0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
|
|
_0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."),
|
|
super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."),
|
|
Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."),
|
|
Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."),
|
|
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."),
|
|
Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."),
|
|
_0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."),
|
|
_0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."),
|
|
_0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
|
|
_0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."),
|
|
_0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."),
|
|
A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."),
|
|
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: diag(1046, ts.DiagnosticCategory.Error, "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", "A 'declare' modifier is required for a top level declaration in a .d.ts file."),
|
|
A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
|
|
A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."),
|
|
A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."),
|
|
A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."),
|
|
A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."),
|
|
A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."),
|
|
A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
|
|
Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."),
|
|
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."),
|
|
An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."),
|
|
The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."),
|
|
A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."),
|
|
The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."),
|
|
Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
|
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise<T> type."),
|
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
_0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."),
|
|
_0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."),
|
|
A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."),
|
|
Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
|
|
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."),
|
|
An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."),
|
|
_0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."),
|
|
_0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."),
|
|
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."),
|
|
Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."),
|
|
Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."),
|
|
An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
|
|
A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."),
|
|
An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."),
|
|
_0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
|
|
Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
|
|
Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
|
|
Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."),
|
|
with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."),
|
|
delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."),
|
|
A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."),
|
|
A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."),
|
|
A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."),
|
|
Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
|
|
A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."),
|
|
Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
|
|
Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
|
|
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."),
|
|
Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
|
|
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."),
|
|
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."),
|
|
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."),
|
|
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."),
|
|
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."),
|
|
An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
|
|
Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."),
|
|
A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."),
|
|
Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
|
|
Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
|
|
Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
|
|
Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
|
|
Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
|
|
Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
|
|
Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
|
|
case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
|
|
Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
|
|
Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
|
|
Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
|
|
Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
|
|
Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
|
|
Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
|
|
Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
|
|
Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
|
|
Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
|
|
String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
|
|
Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
|
|
or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
|
|
Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
|
|
Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."),
|
|
Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."),
|
|
File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."),
|
|
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead."),
|
|
const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
|
|
const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."),
|
|
let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."),
|
|
Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
|
|
Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
|
|
An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."),
|
|
A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."),
|
|
Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."),
|
|
A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."),
|
|
A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."),
|
|
A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."),
|
|
A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."),
|
|
A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."),
|
|
A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."),
|
|
extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
|
|
extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
|
|
Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."),
|
|
implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
|
|
Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
|
|
Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
|
|
Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
|
|
Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
|
|
Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
|
|
Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
|
|
A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."),
|
|
An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."),
|
|
Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
|
|
Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
|
|
A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."),
|
|
A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."),
|
|
Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."),
|
|
The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."),
|
|
The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."),
|
|
An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
|
|
Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
|
|
An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
|
|
Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."),
|
|
Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."),
|
|
Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."),
|
|
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."),
|
|
Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
|
|
Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
|
|
Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."),
|
|
Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."),
|
|
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
|
|
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
|
|
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
|
|
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
|
|
Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: diag(1209, ts.DiagnosticCategory.Error, "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", "Ambient const enums are not allowed when the '--isolatedModules' flag is provided."),
|
|
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
|
|
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
|
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
|
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."),
|
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."),
|
|
Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."),
|
|
Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."),
|
|
Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."),
|
|
Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning."),
|
|
Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."),
|
|
Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."),
|
|
An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."),
|
|
_0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
|
|
Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."),
|
|
Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
|
|
Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."),
|
|
Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."),
|
|
A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."),
|
|
A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
|
|
A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
|
|
An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."),
|
|
An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."),
|
|
An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."),
|
|
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
|
|
A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."),
|
|
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
|
|
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
|
|
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
|
|
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."),
|
|
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."),
|
|
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."),
|
|
abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."),
|
|
_0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."),
|
|
Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."),
|
|
Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."),
|
|
An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."),
|
|
A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."),
|
|
A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."),
|
|
A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."),
|
|
Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."),
|
|
Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."),
|
|
Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."),
|
|
_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."),
|
|
A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."),
|
|
A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."),
|
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."),
|
|
can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."),
|
|
The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."),
|
|
Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."),
|
|
Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."),
|
|
Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."),
|
|
A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."),
|
|
An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."),
|
|
A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."),
|
|
Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
|
|
Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."),
|
|
Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."),
|
|
Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."),
|
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"),
|
|
String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
|
|
Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."),
|
|
_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"),
|
|
A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."),
|
|
A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."),
|
|
A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."),
|
|
unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."),
|
|
unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."),
|
|
unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."),
|
|
An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."),
|
|
An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."),
|
|
infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."),
|
|
Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
|
|
Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."),
|
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."),
|
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
|
|
Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
|
|
Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."),
|
|
File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
|
|
Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."),
|
|
Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."),
|
|
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."),
|
|
Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."),
|
|
A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."),
|
|
An_interface_may_only_extend_a_class_or_another_interface: diag(2312, ts.DiagnosticCategory.Error, "An_interface_may_only_extend_a_class_or_another_interface_2312", "An interface may only extend a class or another interface."),
|
|
Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."),
|
|
Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."),
|
|
Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
|
|
Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."),
|
|
Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."),
|
|
Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
|
|
Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."),
|
|
Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."),
|
|
Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."),
|
|
Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."),
|
|
Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
|
|
Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."),
|
|
Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."),
|
|
Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
|
|
Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."),
|
|
Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."),
|
|
Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."),
|
|
Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
|
|
this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."),
|
|
this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."),
|
|
this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."),
|
|
this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."),
|
|
super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."),
|
|
super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."),
|
|
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."),
|
|
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."),
|
|
Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."),
|
|
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."),
|
|
Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."),
|
|
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."),
|
|
This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."),
|
|
Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."),
|
|
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."),
|
|
Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."),
|
|
Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."),
|
|
Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"),
|
|
Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: diag(2349, ts.DiagnosticCategory.Error, "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatur_2349", "Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures."),
|
|
Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."),
|
|
Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: diag(2351, ts.DiagnosticCategory.Error, "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", "Cannot use 'new' with an expression whose type lacks a call or construct signature."),
|
|
Type_0_cannot_be_converted_to_type_1: diag(2352, ts.DiagnosticCategory.Error, "Type_0_cannot_be_converted_to_type_1_2352", "Type '{0}' cannot be converted to type '{1}'."),
|
|
Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
|
|
This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
|
|
A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
|
|
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."),
|
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
|
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
|
The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."),
|
|
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."),
|
|
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."),
|
|
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."),
|
|
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
|
|
Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."),
|
|
Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."),
|
|
Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
|
|
A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."),
|
|
A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."),
|
|
A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."),
|
|
Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."),
|
|
Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."),
|
|
Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
|
|
Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
|
|
A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."),
|
|
Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
|
|
A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
|
|
Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."),
|
|
get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."),
|
|
A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."),
|
|
Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."),
|
|
Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."),
|
|
Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."),
|
|
Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."),
|
|
Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."),
|
|
Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
|
|
Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
|
|
Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
|
|
Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
|
|
Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."),
|
|
Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
|
|
Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
|
|
Overload_signature_is_not_compatible_with_function_implementation: diag(2394, ts.DiagnosticCategory.Error, "Overload_signature_is_not_compatible_with_function_implementation_2394", "Overload signature is not compatible with function implementation."),
|
|
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."),
|
|
Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."),
|
|
Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."),
|
|
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
|
|
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
|
|
Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."),
|
|
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
|
|
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
|
|
The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
|
|
The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: diag(2405, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'."),
|
|
The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: diag(2406, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", "The left-hand side of a 'for...in' statement must be a variable or a property access."),
|
|
The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: diag(2407, ts.DiagnosticCategory.Error, "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407", "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'."),
|
|
Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
|
|
Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."),
|
|
The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, ts.DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."),
|
|
Property_0_of_type_1_is_not_assignable_to_string_index_type_2: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", "Property '{0}' of type '{1}' is not assignable to string index type '{2}'."),
|
|
Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: diag(2412, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'."),
|
|
Numeric_index_type_0_is_not_assignable_to_string_index_type_1: diag(2413, ts.DiagnosticCategory.Error, "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", "Numeric index type '{0}' is not assignable to string index type '{1}'."),
|
|
Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
|
|
Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."),
|
|
Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."),
|
|
Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."),
|
|
Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
|
|
A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."),
|
|
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."),
|
|
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."),
|
|
Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."),
|
|
Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."),
|
|
Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
|
|
All_declarations_of_0_must_have_identical_type_parameters: diag(2428, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_type_parameters_2428", "All declarations of '{0}' must have identical type parameters."),
|
|
Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
|
|
Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
|
|
In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: diag(2432, ts.DiagnosticCategory.Error, "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element."),
|
|
A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: diag(2433, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", "A namespace declaration cannot be in a different file from a class or function with which it is merged."),
|
|
A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: diag(2434, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", "A namespace declaration cannot be located prior to a class or function with which it is merged."),
|
|
Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: diag(2435, ts.DiagnosticCategory.Error, "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", "Ambient modules cannot be nested in other modules or namespaces."),
|
|
Ambient_module_declaration_cannot_specify_relative_module_name: diag(2436, ts.DiagnosticCategory.Error, "Ambient_module_declaration_cannot_specify_relative_module_name_2436", "Ambient module declaration cannot specify relative module name."),
|
|
Module_0_is_hidden_by_a_local_declaration_with_the_same_name: diag(2437, ts.DiagnosticCategory.Error, "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", "Module '{0}' is hidden by a local declaration with the same name."),
|
|
Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
|
|
Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: diag(2439, ts.DiagnosticCategory.Error, "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", "Import or export declaration in an ambient module declaration cannot reference module through relative module name."),
|
|
Import_declaration_conflicts_with_local_declaration_of_0: diag(2440, ts.DiagnosticCategory.Error, "Import_declaration_conflicts_with_local_declaration_of_0_2440", "Import declaration conflicts with local declaration of '{0}'."),
|
|
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: diag(2441, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module."),
|
|
Types_have_separate_declarations_of_a_private_property_0: diag(2442, ts.DiagnosticCategory.Error, "Types_have_separate_declarations_of_a_private_property_0_2442", "Types have separate declarations of a private property '{0}'."),
|
|
Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."),
|
|
Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."),
|
|
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."),
|
|
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."),
|
|
The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."),
|
|
Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."),
|
|
Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
|
|
Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
|
|
Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
|
|
An_enum_member_cannot_have_a_numeric_name: diag(2452, ts.DiagnosticCategory.Error, "An_enum_member_cannot_have_a_numeric_name_2452", "An enum member cannot have a numeric name."),
|
|
The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: diag(2453, ts.DiagnosticCategory.Error, "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly."),
|
|
Variable_0_is_used_before_being_assigned: diag(2454, ts.DiagnosticCategory.Error, "Variable_0_is_used_before_being_assigned_2454", "Variable '{0}' is used before being assigned."),
|
|
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: diag(2455, ts.DiagnosticCategory.Error, "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'."),
|
|
Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
|
|
Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
|
|
An_AMD_module_cannot_have_multiple_name_assignments: diag(2458, ts.DiagnosticCategory.Error, "An_AMD_module_cannot_have_multiple_name_assignments_2458", "An AMD module cannot have multiple name assignments."),
|
|
Type_0_has_no_property_1_and_no_string_index_signature: diag(2459, ts.DiagnosticCategory.Error, "Type_0_has_no_property_1_and_no_string_index_signature_2459", "Type '{0}' has no property '{1}' and no string index signature."),
|
|
Type_0_has_no_property_1: diag(2460, ts.DiagnosticCategory.Error, "Type_0_has_no_property_1_2460", "Type '{0}' has no property '{1}'."),
|
|
Type_0_is_not_an_array_type: diag(2461, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_2461", "Type '{0}' is not an array type."),
|
|
A_rest_element_must_be_last_in_a_destructuring_pattern: diag(2462, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", "A rest element must be last in a destructuring pattern."),
|
|
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: diag(2463, ts.DiagnosticCategory.Error, "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", "A binding pattern parameter cannot be optional in an implementation signature."),
|
|
A_computed_property_name_must_be_of_type_string_number_symbol_or_any: diag(2464, ts.DiagnosticCategory.Error, "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", "A computed property name must be of type 'string', 'number', 'symbol', or 'any'."),
|
|
this_cannot_be_referenced_in_a_computed_property_name: diag(2465, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_computed_property_name_2465", "'this' cannot be referenced in a computed property name."),
|
|
super_cannot_be_referenced_in_a_computed_property_name: diag(2466, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_a_computed_property_name_2466", "'super' cannot be referenced in a computed property name."),
|
|
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: diag(2467, ts.DiagnosticCategory.Error, "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", "A computed property name cannot reference a type parameter from its containing type."),
|
|
Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
|
|
The_0_operator_cannot_be_applied_to_type_symbol: diag(2469, ts.DiagnosticCategory.Error, "The_0_operator_cannot_be_applied_to_type_symbol_2469", "The '{0}' operator cannot be applied to type 'symbol'."),
|
|
Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: diag(2470, ts.DiagnosticCategory.Error, "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", "'Symbol' reference does not refer to the global Symbol constructor object."),
|
|
A_computed_property_name_of_the_form_0_must_be_of_type_symbol: diag(2471, ts.DiagnosticCategory.Error, "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", "A computed property name of the form '{0}' must be of type 'symbol'."),
|
|
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: diag(2472, ts.DiagnosticCategory.Error, "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher."),
|
|
Enum_declarations_must_all_be_const_or_non_const: diag(2473, ts.DiagnosticCategory.Error, "Enum_declarations_must_all_be_const_or_non_const_2473", "Enum declarations must all be const or non-const."),
|
|
In_const_enum_declarations_member_initializer_must_be_constant_expression: diag(2474, ts.DiagnosticCategory.Error, "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", "In 'const' enum declarations member initializer must be constant expression."),
|
|
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query: diag(2475, ts.DiagnosticCategory.Error, "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query."),
|
|
A_const_enum_member_can_only_be_accessed_using_a_string_literal: diag(2476, ts.DiagnosticCategory.Error, "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", "A const enum member can only be accessed using a string literal."),
|
|
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: diag(2477, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", "'const' enum member initializer was evaluated to a non-finite value."),
|
|
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: diag(2478, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", "'const' enum member initializer was evaluated to disallowed value 'NaN'."),
|
|
Property_0_does_not_exist_on_const_enum_1: diag(2479, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_const_enum_1_2479", "Property '{0}' does not exist on 'const' enum '{1}'."),
|
|
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: diag(2480, ts.DiagnosticCategory.Error, "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", "'let' is not allowed to be used as a name in 'let' or 'const' declarations."),
|
|
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: diag(2481, ts.DiagnosticCategory.Error, "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'."),
|
|
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: diag(2483, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", "The left-hand side of a 'for...of' statement cannot use a type annotation."),
|
|
Export_declaration_conflicts_with_exported_declaration_of_0: diag(2484, ts.DiagnosticCategory.Error, "Export_declaration_conflicts_with_exported_declaration_of_0_2484", "Export declaration conflicts with exported declaration of '{0}'."),
|
|
The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: diag(2487, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", "The left-hand side of a 'for...of' statement must be a variable or a property access."),
|
|
Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2488, ts.DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", "Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator."),
|
|
An_iterator_must_have_a_next_method: diag(2489, ts.DiagnosticCategory.Error, "An_iterator_must_have_a_next_method_2489", "An iterator must have a 'next()' method."),
|
|
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: diag(2490, ts.DiagnosticCategory.Error, "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", "The type returned by the 'next()' method of an iterator must have a 'value' property."),
|
|
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: diag(2491, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", "The left-hand side of a 'for...in' statement cannot be a destructuring pattern."),
|
|
Cannot_redeclare_identifier_0_in_catch_clause: diag(2492, ts.DiagnosticCategory.Error, "Cannot_redeclare_identifier_0_in_catch_clause_2492", "Cannot redeclare identifier '{0}' in catch clause."),
|
|
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: diag(2493, ts.DiagnosticCategory.Error, "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'."),
|
|
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: diag(2494, ts.DiagnosticCategory.Error, "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher."),
|
|
Type_0_is_not_an_array_type_or_a_string_type: diag(2495, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_2495", "Type '{0}' is not an array type or a string type."),
|
|
The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: diag(2496, ts.DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression."),
|
|
Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: diag(2497, ts.DiagnosticCategory.Error, "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", "Module '{0}' resolves to a non-module entity and cannot be imported using this construct."),
|
|
Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: diag(2498, ts.DiagnosticCategory.Error, "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", "Module '{0}' uses 'export =' and cannot be used with 'export *'."),
|
|
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2499, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", "An interface can only extend an identifier/qualified-name with optional type arguments."),
|
|
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2500, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", "A class can only implement an identifier/qualified-name with optional type arguments."),
|
|
A_rest_element_cannot_contain_a_binding_pattern: diag(2501, ts.DiagnosticCategory.Error, "A_rest_element_cannot_contain_a_binding_pattern_2501", "A rest element cannot contain a binding pattern."),
|
|
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: diag(2502, ts.DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", "'{0}' is referenced directly or indirectly in its own type annotation."),
|
|
Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
|
|
Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: diag(2504, ts.DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", "Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator."),
|
|
A_generator_cannot_have_a_void_type_annotation: diag(2505, ts.DiagnosticCategory.Error, "A_generator_cannot_have_a_void_type_annotation_2505", "A generator cannot have a 'void' type annotation."),
|
|
_0_is_referenced_directly_or_indirectly_in_its_own_base_expression: diag(2506, ts.DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", "'{0}' is referenced directly or indirectly in its own base expression."),
|
|
Type_0_is_not_a_constructor_function_type: diag(2507, ts.DiagnosticCategory.Error, "Type_0_is_not_a_constructor_function_type_2507", "Type '{0}' is not a constructor function type."),
|
|
No_base_constructor_has_the_specified_number_of_type_arguments: diag(2508, ts.DiagnosticCategory.Error, "No_base_constructor_has_the_specified_number_of_type_arguments_2508", "No base constructor has the specified number of type arguments."),
|
|
Base_constructor_return_type_0_is_not_a_class_or_interface_type: diag(2509, ts.DiagnosticCategory.Error, "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", "Base constructor return type '{0}' is not a class or interface type."),
|
|
Base_constructors_must_all_have_the_same_return_type: diag(2510, ts.DiagnosticCategory.Error, "Base_constructors_must_all_have_the_same_return_type_2510", "Base constructors must all have the same return type."),
|
|
Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
|
|
Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
|
|
Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
|
|
Classes_containing_abstract_methods_must_be_marked_abstract: diag(2514, ts.DiagnosticCategory.Error, "Classes_containing_abstract_methods_must_be_marked_abstract_2514", "Classes containing abstract methods must be marked abstract."),
|
|
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
|
|
All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
|
|
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
|
|
A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: diag(2518, ts.DiagnosticCategory.Error, "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", "A 'this'-based type guard is not compatible with a parameter-based type guard."),
|
|
An_async_iterator_must_have_a_next_method: diag(2519, ts.DiagnosticCategory.Error, "An_async_iterator_must_have_a_next_method_2519", "An async iterator must have a 'next()' method."),
|
|
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: diag(2520, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions."),
|
|
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: diag(2521, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", "Expression resolves to variable declaration '{0}' that compiler uses to support async functions."),
|
|
The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: diag(2522, ts.DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method."),
|
|
yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, ts.DiagnosticCategory.Error, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."),
|
|
await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, ts.DiagnosticCategory.Error, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."),
|
|
Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: diag(2525, ts.DiagnosticCategory.Error, "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", "Initializer provides no value for this binding element and the binding element has no default value."),
|
|
A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: diag(2526, ts.DiagnosticCategory.Error, "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", "A 'this' type is available only in a non-static member of a class or interface."),
|
|
The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: diag(2527, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527", "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary."),
|
|
A_module_cannot_have_multiple_default_exports: diag(2528, ts.DiagnosticCategory.Error, "A_module_cannot_have_multiple_default_exports_2528", "A module cannot have multiple default exports."),
|
|
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: diag(2529, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions."),
|
|
Property_0_is_incompatible_with_index_signature: diag(2530, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_index_signature_2530", "Property '{0}' is incompatible with index signature."),
|
|
Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
|
|
Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
|
|
Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
|
|
A_function_returning_never_cannot_have_a_reachable_end_point: diag(2534, ts.DiagnosticCategory.Error, "A_function_returning_never_cannot_have_a_reachable_end_point_2534", "A function returning 'never' cannot have a reachable end point."),
|
|
Enum_type_0_has_members_with_initializers_that_are_not_literals: diag(2535, ts.DiagnosticCategory.Error, "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", "Enum type '{0}' has members with initializers that are not literals."),
|
|
Type_0_cannot_be_used_to_index_type_1: diag(2536, ts.DiagnosticCategory.Error, "Type_0_cannot_be_used_to_index_type_1_2536", "Type '{0}' cannot be used to index type '{1}'."),
|
|
Type_0_has_no_matching_index_signature_for_type_1: diag(2537, ts.DiagnosticCategory.Error, "Type_0_has_no_matching_index_signature_for_type_1_2537", "Type '{0}' has no matching index signature for type '{1}'."),
|
|
Type_0_cannot_be_used_as_an_index_type: diag(2538, ts.DiagnosticCategory.Error, "Type_0_cannot_be_used_as_an_index_type_2538", "Type '{0}' cannot be used as an index type."),
|
|
Cannot_assign_to_0_because_it_is_not_a_variable: diag(2539, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_not_a_variable_2539", "Cannot assign to '{0}' because it is not a variable."),
|
|
Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: diag(2540, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", "Cannot assign to '{0}' because it is a constant or a read-only property."),
|
|
The_target_of_an_assignment_must_be_a_variable_or_a_property_access: diag(2541, ts.DiagnosticCategory.Error, "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", "The target of an assignment must be a variable or a property access."),
|
|
Index_signature_in_type_0_only_permits_reading: diag(2542, ts.DiagnosticCategory.Error, "Index_signature_in_type_0_only_permits_reading_2542", "Index signature in type '{0}' only permits reading."),
|
|
Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: diag(2543, ts.DiagnosticCategory.Error, "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference."),
|
|
Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: diag(2544, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference."),
|
|
A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: diag(2545, ts.DiagnosticCategory.Error, "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", "A mixin class must have a constructor with a single rest parameter of type 'any[]'."),
|
|
Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: diag(2546, ts.DiagnosticCategory.Error, "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'."),
|
|
The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property."),
|
|
Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."),
|
|
Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."),
|
|
Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2550, ts.DiagnosticCategory.Error, "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", "Generic type instantiation is excessively deep and possibly infinite."),
|
|
Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"),
|
|
Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"),
|
|
Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."),
|
|
Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
|
|
Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."),
|
|
Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."),
|
|
Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."),
|
|
Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."),
|
|
Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."),
|
|
Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"),
|
|
Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"),
|
|
Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."),
|
|
The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."),
|
|
Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: diag(2564, ts.DiagnosticCategory.Error, "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564", "Property '{0}' has no initializer and is not definitely assigned in the constructor."),
|
|
Property_0_is_used_before_being_assigned: diag(2565, ts.DiagnosticCategory.Error, "Property_0_is_used_before_being_assigned_2565", "Property '{0}' is used before being assigned."),
|
|
A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."),
|
|
Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."),
|
|
Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."),
|
|
Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."),
|
|
Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"),
|
|
Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
|
|
JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."),
|
|
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."),
|
|
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."),
|
|
Property_0_in_type_1_is_not_assignable_to_type_2: diag(2603, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_type_2_2603", "Property '{0}' in type '{1}' is not assignable to type '{2}'."),
|
|
JSX_element_type_0_does_not_have_any_construct_or_call_signatures: diag(2604, ts.DiagnosticCategory.Error, "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", "JSX element type '{0}' does not have any construct or call signatures."),
|
|
JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: diag(2605, ts.DiagnosticCategory.Error, "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", "JSX element type '{0}' is not a constructor function for JSX elements."),
|
|
Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: diag(2606, ts.DiagnosticCategory.Error, "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", "Property '{0}' of JSX spread attribute is not assignable to target property."),
|
|
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."),
|
|
The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."),
|
|
JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."),
|
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: diag(2653, ts.DiagnosticCategory.Error, "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'."),
|
|
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: diag(2654, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition."),
|
|
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: diag(2656, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition."),
|
|
JSX_expressions_must_have_one_parent_element: diag(2657, ts.DiagnosticCategory.Error, "JSX_expressions_must_have_one_parent_element_2657", "JSX expressions must have one parent element."),
|
|
Type_0_provides_no_match_for_the_signature_1: diag(2658, ts.DiagnosticCategory.Error, "Type_0_provides_no_match_for_the_signature_1_2658", "Type '{0}' provides no match for the signature '{1}'."),
|
|
super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: diag(2659, ts.DiagnosticCategory.Error, "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher."),
|
|
super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: diag(2660, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", "'super' can only be referenced in members of derived classes or object literal expressions."),
|
|
Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: diag(2661, ts.DiagnosticCategory.Error, "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", "Cannot export '{0}'. Only local declarations can be exported from a module."),
|
|
Cannot_find_name_0_Did_you_mean_the_static_member_1_0: diag(2662, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?"),
|
|
Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: diag(2663, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?"),
|
|
Invalid_module_name_in_augmentation_module_0_cannot_be_found: diag(2664, ts.DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", "Invalid module name in augmentation, module '{0}' cannot be found."),
|
|
Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: diag(2665, ts.DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented."),
|
|
Exports_and_export_assignments_are_not_permitted_in_module_augmentations: diag(2666, ts.DiagnosticCategory.Error, "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", "Exports and export assignments are not permitted in module augmentations."),
|
|
Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: diag(2667, ts.DiagnosticCategory.Error, "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module."),
|
|
export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: diag(2668, ts.DiagnosticCategory.Error, "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible."),
|
|
Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: diag(2669, ts.DiagnosticCategory.Error, "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations."),
|
|
Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: diag(2670, ts.DiagnosticCategory.Error, "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context."),
|
|
Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: diag(2671, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", "Cannot augment module '{0}' because it resolves to a non-module entity."),
|
|
Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: diag(2672, ts.DiagnosticCategory.Error, "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", "Cannot assign a '{0}' constructor type to a '{1}' constructor type."),
|
|
Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: diag(2673, ts.DiagnosticCategory.Error, "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", "Constructor of class '{0}' is private and only accessible within the class declaration."),
|
|
Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: diag(2674, ts.DiagnosticCategory.Error, "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", "Constructor of class '{0}' is protected and only accessible within the class declaration."),
|
|
Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: diag(2675, ts.DiagnosticCategory.Error, "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", "Cannot extend a class '{0}'. Class constructor is marked as private."),
|
|
Accessors_must_both_be_abstract_or_non_abstract: diag(2676, ts.DiagnosticCategory.Error, "Accessors_must_both_be_abstract_or_non_abstract_2676", "Accessors must both be abstract or non-abstract."),
|
|
A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: diag(2677, ts.DiagnosticCategory.Error, "A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type_2677", "A type predicate's type must be assignable to its parameter's type."),
|
|
Type_0_is_not_comparable_to_type_1: diag(2678, ts.DiagnosticCategory.Error, "Type_0_is_not_comparable_to_type_1_2678", "Type '{0}' is not comparable to type '{1}'."),
|
|
A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: diag(2679, ts.DiagnosticCategory.Error, "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679", "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'."),
|
|
A_0_parameter_must_be_the_first_parameter: diag(2680, ts.DiagnosticCategory.Error, "A_0_parameter_must_be_the_first_parameter_2680", "A '{0}' parameter must be the first parameter."),
|
|
A_constructor_cannot_have_a_this_parameter: diag(2681, ts.DiagnosticCategory.Error, "A_constructor_cannot_have_a_this_parameter_2681", "A constructor cannot have a 'this' parameter."),
|
|
get_and_set_accessor_must_have_the_same_this_type: diag(2682, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_this_type_2682", "'get' and 'set' accessor must have the same 'this' type."),
|
|
this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: diag(2683, ts.DiagnosticCategory.Error, "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", "'this' implicitly has type 'any' because it does not have a type annotation."),
|
|
The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: diag(2684, ts.DiagnosticCategory.Error, "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'."),
|
|
The_this_types_of_each_signature_are_incompatible: diag(2685, ts.DiagnosticCategory.Error, "The_this_types_of_each_signature_are_incompatible_2685", "The 'this' types of each signature are incompatible."),
|
|
_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: diag(2686, ts.DiagnosticCategory.Error, "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead."),
|
|
All_declarations_of_0_must_have_identical_modifiers: diag(2687, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_modifiers_2687", "All declarations of '{0}' must have identical modifiers."),
|
|
Cannot_find_type_definition_file_for_0: diag(2688, ts.DiagnosticCategory.Error, "Cannot_find_type_definition_file_for_0_2688", "Cannot find type definition file for '{0}'."),
|
|
Cannot_extend_an_interface_0_Did_you_mean_implements: diag(2689, ts.DiagnosticCategory.Error, "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", "Cannot extend an interface '{0}'. Did you mean 'implements'?"),
|
|
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: diag(2691, ts.DiagnosticCategory.Error, "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead."),
|
|
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."),
|
|
_0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."),
|
|
Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."),
|
|
Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true),
|
|
The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"),
|
|
An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."),
|
|
Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."),
|
|
Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."),
|
|
Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."),
|
|
The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: diag(2701, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", "The target of an object rest assignment must be a variable or a property access."),
|
|
_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."),
|
|
The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a delete operator must be a property reference."),
|
|
The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a delete operator cannot be a read-only property."),
|
|
An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."),
|
|
Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."),
|
|
Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."),
|
|
Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."),
|
|
Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."),
|
|
_0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."),
|
|
A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."),
|
|
A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."),
|
|
Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"),
|
|
The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."),
|
|
Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."),
|
|
Type_parameter_0_has_a_circular_default: diag(2716, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_default_2716", "Type parameter '{0}' has a circular default."),
|
|
Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2: diag(2717, ts.DiagnosticCategory.Error, "Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_t_2717", "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'."),
|
|
Duplicate_declaration_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_declaration_0_2718", "Duplicate declaration '{0}'."),
|
|
Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: diag(2719, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_2719", "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated."),
|
|
Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass: diag(2720, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720", "Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?"),
|
|
Cannot_invoke_an_object_which_is_possibly_null: diag(2721, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_2721", "Cannot invoke an object which is possibly 'null'."),
|
|
Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."),
|
|
Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."),
|
|
Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"),
|
|
Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."),
|
|
Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
|
|
Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"),
|
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4006, ts.DiagnosticCategory.Error, "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."),
|
|
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4008, ts.DiagnosticCategory.Error, "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'."),
|
|
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4010, ts.DiagnosticCategory.Error, "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'."),
|
|
Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4012, ts.DiagnosticCategory.Error, "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", "Type parameter '{0}' of public method from exported class has or is using private name '{1}'."),
|
|
Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4014, ts.DiagnosticCategory.Error, "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", "Type parameter '{0}' of method from exported interface has or is using private name '{1}'."),
|
|
Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4016, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", "Type parameter '{0}' of exported function has or is using private name '{1}'."),
|
|
Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4019, ts.DiagnosticCategory.Error, "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", "Implements clause of exported class '{0}' has or is using private name '{1}'."),
|
|
extends_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4020, ts.DiagnosticCategory.Error, "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", "'extends' clause of exported class '{0}' has or is using private name '{1}'."),
|
|
extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: diag(4022, ts.DiagnosticCategory.Error, "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", "'extends' clause of exported interface '{0}' has or is using private name '{1}'."),
|
|
Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4023, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Exported_variable_0_has_or_is_using_name_1_from_private_module_2: diag(4024, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", "Exported variable '{0}' has or is using name '{1}' from private module '{2}'."),
|
|
Exported_variable_0_has_or_is_using_private_name_1: diag(4025, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_private_name_1_4025", "Exported variable '{0}' has or is using private name '{1}'."),
|
|
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4026, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4027, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
|
|
Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4028, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", "Public static property '{0}' of exported class has or is using private name '{1}'."),
|
|
Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4029, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4030, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
|
|
Public_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4031, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", "Public property '{0}' of exported class has or is using private name '{1}'."),
|
|
Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4032, ts.DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Property_0_of_exported_interface_has_or_is_using_private_name_1: diag(4033, ts.DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", "Property '{0}' of exported interface has or is using private name '{1}'."),
|
|
Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4034, ts.DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_mod_4034", "Parameter type of public static setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4035, ts.DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1_4035", "Parameter type of public static setter '{0}' from exported class has or is using private name '{1}'."),
|
|
Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4036, ts.DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4036", "Parameter type of public setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4037, ts.DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1_4037", "Parameter type of public setter '{0}' from exported class has or is using private name '{1}'."),
|
|
Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4038, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_modul_4038", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4039, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_4039", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4040, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1_4040", "Return type of public static getter '{0}' from exported class has or is using private name '{1}'."),
|
|
Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4041, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_4041", "Return type of public getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4042, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4042", "Return type of public getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4043, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1_4043", "Return type of public getter '{0}' from exported class has or is using private name '{1}'."),
|
|
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4044, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4045, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", "Return type of constructor signature from exported interface has or is using private name '{0}'."),
|
|
Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4046, ts.DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4047, ts.DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", "Return type of call signature from exported interface has or is using private name '{0}'."),
|
|
Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4048, ts.DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4049, ts.DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", "Return type of index signature from exported interface has or is using private name '{0}'."),
|
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4050, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named."),
|
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4051, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: diag(4052, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", "Return type of public static method from exported class has or is using private name '{0}'."),
|
|
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4053, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named."),
|
|
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4054, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", "Return type of public method from exported class has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: diag(4055, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", "Return type of public method from exported class has or is using private name '{0}'."),
|
|
Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4056, ts.DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", "Return type of method from exported interface has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: diag(4057, ts.DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", "Return type of method from exported interface has or is using private name '{0}'."),
|
|
Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4058, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named."),
|
|
Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: diag(4059, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", "Return type of exported function has or is using name '{0}' from private module '{1}'."),
|
|
Return_type_of_exported_function_has_or_is_using_private_name_0: diag(4060, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", "Return type of exported function has or is using private name '{0}'."),
|
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4061, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4062, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: diag(4063, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", "Parameter '{0}' of constructor from exported class has or is using private name '{1}'."),
|
|
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4064, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4065, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."),
|
|
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4066, ts.DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4067, ts.DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'."),
|
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4068, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4069, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4070, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", "Parameter '{0}' of public static method from exported class has or is using private name '{1}'."),
|
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4071, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4072, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4073, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", "Parameter '{0}' of public method from exported class has or is using private name '{1}'."),
|
|
Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4074, ts.DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4075, ts.DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", "Parameter '{0}' of method from exported interface has or is using private name '{1}'."),
|
|
Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4076, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: diag(4077, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4078, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", "Parameter '{0}' of exported function has or is using private name '{1}'."),
|
|
Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."),
|
|
Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."),
|
|
Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
|
|
Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
|
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
|
|
Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, ts.DiagnosticCategory.Error, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
|
|
Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4095, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095", "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4096, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096", "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
|
|
Public_static_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4097, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097", "Public static method '{0}' of exported class has or is using private name '{1}'."),
|
|
Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4098, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4098", "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
|
|
Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4099, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4099", "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
|
|
Public_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4100, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_private_name_1_4100", "Public method '{0}' of exported class has or is using private name '{1}'."),
|
|
Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4101, ts.DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101", "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'."),
|
|
Method_0_of_exported_interface_has_or_is_using_private_name_1: diag(4102, ts.DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102", "Method '{0}' of exported interface has or is using private name '{1}'."),
|
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
|
|
Failed_to_parse_file_0_Colon_1: diag(5014, ts.DiagnosticCategory.Error, "Failed_to_parse_file_0_Colon_1_5014", "Failed to parse file '{0}': {1}."),
|
|
Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
|
|
Compiler_option_0_requires_a_value_of_type_1: diag(5024, ts.DiagnosticCategory.Error, "Compiler_option_0_requires_a_value_of_type_1_5024", "Compiler option '{0}' requires a value of type {1}."),
|
|
Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."),
|
|
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."),
|
|
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."),
|
|
Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."),
|
|
Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."),
|
|
Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."),
|
|
A_tsconfig_json_file_is_already_defined_at_Colon_0: diag(5054, ts.DiagnosticCategory.Error, "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", "A 'tsconfig.json' file is already defined at: '{0}'."),
|
|
Cannot_write_file_0_because_it_would_overwrite_input_file: diag(5055, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", "Cannot write file '{0}' because it would overwrite input file."),
|
|
Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: diag(5056, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", "Cannot write file '{0}' because it would be overwritten by multiple input files."),
|
|
Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: diag(5057, ts.DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", "Cannot find a tsconfig.json file at the specified directory: '{0}'."),
|
|
The_specified_path_does_not_exist_Colon_0: diag(5058, ts.DiagnosticCategory.Error, "The_specified_path_does_not_exist_Colon_0_5058", "The specified path does not exist: '{0}'."),
|
|
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
|
|
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
|
|
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
|
|
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
|
|
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
|
|
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
|
|
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
|
|
Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: diag(5066, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", "Substitutions for pattern '{0}' shouldn't be an empty array."),
|
|
Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(5067, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name."),
|
|
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: diag(5068, ts.DiagnosticCategory.Error, "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068", "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig."),
|
|
Option_0_cannot_be_specified_without_specifying_option_1_or_option_2: diag(5069, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069", "Option '{0}' cannot be specified without specifying option '{1}' or option '{2}'."),
|
|
Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy: diag(5070, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy_5070", "Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy."),
|
|
Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."),
|
|
Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."),
|
|
Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
|
|
Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6003, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", "Specify the location where debugger should locate map files instead of generated locations."),
|
|
Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: diag(6004, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", "Specify the location where debugger should locate TypeScript files instead of source locations."),
|
|
Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
|
|
Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
|
|
Do_not_erase_const_enum_declarations_in_generated_code: diag(6007, ts.DiagnosticCategory.Message, "Do_not_erase_const_enum_declarations_in_generated_code_6007", "Do not erase const enum declarations in generated code."),
|
|
Do_not_emit_outputs_if_any_errors_were_reported: diag(6008, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_if_any_errors_were_reported_6008", "Do not emit outputs if any errors were reported."),
|
|
Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
|
|
Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
|
|
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."),
|
|
Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
|
|
Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."),
|
|
Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
|
|
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'."),
|
|
Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."),
|
|
Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
|
|
Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
|
|
Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."),
|
|
Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
|
|
options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
|
|
file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
|
|
Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
|
|
Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
|
|
Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
|
|
Insert_command_line_options_and_files_from_a_file: diag(6030, ts.DiagnosticCategory.Message, "Insert_command_line_options_and_files_from_a_file_6030", "Insert command line options and files from a file."),
|
|
Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
|
|
File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
|
|
KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
|
|
FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
|
|
VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
|
|
LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
|
|
DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
|
|
STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
|
|
FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
|
|
Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
|
|
Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
|
|
Unterminated_quoted_string_in_response_file_0: diag(6045, ts.DiagnosticCategory.Error, "Unterminated_quoted_string_in_response_file_0_6045", "Unterminated quoted string in response file '{0}'."),
|
|
Argument_for_0_option_must_be_Colon_1: diag(6046, ts.DiagnosticCategory.Error, "Argument_for_0_option_must_be_Colon_1_6046", "Argument for '{0}' option must be: {1}."),
|
|
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: diag(6048, ts.DiagnosticCategory.Error, "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'."),
|
|
Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
|
|
Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
|
|
Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
|
|
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: diag(6052, ts.DiagnosticCategory.Message, "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", "Raise error on expressions and declarations with an implied 'any' type."),
|
|
File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
|
|
File_0_has_unsupported_extension_The_only_supported_extensions_are_1: diag(6054, ts.DiagnosticCategory.Error, "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", "File '{0}' has unsupported extension. The only supported extensions are {1}."),
|
|
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: diag(6055, ts.DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", "Suppress noImplicitAny errors for indexing objects lacking index signatures."),
|
|
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: diag(6056, ts.DiagnosticCategory.Message, "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", "Do not emit declarations for code that has an '@internal' annotation."),
|
|
Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: diag(6058, ts.DiagnosticCategory.Message, "Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir_6058", "Specify the root directory of input files. Use to control the output directory structure with --outDir."),
|
|
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."),
|
|
Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."),
|
|
NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
|
|
Option_0_can_only_be_specified_in_tsconfig_json_file: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", "Option '{0}' can only be specified in 'tsconfig.json' file."),
|
|
Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
|
|
Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."),
|
|
Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."),
|
|
Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: diag(6069, ts.DiagnosticCategory.Message, "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)."),
|
|
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: diag(6070, ts.DiagnosticCategory.Message, "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", "Initializes a TypeScript project and creates a tsconfig.json file."),
|
|
Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
|
|
Suppress_excess_property_checks_for_object_literals: diag(6072, ts.DiagnosticCategory.Message, "Suppress_excess_property_checks_for_object_literals_6072", "Suppress excess property checks for object literals."),
|
|
Stylize_errors_and_messages_using_color_and_context_experimental: diag(6073, ts.DiagnosticCategory.Message, "Stylize_errors_and_messages_using_color_and_context_experimental_6073", "Stylize errors and messages using color and context (experimental)."),
|
|
Do_not_report_errors_on_unused_labels: diag(6074, ts.DiagnosticCategory.Message, "Do_not_report_errors_on_unused_labels_6074", "Do not report errors on unused labels."),
|
|
Report_error_when_not_all_code_paths_in_function_return_a_value: diag(6075, ts.DiagnosticCategory.Message, "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", "Report error when not all code paths in function return a value."),
|
|
Report_errors_for_fallthrough_cases_in_switch_statement: diag(6076, ts.DiagnosticCategory.Message, "Report_errors_for_fallthrough_cases_in_switch_statement_6076", "Report errors for fallthrough cases in switch statement."),
|
|
Do_not_report_errors_on_unreachable_code: diag(6077, ts.DiagnosticCategory.Message, "Do_not_report_errors_on_unreachable_code_6077", "Do not report errors on unreachable code."),
|
|
Disallow_inconsistently_cased_references_to_the_same_file: diag(6078, ts.DiagnosticCategory.Message, "Disallow_inconsistently_cased_references_to_the_same_file_6078", "Disallow inconsistently-cased references to the same file."),
|
|
Specify_library_files_to_be_included_in_the_compilation: diag(6079, ts.DiagnosticCategory.Message, "Specify_library_files_to_be_included_in_the_compilation_6079", "Specify library files to be included in the compilation."),
|
|
Specify_JSX_code_generation_Colon_preserve_react_native_or_react: diag(6080, ts.DiagnosticCategory.Message, "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", "Specify JSX code generation: 'preserve', 'react-native', or 'react'."),
|
|
File_0_has_an_unsupported_extension_so_skipping_it: diag(6081, ts.DiagnosticCategory.Message, "File_0_has_an_unsupported_extension_so_skipping_it_6081", "File '{0}' has an unsupported extension, so skipping it."),
|
|
Only_amd_and_system_modules_are_supported_alongside_0: diag(6082, ts.DiagnosticCategory.Error, "Only_amd_and_system_modules_are_supported_alongside_0_6082", "Only 'amd' and 'system' modules are supported alongside --{0}."),
|
|
Base_directory_to_resolve_non_absolute_module_names: diag(6083, ts.DiagnosticCategory.Message, "Base_directory_to_resolve_non_absolute_module_names_6083", "Base directory to resolve non-absolute module names."),
|
|
Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: diag(6084, ts.DiagnosticCategory.Message, "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit"),
|
|
Enable_tracing_of_the_name_resolution_process: diag(6085, ts.DiagnosticCategory.Message, "Enable_tracing_of_the_name_resolution_process_6085", "Enable tracing of the name resolution process."),
|
|
Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
|
|
Explicitly_specified_module_resolution_kind_Colon_0: diag(6087, ts.DiagnosticCategory.Message, "Explicitly_specified_module_resolution_kind_Colon_0_6087", "Explicitly specified module resolution kind: '{0}'."),
|
|
Module_resolution_kind_is_not_specified_using_0: diag(6088, ts.DiagnosticCategory.Message, "Module_resolution_kind_is_not_specified_using_0_6088", "Module resolution kind is not specified, using '{0}'."),
|
|
Module_name_0_was_successfully_resolved_to_1: diag(6089, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_6089", "======== Module name '{0}' was successfully resolved to '{1}'. ========"),
|
|
Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
|
|
paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: diag(6091, ts.DiagnosticCategory.Message, "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", "'paths' option is specified, looking for a pattern to match module name '{0}'."),
|
|
Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
|
|
Trying_substitution_0_candidate_module_location_Colon_1: diag(6093, ts.DiagnosticCategory.Message, "Trying_substitution_0_candidate_module_location_Colon_1_6093", "Trying substitution '{0}', candidate module location: '{1}'."),
|
|
Resolving_module_name_0_relative_to_base_url_1_2: diag(6094, ts.DiagnosticCategory.Message, "Resolving_module_name_0_relative_to_base_url_1_2_6094", "Resolving module name '{0}' relative to base url '{1}' - '{2}'."),
|
|
Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: diag(6095, ts.DiagnosticCategory.Message, "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", "Loading module as file / folder, candidate module location '{0}', target file type '{1}'."),
|
|
File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
|
|
File_0_exist_use_it_as_a_name_resolution_result: diag(6097, ts.DiagnosticCategory.Message, "File_0_exist_use_it_as_a_name_resolution_result_6097", "File '{0}' exist - use it as a name resolution result."),
|
|
Loading_module_0_from_node_modules_folder_target_file_type_1: diag(6098, ts.DiagnosticCategory.Message, "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", "Loading module '{0}' from 'node_modules' folder, target file type '{1}'."),
|
|
Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
|
|
package_json_does_not_have_a_0_field: diag(6100, ts.DiagnosticCategory.Message, "package_json_does_not_have_a_0_field_6100", "'package.json' does not have a '{0}' field."),
|
|
package_json_has_0_field_1_that_references_2: diag(6101, ts.DiagnosticCategory.Message, "package_json_has_0_field_1_that_references_2_6101", "'package.json' has '{0}' field '{1}' that references '{2}'."),
|
|
Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
|
|
Option_0_should_have_array_of_strings_as_a_value: diag(6103, ts.DiagnosticCategory.Error, "Option_0_should_have_array_of_strings_as_a_value_6103", "Option '{0}' should have array of strings as a value."),
|
|
Checking_if_0_is_the_longest_matching_prefix_for_1_2: diag(6104, ts.DiagnosticCategory.Message, "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'."),
|
|
Expected_type_of_0_field_in_package_json_to_be_string_got_1: diag(6105, ts.DiagnosticCategory.Message, "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'."),
|
|
baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: diag(6106, ts.DiagnosticCategory.Message, "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'."),
|
|
rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: diag(6107, ts.DiagnosticCategory.Message, "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", "'rootDirs' option is set, using it to resolve relative module name '{0}'."),
|
|
Longest_matching_prefix_for_0_is_1: diag(6108, ts.DiagnosticCategory.Message, "Longest_matching_prefix_for_0_is_1_6108", "Longest matching prefix for '{0}' is '{1}'."),
|
|
Loading_0_from_the_root_dir_1_candidate_location_2: diag(6109, ts.DiagnosticCategory.Message, "Loading_0_from_the_root_dir_1_candidate_location_2_6109", "Loading '{0}' from the root dir '{1}', candidate location '{2}'."),
|
|
Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
|
|
Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
|
|
Do_not_emit_use_strict_directives_in_module_output: diag(6112, ts.DiagnosticCategory.Message, "Do_not_emit_use_strict_directives_in_module_output_6112", "Do not emit 'use strict' directives in module output."),
|
|
Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
|
|
Unknown_option_excludes_Did_you_mean_exclude: diag(6114, ts.DiagnosticCategory.Error, "Unknown_option_excludes_Did_you_mean_exclude_6114", "Unknown option 'excludes'. Did you mean 'exclude'?"),
|
|
Raise_error_on_this_expressions_with_an_implied_any_type: diag(6115, ts.DiagnosticCategory.Message, "Raise_error_on_this_expressions_with_an_implied_any_type_6115", "Raise error on 'this' expressions with an implied 'any' type."),
|
|
Resolving_type_reference_directive_0_containing_file_1_root_directory_2: diag(6116, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116", "======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========"),
|
|
Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
|
|
Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
|
|
Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: diag(6119, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========"),
|
|
Type_reference_directive_0_was_not_resolved: diag(6120, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_not_resolved_6120", "======== Type reference directive '{0}' was not resolved. ========"),
|
|
Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
|
|
Root_directory_cannot_be_determined_skipping_primary_search_paths: diag(6122, ts.DiagnosticCategory.Message, "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", "Root directory cannot be determined, skipping primary search paths."),
|
|
Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: diag(6123, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========"),
|
|
Type_declaration_files_to_be_included_in_compilation: diag(6124, ts.DiagnosticCategory.Message, "Type_declaration_files_to_be_included_in_compilation_6124", "Type declaration files to be included in compilation."),
|
|
Looking_up_in_node_modules_folder_initial_location_0: diag(6125, ts.DiagnosticCategory.Message, "Looking_up_in_node_modules_folder_initial_location_0_6125", "Looking up in 'node_modules' folder, initial location '{0}'."),
|
|
Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: diag(6126, ts.DiagnosticCategory.Message, "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder."),
|
|
Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: diag(6127, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========"),
|
|
Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: diag(6128, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========"),
|
|
Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."),
|
|
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."),
|
|
File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."),
|
|
_0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read.", /*reportsUnnecessary*/ true),
|
|
Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
|
|
Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
|
|
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."),
|
|
Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."),
|
|
Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read.", /*reportsUnnecessary*/ true),
|
|
Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
|
|
Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."),
|
|
Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."),
|
|
Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."),
|
|
Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."),
|
|
Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."),
|
|
Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."),
|
|
Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, ts.DiagnosticCategory.Message, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."),
|
|
Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, ts.DiagnosticCategory.Message, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."),
|
|
Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
|
|
Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
|
|
Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: diag(6151, ts.DiagnosticCategory.Message, "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", "Emit a single file with source maps instead of having a separate file."),
|
|
Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: diag(6152, ts.DiagnosticCategory.Message, "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set."),
|
|
Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: diag(6153, ts.DiagnosticCategory.Message, "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", "Transpile each file as a separate module (similar to 'ts.transpileModule')."),
|
|
Print_names_of_generated_files_part_of_the_compilation: diag(6154, ts.DiagnosticCategory.Message, "Print_names_of_generated_files_part_of_the_compilation_6154", "Print names of generated files part of the compilation."),
|
|
Print_names_of_files_part_of_the_compilation: diag(6155, ts.DiagnosticCategory.Message, "Print_names_of_files_part_of_the_compilation_6155", "Print names of files part of the compilation."),
|
|
The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: diag(6156, ts.DiagnosticCategory.Message, "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", "The locale used when displaying messages to the user (e.g. 'en-us')"),
|
|
Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: diag(6157, ts.DiagnosticCategory.Message, "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", "Do not generate custom helper functions like '__extends' in compiled output."),
|
|
Do_not_include_the_default_library_file_lib_d_ts: diag(6158, ts.DiagnosticCategory.Message, "Do_not_include_the_default_library_file_lib_d_ts_6158", "Do not include the default library file (lib.d.ts)."),
|
|
Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: diag(6159, ts.DiagnosticCategory.Message, "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", "Do not add triple-slash references or imported modules to the list of compiled files."),
|
|
Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: diag(6160, ts.DiagnosticCategory.Message, "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files."),
|
|
List_of_folders_to_include_type_definitions_from: diag(6161, ts.DiagnosticCategory.Message, "List_of_folders_to_include_type_definitions_from_6161", "List of folders to include type definitions from."),
|
|
Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
|
|
The_character_set_of_the_input_files: diag(6163, ts.DiagnosticCategory.Message, "The_character_set_of_the_input_files_6163", "The character set of the input files."),
|
|
Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6164, ts.DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."),
|
|
Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
|
|
Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
|
|
A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: diag(6167, ts.DiagnosticCategory.Message, "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'."),
|
|
List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: diag(6168, ts.DiagnosticCategory.Message, "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", "List of root folders whose combined content represents the structure of the project at runtime."),
|
|
Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
|
|
Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"),
|
|
Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
|
|
Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
|
|
Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
|
|
Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
|
|
Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
|
|
Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
|
|
Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
|
|
Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
|
|
Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."),
|
|
Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
|
|
List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
|
|
Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
|
|
Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."),
|
|
Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."),
|
|
Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."),
|
|
Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
|
|
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
|
|
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
|
|
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
|
|
Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
|
|
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
|
|
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
|
|
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
|
|
Found_0_errors_Watching_for_file_changes: diag(6194, ts.DiagnosticCategory.Message, "Found_0_errors_Watching_for_file_changes_6194", "Found {0} errors. Watching for file changes."),
|
|
Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols: diag(6195, ts.DiagnosticCategory.Message, "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195", "Resolve 'keyof' to string valued property names only (no numbers or symbols)."),
|
|
_0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", /*reportsUnnecessary*/ true),
|
|
Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
|
|
All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true),
|
|
All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true),
|
|
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
|
|
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
|
|
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
|
|
Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."),
|
|
Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."),
|
|
Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."),
|
|
File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern: diag(6307, ts.DiagnosticCategory.Error, "File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern_6307", "File '{0}' is not in project file list. Projects must list all files or use an 'include' pattern."),
|
|
Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, ts.DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"),
|
|
Output_file_0_from_project_1_does_not_exist: diag(6309, ts.DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"),
|
|
Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2_6350", "Project '{0}' is out of date because oldest output '{1}' is older than newest input '{2}'"),
|
|
Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than oldest output '{2}'"),
|
|
Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"),
|
|
Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"),
|
|
Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"),
|
|
Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
|
|
A_non_dry_build_would_delete_the_following_files_Colon_0: diag(6356, ts.DiagnosticCategory.Message, "A_non_dry_build_would_delete_the_following_files_Colon_0_6356", "A non-dry build would delete the following files: {0}"),
|
|
A_non_dry_build_would_build_project_0: diag(6357, ts.DiagnosticCategory.Message, "A_non_dry_build_would_build_project_0_6357", "A non-dry build would build project '{0}'"),
|
|
Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
|
|
Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
|
|
delete_this_Project_0_is_up_to_date_because_it_was_previously_built: diag(6360, ts.DiagnosticCategory.Message, "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360", "delete this - Project '{0}' is up to date because it was previously built"),
|
|
Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
|
|
Skipping_build_of_project_0_because_its_dependency_1_has_errors: diag(6362, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362", "Skipping build of project '{0}' because its dependency '{1}' has errors"),
|
|
Project_0_can_t_be_built_because_its_dependency_1_has_errors: diag(6363, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363", "Project '{0}' can't be built because its dependency '{1}' has errors"),
|
|
Build_one_or_more_projects_and_their_dependencies_if_out_of_date: diag(6364, ts.DiagnosticCategory.Message, "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364", "Build one or more projects and their dependencies, if out of date"),
|
|
Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
|
|
Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
|
|
Show_what_would_be_built_or_deleted_if_specified_with_clean: diag(6367, ts.DiagnosticCategory.Message, "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367", "Show what would be built (or deleted, if specified with '--clean')"),
|
|
Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6368, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6368", "Build all projects, including those that appear to be up to date"),
|
|
Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."),
|
|
Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."),
|
|
Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"),
|
|
Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
|
|
Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
|
|
Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
|
|
new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: diag(7009, ts.DiagnosticCategory.Error, "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type."),
|
|
_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."),
|
|
Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."),
|
|
Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."),
|
|
Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."),
|
|
Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."),
|
|
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."),
|
|
Object_literal_s_property_0_implicitly_has_an_1_type: diag(7018, ts.DiagnosticCategory.Error, "Object_literal_s_property_0_implicitly_has_an_1_type_7018", "Object literal's property '{0}' implicitly has an '{1}' type."),
|
|
Rest_parameter_0_implicitly_has_an_any_type: diag(7019, ts.DiagnosticCategory.Error, "Rest_parameter_0_implicitly_has_an_any_type_7019", "Rest parameter '{0}' implicitly has an 'any[]' type."),
|
|
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7020, ts.DiagnosticCategory.Error, "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", "Call signature, which lacks return-type annotation, implicitly has an 'any' return type."),
|
|
_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: diag(7022, ts.DiagnosticCategory.Error, "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer."),
|
|
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7023, ts.DiagnosticCategory.Error, "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."),
|
|
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."),
|
|
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."),
|
|
JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."),
|
|
Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", /*reportsUnnecessary*/ true),
|
|
Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", /*reportsUnnecessary*/ true),
|
|
Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
|
|
Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."),
|
|
Binding_element_0_implicitly_has_an_1_type: diag(7031, ts.DiagnosticCategory.Error, "Binding_element_0_implicitly_has_an_1_type_7031", "Binding element '{0}' implicitly has an '{1}' type."),
|
|
Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: diag(7032, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation."),
|
|
Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: diag(7033, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation."),
|
|
Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: diag(7034, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined."),
|
|
Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: diag(7035, ts.DiagnosticCategory.Error, "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"),
|
|
Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0: diag(7036, ts.DiagnosticCategory.Error, "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036", "Dynamic import's specifier must be of type 'string', but here has type '{0}'."),
|
|
Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."),
|
|
A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime: diag(7038, ts.DiagnosticCategory.Error, "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038", "A namespace-style import cannot be called or constructed, and will cause a failure at runtime."),
|
|
Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."),
|
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
|
|
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
|
|
export_can_only_be_used_in_a_ts_file: diag(8003, ts.DiagnosticCategory.Error, "export_can_only_be_used_in_a_ts_file_8003", "'export=' can only be used in a .ts file."),
|
|
type_parameter_declarations_can_only_be_used_in_a_ts_file: diag(8004, ts.DiagnosticCategory.Error, "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", "'type parameter declarations' can only be used in a .ts file."),
|
|
implements_clauses_can_only_be_used_in_a_ts_file: diag(8005, ts.DiagnosticCategory.Error, "implements_clauses_can_only_be_used_in_a_ts_file_8005", "'implements clauses' can only be used in a .ts file."),
|
|
interface_declarations_can_only_be_used_in_a_ts_file: diag(8006, ts.DiagnosticCategory.Error, "interface_declarations_can_only_be_used_in_a_ts_file_8006", "'interface declarations' can only be used in a .ts file."),
|
|
module_declarations_can_only_be_used_in_a_ts_file: diag(8007, ts.DiagnosticCategory.Error, "module_declarations_can_only_be_used_in_a_ts_file_8007", "'module declarations' can only be used in a .ts file."),
|
|
type_aliases_can_only_be_used_in_a_ts_file: diag(8008, ts.DiagnosticCategory.Error, "type_aliases_can_only_be_used_in_a_ts_file_8008", "'type aliases' can only be used in a .ts file."),
|
|
_0_can_only_be_used_in_a_ts_file: diag(8009, ts.DiagnosticCategory.Error, "_0_can_only_be_used_in_a_ts_file_8009", "'{0}' can only be used in a .ts file."),
|
|
types_can_only_be_used_in_a_ts_file: diag(8010, ts.DiagnosticCategory.Error, "types_can_only_be_used_in_a_ts_file_8010", "'types' can only be used in a .ts file."),
|
|
type_arguments_can_only_be_used_in_a_ts_file: diag(8011, ts.DiagnosticCategory.Error, "type_arguments_can_only_be_used_in_a_ts_file_8011", "'type arguments' can only be used in a .ts file."),
|
|
parameter_modifiers_can_only_be_used_in_a_ts_file: diag(8012, ts.DiagnosticCategory.Error, "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", "'parameter modifiers' can only be used in a .ts file."),
|
|
non_null_assertions_can_only_be_used_in_a_ts_file: diag(8013, ts.DiagnosticCategory.Error, "non_null_assertions_can_only_be_used_in_a_ts_file_8013", "'non-null assertions' can only be used in a .ts file."),
|
|
enum_declarations_can_only_be_used_in_a_ts_file: diag(8015, ts.DiagnosticCategory.Error, "enum_declarations_can_only_be_used_in_a_ts_file_8015", "'enum declarations' can only be used in a .ts file."),
|
|
type_assertion_expressions_can_only_be_used_in_a_ts_file: diag(8016, ts.DiagnosticCategory.Error, "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", "'type assertion expressions' can only be used in a .ts file."),
|
|
Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: diag(8017, ts.DiagnosticCategory.Error, "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", "Octal literal types must use ES2015 syntax. Use the syntax '{0}'."),
|
|
Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."),
|
|
Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
|
|
JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."),
|
|
JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."),
|
|
JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."),
|
|
JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."),
|
|
JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."),
|
|
Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."),
|
|
Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."),
|
|
Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."),
|
|
JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."),
|
|
JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type: diag(8029, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_h_8029", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name. It would match 'arguments' if it had an array type."),
|
|
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."),
|
|
class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
|
|
Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
|
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
|
|
Cannot_use_JSX_unless_the_jsx_flag_is_provided: diag(17004, ts.DiagnosticCategory.Error, "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", "Cannot use JSX unless the '--jsx' flag is provided."),
|
|
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: diag(17005, ts.DiagnosticCategory.Error, "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", "A constructor cannot contain a 'super' call when its class extends 'null'."),
|
|
An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17006, ts.DiagnosticCategory.Error, "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."),
|
|
A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17007, ts.DiagnosticCategory.Error, "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."),
|
|
JSX_element_0_has_no_corresponding_closing_tag: diag(17008, ts.DiagnosticCategory.Error, "JSX_element_0_has_no_corresponding_closing_tag_17008", "JSX element '{0}' has no corresponding closing tag."),
|
|
super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: diag(17009, ts.DiagnosticCategory.Error, "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", "'super' must be called before accessing 'this' in the constructor of a derived class."),
|
|
Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
|
|
super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: diag(17011, ts.DiagnosticCategory.Error, "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", "'super' must be called before accessing a property of 'super' in the constructor of a derived class."),
|
|
_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: diag(17012, ts.DiagnosticCategory.Error, "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?"),
|
|
Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: diag(17013, ts.DiagnosticCategory.Error, "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor."),
|
|
JSX_fragment_has_no_corresponding_closing_tag: diag(17014, ts.DiagnosticCategory.Error, "JSX_fragment_has_no_corresponding_closing_tag_17014", "JSX fragment has no corresponding closing tag."),
|
|
Expected_corresponding_closing_tag_for_JSX_fragment: diag(17015, ts.DiagnosticCategory.Error, "Expected_corresponding_closing_tag_for_JSX_fragment_17015", "Expected corresponding closing tag for JSX fragment."),
|
|
JSX_fragment_is_not_supported_when_using_jsxFactory: diag(17016, ts.DiagnosticCategory.Error, "JSX_fragment_is_not_supported_when_using_jsxFactory_17016", "JSX fragment is not supported when using --jsxFactory"),
|
|
JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma: diag(17017, ts.DiagnosticCategory.Error, "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017", "JSX fragment is not supported when using an inline JSX factory pragma"),
|
|
Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, ts.DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"),
|
|
A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: diag(18001, ts.DiagnosticCategory.Error, "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", "A path in an 'extends' option must be relative or rooted, but '{0}' is not."),
|
|
The_files_list_in_config_file_0_is_empty: diag(18002, ts.DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."),
|
|
No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, ts.DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."),
|
|
File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001", "File is a CommonJS module; it may be converted to an ES6 module."),
|
|
This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, ts.DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."),
|
|
Import_may_be_converted_to_a_default_import: diag(80003, ts.DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."),
|
|
JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, ts.DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."),
|
|
require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."),
|
|
Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
|
|
Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
Remove_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_declaration_for_Colon_0_90004", "Remove declaration for: '{0}'"),
|
|
Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
|
|
Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
|
|
Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
|
|
Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
|
|
Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"),
|
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
|
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
|
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
|
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
|
|
Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
|
|
Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
|
|
Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
|
|
Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
|
|
Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
|
|
Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
|
|
Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'"),
|
|
Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
|
|
Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
|
|
Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
|
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
|
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
|
|
Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
|
|
Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
|
|
Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
|
|
Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
|
|
Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
|
|
Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
|
|
Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
|
|
Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
|
|
Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
|
|
Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
|
|
Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
|
|
Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
|
|
Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
|
|
Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
|
|
Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"),
|
|
Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
|
|
Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
|
|
Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
|
|
Prefix_all_unused_declarations_with_where_possible: diag(95025, ts.DiagnosticCategory.Message, "Prefix_all_unused_declarations_with_where_possible_95025", "Prefix all unused declarations with '_' where possible"),
|
|
Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
|
|
Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
|
|
Add_definite_assignment_assertions_to_all_uninitialized_properties: diag(95028, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028", "Add definite assignment assertions to all uninitialized properties"),
|
|
Add_undefined_type_to_all_uninitialized_properties: diag(95029, ts.DiagnosticCategory.Message, "Add_undefined_type_to_all_uninitialized_properties_95029", "Add undefined type to all uninitialized properties"),
|
|
Change_all_jsdoc_style_types_to_TypeScript: diag(95030, ts.DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_95030", "Change all jsdoc-style types to TypeScript"),
|
|
Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types: diag(95031, ts.DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types_95031", "Change all jsdoc-style types to TypeScript (and add '| undefined' to nullable types)"),
|
|
Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
|
|
Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
|
|
Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
|
|
Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
|
|
Make_all_super_calls_the_first_statement_in_their_constructor: diag(95036, ts.DiagnosticCategory.Message, "Make_all_super_calls_the_first_statement_in_their_constructor_95036", "Make all 'super()' calls the first statement in their constructor"),
|
|
Add_qualifier_to_all_unresolved_variables_matching_a_member_name: diag(95037, ts.DiagnosticCategory.Message, "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037", "Add qualifier to all unresolved variables matching a member name"),
|
|
Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
|
|
Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
|
|
Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
|
|
Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
|
|
Add_ts_ignore_to_all_error_messages: diag(95042, ts.DiagnosticCategory.Message, "Add_ts_ignore_to_all_error_messages_95042", "Add '@ts-ignore' to all error messages"),
|
|
Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
|
|
Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
|
|
Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
|
|
Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
|
|
Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
|
|
Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
|
|
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
|
|
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
|
|
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
|
|
Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
|
|
Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
|
|
Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
|
|
Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
|
|
Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
|
|
Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
|
|
Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"),
|
|
Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
|
|
Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
|
|
};
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
/* @internal */
|
|
function tokenIsIdentifierOrKeyword(token) {
|
|
return token >= 71 /* Identifier */;
|
|
}
|
|
ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
|
|
/* @internal */
|
|
function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
|
|
return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token);
|
|
}
|
|
ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
|
|
var textToToken = ts.createMapFromTemplate({
|
|
"abstract": 117 /* AbstractKeyword */,
|
|
"any": 119 /* AnyKeyword */,
|
|
"as": 118 /* AsKeyword */,
|
|
"boolean": 122 /* BooleanKeyword */,
|
|
"break": 72 /* BreakKeyword */,
|
|
"case": 73 /* CaseKeyword */,
|
|
"catch": 74 /* CatchKeyword */,
|
|
"class": 75 /* ClassKeyword */,
|
|
"continue": 77 /* ContinueKeyword */,
|
|
"const": 76 /* ConstKeyword */,
|
|
"constructor": 123 /* ConstructorKeyword */,
|
|
"debugger": 78 /* DebuggerKeyword */,
|
|
"declare": 124 /* DeclareKeyword */,
|
|
"default": 79 /* DefaultKeyword */,
|
|
"delete": 80 /* DeleteKeyword */,
|
|
"do": 81 /* DoKeyword */,
|
|
"else": 82 /* ElseKeyword */,
|
|
"enum": 83 /* EnumKeyword */,
|
|
"export": 84 /* ExportKeyword */,
|
|
"extends": 85 /* ExtendsKeyword */,
|
|
"false": 86 /* FalseKeyword */,
|
|
"finally": 87 /* FinallyKeyword */,
|
|
"for": 88 /* ForKeyword */,
|
|
"from": 143 /* FromKeyword */,
|
|
"function": 89 /* FunctionKeyword */,
|
|
"get": 125 /* GetKeyword */,
|
|
"if": 90 /* IfKeyword */,
|
|
"implements": 108 /* ImplementsKeyword */,
|
|
"import": 91 /* ImportKeyword */,
|
|
"in": 92 /* InKeyword */,
|
|
"infer": 126 /* InferKeyword */,
|
|
"instanceof": 93 /* InstanceOfKeyword */,
|
|
"interface": 109 /* InterfaceKeyword */,
|
|
"is": 127 /* IsKeyword */,
|
|
"keyof": 128 /* KeyOfKeyword */,
|
|
"let": 110 /* LetKeyword */,
|
|
"module": 129 /* ModuleKeyword */,
|
|
"namespace": 130 /* NamespaceKeyword */,
|
|
"never": 131 /* NeverKeyword */,
|
|
"new": 94 /* NewKeyword */,
|
|
"null": 95 /* NullKeyword */,
|
|
"number": 134 /* NumberKeyword */,
|
|
"object": 135 /* ObjectKeyword */,
|
|
"package": 111 /* PackageKeyword */,
|
|
"private": 112 /* PrivateKeyword */,
|
|
"protected": 113 /* ProtectedKeyword */,
|
|
"public": 114 /* PublicKeyword */,
|
|
"readonly": 132 /* ReadonlyKeyword */,
|
|
"require": 133 /* RequireKeyword */,
|
|
"global": 144 /* GlobalKeyword */,
|
|
"return": 96 /* ReturnKeyword */,
|
|
"set": 136 /* SetKeyword */,
|
|
"static": 115 /* StaticKeyword */,
|
|
"string": 137 /* StringKeyword */,
|
|
"super": 97 /* SuperKeyword */,
|
|
"switch": 98 /* SwitchKeyword */,
|
|
"symbol": 138 /* SymbolKeyword */,
|
|
"this": 99 /* ThisKeyword */,
|
|
"throw": 100 /* ThrowKeyword */,
|
|
"true": 101 /* TrueKeyword */,
|
|
"try": 102 /* TryKeyword */,
|
|
"type": 139 /* TypeKeyword */,
|
|
"typeof": 103 /* TypeOfKeyword */,
|
|
"undefined": 140 /* UndefinedKeyword */,
|
|
"unique": 141 /* UniqueKeyword */,
|
|
"unknown": 142 /* UnknownKeyword */,
|
|
"var": 104 /* VarKeyword */,
|
|
"void": 105 /* VoidKeyword */,
|
|
"while": 106 /* WhileKeyword */,
|
|
"with": 107 /* WithKeyword */,
|
|
"yield": 116 /* YieldKeyword */,
|
|
"async": 120 /* AsyncKeyword */,
|
|
"await": 121 /* AwaitKeyword */,
|
|
"of": 145 /* OfKeyword */,
|
|
"{": 17 /* OpenBraceToken */,
|
|
"}": 18 /* CloseBraceToken */,
|
|
"(": 19 /* OpenParenToken */,
|
|
")": 20 /* CloseParenToken */,
|
|
"[": 21 /* OpenBracketToken */,
|
|
"]": 22 /* CloseBracketToken */,
|
|
".": 23 /* DotToken */,
|
|
"...": 24 /* DotDotDotToken */,
|
|
";": 25 /* SemicolonToken */,
|
|
",": 26 /* CommaToken */,
|
|
"<": 27 /* LessThanToken */,
|
|
">": 29 /* GreaterThanToken */,
|
|
"<=": 30 /* LessThanEqualsToken */,
|
|
">=": 31 /* GreaterThanEqualsToken */,
|
|
"==": 32 /* EqualsEqualsToken */,
|
|
"!=": 33 /* ExclamationEqualsToken */,
|
|
"===": 34 /* EqualsEqualsEqualsToken */,
|
|
"!==": 35 /* ExclamationEqualsEqualsToken */,
|
|
"=>": 36 /* EqualsGreaterThanToken */,
|
|
"+": 37 /* PlusToken */,
|
|
"-": 38 /* MinusToken */,
|
|
"**": 40 /* AsteriskAsteriskToken */,
|
|
"*": 39 /* AsteriskToken */,
|
|
"/": 41 /* SlashToken */,
|
|
"%": 42 /* PercentToken */,
|
|
"++": 43 /* PlusPlusToken */,
|
|
"--": 44 /* MinusMinusToken */,
|
|
"<<": 45 /* LessThanLessThanToken */,
|
|
"</": 28 /* LessThanSlashToken */,
|
|
">>": 46 /* GreaterThanGreaterThanToken */,
|
|
">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */,
|
|
"&": 48 /* AmpersandToken */,
|
|
"|": 49 /* BarToken */,
|
|
"^": 50 /* CaretToken */,
|
|
"!": 51 /* ExclamationToken */,
|
|
"~": 52 /* TildeToken */,
|
|
"&&": 53 /* AmpersandAmpersandToken */,
|
|
"||": 54 /* BarBarToken */,
|
|
"?": 55 /* QuestionToken */,
|
|
":": 56 /* ColonToken */,
|
|
"=": 58 /* EqualsToken */,
|
|
"+=": 59 /* PlusEqualsToken */,
|
|
"-=": 60 /* MinusEqualsToken */,
|
|
"*=": 61 /* AsteriskEqualsToken */,
|
|
"**=": 62 /* AsteriskAsteriskEqualsToken */,
|
|
"/=": 63 /* SlashEqualsToken */,
|
|
"%=": 64 /* PercentEqualsToken */,
|
|
"<<=": 65 /* LessThanLessThanEqualsToken */,
|
|
">>=": 66 /* GreaterThanGreaterThanEqualsToken */,
|
|
">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */,
|
|
"&=": 68 /* AmpersandEqualsToken */,
|
|
"|=": 69 /* BarEqualsToken */,
|
|
"^=": 70 /* CaretEqualsToken */,
|
|
"@": 57 /* AtToken */,
|
|
});
|
|
/*
|
|
As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers
|
|
IdentifierStart ::
|
|
Can contain Unicode 3.0.0 categories:
|
|
Uppercase letter (Lu),
|
|
Lowercase letter (Ll),
|
|
Titlecase letter (Lt),
|
|
Modifier letter (Lm),
|
|
Other letter (Lo), or
|
|
Letter number (Nl).
|
|
IdentifierPart :: =
|
|
Can contain IdentifierStart + Unicode 3.0.0 categories:
|
|
Non-spacing mark (Mn),
|
|
Combining spacing mark (Mc),
|
|
Decimal number (Nd), or
|
|
Connector punctuation (Pc).
|
|
|
|
Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at:
|
|
http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt
|
|
*/
|
|
var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
|
|
var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
|
|
/*
|
|
As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers
|
|
IdentifierStart ::
|
|
Can contain Unicode 6.2 categories:
|
|
Uppercase letter (Lu),
|
|
Lowercase letter (Ll),
|
|
Titlecase letter (Lt),
|
|
Modifier letter (Lm),
|
|
Other letter (Lo), or
|
|
Letter number (Nl).
|
|
IdentifierPart ::
|
|
Can contain IdentifierStart + Unicode 6.2 categories:
|
|
Non-spacing mark (Mn),
|
|
Combining spacing mark (Mc),
|
|
Decimal number (Nd),
|
|
Connector punctuation (Pc),
|
|
<ZWNJ>, or
|
|
<ZWJ>.
|
|
|
|
Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at:
|
|
http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt
|
|
*/
|
|
var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
|
|
var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
|
|
function lookupInUnicodeMap(code, map) {
|
|
// Bail out quickly if it couldn't possibly be in the map.
|
|
if (code < map[0]) {
|
|
return false;
|
|
}
|
|
// Perform binary search in one of the Unicode range maps
|
|
var lo = 0;
|
|
var hi = map.length;
|
|
var mid;
|
|
while (lo + 1 < hi) {
|
|
mid = lo + (hi - lo) / 2;
|
|
// mid has to be even to catch a range's beginning
|
|
mid -= mid % 2;
|
|
if (map[mid] <= code && code <= map[mid + 1]) {
|
|
return true;
|
|
}
|
|
if (code < map[mid]) {
|
|
hi = mid;
|
|
}
|
|
else {
|
|
lo = mid + 2;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
/* @internal */ function isUnicodeIdentifierStart(code, languageVersion) {
|
|
return languageVersion >= 1 /* ES5 */ ?
|
|
lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
|
|
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
|
|
}
|
|
ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
|
|
function isUnicodeIdentifierPart(code, languageVersion) {
|
|
return languageVersion >= 1 /* ES5 */ ?
|
|
lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
|
|
lookupInUnicodeMap(code, unicodeES3IdentifierPart);
|
|
}
|
|
function makeReverseMap(source) {
|
|
var result = [];
|
|
source.forEach(function (value, name) {
|
|
result[value] = name;
|
|
});
|
|
return result;
|
|
}
|
|
var tokenStrings = makeReverseMap(textToToken);
|
|
function tokenToString(t) {
|
|
return tokenStrings[t];
|
|
}
|
|
ts.tokenToString = tokenToString;
|
|
/* @internal */
|
|
function stringToToken(s) {
|
|
return textToToken.get(s);
|
|
}
|
|
ts.stringToToken = stringToToken;
|
|
/* @internal */
|
|
function computeLineStarts(text) {
|
|
var result = new Array();
|
|
var pos = 0;
|
|
var lineStart = 0;
|
|
while (pos < text.length) {
|
|
var ch = text.charCodeAt(pos);
|
|
pos++;
|
|
switch (ch) {
|
|
case 13 /* carriageReturn */:
|
|
if (text.charCodeAt(pos) === 10 /* lineFeed */) {
|
|
pos++;
|
|
}
|
|
// falls through
|
|
case 10 /* lineFeed */:
|
|
result.push(lineStart);
|
|
lineStart = pos;
|
|
break;
|
|
default:
|
|
if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) {
|
|
result.push(lineStart);
|
|
lineStart = pos;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
result.push(lineStart);
|
|
return result;
|
|
}
|
|
ts.computeLineStarts = computeLineStarts;
|
|
function getPositionOfLineAndCharacter(sourceFile, line, character) {
|
|
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text);
|
|
}
|
|
ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
|
|
/* @internal */
|
|
function computePositionOfLineAndCharacter(lineStarts, line, character, debugText) {
|
|
if (line < 0 || line >= lineStarts.length) {
|
|
ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
|
|
}
|
|
var res = lineStarts[line] + character;
|
|
if (line < lineStarts.length - 1) {
|
|
ts.Debug.assert(res < lineStarts[line + 1]);
|
|
}
|
|
else if (debugText !== undefined) {
|
|
ts.Debug.assert(res <= debugText.length); // Allow single character overflow for trailing newline
|
|
}
|
|
return res;
|
|
}
|
|
ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
|
|
/* @internal */
|
|
function getLineStarts(sourceFile) {
|
|
return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
|
|
}
|
|
ts.getLineStarts = getLineStarts;
|
|
/* @internal */
|
|
/**
|
|
* We assume the first line starts at position 0 and 'position' is non-negative.
|
|
*/
|
|
function computeLineAndCharacterOfPosition(lineStarts, position) {
|
|
var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues);
|
|
if (lineNumber < 0) {
|
|
// If the actual position was not found,
|
|
// the binary search returns the 2's-complement of the next line start
|
|
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
|
|
// then the search will return -2.
|
|
//
|
|
// We want the index of the previous line start, so we subtract 1.
|
|
// Review 2's-complement if this is confusing.
|
|
lineNumber = ~lineNumber - 1;
|
|
ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
|
|
}
|
|
return {
|
|
line: lineNumber,
|
|
character: position - lineStarts[lineNumber]
|
|
};
|
|
}
|
|
ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
|
|
function getLineAndCharacterOfPosition(sourceFile, position) {
|
|
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
|
}
|
|
ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
|
|
function isWhiteSpaceLike(ch) {
|
|
return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
|
|
}
|
|
ts.isWhiteSpaceLike = isWhiteSpaceLike;
|
|
/** Does not include line breaks. For that, see isWhiteSpaceLike. */
|
|
function isWhiteSpaceSingleLine(ch) {
|
|
// Note: nextLine is in the Zs space, and should be considered to be a whitespace.
|
|
// It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
|
|
return ch === 32 /* space */ ||
|
|
ch === 9 /* tab */ ||
|
|
ch === 11 /* verticalTab */ ||
|
|
ch === 12 /* formFeed */ ||
|
|
ch === 160 /* nonBreakingSpace */ ||
|
|
ch === 133 /* nextLine */ ||
|
|
ch === 5760 /* ogham */ ||
|
|
ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ ||
|
|
ch === 8239 /* narrowNoBreakSpace */ ||
|
|
ch === 8287 /* mathematicalSpace */ ||
|
|
ch === 12288 /* ideographicSpace */ ||
|
|
ch === 65279 /* byteOrderMark */;
|
|
}
|
|
ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
|
|
function isLineBreak(ch) {
|
|
// ES5 7.3:
|
|
// The ECMAScript line terminator characters are listed in Table 3.
|
|
// Table 3: Line Terminator Characters
|
|
// Code Unit Value Name Formal Name
|
|
// \u000A Line Feed <LF>
|
|
// \u000D Carriage Return <CR>
|
|
// \u2028 Line separator <LS>
|
|
// \u2029 Paragraph separator <PS>
|
|
// Only the characters in Table 3 are treated as line terminators. Other new line or line
|
|
// breaking characters are treated as white space but not as line terminators.
|
|
return ch === 10 /* lineFeed */ ||
|
|
ch === 13 /* carriageReturn */ ||
|
|
ch === 8232 /* lineSeparator */ ||
|
|
ch === 8233 /* paragraphSeparator */;
|
|
}
|
|
ts.isLineBreak = isLineBreak;
|
|
function isDigit(ch) {
|
|
return ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
|
|
}
|
|
/* @internal */
|
|
function isOctalDigit(ch) {
|
|
return ch >= 48 /* _0 */ && ch <= 55 /* _7 */;
|
|
}
|
|
ts.isOctalDigit = isOctalDigit;
|
|
function couldStartTrivia(text, pos) {
|
|
// Keep in sync with skipTrivia
|
|
var ch = text.charCodeAt(pos);
|
|
switch (ch) {
|
|
case 13 /* carriageReturn */:
|
|
case 10 /* lineFeed */:
|
|
case 9 /* tab */:
|
|
case 11 /* verticalTab */:
|
|
case 12 /* formFeed */:
|
|
case 32 /* space */:
|
|
case 47 /* slash */:
|
|
// starts of normal trivia
|
|
case 60 /* lessThan */:
|
|
case 124 /* bar */:
|
|
case 61 /* equals */:
|
|
case 62 /* greaterThan */:
|
|
// Starts of conflict marker trivia
|
|
return true;
|
|
case 35 /* hash */:
|
|
// Only if its the beginning can we have #! trivia
|
|
return pos === 0;
|
|
default:
|
|
return ch > 127 /* maxAsciiCharacter */;
|
|
}
|
|
}
|
|
ts.couldStartTrivia = couldStartTrivia;
|
|
/* @internal */
|
|
function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
|
|
if (stopAtComments === void 0) { stopAtComments = false; }
|
|
if (ts.positionIsSynthesized(pos)) {
|
|
return pos;
|
|
}
|
|
// Keep in sync with couldStartTrivia
|
|
while (true) {
|
|
var ch = text.charCodeAt(pos);
|
|
switch (ch) {
|
|
case 13 /* carriageReturn */:
|
|
if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
|
|
pos++;
|
|
}
|
|
// falls through
|
|
case 10 /* lineFeed */:
|
|
pos++;
|
|
if (stopAfterLineBreak) {
|
|
return pos;
|
|
}
|
|
continue;
|
|
case 9 /* tab */:
|
|
case 11 /* verticalTab */:
|
|
case 12 /* formFeed */:
|
|
case 32 /* space */:
|
|
pos++;
|
|
continue;
|
|
case 47 /* slash */:
|
|
if (stopAtComments) {
|
|
break;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
while (pos < text.length) {
|
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
continue;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
|
|
pos += 2;
|
|
while (pos < text.length) {
|
|
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
continue;
|
|
}
|
|
break;
|
|
case 60 /* lessThan */:
|
|
case 124 /* bar */:
|
|
case 61 /* equals */:
|
|
case 62 /* greaterThan */:
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos);
|
|
continue;
|
|
}
|
|
break;
|
|
case 35 /* hash */:
|
|
if (pos === 0 && isShebangTrivia(text, pos)) {
|
|
pos = scanShebangTrivia(text, pos);
|
|
continue;
|
|
}
|
|
break;
|
|
default:
|
|
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
|
|
pos++;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
return pos;
|
|
}
|
|
}
|
|
ts.skipTrivia = skipTrivia;
|
|
// All conflict markers consist of the same character repeated seven times. If it is
|
|
// a <<<<<<< or >>>>>>> marker then it is also followed by a space.
|
|
var mergeConflictMarkerLength = "<<<<<<<".length;
|
|
function isConflictMarkerTrivia(text, pos) {
|
|
ts.Debug.assert(pos >= 0);
|
|
// Conflict markers must be at the start of a line.
|
|
if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
|
|
var ch = text.charCodeAt(pos);
|
|
if ((pos + mergeConflictMarkerLength) < text.length) {
|
|
for (var i = 0; i < mergeConflictMarkerLength; i++) {
|
|
if (text.charCodeAt(pos + i) !== ch) {
|
|
return false;
|
|
}
|
|
}
|
|
return ch === 61 /* equals */ ||
|
|
text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function scanConflictMarkerTrivia(text, pos, error) {
|
|
if (error) {
|
|
error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
|
|
}
|
|
var ch = text.charCodeAt(pos);
|
|
var len = text.length;
|
|
if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) {
|
|
while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
|
|
pos++;
|
|
}
|
|
}
|
|
else {
|
|
ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */);
|
|
// Consume everything from the start of a ||||||| or ======= marker to the start
|
|
// of the next ======= or >>>>>>> marker.
|
|
while (pos < len) {
|
|
var currentChar = text.charCodeAt(pos);
|
|
if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
}
|
|
return pos;
|
|
}
|
|
var shebangTriviaRegex = /^#!.*/;
|
|
function isShebangTrivia(text, pos) {
|
|
// Shebangs check must only be done at the start of the file
|
|
ts.Debug.assert(pos === 0);
|
|
return shebangTriviaRegex.test(text);
|
|
}
|
|
function scanShebangTrivia(text, pos) {
|
|
var shebang = shebangTriviaRegex.exec(text)[0];
|
|
pos = pos + shebang.length;
|
|
return pos;
|
|
}
|
|
/**
|
|
* Invokes a callback for each comment range following the provided position.
|
|
*
|
|
* Single-line comment ranges include the leading double-slash characters but not the ending
|
|
* line break. Multi-line comment ranges include the leading slash-asterisk and trailing
|
|
* asterisk-slash characters.
|
|
*
|
|
* @param reduce If true, accumulates the result of calling the callback in a fashion similar
|
|
* to reduceLeft. If false, iteration stops when the callback returns a truthy value.
|
|
* @param text The source text to scan.
|
|
* @param pos The position at which to start scanning.
|
|
* @param trailing If false, whitespace is skipped until the first line break and comments
|
|
* between that location and the next token are returned. If true, comments occurring
|
|
* between the given position and the next line break are returned.
|
|
* @param cb The callback to execute as each comment range is encountered.
|
|
* @param state A state value to pass to each iteration of the callback.
|
|
* @param initial An initial value to pass when accumulating results (when "reduce" is true).
|
|
* @returns If "reduce" is true, the accumulated value. If "reduce" is false, the first truthy
|
|
* return value of the callback.
|
|
*/
|
|
function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
|
|
var pendingPos;
|
|
var pendingEnd;
|
|
var pendingKind;
|
|
var pendingHasTrailingNewLine;
|
|
var hasPendingCommentRange = false;
|
|
var collecting = trailing || pos === 0;
|
|
var accumulator = initial;
|
|
scan: while (pos >= 0 && pos < text.length) {
|
|
var ch = text.charCodeAt(pos);
|
|
switch (ch) {
|
|
case 13 /* carriageReturn */:
|
|
if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
|
|
pos++;
|
|
}
|
|
// falls through
|
|
case 10 /* lineFeed */:
|
|
pos++;
|
|
if (trailing) {
|
|
break scan;
|
|
}
|
|
collecting = true;
|
|
if (hasPendingCommentRange) {
|
|
pendingHasTrailingNewLine = true;
|
|
}
|
|
continue;
|
|
case 9 /* tab */:
|
|
case 11 /* verticalTab */:
|
|
case 12 /* formFeed */:
|
|
case 32 /* space */:
|
|
pos++;
|
|
continue;
|
|
case 47 /* slash */:
|
|
var nextChar = text.charCodeAt(pos + 1);
|
|
var hasTrailingNewLine = false;
|
|
if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) {
|
|
var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */;
|
|
var startPos = pos;
|
|
pos += 2;
|
|
if (nextChar === 47 /* slash */) {
|
|
while (pos < text.length) {
|
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
hasTrailingNewLine = true;
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
}
|
|
else {
|
|
while (pos < text.length) {
|
|
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
}
|
|
if (collecting) {
|
|
if (hasPendingCommentRange) {
|
|
accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
|
|
if (!reduce && accumulator) {
|
|
// If we are not reducing and we have a truthy result, return it.
|
|
return accumulator;
|
|
}
|
|
}
|
|
pendingPos = startPos;
|
|
pendingEnd = pos;
|
|
pendingKind = kind;
|
|
pendingHasTrailingNewLine = hasTrailingNewLine;
|
|
hasPendingCommentRange = true;
|
|
}
|
|
continue;
|
|
}
|
|
break scan;
|
|
default:
|
|
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
|
|
if (hasPendingCommentRange && isLineBreak(ch)) {
|
|
pendingHasTrailingNewLine = true;
|
|
}
|
|
pos++;
|
|
continue;
|
|
}
|
|
break scan;
|
|
}
|
|
}
|
|
if (hasPendingCommentRange) {
|
|
accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
|
|
}
|
|
return accumulator;
|
|
}
|
|
function forEachLeadingCommentRange(text, pos, cb, state) {
|
|
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state);
|
|
}
|
|
ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
|
|
function forEachTrailingCommentRange(text, pos, cb, state) {
|
|
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state);
|
|
}
|
|
ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
|
|
function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
|
|
return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ false, cb, state, initial);
|
|
}
|
|
ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
|
|
function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
|
|
return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial);
|
|
}
|
|
ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
|
|
function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
|
|
if (!comments) {
|
|
comments = [];
|
|
}
|
|
comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
|
|
return comments;
|
|
}
|
|
function getLeadingCommentRanges(text, pos) {
|
|
return reduceEachLeadingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined);
|
|
}
|
|
ts.getLeadingCommentRanges = getLeadingCommentRanges;
|
|
function getTrailingCommentRanges(text, pos) {
|
|
return reduceEachTrailingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined);
|
|
}
|
|
ts.getTrailingCommentRanges = getTrailingCommentRanges;
|
|
/** Optionally, get the shebang */
|
|
function getShebang(text) {
|
|
var match = shebangTriviaRegex.exec(text);
|
|
if (match) {
|
|
return match[0];
|
|
}
|
|
}
|
|
ts.getShebang = getShebang;
|
|
function isIdentifierStart(ch, languageVersion) {
|
|
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ ||
|
|
ch === 36 /* $ */ || ch === 95 /* _ */ ||
|
|
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
|
|
}
|
|
ts.isIdentifierStart = isIdentifierStart;
|
|
function isIdentifierPart(ch, languageVersion) {
|
|
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ ||
|
|
ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ ||
|
|
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
|
|
}
|
|
ts.isIdentifierPart = isIdentifierPart;
|
|
/* @internal */
|
|
function isIdentifierText(name, languageVersion) {
|
|
if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) {
|
|
return false;
|
|
}
|
|
for (var i = 1; i < name.length; i++) {
|
|
if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.isIdentifierText = isIdentifierText;
|
|
// Creates a scanner over a (possibly unspecified) range of a piece of text.
|
|
function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
|
|
if (languageVariant === void 0) { languageVariant = 0 /* Standard */; }
|
|
var text = textInitial;
|
|
// Current position (end position of text of current token)
|
|
var pos;
|
|
// end of text
|
|
var end;
|
|
// Start position of whitespace before current token
|
|
var startPos;
|
|
// Start position of text of current token
|
|
var tokenPos;
|
|
var token;
|
|
var tokenValue;
|
|
var tokenFlags;
|
|
setText(text, start, length);
|
|
return {
|
|
getStartPos: function () { return startPos; },
|
|
getTextPos: function () { return pos; },
|
|
getToken: function () { return token; },
|
|
getTokenPos: function () { return tokenPos; },
|
|
getTokenText: function () { return text.substring(tokenPos, pos); },
|
|
getTokenValue: function () { return tokenValue; },
|
|
hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; },
|
|
hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; },
|
|
isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; },
|
|
isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; },
|
|
isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; },
|
|
getTokenFlags: function () { return tokenFlags; },
|
|
reScanGreaterToken: reScanGreaterToken,
|
|
reScanSlashToken: reScanSlashToken,
|
|
reScanTemplateToken: reScanTemplateToken,
|
|
scanJsxIdentifier: scanJsxIdentifier,
|
|
scanJsxAttributeValue: scanJsxAttributeValue,
|
|
reScanJsxToken: reScanJsxToken,
|
|
scanJsxToken: scanJsxToken,
|
|
scanJSDocToken: scanJSDocToken,
|
|
scan: scan,
|
|
getText: getText,
|
|
setText: setText,
|
|
setScriptTarget: setScriptTarget,
|
|
setLanguageVariant: setLanguageVariant,
|
|
setOnError: setOnError,
|
|
setTextPos: setTextPos,
|
|
tryScan: tryScan,
|
|
lookAhead: lookAhead,
|
|
scanRange: scanRange,
|
|
};
|
|
function error(message, errPos, length) {
|
|
if (errPos === void 0) { errPos = pos; }
|
|
if (onError) {
|
|
var oldPos = pos;
|
|
pos = errPos;
|
|
onError(message, length || 0);
|
|
pos = oldPos;
|
|
}
|
|
}
|
|
function scanNumberFragment() {
|
|
var start = pos;
|
|
var allowSeparator = false;
|
|
var isPreviousTokenSeparator = false;
|
|
var result = "";
|
|
while (true) {
|
|
var ch = text.charCodeAt(pos);
|
|
if (ch === 95 /* _ */) {
|
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
if (allowSeparator) {
|
|
allowSeparator = false;
|
|
isPreviousTokenSeparator = true;
|
|
result += text.substring(start, pos);
|
|
}
|
|
else if (isPreviousTokenSeparator) {
|
|
error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
}
|
|
else {
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
}
|
|
pos++;
|
|
start = pos;
|
|
continue;
|
|
}
|
|
if (isDigit(ch)) {
|
|
allowSeparator = true;
|
|
isPreviousTokenSeparator = false;
|
|
pos++;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
}
|
|
return result + text.substring(start, pos);
|
|
}
|
|
function scanNumber() {
|
|
var start = pos;
|
|
var mainFragment = scanNumberFragment();
|
|
var decimalFragment;
|
|
var scientificFragment;
|
|
if (text.charCodeAt(pos) === 46 /* dot */) {
|
|
pos++;
|
|
decimalFragment = scanNumberFragment();
|
|
}
|
|
var end = pos;
|
|
if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) {
|
|
pos++;
|
|
tokenFlags |= 16 /* Scientific */;
|
|
if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */)
|
|
pos++;
|
|
var preNumericPart = pos;
|
|
var finalFragment = scanNumberFragment();
|
|
if (!finalFragment) {
|
|
error(ts.Diagnostics.Digit_expected);
|
|
}
|
|
else {
|
|
scientificFragment = text.substring(end, preNumericPart) + finalFragment;
|
|
end = pos;
|
|
}
|
|
}
|
|
if (tokenFlags & 512 /* ContainsSeparator */) {
|
|
var result = mainFragment;
|
|
if (decimalFragment) {
|
|
result += "." + decimalFragment;
|
|
}
|
|
if (scientificFragment) {
|
|
result += scientificFragment;
|
|
}
|
|
return "" + +result;
|
|
}
|
|
else {
|
|
return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed
|
|
}
|
|
}
|
|
function scanOctalDigits() {
|
|
var start = pos;
|
|
while (isOctalDigit(text.charCodeAt(pos))) {
|
|
pos++;
|
|
}
|
|
return +(text.substring(start, pos));
|
|
}
|
|
/**
|
|
* Scans the given number of hexadecimal digits in the text,
|
|
* returning -1 if the given number is unavailable.
|
|
*/
|
|
function scanExactNumberOfHexDigits(count, canHaveSeparators) {
|
|
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators);
|
|
}
|
|
/**
|
|
* Scans as many hexadecimal digits as are available in the text,
|
|
* returning -1 if the given number of digits was unavailable.
|
|
*/
|
|
function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
|
|
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators);
|
|
}
|
|
function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
|
|
var digits = 0;
|
|
var value = 0;
|
|
var allowSeparator = false;
|
|
var isPreviousTokenSeparator = false;
|
|
while (digits < minCount || scanAsManyAsPossible) {
|
|
var ch = text.charCodeAt(pos);
|
|
if (canHaveSeparators && ch === 95 /* _ */) {
|
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
if (allowSeparator) {
|
|
allowSeparator = false;
|
|
isPreviousTokenSeparator = true;
|
|
}
|
|
else if (isPreviousTokenSeparator) {
|
|
error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
}
|
|
else {
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
}
|
|
pos++;
|
|
continue;
|
|
}
|
|
allowSeparator = canHaveSeparators;
|
|
if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) {
|
|
value = value * 16 + ch - 48 /* _0 */;
|
|
}
|
|
else if (ch >= 65 /* A */ && ch <= 70 /* F */) {
|
|
value = value * 16 + ch - 65 /* A */ + 10;
|
|
}
|
|
else if (ch >= 97 /* a */ && ch <= 102 /* f */) {
|
|
value = value * 16 + ch - 97 /* a */ + 10;
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
pos++;
|
|
digits++;
|
|
isPreviousTokenSeparator = false;
|
|
}
|
|
if (digits < minCount) {
|
|
value = -1;
|
|
}
|
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
}
|
|
return value;
|
|
}
|
|
function scanString(jsxAttributeString) {
|
|
if (jsxAttributeString === void 0) { jsxAttributeString = false; }
|
|
var quote = text.charCodeAt(pos);
|
|
pos++;
|
|
var result = "";
|
|
var start = pos;
|
|
while (true) {
|
|
if (pos >= end) {
|
|
result += text.substring(start, pos);
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
error(ts.Diagnostics.Unterminated_string_literal);
|
|
break;
|
|
}
|
|
var ch = text.charCodeAt(pos);
|
|
if (ch === quote) {
|
|
result += text.substring(start, pos);
|
|
pos++;
|
|
break;
|
|
}
|
|
if (ch === 92 /* backslash */ && !jsxAttributeString) {
|
|
result += text.substring(start, pos);
|
|
result += scanEscapeSequence();
|
|
start = pos;
|
|
continue;
|
|
}
|
|
if (isLineBreak(ch) && !jsxAttributeString) {
|
|
result += text.substring(start, pos);
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
error(ts.Diagnostics.Unterminated_string_literal);
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
return result;
|
|
}
|
|
/**
|
|
* Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or
|
|
* a literal component of a TemplateExpression.
|
|
*/
|
|
function scanTemplateAndSetTokenValue() {
|
|
var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
|
|
pos++;
|
|
var start = pos;
|
|
var contents = "";
|
|
var resultingToken;
|
|
while (true) {
|
|
if (pos >= end) {
|
|
contents += text.substring(start, pos);
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
error(ts.Diagnostics.Unterminated_template_literal);
|
|
resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */;
|
|
break;
|
|
}
|
|
var currChar = text.charCodeAt(pos);
|
|
// '`'
|
|
if (currChar === 96 /* backtick */) {
|
|
contents += text.substring(start, pos);
|
|
pos++;
|
|
resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */;
|
|
break;
|
|
}
|
|
// '${'
|
|
if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) {
|
|
contents += text.substring(start, pos);
|
|
pos += 2;
|
|
resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */;
|
|
break;
|
|
}
|
|
// Escape character
|
|
if (currChar === 92 /* backslash */) {
|
|
contents += text.substring(start, pos);
|
|
contents += scanEscapeSequence();
|
|
start = pos;
|
|
continue;
|
|
}
|
|
// Speculated ECMAScript 6 Spec 11.8.6.1:
|
|
// <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF> for Template Values
|
|
if (currChar === 13 /* carriageReturn */) {
|
|
contents += text.substring(start, pos);
|
|
pos++;
|
|
if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
|
|
pos++;
|
|
}
|
|
contents += "\n";
|
|
start = pos;
|
|
continue;
|
|
}
|
|
pos++;
|
|
}
|
|
ts.Debug.assert(resultingToken !== undefined);
|
|
tokenValue = contents;
|
|
return resultingToken;
|
|
}
|
|
function scanEscapeSequence() {
|
|
pos++;
|
|
if (pos >= end) {
|
|
error(ts.Diagnostics.Unexpected_end_of_text);
|
|
return "";
|
|
}
|
|
var ch = text.charCodeAt(pos);
|
|
pos++;
|
|
switch (ch) {
|
|
case 48 /* _0 */:
|
|
return "\0";
|
|
case 98 /* b */:
|
|
return "\b";
|
|
case 116 /* t */:
|
|
return "\t";
|
|
case 110 /* n */:
|
|
return "\n";
|
|
case 118 /* v */:
|
|
return "\v";
|
|
case 102 /* f */:
|
|
return "\f";
|
|
case 114 /* r */:
|
|
return "\r";
|
|
case 39 /* singleQuote */:
|
|
return "\'";
|
|
case 34 /* doubleQuote */:
|
|
return "\"";
|
|
case 117 /* u */:
|
|
// '\u{DDDDDDDD}'
|
|
if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
pos++;
|
|
return scanExtendedUnicodeEscape();
|
|
}
|
|
// '\uDDDD'
|
|
return scanHexadecimalEscape(/*numDigits*/ 4);
|
|
case 120 /* x */:
|
|
// '\xDD'
|
|
return scanHexadecimalEscape(/*numDigits*/ 2);
|
|
// when encountering a LineContinuation (i.e. a backslash and a line terminator sequence),
|
|
// the line terminator is interpreted to be "the empty code unit sequence".
|
|
case 13 /* carriageReturn */:
|
|
if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
|
|
pos++;
|
|
}
|
|
// falls through
|
|
case 10 /* lineFeed */:
|
|
case 8232 /* lineSeparator */:
|
|
case 8233 /* paragraphSeparator */:
|
|
return "";
|
|
default:
|
|
return String.fromCharCode(ch);
|
|
}
|
|
}
|
|
function scanHexadecimalEscape(numDigits) {
|
|
var escapedValue = scanExactNumberOfHexDigits(numDigits, /*canHaveSeparators*/ false);
|
|
if (escapedValue >= 0) {
|
|
return String.fromCharCode(escapedValue);
|
|
}
|
|
else {
|
|
error(ts.Diagnostics.Hexadecimal_digit_expected);
|
|
return "";
|
|
}
|
|
}
|
|
function scanExtendedUnicodeEscape() {
|
|
var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
|
|
var isInvalidExtendedEscape = false;
|
|
// Validate the value of the digit
|
|
if (escapedValue < 0) {
|
|
error(ts.Diagnostics.Hexadecimal_digit_expected);
|
|
isInvalidExtendedEscape = true;
|
|
}
|
|
else if (escapedValue > 0x10FFFF) {
|
|
error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
|
|
isInvalidExtendedEscape = true;
|
|
}
|
|
if (pos >= end) {
|
|
error(ts.Diagnostics.Unexpected_end_of_text);
|
|
isInvalidExtendedEscape = true;
|
|
}
|
|
else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
// Only swallow the following character up if it's a '}'.
|
|
pos++;
|
|
}
|
|
else {
|
|
error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
isInvalidExtendedEscape = true;
|
|
}
|
|
if (isInvalidExtendedEscape) {
|
|
return "";
|
|
}
|
|
return utf16EncodeAsString(escapedValue);
|
|
}
|
|
// Derived from the 10.1.1 UTF16Encoding of the ES6 Spec.
|
|
function utf16EncodeAsString(codePoint) {
|
|
ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
|
|
if (codePoint <= 65535) {
|
|
return String.fromCharCode(codePoint);
|
|
}
|
|
var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
|
|
var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
|
|
return String.fromCharCode(codeUnit1, codeUnit2);
|
|
}
|
|
// Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX'
|
|
// and return code point value if valid Unicode escape is found. Otherwise return -1.
|
|
function peekUnicodeEscape() {
|
|
if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) {
|
|
var start_1 = pos;
|
|
pos += 2;
|
|
var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false);
|
|
pos = start_1;
|
|
return value;
|
|
}
|
|
return -1;
|
|
}
|
|
function scanIdentifierParts() {
|
|
var result = "";
|
|
var start = pos;
|
|
while (pos < end) {
|
|
var ch = text.charCodeAt(pos);
|
|
if (isIdentifierPart(ch, languageVersion)) {
|
|
pos++;
|
|
}
|
|
else if (ch === 92 /* backslash */) {
|
|
ch = peekUnicodeEscape();
|
|
if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
|
|
break;
|
|
}
|
|
result += text.substring(start, pos);
|
|
result += String.fromCharCode(ch);
|
|
// Valid Unicode escape is always six characters
|
|
pos += 6;
|
|
start = pos;
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
result += text.substring(start, pos);
|
|
return result;
|
|
}
|
|
function getIdentifierToken() {
|
|
// Reserved words are between 2 and 11 characters long and start with a lowercase letter
|
|
var len = tokenValue.length;
|
|
if (len >= 2 && len <= 11) {
|
|
var ch = tokenValue.charCodeAt(0);
|
|
if (ch >= 97 /* a */ && ch <= 122 /* z */) {
|
|
token = textToToken.get(tokenValue);
|
|
if (token !== undefined) {
|
|
return token;
|
|
}
|
|
}
|
|
}
|
|
return token = 71 /* Identifier */;
|
|
}
|
|
function scanBinaryOrOctalDigits(base) {
|
|
ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8");
|
|
var value = 0;
|
|
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
|
|
// Similarly valid octalIntegerLiteral must have at least one octal digit following o or O.
|
|
var numberOfDigits = 0;
|
|
var separatorAllowed = false;
|
|
var isPreviousTokenSeparator = false;
|
|
while (true) {
|
|
var ch = text.charCodeAt(pos);
|
|
// Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator
|
|
if (ch === 95 /* _ */) {
|
|
tokenFlags |= 512 /* ContainsSeparator */;
|
|
if (separatorAllowed) {
|
|
separatorAllowed = false;
|
|
isPreviousTokenSeparator = true;
|
|
}
|
|
else if (isPreviousTokenSeparator) {
|
|
error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
}
|
|
else {
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
}
|
|
pos++;
|
|
continue;
|
|
}
|
|
separatorAllowed = true;
|
|
var valueOfCh = ch - 48 /* _0 */;
|
|
if (!isDigit(ch) || valueOfCh >= base) {
|
|
break;
|
|
}
|
|
value = value * base + valueOfCh;
|
|
pos++;
|
|
numberOfDigits++;
|
|
isPreviousTokenSeparator = false;
|
|
}
|
|
// Invalid binaryIntegerLiteral or octalIntegerLiteral
|
|
if (numberOfDigits === 0) {
|
|
return -1;
|
|
}
|
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
// Literal ends with underscore - not allowed
|
|
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
return value;
|
|
}
|
|
return value;
|
|
}
|
|
function scan() {
|
|
startPos = pos;
|
|
tokenFlags = 0;
|
|
while (true) {
|
|
tokenPos = pos;
|
|
if (pos >= end) {
|
|
return token = 1 /* EndOfFileToken */;
|
|
}
|
|
var ch = text.charCodeAt(pos);
|
|
// Special handling for shebang
|
|
if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) {
|
|
pos = scanShebangTrivia(text, pos);
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 6 /* ShebangTrivia */;
|
|
}
|
|
}
|
|
switch (ch) {
|
|
case 10 /* lineFeed */:
|
|
case 13 /* carriageReturn */:
|
|
tokenFlags |= 1 /* PrecedingLineBreak */;
|
|
if (skipTrivia) {
|
|
pos++;
|
|
continue;
|
|
}
|
|
else {
|
|
if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
|
|
// consume both CR and LF
|
|
pos += 2;
|
|
}
|
|
else {
|
|
pos++;
|
|
}
|
|
return token = 4 /* NewLineTrivia */;
|
|
}
|
|
case 9 /* tab */:
|
|
case 11 /* verticalTab */:
|
|
case 12 /* formFeed */:
|
|
case 32 /* space */:
|
|
if (skipTrivia) {
|
|
pos++;
|
|
continue;
|
|
}
|
|
else {
|
|
while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
|
|
pos++;
|
|
}
|
|
return token = 5 /* WhitespaceTrivia */;
|
|
}
|
|
case 33 /* exclamation */:
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
|
|
return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */;
|
|
}
|
|
return pos += 2, token = 33 /* ExclamationEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 51 /* ExclamationToken */;
|
|
case 34 /* doubleQuote */:
|
|
case 39 /* singleQuote */:
|
|
tokenValue = scanString();
|
|
return token = 9 /* StringLiteral */;
|
|
case 96 /* backtick */:
|
|
return token = scanTemplateAndSetTokenValue();
|
|
case 37 /* percent */:
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 64 /* PercentEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 42 /* PercentToken */;
|
|
case 38 /* ampersand */:
|
|
if (text.charCodeAt(pos + 1) === 38 /* ampersand */) {
|
|
return pos += 2, token = 53 /* AmpersandAmpersandToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 68 /* AmpersandEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 48 /* AmpersandToken */;
|
|
case 40 /* openParen */:
|
|
pos++;
|
|
return token = 19 /* OpenParenToken */;
|
|
case 41 /* closeParen */:
|
|
pos++;
|
|
return token = 20 /* CloseParenToken */;
|
|
case 42 /* asterisk */:
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 61 /* AsteriskEqualsToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
|
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
|
|
return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */;
|
|
}
|
|
return pos += 2, token = 40 /* AsteriskAsteriskToken */;
|
|
}
|
|
pos++;
|
|
return token = 39 /* AsteriskToken */;
|
|
case 43 /* plus */:
|
|
if (text.charCodeAt(pos + 1) === 43 /* plus */) {
|
|
return pos += 2, token = 43 /* PlusPlusToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 59 /* PlusEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 37 /* PlusToken */;
|
|
case 44 /* comma */:
|
|
pos++;
|
|
return token = 26 /* CommaToken */;
|
|
case 45 /* minus */:
|
|
if (text.charCodeAt(pos + 1) === 45 /* minus */) {
|
|
return pos += 2, token = 44 /* MinusMinusToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 60 /* MinusEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 38 /* MinusToken */;
|
|
case 46 /* dot */:
|
|
if (isDigit(text.charCodeAt(pos + 1))) {
|
|
tokenValue = scanNumber();
|
|
return token = 8 /* NumericLiteral */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) {
|
|
return pos += 3, token = 24 /* DotDotDotToken */;
|
|
}
|
|
pos++;
|
|
return token = 23 /* DotToken */;
|
|
case 47 /* slash */:
|
|
// Single-line comment
|
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
while (pos < end) {
|
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
break;
|
|
}
|
|
pos++;
|
|
}
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 2 /* SingleLineCommentTrivia */;
|
|
}
|
|
}
|
|
// Multi-line comment
|
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
|
|
pos += 2;
|
|
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) {
|
|
tokenFlags |= 2 /* PrecedingJSDocComment */;
|
|
}
|
|
var commentClosed = false;
|
|
while (pos < end) {
|
|
var ch_1 = text.charCodeAt(pos);
|
|
if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
commentClosed = true;
|
|
break;
|
|
}
|
|
if (isLineBreak(ch_1)) {
|
|
tokenFlags |= 1 /* PrecedingLineBreak */;
|
|
}
|
|
pos++;
|
|
}
|
|
if (!commentClosed) {
|
|
error(ts.Diagnostics.Asterisk_Slash_expected);
|
|
}
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
if (!commentClosed) {
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
}
|
|
return token = 3 /* MultiLineCommentTrivia */;
|
|
}
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 63 /* SlashEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 41 /* SlashToken */;
|
|
case 48 /* _0 */:
|
|
if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) {
|
|
pos += 2;
|
|
var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
|
|
if (value < 0) {
|
|
error(ts.Diagnostics.Hexadecimal_digit_expected);
|
|
value = 0;
|
|
}
|
|
tokenValue = "" + value;
|
|
tokenFlags |= 64 /* HexSpecifier */;
|
|
return token = 8 /* NumericLiteral */;
|
|
}
|
|
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) {
|
|
pos += 2;
|
|
var value = scanBinaryOrOctalDigits(/* base */ 2);
|
|
if (value < 0) {
|
|
error(ts.Diagnostics.Binary_digit_expected);
|
|
value = 0;
|
|
}
|
|
tokenValue = "" + value;
|
|
tokenFlags |= 128 /* BinarySpecifier */;
|
|
return token = 8 /* NumericLiteral */;
|
|
}
|
|
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) {
|
|
pos += 2;
|
|
var value = scanBinaryOrOctalDigits(/* base */ 8);
|
|
if (value < 0) {
|
|
error(ts.Diagnostics.Octal_digit_expected);
|
|
value = 0;
|
|
}
|
|
tokenValue = "" + value;
|
|
tokenFlags |= 256 /* OctalSpecifier */;
|
|
return token = 8 /* NumericLiteral */;
|
|
}
|
|
// Try to parse as an octal
|
|
if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
|
|
tokenValue = "" + scanOctalDigits();
|
|
tokenFlags |= 32 /* Octal */;
|
|
return token = 8 /* NumericLiteral */;
|
|
}
|
|
// This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero
|
|
// can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being
|
|
// permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do).
|
|
// falls through
|
|
case 49 /* _1 */:
|
|
case 50 /* _2 */:
|
|
case 51 /* _3 */:
|
|
case 52 /* _4 */:
|
|
case 53 /* _5 */:
|
|
case 54 /* _6 */:
|
|
case 55 /* _7 */:
|
|
case 56 /* _8 */:
|
|
case 57 /* _9 */:
|
|
tokenValue = scanNumber();
|
|
return token = 8 /* NumericLiteral */;
|
|
case 58 /* colon */:
|
|
pos++;
|
|
return token = 56 /* ColonToken */;
|
|
case 59 /* semicolon */:
|
|
pos++;
|
|
return token = 25 /* SemicolonToken */;
|
|
case 60 /* lessThan */:
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos, error);
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
}
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 60 /* lessThan */) {
|
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
|
|
return pos += 3, token = 65 /* LessThanLessThanEqualsToken */;
|
|
}
|
|
return pos += 2, token = 45 /* LessThanLessThanToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 30 /* LessThanEqualsToken */;
|
|
}
|
|
if (languageVariant === 1 /* JSX */ &&
|
|
text.charCodeAt(pos + 1) === 47 /* slash */ &&
|
|
text.charCodeAt(pos + 2) !== 42 /* asterisk */) {
|
|
return pos += 2, token = 28 /* LessThanSlashToken */;
|
|
}
|
|
pos++;
|
|
return token = 27 /* LessThanToken */;
|
|
case 61 /* equals */:
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos, error);
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
}
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
|
|
return pos += 3, token = 34 /* EqualsEqualsEqualsToken */;
|
|
}
|
|
return pos += 2, token = 32 /* EqualsEqualsToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
|
|
return pos += 2, token = 36 /* EqualsGreaterThanToken */;
|
|
}
|
|
pos++;
|
|
return token = 58 /* EqualsToken */;
|
|
case 62 /* greaterThan */:
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos, error);
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
}
|
|
}
|
|
pos++;
|
|
return token = 29 /* GreaterThanToken */;
|
|
case 63 /* question */:
|
|
pos++;
|
|
return token = 55 /* QuestionToken */;
|
|
case 91 /* openBracket */:
|
|
pos++;
|
|
return token = 21 /* OpenBracketToken */;
|
|
case 93 /* closeBracket */:
|
|
pos++;
|
|
return token = 22 /* CloseBracketToken */;
|
|
case 94 /* caret */:
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 70 /* CaretEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 50 /* CaretToken */;
|
|
case 123 /* openBrace */:
|
|
pos++;
|
|
return token = 17 /* OpenBraceToken */;
|
|
case 124 /* bar */:
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos, error);
|
|
if (skipTrivia) {
|
|
continue;
|
|
}
|
|
else {
|
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
}
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 124 /* bar */) {
|
|
return pos += 2, token = 54 /* BarBarToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 69 /* BarEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 49 /* BarToken */;
|
|
case 125 /* closeBrace */:
|
|
pos++;
|
|
return token = 18 /* CloseBraceToken */;
|
|
case 126 /* tilde */:
|
|
pos++;
|
|
return token = 52 /* TildeToken */;
|
|
case 64 /* at */:
|
|
pos++;
|
|
return token = 57 /* AtToken */;
|
|
case 92 /* backslash */:
|
|
var cookedChar = peekUnicodeEscape();
|
|
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
|
|
pos += 6;
|
|
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
|
|
return token = getIdentifierToken();
|
|
}
|
|
error(ts.Diagnostics.Invalid_character);
|
|
pos++;
|
|
return token = 0 /* Unknown */;
|
|
default:
|
|
if (isIdentifierStart(ch, languageVersion)) {
|
|
pos++;
|
|
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
|
|
pos++;
|
|
tokenValue = text.substring(tokenPos, pos);
|
|
if (ch === 92 /* backslash */) {
|
|
tokenValue += scanIdentifierParts();
|
|
}
|
|
return token = getIdentifierToken();
|
|
}
|
|
else if (isWhiteSpaceSingleLine(ch)) {
|
|
pos++;
|
|
continue;
|
|
}
|
|
else if (isLineBreak(ch)) {
|
|
tokenFlags |= 1 /* PrecedingLineBreak */;
|
|
pos++;
|
|
continue;
|
|
}
|
|
error(ts.Diagnostics.Invalid_character);
|
|
pos++;
|
|
return token = 0 /* Unknown */;
|
|
}
|
|
}
|
|
}
|
|
function reScanGreaterToken() {
|
|
if (token === 29 /* GreaterThanToken */) {
|
|
if (text.charCodeAt(pos) === 62 /* greaterThan */) {
|
|
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
|
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
|
|
return pos += 3, token = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
|
|
}
|
|
return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */;
|
|
}
|
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
|
|
return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */;
|
|
}
|
|
pos++;
|
|
return token = 46 /* GreaterThanGreaterThanToken */;
|
|
}
|
|
if (text.charCodeAt(pos) === 61 /* equals */) {
|
|
pos++;
|
|
return token = 31 /* GreaterThanEqualsToken */;
|
|
}
|
|
}
|
|
return token;
|
|
}
|
|
function reScanSlashToken() {
|
|
if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) {
|
|
var p = tokenPos + 1;
|
|
var inEscape = false;
|
|
var inCharacterClass = false;
|
|
while (true) {
|
|
// If we reach the end of a file, or hit a newline, then this is an unterminated
|
|
// regex. Report error and return what we have so far.
|
|
if (p >= end) {
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
error(ts.Diagnostics.Unterminated_regular_expression_literal);
|
|
break;
|
|
}
|
|
var ch = text.charCodeAt(p);
|
|
if (isLineBreak(ch)) {
|
|
tokenFlags |= 4 /* Unterminated */;
|
|
error(ts.Diagnostics.Unterminated_regular_expression_literal);
|
|
break;
|
|
}
|
|
if (inEscape) {
|
|
// Parsing an escape character;
|
|
// reset the flag and just advance to the next char.
|
|
inEscape = false;
|
|
}
|
|
else if (ch === 47 /* slash */ && !inCharacterClass) {
|
|
// A slash within a character class is permissible,
|
|
// but in general it signals the end of the regexp literal.
|
|
p++;
|
|
break;
|
|
}
|
|
else if (ch === 91 /* openBracket */) {
|
|
inCharacterClass = true;
|
|
}
|
|
else if (ch === 92 /* backslash */) {
|
|
inEscape = true;
|
|
}
|
|
else if (ch === 93 /* closeBracket */) {
|
|
inCharacterClass = false;
|
|
}
|
|
p++;
|
|
}
|
|
while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
|
|
p++;
|
|
}
|
|
pos = p;
|
|
tokenValue = text.substring(tokenPos, pos);
|
|
token = 12 /* RegularExpressionLiteral */;
|
|
}
|
|
return token;
|
|
}
|
|
/**
|
|
* Unconditionally back up and scan a template expression portion.
|
|
*/
|
|
function reScanTemplateToken() {
|
|
ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
|
|
pos = tokenPos;
|
|
return token = scanTemplateAndSetTokenValue();
|
|
}
|
|
function reScanJsxToken() {
|
|
pos = tokenPos = startPos;
|
|
return token = scanJsxToken();
|
|
}
|
|
function scanJsxToken() {
|
|
startPos = tokenPos = pos;
|
|
if (pos >= end) {
|
|
return token = 1 /* EndOfFileToken */;
|
|
}
|
|
var char = text.charCodeAt(pos);
|
|
if (char === 60 /* lessThan */) {
|
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) {
|
|
pos += 2;
|
|
return token = 28 /* LessThanSlashToken */;
|
|
}
|
|
pos++;
|
|
return token = 27 /* LessThanToken */;
|
|
}
|
|
if (char === 123 /* openBrace */) {
|
|
pos++;
|
|
return token = 17 /* OpenBraceToken */;
|
|
}
|
|
// First non-whitespace character on this line.
|
|
var firstNonWhitespace = 0;
|
|
// These initial values are special because the first line is:
|
|
// firstNonWhitespace = 0 to indicate that we want leading whitspace,
|
|
while (pos < end) {
|
|
char = text.charCodeAt(pos);
|
|
if (char === 123 /* openBrace */) {
|
|
break;
|
|
}
|
|
if (char === 60 /* lessThan */) {
|
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
pos = scanConflictMarkerTrivia(text, pos, error);
|
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
}
|
|
break;
|
|
}
|
|
// FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces.
|
|
// i.e (- : whitespace)
|
|
// <div>----
|
|
// </div> becomes <div></div>
|
|
//
|
|
// <div>----</div> becomes <div>----</div>
|
|
if (isLineBreak(char) && firstNonWhitespace === 0) {
|
|
firstNonWhitespace = -1;
|
|
}
|
|
else if (!isWhiteSpaceLike(char)) {
|
|
firstNonWhitespace = pos;
|
|
}
|
|
pos++;
|
|
}
|
|
return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */;
|
|
}
|
|
// Scans a JSX identifier; these differ from normal identifiers in that
|
|
// they allow dashes
|
|
function scanJsxIdentifier() {
|
|
if (tokenIsIdentifierOrKeyword(token)) {
|
|
var firstCharPosition = pos;
|
|
while (pos < end) {
|
|
var ch = text.charCodeAt(pos);
|
|
if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) {
|
|
pos++;
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
tokenValue += text.substring(firstCharPosition, pos);
|
|
}
|
|
return token;
|
|
}
|
|
function scanJsxAttributeValue() {
|
|
startPos = pos;
|
|
switch (text.charCodeAt(pos)) {
|
|
case 34 /* doubleQuote */:
|
|
case 39 /* singleQuote */:
|
|
tokenValue = scanString(/*jsxAttributeString*/ true);
|
|
return token = 9 /* StringLiteral */;
|
|
default:
|
|
// If this scans anything other than `{`, it's a parse error.
|
|
return scan();
|
|
}
|
|
}
|
|
function scanJSDocToken() {
|
|
startPos = tokenPos = pos;
|
|
if (pos >= end) {
|
|
return token = 1 /* EndOfFileToken */;
|
|
}
|
|
var ch = text.charCodeAt(pos);
|
|
pos++;
|
|
switch (ch) {
|
|
case 9 /* tab */:
|
|
case 11 /* verticalTab */:
|
|
case 12 /* formFeed */:
|
|
case 32 /* space */:
|
|
while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
|
|
pos++;
|
|
}
|
|
return token = 5 /* WhitespaceTrivia */;
|
|
case 64 /* at */:
|
|
return token = 57 /* AtToken */;
|
|
case 10 /* lineFeed */:
|
|
case 13 /* carriageReturn */:
|
|
return token = 4 /* NewLineTrivia */;
|
|
case 42 /* asterisk */:
|
|
return token = 39 /* AsteriskToken */;
|
|
case 123 /* openBrace */:
|
|
return token = 17 /* OpenBraceToken */;
|
|
case 125 /* closeBrace */:
|
|
return token = 18 /* CloseBraceToken */;
|
|
case 91 /* openBracket */:
|
|
return token = 21 /* OpenBracketToken */;
|
|
case 93 /* closeBracket */:
|
|
return token = 22 /* CloseBracketToken */;
|
|
case 60 /* lessThan */:
|
|
return token = 27 /* LessThanToken */;
|
|
case 61 /* equals */:
|
|
return token = 58 /* EqualsToken */;
|
|
case 44 /* comma */:
|
|
return token = 26 /* CommaToken */;
|
|
case 46 /* dot */:
|
|
return token = 23 /* DotToken */;
|
|
case 96 /* backtick */:
|
|
while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) {
|
|
pos++;
|
|
}
|
|
tokenValue = text.substring(tokenPos + 1, pos);
|
|
pos++;
|
|
return token = 13 /* NoSubstitutionTemplateLiteral */;
|
|
}
|
|
if (isIdentifierStart(ch, 6 /* Latest */)) {
|
|
while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) {
|
|
pos++;
|
|
}
|
|
tokenValue = text.substring(tokenPos, pos);
|
|
return token = 71 /* Identifier */;
|
|
}
|
|
else {
|
|
return token = 0 /* Unknown */;
|
|
}
|
|
}
|
|
function speculationHelper(callback, isLookahead) {
|
|
var savePos = pos;
|
|
var saveStartPos = startPos;
|
|
var saveTokenPos = tokenPos;
|
|
var saveToken = token;
|
|
var saveTokenValue = tokenValue;
|
|
var saveTokenFlags = tokenFlags;
|
|
var result = callback();
|
|
// If our callback returned something 'falsy' or we're just looking ahead,
|
|
// then unconditionally restore us to where we were.
|
|
if (!result || isLookahead) {
|
|
pos = savePos;
|
|
startPos = saveStartPos;
|
|
tokenPos = saveTokenPos;
|
|
token = saveToken;
|
|
tokenValue = saveTokenValue;
|
|
tokenFlags = saveTokenFlags;
|
|
}
|
|
return result;
|
|
}
|
|
function scanRange(start, length, callback) {
|
|
var saveEnd = end;
|
|
var savePos = pos;
|
|
var saveStartPos = startPos;
|
|
var saveTokenPos = tokenPos;
|
|
var saveToken = token;
|
|
var saveTokenValue = tokenValue;
|
|
var saveTokenFlags = tokenFlags;
|
|
setText(text, start, length);
|
|
var result = callback();
|
|
end = saveEnd;
|
|
pos = savePos;
|
|
startPos = saveStartPos;
|
|
tokenPos = saveTokenPos;
|
|
token = saveToken;
|
|
tokenValue = saveTokenValue;
|
|
tokenFlags = saveTokenFlags;
|
|
return result;
|
|
}
|
|
function lookAhead(callback) {
|
|
return speculationHelper(callback, /*isLookahead*/ true);
|
|
}
|
|
function tryScan(callback) {
|
|
return speculationHelper(callback, /*isLookahead*/ false);
|
|
}
|
|
function getText() {
|
|
return text;
|
|
}
|
|
function setText(newText, start, length) {
|
|
text = newText || "";
|
|
end = length === undefined ? text.length : start + length;
|
|
setTextPos(start || 0);
|
|
}
|
|
function setOnError(errorCallback) {
|
|
onError = errorCallback;
|
|
}
|
|
function setScriptTarget(scriptTarget) {
|
|
languageVersion = scriptTarget;
|
|
}
|
|
function setLanguageVariant(variant) {
|
|
languageVariant = variant;
|
|
}
|
|
function setTextPos(textPos) {
|
|
ts.Debug.assert(textPos >= 0);
|
|
pos = textPos;
|
|
startPos = textPos;
|
|
tokenPos = textPos;
|
|
token = 0 /* Unknown */;
|
|
tokenValue = undefined;
|
|
tokenFlags = 0;
|
|
}
|
|
}
|
|
ts.createScanner = createScanner;
|
|
})(ts || (ts = {}));
|
|
/** Non-internal stuff goes here */
|
|
var ts;
|
|
(function (ts) {
|
|
ts.emptyArray = [];
|
|
function closeFileWatcher(watcher) {
|
|
watcher.close();
|
|
}
|
|
ts.closeFileWatcher = closeFileWatcher;
|
|
function isExternalModuleNameRelative(moduleName) {
|
|
// TypeScript 1.0 spec (April 2014): 11.2.1
|
|
// An external module name is "relative" if the first term is "." or "..".
|
|
// Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module.
|
|
return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
|
|
}
|
|
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
|
|
function sortAndDeduplicateDiagnostics(diagnostics) {
|
|
return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
|
|
}
|
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
|
|
function toPath(fileName, basePath, getCanonicalFileName) {
|
|
var nonCanonicalizedPath = ts.isRootedDiskPath(fileName)
|
|
? ts.normalizePath(fileName)
|
|
: ts.getNormalizedAbsolutePath(fileName, basePath);
|
|
return getCanonicalFileName(nonCanonicalizedPath);
|
|
}
|
|
ts.toPath = toPath;
|
|
function hasEntries(map) {
|
|
return !!map && !!map.size;
|
|
}
|
|
ts.hasEntries = hasEntries;
|
|
})(ts || (ts = {}));
|
|
/* @internal */
|
|
(function (ts) {
|
|
ts.resolvingEmptyArray = [];
|
|
ts.emptyMap = ts.createMap();
|
|
ts.emptyUnderscoreEscapedMap = ts.emptyMap;
|
|
ts.externalHelpersModuleNameText = "tslib";
|
|
function getDeclarationOfKind(symbol, kind) {
|
|
var declarations = symbol.declarations;
|
|
if (declarations) {
|
|
for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
|
|
var declaration = declarations_1[_i];
|
|
if (declaration.kind === kind) {
|
|
return declaration;
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getDeclarationOfKind = getDeclarationOfKind;
|
|
/** Create a new escaped identifier map. */
|
|
function createUnderscoreEscapedMap() {
|
|
return new ts.MapCtr();
|
|
}
|
|
ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
|
|
function createSymbolTable(symbols) {
|
|
var result = ts.createMap();
|
|
if (symbols) {
|
|
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
var symbol = symbols_1[_i];
|
|
result.set(symbol.escapedName, symbol);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.createSymbolTable = createSymbolTable;
|
|
var stringWriter = createSingleLineStringWriter();
|
|
function createSingleLineStringWriter() {
|
|
var str = "";
|
|
var writeText = function (text) { return str += text; };
|
|
return {
|
|
getText: function () { return str; },
|
|
write: writeText,
|
|
rawWrite: writeText,
|
|
writeTextOfNode: writeText,
|
|
writeKeyword: writeText,
|
|
writeOperator: writeText,
|
|
writePunctuation: writeText,
|
|
writeSpace: writeText,
|
|
writeStringLiteral: writeText,
|
|
writeLiteral: writeText,
|
|
writeParameter: writeText,
|
|
writeProperty: writeText,
|
|
writeSymbol: writeText,
|
|
getTextPos: function () { return str.length; },
|
|
getLine: function () { return 0; },
|
|
getColumn: function () { return 0; },
|
|
getIndent: function () { return 0; },
|
|
isAtStartOfLine: function () { return false; },
|
|
// Completely ignore indentation for string writers. And map newlines to
|
|
// a single space.
|
|
writeLine: function () { return str += " "; },
|
|
increaseIndent: ts.noop,
|
|
decreaseIndent: ts.noop,
|
|
clear: function () { return str = ""; },
|
|
trackSymbol: ts.noop,
|
|
reportInaccessibleThisError: ts.noop,
|
|
reportInaccessibleUniqueSymbolError: ts.noop,
|
|
reportPrivateInBaseOfClassExpression: ts.noop,
|
|
};
|
|
}
|
|
function changesAffectModuleResolution(oldOptions, newOptions) {
|
|
return !oldOptions ||
|
|
(oldOptions.module !== newOptions.module) ||
|
|
(oldOptions.moduleResolution !== newOptions.moduleResolution) ||
|
|
(oldOptions.noResolve !== newOptions.noResolve) ||
|
|
(oldOptions.target !== newOptions.target) ||
|
|
(oldOptions.noLib !== newOptions.noLib) ||
|
|
(oldOptions.jsx !== newOptions.jsx) ||
|
|
(oldOptions.allowJs !== newOptions.allowJs) ||
|
|
(oldOptions.rootDir !== newOptions.rootDir) ||
|
|
(oldOptions.configFilePath !== newOptions.configFilePath) ||
|
|
(oldOptions.baseUrl !== newOptions.baseUrl) ||
|
|
(oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) ||
|
|
!ts.arrayIsEqualTo(oldOptions.lib, newOptions.lib) ||
|
|
!ts.arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) ||
|
|
!ts.arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) ||
|
|
!ts.equalOwnProperties(oldOptions.paths, newOptions.paths);
|
|
}
|
|
ts.changesAffectModuleResolution = changesAffectModuleResolution;
|
|
function findAncestor(node, callback) {
|
|
while (node) {
|
|
var result = callback(node);
|
|
if (result === "quit") {
|
|
return undefined;
|
|
}
|
|
else if (result) {
|
|
return node;
|
|
}
|
|
node = node.parent;
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.findAncestor = findAncestor;
|
|
function forEachEntry(map, callback) {
|
|
var _a;
|
|
var iterator = map.entries();
|
|
for (var _b = iterator.next(), pair = _b.value, done = _b.done; !done; _a = iterator.next(), pair = _a.value, done = _a.done, _a) {
|
|
var key = pair[0], value = pair[1];
|
|
var result = callback(value, key);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.forEachEntry = forEachEntry;
|
|
function forEachKey(map, callback) {
|
|
var _a;
|
|
var iterator = map.keys();
|
|
for (var _b = iterator.next(), key = _b.value, done = _b.done; !done; _a = iterator.next(), key = _a.value, done = _a.done, _a) {
|
|
var result = callback(key);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.forEachKey = forEachKey;
|
|
function copyEntries(source, target) {
|
|
source.forEach(function (value, key) {
|
|
target.set(key, value);
|
|
});
|
|
}
|
|
ts.copyEntries = copyEntries;
|
|
function arrayToSet(array, makeKey) {
|
|
return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; });
|
|
}
|
|
ts.arrayToSet = arrayToSet;
|
|
function cloneMap(map) {
|
|
var clone = ts.createMap();
|
|
copyEntries(map, clone);
|
|
return clone;
|
|
}
|
|
ts.cloneMap = cloneMap;
|
|
function usingSingleLineStringWriter(action) {
|
|
var oldString = stringWriter.getText();
|
|
try {
|
|
action(stringWriter);
|
|
return stringWriter.getText();
|
|
}
|
|
finally {
|
|
stringWriter.clear();
|
|
stringWriter.writeKeyword(oldString);
|
|
}
|
|
}
|
|
ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
|
|
function getFullWidth(node) {
|
|
return node.end - node.pos;
|
|
}
|
|
ts.getFullWidth = getFullWidth;
|
|
function getResolvedModule(sourceFile, moduleNameText) {
|
|
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
|
|
}
|
|
ts.getResolvedModule = getResolvedModule;
|
|
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
|
|
if (!sourceFile.resolvedModules) {
|
|
sourceFile.resolvedModules = ts.createMap();
|
|
}
|
|
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
|
}
|
|
ts.setResolvedModule = setResolvedModule;
|
|
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap();
|
|
}
|
|
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
|
}
|
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
function moduleResolutionIsEqualTo(oldResolution, newResolution) {
|
|
return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
|
|
oldResolution.extension === newResolution.extension &&
|
|
oldResolution.resolvedFileName === newResolution.resolvedFileName &&
|
|
oldResolution.originalPath === newResolution.originalPath &&
|
|
packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
|
|
}
|
|
ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
|
|
function packageIdIsEqual(a, b) {
|
|
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
|
|
}
|
|
function packageIdToString(_a) {
|
|
var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
|
|
var fullName = subModuleName ? name + "/" + subModuleName : name;
|
|
return fullName + "@" + version;
|
|
}
|
|
ts.packageIdToString = packageIdToString;
|
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
|
|
}
|
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
|
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
for (var i = 0; i < names.length; i++) {
|
|
var newResolution = newResolutions[i];
|
|
var oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
|
var changed = oldResolution
|
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
: newResolution;
|
|
if (changed) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.hasChangesInResolutions = hasChangesInResolutions;
|
|
// Returns true if this node contains a parse error anywhere underneath it.
|
|
function containsParseError(node) {
|
|
aggregateChildData(node);
|
|
return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0;
|
|
}
|
|
ts.containsParseError = containsParseError;
|
|
function aggregateChildData(node) {
|
|
if (!(node.flags & 262144 /* HasAggregatedChildData */)) {
|
|
// A node is considered to contain a parse error if:
|
|
// a) the parser explicitly marked that it had an error
|
|
// b) any of it's children reported that it had an error.
|
|
var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) ||
|
|
ts.forEachChild(node, containsParseError);
|
|
// If so, mark ourselves accordingly.
|
|
if (thisNodeOrAnySubNodesHasError) {
|
|
node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */;
|
|
}
|
|
// Also mark that we've propagated the child information to this node. This way we can
|
|
// always consult the bit directly on this node without needing to check its children
|
|
// again.
|
|
node.flags |= 262144 /* HasAggregatedChildData */;
|
|
}
|
|
}
|
|
function getSourceFileOfNode(node) {
|
|
while (node && node.kind !== 274 /* SourceFile */) {
|
|
node = node.parent;
|
|
}
|
|
return node;
|
|
}
|
|
ts.getSourceFileOfNode = getSourceFileOfNode;
|
|
function isStatementWithLocals(node) {
|
|
switch (node.kind) {
|
|
case 213 /* Block */:
|
|
case 241 /* CaseBlock */:
|
|
case 220 /* ForStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isStatementWithLocals = isStatementWithLocals;
|
|
function getStartPositionOfLine(line, sourceFile) {
|
|
ts.Debug.assert(line >= 0);
|
|
return ts.getLineStarts(sourceFile)[line];
|
|
}
|
|
ts.getStartPositionOfLine = getStartPositionOfLine;
|
|
// This is a useful function for debugging purposes.
|
|
function nodePosToString(node) {
|
|
var file = getSourceFileOfNode(node);
|
|
var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
|
|
return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
|
|
}
|
|
ts.nodePosToString = nodePosToString;
|
|
function getEndLinePosition(line, sourceFile) {
|
|
ts.Debug.assert(line >= 0);
|
|
var lineStarts = ts.getLineStarts(sourceFile);
|
|
var lineIndex = line;
|
|
var sourceText = sourceFile.text;
|
|
if (lineIndex + 1 === lineStarts.length) {
|
|
// last line - return EOF
|
|
return sourceText.length - 1;
|
|
}
|
|
else {
|
|
// current line start
|
|
var start = lineStarts[lineIndex];
|
|
// take the start position of the next line - 1 = it should be some line break
|
|
var pos = lineStarts[lineIndex + 1] - 1;
|
|
ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
|
|
// walk backwards skipping line breaks, stop the the beginning of current line.
|
|
// i.e:
|
|
// <some text>
|
|
// $ <- end of line for this position should match the start position
|
|
while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
|
|
pos--;
|
|
}
|
|
return pos;
|
|
}
|
|
}
|
|
ts.getEndLinePosition = getEndLinePosition;
|
|
/**
|
|
* Returns a value indicating whether a name is unique globally or within the current file.
|
|
* Note: This does not consider whether a name appears as a free identifier or not, so at the expression `x.y` this includes both `x` and `y`.
|
|
*/
|
|
function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
|
|
return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
|
|
}
|
|
ts.isFileLevelUniqueName = isFileLevelUniqueName;
|
|
// Returns true if this node is missing from the actual source code. A 'missing' node is different
|
|
// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes
|
|
// in the tree), it is definitely missing. However, a node may be defined, but still be
|
|
// missing. This happens whenever the parser knows it needs to parse something, but can't
|
|
// get anything in the source code that it expects at that location. For example:
|
|
//
|
|
// let a: ;
|
|
//
|
|
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source
|
|
// code). So the parser will attempt to parse out a type, and will create an actual node.
|
|
// However, this node will be 'missing' in the sense that no actual source-code/tokens are
|
|
// contained within it.
|
|
function nodeIsMissing(node) {
|
|
if (node === undefined) {
|
|
return true;
|
|
}
|
|
return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */;
|
|
}
|
|
ts.nodeIsMissing = nodeIsMissing;
|
|
function nodeIsPresent(node) {
|
|
return !nodeIsMissing(node);
|
|
}
|
|
ts.nodeIsPresent = nodeIsPresent;
|
|
/**
|
|
* Appends a range of value to begin of an array, returning the array.
|
|
*
|
|
* @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
|
|
* is created if `value` was appended.
|
|
* @param from The values to append to the array. If `from` is `undefined`, nothing is
|
|
* appended. If an element of `from` is `undefined`, that element is not appended.
|
|
*/
|
|
function prependStatements(to, from) {
|
|
if (from === undefined || from.length === 0)
|
|
return to;
|
|
if (to === undefined)
|
|
return from.slice();
|
|
var prologue = to.length && isPrologueDirective(to[0]) && to.shift();
|
|
to.unshift.apply(to, from);
|
|
if (prologue) {
|
|
to.unshift(prologue);
|
|
}
|
|
return to;
|
|
}
|
|
ts.prependStatements = prependStatements;
|
|
/**
|
|
* Determine if the given comment is a triple-slash
|
|
*
|
|
* @return true if the comment is a triple-slash comment else false
|
|
*/
|
|
function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
|
|
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
|
// so that we don't end up computing comment string and doing match for all // comments
|
|
if (text.charCodeAt(commentPos + 1) === 47 /* slash */ &&
|
|
commentPos + 2 < commentEnd &&
|
|
text.charCodeAt(commentPos + 2) === 47 /* slash */) {
|
|
var textSubStr = text.substring(commentPos, commentEnd);
|
|
return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
|
|
textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
|
|
textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
|
|
textSubStr.match(defaultLibReferenceRegEx) ?
|
|
true : false;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
|
|
function isPinnedComment(text, start) {
|
|
return text.charCodeAt(start + 1) === 42 /* asterisk */ &&
|
|
text.charCodeAt(start + 2) === 33 /* exclamation */;
|
|
}
|
|
ts.isPinnedComment = isPinnedComment;
|
|
function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
|
|
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
|
// want to skip trivia because this will launch us forward to the next token.
|
|
if (nodeIsMissing(node)) {
|
|
return node.pos;
|
|
}
|
|
if (ts.isJSDocNode(node)) {
|
|
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
|
}
|
|
if (includeJsDoc && ts.hasJSDocNodes(node)) {
|
|
return getTokenPosOfNode(node.jsDoc[0]);
|
|
}
|
|
// For a syntax list, it is possible that one of its children has JSDocComment nodes, while
|
|
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
|
|
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
|
|
// first child to determine the actual position of its first token.
|
|
if (node.kind === 299 /* SyntaxList */ && node._children.length > 0) {
|
|
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
|
|
}
|
|
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
|
}
|
|
ts.getTokenPosOfNode = getTokenPosOfNode;
|
|
function getNonDecoratorTokenPosOfNode(node, sourceFile) {
|
|
if (nodeIsMissing(node) || !node.decorators) {
|
|
return getTokenPosOfNode(node, sourceFile);
|
|
}
|
|
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
|
|
}
|
|
ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
|
|
function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
|
|
if (includeTrivia === void 0) { includeTrivia = false; }
|
|
return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
|
|
}
|
|
ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
|
|
function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
|
|
if (includeTrivia === void 0) { includeTrivia = false; }
|
|
if (nodeIsMissing(node)) {
|
|
return "";
|
|
}
|
|
return sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
|
|
}
|
|
ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
|
|
function getTextOfNode(node, includeTrivia) {
|
|
if (includeTrivia === void 0) { includeTrivia = false; }
|
|
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
|
|
}
|
|
ts.getTextOfNode = getTextOfNode;
|
|
function getPos(range) {
|
|
return range.pos;
|
|
}
|
|
/**
|
|
* Note: it is expected that the `nodeArray` and the `node` are within the same file.
|
|
* For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work.
|
|
*/
|
|
function indexOfNode(nodeArray, node) {
|
|
return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
|
|
}
|
|
ts.indexOfNode = indexOfNode;
|
|
/**
|
|
* Gets flags that control emit behavior of a node.
|
|
*/
|
|
function getEmitFlags(node) {
|
|
var emitNode = node.emitNode;
|
|
return emitNode && emitNode.flags || 0;
|
|
}
|
|
ts.getEmitFlags = getEmitFlags;
|
|
function getLiteralText(node, sourceFile) {
|
|
// If we don't need to downlevel and we can reach the original source text using
|
|
// the node's parent reference, then simply get the text as it was originally written.
|
|
if (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) {
|
|
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
|
}
|
|
var escapeText = getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
|
|
// If we can't reach the original source text, use the canonical form if it's a number,
|
|
// or a (possibly escaped) quoted form of the original text if it's string-like.
|
|
switch (node.kind) {
|
|
case 9 /* StringLiteral */:
|
|
if (node.singleQuote) {
|
|
return "'" + escapeText(node.text, 39 /* singleQuote */) + "'";
|
|
}
|
|
else {
|
|
return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"';
|
|
}
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
return "`" + escapeText(node.text, 96 /* backtick */) + "`";
|
|
case 14 /* TemplateHead */:
|
|
// tslint:disable-next-line no-invalid-template-strings
|
|
return "`" + escapeText(node.text, 96 /* backtick */) + "${";
|
|
case 15 /* TemplateMiddle */:
|
|
// tslint:disable-next-line no-invalid-template-strings
|
|
return "}" + escapeText(node.text, 96 /* backtick */) + "${";
|
|
case 16 /* TemplateTail */:
|
|
return "}" + escapeText(node.text, 96 /* backtick */) + "`";
|
|
case 8 /* NumericLiteral */:
|
|
case 12 /* RegularExpressionLiteral */:
|
|
return node.text;
|
|
}
|
|
return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
|
|
}
|
|
ts.getLiteralText = getLiteralText;
|
|
function getTextOfConstantValue(value) {
|
|
return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
|
|
}
|
|
ts.getTextOfConstantValue = getTextOfConstantValue;
|
|
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
|
function escapeLeadingUnderscores(identifier) {
|
|
return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier);
|
|
}
|
|
ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
|
|
/**
|
|
* @deprecated Use `id.escapedText` to get the escaped text of an Identifier.
|
|
* @param identifier The identifier to escape
|
|
*/
|
|
function escapeIdentifier(identifier) {
|
|
return identifier;
|
|
}
|
|
ts.escapeIdentifier = escapeIdentifier;
|
|
// Make an identifier from an external module name by extracting the string after the last "/" and replacing
|
|
// all non-alphanumeric characters with underscores
|
|
function makeIdentifierFromModuleName(moduleName) {
|
|
return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
|
|
}
|
|
ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
|
|
function isBlockOrCatchScoped(declaration) {
|
|
return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 ||
|
|
isCatchClauseVariableDeclarationOrBindingElement(declaration);
|
|
}
|
|
ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
|
|
function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
|
|
var node = getRootDeclaration(declaration);
|
|
return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */;
|
|
}
|
|
ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
|
|
function isAmbientModule(node) {
|
|
return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node));
|
|
}
|
|
ts.isAmbientModule = isAmbientModule;
|
|
function isModuleWithStringLiteralName(node) {
|
|
return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */;
|
|
}
|
|
ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
|
|
function isNonGlobalAmbientModule(node) {
|
|
return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
|
|
}
|
|
ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
|
|
/**
|
|
* An effective module (namespace) declaration is either
|
|
* 1. An actual declaration: namespace X { ... }
|
|
* 2. A Javascript declaration, which is:
|
|
* An identifier in a nested property access expression: Y in `X.Y.Z = { ... }`
|
|
*/
|
|
function isEffectiveModuleDeclaration(node) {
|
|
return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
|
|
}
|
|
ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
|
|
/** Given a symbol for a module, checks that it is a shorthand ambient module. */
|
|
function isShorthandAmbientModuleSymbol(moduleSymbol) {
|
|
return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
|
|
}
|
|
ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
|
|
function isShorthandAmbientModule(node) {
|
|
// The only kind of module that can be missing a body is a shorthand ambient module.
|
|
return node && node.kind === 239 /* ModuleDeclaration */ && (!node.body);
|
|
}
|
|
function isBlockScopedContainerTopLevel(node) {
|
|
return node.kind === 274 /* SourceFile */ ||
|
|
node.kind === 239 /* ModuleDeclaration */ ||
|
|
ts.isFunctionLike(node);
|
|
}
|
|
ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
|
|
function isGlobalScopeAugmentation(module) {
|
|
return !!(module.flags & 512 /* GlobalAugmentation */);
|
|
}
|
|
ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
|
|
function isExternalModuleAugmentation(node) {
|
|
return isAmbientModule(node) && isModuleAugmentationExternal(node);
|
|
}
|
|
ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
|
|
function isModuleAugmentationExternal(node) {
|
|
// external module augmentation is a ambient module declaration that is either:
|
|
// - defined in the top level scope and source file is an external module
|
|
// - defined inside ambient module declaration located in the top level scope and source file not an external module
|
|
switch (node.parent.kind) {
|
|
case 274 /* SourceFile */:
|
|
return ts.isExternalModule(node.parent);
|
|
case 240 /* ModuleBlock */:
|
|
return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
|
|
function isEffectiveExternalModule(node, compilerOptions) {
|
|
return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
|
|
}
|
|
ts.isEffectiveExternalModule = isEffectiveExternalModule;
|
|
function isBlockScope(node, parentNode) {
|
|
switch (node.kind) {
|
|
case 274 /* SourceFile */:
|
|
case 241 /* CaseBlock */:
|
|
case 269 /* CatchClause */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 220 /* ForStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
case 155 /* Constructor */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
return true;
|
|
case 213 /* Block */:
|
|
// function block is not considered block-scope container
|
|
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
|
|
return !ts.isFunctionLike(parentNode);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isBlockScope = isBlockScope;
|
|
function isDeclarationWithTypeParameters(node) {
|
|
switch (node.kind) {
|
|
case 158 /* CallSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 153 /* MethodSignature */:
|
|
case 160 /* IndexSignature */:
|
|
case 163 /* FunctionType */:
|
|
case 164 /* ConstructorType */:
|
|
case 284 /* JSDocFunctionType */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 205 /* ClassExpression */:
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
case 296 /* JSDocTemplateTag */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 292 /* JSDocCallbackTag */:
|
|
case 297 /* JSDocTypedefTag */:
|
|
case 288 /* JSDocSignature */:
|
|
return true;
|
|
default:
|
|
ts.assertTypeIsNever(node);
|
|
return false;
|
|
}
|
|
}
|
|
ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
|
|
function isAnyImportSyntax(node) {
|
|
switch (node.kind) {
|
|
case 244 /* ImportDeclaration */:
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
function isLateVisibilityPaintedStatement(node) {
|
|
switch (node.kind) {
|
|
case 244 /* ImportDeclaration */:
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
case 214 /* VariableStatement */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 238 /* EnumDeclaration */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
|
|
function isAnyImportOrReExport(node) {
|
|
return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
|
|
}
|
|
ts.isAnyImportOrReExport = isAnyImportOrReExport;
|
|
// Gets the nearest enclosing block scope container that has the provided node
|
|
// as a descendant, that is not the provided node.
|
|
function getEnclosingBlockScopeContainer(node) {
|
|
return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
|
|
}
|
|
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
|
|
// Return display name of an identifier
|
|
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
|
// text of the expression in the computed property.
|
|
function declarationNameToString(name) {
|
|
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
|
}
|
|
ts.declarationNameToString = declarationNameToString;
|
|
function getNameFromIndexInfo(info) {
|
|
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
|
|
}
|
|
ts.getNameFromIndexInfo = getNameFromIndexInfo;
|
|
function getTextOfPropertyName(name) {
|
|
switch (name.kind) {
|
|
case 71 /* Identifier */:
|
|
return name.escapedText;
|
|
case 9 /* StringLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
return escapeLeadingUnderscores(name.text);
|
|
case 147 /* ComputedPropertyName */:
|
|
return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined!
|
|
default:
|
|
ts.Debug.assertNever(name);
|
|
}
|
|
}
|
|
ts.getTextOfPropertyName = getTextOfPropertyName;
|
|
function entityNameToString(name) {
|
|
switch (name.kind) {
|
|
case 71 /* Identifier */:
|
|
return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
|
|
case 146 /* QualifiedName */:
|
|
return entityNameToString(name.left) + "." + entityNameToString(name.right);
|
|
case 185 /* PropertyAccessExpression */:
|
|
return entityNameToString(name.expression) + "." + entityNameToString(name.name);
|
|
default:
|
|
throw ts.Debug.assertNever(name);
|
|
}
|
|
}
|
|
ts.entityNameToString = entityNameToString;
|
|
function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
|
|
var sourceFile = getSourceFileOfNode(node);
|
|
return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
|
|
}
|
|
ts.createDiagnosticForNode = createDiagnosticForNode;
|
|
function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
|
|
var start = ts.skipTrivia(sourceFile.text, nodes.pos);
|
|
return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
|
|
}
|
|
ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
|
|
function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
|
|
var span = getErrorSpanForNode(sourceFile, node);
|
|
return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
|
|
}
|
|
ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
|
|
function createDiagnosticForNodeFromMessageChain(node, messageChain) {
|
|
var sourceFile = getSourceFileOfNode(node);
|
|
var span = getErrorSpanForNode(sourceFile, node);
|
|
return {
|
|
file: sourceFile,
|
|
start: span.start,
|
|
length: span.length,
|
|
code: messageChain.code,
|
|
category: messageChain.category,
|
|
messageText: messageChain.next ? messageChain : messageChain.messageText
|
|
};
|
|
}
|
|
ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
|
|
function getSpanOfTokenAtPosition(sourceFile, pos) {
|
|
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
|
scanner.scan();
|
|
var start = scanner.getTokenPos();
|
|
return ts.createTextSpanFromBounds(start, scanner.getTextPos());
|
|
}
|
|
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
|
|
function getErrorSpanForArrowFunction(sourceFile, node) {
|
|
var pos = ts.skipTrivia(sourceFile.text, node.pos);
|
|
if (node.body && node.body.kind === 213 /* Block */) {
|
|
var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
|
|
var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
|
|
if (startLine < endLine) {
|
|
// The arrow function spans multiple lines,
|
|
// make the error span be the first line, inclusive.
|
|
return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
|
|
}
|
|
}
|
|
return ts.createTextSpanFromBounds(pos, node.end);
|
|
}
|
|
function getErrorSpanForNode(sourceFile, node) {
|
|
var errorNode = node;
|
|
switch (node.kind) {
|
|
case 274 /* SourceFile */:
|
|
var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false);
|
|
if (pos_1 === sourceFile.text.length) {
|
|
// file is empty - return span for the beginning of the file
|
|
return ts.createTextSpan(0, 0);
|
|
}
|
|
return getSpanOfTokenAtPosition(sourceFile, pos_1);
|
|
// This list is a work in progress. Add missing node kinds to improve their error
|
|
// spans.
|
|
case 232 /* VariableDeclaration */:
|
|
case 182 /* BindingElement */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 205 /* ClassExpression */:
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 238 /* EnumDeclaration */:
|
|
case 273 /* EnumMember */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
errorNode = node.name;
|
|
break;
|
|
case 193 /* ArrowFunction */:
|
|
return getErrorSpanForArrowFunction(sourceFile, node);
|
|
}
|
|
if (errorNode === undefined) {
|
|
// If we don't have a better node, then just set the error on the first token of
|
|
// construct.
|
|
return getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
}
|
|
var isMissing = nodeIsMissing(errorNode);
|
|
var pos = isMissing
|
|
? errorNode.pos
|
|
: ts.skipTrivia(sourceFile.text, errorNode.pos);
|
|
// These asserts should all be satisfied for a properly constructed `errorNode`.
|
|
if (isMissing) {
|
|
ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
|
|
ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
|
|
}
|
|
else {
|
|
ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
|
|
ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
|
|
}
|
|
return ts.createTextSpanFromBounds(pos, errorNode.end);
|
|
}
|
|
ts.getErrorSpanForNode = getErrorSpanForNode;
|
|
function isExternalOrCommonJsModule(file) {
|
|
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
|
}
|
|
ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
|
|
function isJsonSourceFile(file) {
|
|
return file.scriptKind === 6 /* JSON */;
|
|
}
|
|
ts.isJsonSourceFile = isJsonSourceFile;
|
|
function isConstEnumDeclaration(node) {
|
|
return node.kind === 238 /* EnumDeclaration */ && isConst(node);
|
|
}
|
|
ts.isConstEnumDeclaration = isConstEnumDeclaration;
|
|
function isConst(node) {
|
|
return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */)
|
|
|| !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */);
|
|
}
|
|
ts.isConst = isConst;
|
|
function isLet(node) {
|
|
return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */);
|
|
}
|
|
ts.isLet = isLet;
|
|
function isSuperCall(n) {
|
|
return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */;
|
|
}
|
|
ts.isSuperCall = isSuperCall;
|
|
function isImportCall(n) {
|
|
return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */;
|
|
}
|
|
ts.isImportCall = isImportCall;
|
|
function isLiteralImportTypeNode(n) {
|
|
return n.kind === 179 /* ImportType */ &&
|
|
n.argument.kind === 178 /* LiteralType */ &&
|
|
ts.isStringLiteral(n.argument.literal);
|
|
}
|
|
ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
|
|
function isPrologueDirective(node) {
|
|
return node.kind === 216 /* ExpressionStatement */
|
|
&& node.expression.kind === 9 /* StringLiteral */;
|
|
}
|
|
ts.isPrologueDirective = isPrologueDirective;
|
|
function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
|
|
return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
|
|
}
|
|
ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
|
|
function getJSDocCommentRanges(node, text) {
|
|
var commentRanges = (node.kind === 149 /* Parameter */ ||
|
|
node.kind === 148 /* TypeParameter */ ||
|
|
node.kind === 192 /* FunctionExpression */ ||
|
|
node.kind === 193 /* ArrowFunction */ ||
|
|
node.kind === 191 /* ParenthesizedExpression */) ?
|
|
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
|
|
ts.getLeadingCommentRanges(text, node.pos);
|
|
// True if the comment starts with '/**' but not if it is '/**/'
|
|
return ts.filter(commentRanges, function (comment) {
|
|
return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
|
|
text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ &&
|
|
text.charCodeAt(comment.pos + 3) !== 47 /* slash */;
|
|
});
|
|
}
|
|
ts.getJSDocCommentRanges = getJSDocCommentRanges;
|
|
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
|
var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
|
|
ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
|
var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
|
|
function isPartOfTypeNode(node) {
|
|
if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) {
|
|
return true;
|
|
}
|
|
switch (node.kind) {
|
|
case 119 /* AnyKeyword */:
|
|
case 142 /* UnknownKeyword */:
|
|
case 134 /* NumberKeyword */:
|
|
case 137 /* StringKeyword */:
|
|
case 122 /* BooleanKeyword */:
|
|
case 138 /* SymbolKeyword */:
|
|
case 140 /* UndefinedKeyword */:
|
|
case 131 /* NeverKeyword */:
|
|
return true;
|
|
case 105 /* VoidKeyword */:
|
|
return node.parent.kind !== 196 /* VoidExpression */;
|
|
case 207 /* ExpressionWithTypeArguments */:
|
|
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
case 148 /* TypeParameter */:
|
|
return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */;
|
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
|
// above them to find the lowest container
|
|
case 71 /* Identifier */:
|
|
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
|
|
if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) {
|
|
node = node.parent;
|
|
}
|
|
else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) {
|
|
node = node.parent;
|
|
}
|
|
// At this point, node is either a qualified name or an identifier
|
|
ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
|
|
// falls through
|
|
case 146 /* QualifiedName */:
|
|
case 185 /* PropertyAccessExpression */:
|
|
case 99 /* ThisKeyword */: {
|
|
var parent = node.parent;
|
|
if (parent.kind === 165 /* TypeQuery */) {
|
|
return false;
|
|
}
|
|
if (parent.kind === 179 /* ImportType */) {
|
|
return !parent.isTypeOf;
|
|
}
|
|
// Do not recursively call isPartOfTypeNode on the parent. In the example:
|
|
//
|
|
// let a: A.B.C;
|
|
//
|
|
// Calling isPartOfTypeNode would consider the qualified name A.B a type node.
|
|
// Only C and A.B.C are type nodes.
|
|
if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) {
|
|
return true;
|
|
}
|
|
switch (parent.kind) {
|
|
case 207 /* ExpressionWithTypeArguments */:
|
|
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
case 148 /* TypeParameter */:
|
|
return node === parent.constraint;
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 149 /* Parameter */:
|
|
case 232 /* VariableDeclaration */:
|
|
return node === parent.type;
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 155 /* Constructor */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
return node === parent.type;
|
|
case 158 /* CallSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 160 /* IndexSignature */:
|
|
return node === parent.type;
|
|
case 190 /* TypeAssertionExpression */:
|
|
return node === parent.type;
|
|
case 187 /* CallExpression */:
|
|
case 188 /* NewExpression */:
|
|
return ts.contains(parent.typeArguments, node);
|
|
case 189 /* TaggedTemplateExpression */:
|
|
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.isPartOfTypeNode = isPartOfTypeNode;
|
|
function isChildOfNodeWithKind(node, kind) {
|
|
while (node) {
|
|
if (node.kind === kind) {
|
|
return true;
|
|
}
|
|
node = node.parent;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
|
|
// Warning: This has the same semantics as the forEach family of functions,
|
|
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
|
function forEachReturnStatement(body, visitor) {
|
|
return traverse(body);
|
|
function traverse(node) {
|
|
switch (node.kind) {
|
|
case 225 /* ReturnStatement */:
|
|
return visitor(node);
|
|
case 241 /* CaseBlock */:
|
|
case 213 /* Block */:
|
|
case 217 /* IfStatement */:
|
|
case 218 /* DoStatement */:
|
|
case 219 /* WhileStatement */:
|
|
case 220 /* ForStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
case 226 /* WithStatement */:
|
|
case 227 /* SwitchStatement */:
|
|
case 266 /* CaseClause */:
|
|
case 267 /* DefaultClause */:
|
|
case 228 /* LabeledStatement */:
|
|
case 230 /* TryStatement */:
|
|
case 269 /* CatchClause */:
|
|
return ts.forEachChild(node, traverse);
|
|
}
|
|
}
|
|
}
|
|
ts.forEachReturnStatement = forEachReturnStatement;
|
|
function forEachYieldExpression(body, visitor) {
|
|
return traverse(body);
|
|
function traverse(node) {
|
|
switch (node.kind) {
|
|
case 203 /* YieldExpression */:
|
|
visitor(node);
|
|
var operand = node.expression;
|
|
if (operand) {
|
|
traverse(operand);
|
|
}
|
|
return;
|
|
case 238 /* EnumDeclaration */:
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 205 /* ClassExpression */:
|
|
// These are not allowed inside a generator now, but eventually they may be allowed
|
|
// as local types. Regardless, any yield statements contained within them should be
|
|
// skipped in this traversal.
|
|
return;
|
|
default:
|
|
if (ts.isFunctionLike(node)) {
|
|
if (node.name && node.name.kind === 147 /* ComputedPropertyName */) {
|
|
// Note that we will not include methods/accessors of a class because they would require
|
|
// first descending into the class. This is by design.
|
|
traverse(node.name.expression);
|
|
return;
|
|
}
|
|
}
|
|
else if (!isPartOfTypeNode(node)) {
|
|
// This is the general case, which should include mostly expressions and statements.
|
|
// Also includes NodeArrays.
|
|
ts.forEachChild(node, traverse);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ts.forEachYieldExpression = forEachYieldExpression;
|
|
/**
|
|
* Gets the most likely element type for a TypeNode. This is not an exhaustive test
|
|
* as it assumes a rest argument can only be an array type (either T[], or Array<T>).
|
|
*
|
|
* @param node The type node.
|
|
*/
|
|
function getRestParameterElementType(node) {
|
|
if (node && node.kind === 167 /* ArrayType */) {
|
|
return node.elementType;
|
|
}
|
|
else if (node && node.kind === 162 /* TypeReference */) {
|
|
return ts.singleOrUndefined(node.typeArguments);
|
|
}
|
|
else {
|
|
return undefined;
|
|
}
|
|
}
|
|
ts.getRestParameterElementType = getRestParameterElementType;
|
|
function getMembersOfDeclaration(node) {
|
|
switch (node.kind) {
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 205 /* ClassExpression */:
|
|
case 166 /* TypeLiteral */:
|
|
return node.members;
|
|
case 184 /* ObjectLiteralExpression */:
|
|
return node.properties;
|
|
}
|
|
}
|
|
ts.getMembersOfDeclaration = getMembersOfDeclaration;
|
|
function isVariableLike(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 182 /* BindingElement */:
|
|
case 273 /* EnumMember */:
|
|
case 149 /* Parameter */:
|
|
case 270 /* PropertyAssignment */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 271 /* ShorthandPropertyAssignment */:
|
|
case 232 /* VariableDeclaration */:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.isVariableLike = isVariableLike;
|
|
function isVariableLikeOrAccessor(node) {
|
|
return isVariableLike(node) || ts.isAccessor(node);
|
|
}
|
|
ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
|
|
function isVariableDeclarationInVariableStatement(node) {
|
|
return node.parent.kind === 233 /* VariableDeclarationList */
|
|
&& node.parent.parent.kind === 214 /* VariableStatement */;
|
|
}
|
|
ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
|
|
function isValidESSymbolDeclaration(node) {
|
|
return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
|
ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
|
|
ts.isPropertySignature(node) && hasReadonlyModifier(node);
|
|
}
|
|
ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
|
|
function introducesArgumentsExoticObject(node) {
|
|
switch (node.kind) {
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
|
|
function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
|
|
while (true) {
|
|
if (beforeUnwrapLabelCallback) {
|
|
beforeUnwrapLabelCallback(node);
|
|
}
|
|
if (node.statement.kind !== 228 /* LabeledStatement */) {
|
|
return node.statement;
|
|
}
|
|
node = node.statement;
|
|
}
|
|
}
|
|
ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
|
|
function isFunctionBlock(node) {
|
|
return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent);
|
|
}
|
|
ts.isFunctionBlock = isFunctionBlock;
|
|
function isObjectLiteralMethod(node) {
|
|
return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */;
|
|
}
|
|
ts.isObjectLiteralMethod = isObjectLiteralMethod;
|
|
function isObjectLiteralOrClassExpressionMethod(node) {
|
|
return node.kind === 154 /* MethodDeclaration */ &&
|
|
(node.parent.kind === 184 /* ObjectLiteralExpression */ ||
|
|
node.parent.kind === 205 /* ClassExpression */);
|
|
}
|
|
ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
|
|
function isIdentifierTypePredicate(predicate) {
|
|
return predicate && predicate.kind === 1 /* Identifier */;
|
|
}
|
|
ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
|
|
function isThisTypePredicate(predicate) {
|
|
return predicate && predicate.kind === 0 /* This */;
|
|
}
|
|
ts.isThisTypePredicate = isThisTypePredicate;
|
|
function getPropertyAssignment(objectLiteral, key, key2) {
|
|
return objectLiteral.properties.filter(function (property) {
|
|
if (property.kind === 270 /* PropertyAssignment */) {
|
|
var propName = getTextOfPropertyName(property.name);
|
|
return key === propName || (!!key2 && key2 === propName);
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
ts.getPropertyAssignment = getPropertyAssignment;
|
|
function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
|
|
if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
|
|
var expression = tsConfigSourceFile.statements[0].expression;
|
|
return ts.tryCast(expression, ts.isObjectLiteralExpression);
|
|
}
|
|
}
|
|
ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
|
|
function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
|
|
return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
|
|
return ts.isArrayLiteralExpression(property.initializer) ?
|
|
ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
|
|
undefined;
|
|
});
|
|
}
|
|
ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
|
|
function getTsConfigPropArray(tsConfigSourceFile, propKey) {
|
|
var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
|
|
return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
|
|
}
|
|
ts.getTsConfigPropArray = getTsConfigPropArray;
|
|
function getContainingFunction(node) {
|
|
return findAncestor(node.parent, ts.isFunctionLike);
|
|
}
|
|
ts.getContainingFunction = getContainingFunction;
|
|
function getContainingClass(node) {
|
|
return findAncestor(node.parent, ts.isClassLike);
|
|
}
|
|
ts.getContainingClass = getContainingClass;
|
|
function getThisContainer(node, includeArrowFunctions) {
|
|
ts.Debug.assert(node.kind !== 274 /* SourceFile */);
|
|
while (true) {
|
|
node = node.parent;
|
|
if (!node) {
|
|
return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that.
|
|
}
|
|
switch (node.kind) {
|
|
case 147 /* ComputedPropertyName */:
|
|
// If the grandparent node is an object literal (as opposed to a class),
|
|
// then the computed property is not a 'this' container.
|
|
// A computed property name in a class needs to be a this container
|
|
// so that we can error on it.
|
|
if (ts.isClassLike(node.parent.parent)) {
|
|
return node;
|
|
}
|
|
// If this is a computed property, then the parent should not
|
|
// make it a this container. The parent might be a property
|
|
// in an object literal, like a method or accessor. But in order for
|
|
// such a parent to be a this container, the reference must be in
|
|
// the *body* of the container.
|
|
node = node.parent;
|
|
break;
|
|
case 150 /* Decorator */:
|
|
// Decorators are always applied outside of the body of a class or method.
|
|
if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) {
|
|
// If the decorator's parent is a Parameter, we resolve the this container from
|
|
// the grandparent class declaration.
|
|
node = node.parent.parent;
|
|
}
|
|
else if (ts.isClassElement(node.parent)) {
|
|
// If the decorator's parent is a class element, we resolve the 'this' container
|
|
// from the parent class declaration.
|
|
node = node.parent;
|
|
}
|
|
break;
|
|
case 193 /* ArrowFunction */:
|
|
if (!includeArrowFunctions) {
|
|
continue;
|
|
}
|
|
// falls through
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 158 /* CallSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 160 /* IndexSignature */:
|
|
case 238 /* EnumDeclaration */:
|
|
case 274 /* SourceFile */:
|
|
return node;
|
|
}
|
|
}
|
|
}
|
|
ts.getThisContainer = getThisContainer;
|
|
function getNewTargetContainer(node) {
|
|
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
|
if (container) {
|
|
switch (container.kind) {
|
|
case 155 /* Constructor */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
return container;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getNewTargetContainer = getNewTargetContainer;
|
|
/**
|
|
* Given an super call/property node, returns the closest node where
|
|
* - a super call/property access is legal in the node and not legal in the parent node the node.
|
|
* i.e. super call is legal in constructor but not legal in the class body.
|
|
* - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher)
|
|
* - a super call/property is definitely illegal in the container (but might be legal in some subnode)
|
|
* i.e. super property access is illegal in function declaration but can be legal in the statement list
|
|
*/
|
|
function getSuperContainer(node, stopOnFunctions) {
|
|
while (true) {
|
|
node = node.parent;
|
|
if (!node) {
|
|
return node;
|
|
}
|
|
switch (node.kind) {
|
|
case 147 /* ComputedPropertyName */:
|
|
node = node.parent;
|
|
break;
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
if (!stopOnFunctions) {
|
|
continue;
|
|
}
|
|
// falls through
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
return node;
|
|
case 150 /* Decorator */:
|
|
// Decorators are always applied outside of the body of a class or method.
|
|
if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) {
|
|
// If the decorator's parent is a Parameter, we resolve the this container from
|
|
// the grandparent class declaration.
|
|
node = node.parent.parent;
|
|
}
|
|
else if (ts.isClassElement(node.parent)) {
|
|
// If the decorator's parent is a class element, we resolve the 'this' container
|
|
// from the parent class declaration.
|
|
node = node.parent;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
ts.getSuperContainer = getSuperContainer;
|
|
function getImmediatelyInvokedFunctionExpression(func) {
|
|
if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) {
|
|
var prev = func;
|
|
var parent = func.parent;
|
|
while (parent.kind === 191 /* ParenthesizedExpression */) {
|
|
prev = parent;
|
|
parent = parent.parent;
|
|
}
|
|
if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) {
|
|
return parent;
|
|
}
|
|
}
|
|
}
|
|
ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
|
|
/**
|
|
* Determines whether a node is a property or element access expression for `super`.
|
|
*/
|
|
function isSuperProperty(node) {
|
|
var kind = node.kind;
|
|
return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */)
|
|
&& node.expression.kind === 97 /* SuperKeyword */;
|
|
}
|
|
ts.isSuperProperty = isSuperProperty;
|
|
/**
|
|
* Determines whether a node is a property or element access expression for `this`.
|
|
*/
|
|
function isThisProperty(node) {
|
|
var kind = node.kind;
|
|
return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */)
|
|
&& node.expression.kind === 99 /* ThisKeyword */;
|
|
}
|
|
ts.isThisProperty = isThisProperty;
|
|
function getEntityNameFromTypeNode(node) {
|
|
switch (node.kind) {
|
|
case 162 /* TypeReference */:
|
|
return node.typeName;
|
|
case 207 /* ExpressionWithTypeArguments */:
|
|
return isEntityNameExpression(node.expression)
|
|
? node.expression
|
|
: undefined;
|
|
case 71 /* Identifier */:
|
|
case 146 /* QualifiedName */:
|
|
return node;
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
|
|
function getInvokedExpression(node) {
|
|
switch (node.kind) {
|
|
case 189 /* TaggedTemplateExpression */:
|
|
return node.tag;
|
|
case 257 /* JsxOpeningElement */:
|
|
case 256 /* JsxSelfClosingElement */:
|
|
return node.tagName;
|
|
default:
|
|
return node.expression;
|
|
}
|
|
}
|
|
ts.getInvokedExpression = getInvokedExpression;
|
|
function nodeCanBeDecorated(node, parent, grandparent) {
|
|
switch (node.kind) {
|
|
case 235 /* ClassDeclaration */:
|
|
// classes are valid targets
|
|
return true;
|
|
case 152 /* PropertyDeclaration */:
|
|
// property declarations are valid if their parent is a class declaration.
|
|
return parent.kind === 235 /* ClassDeclaration */;
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 154 /* MethodDeclaration */:
|
|
// if this method has a body and its parent is a class declaration, this is a valid target.
|
|
return node.body !== undefined
|
|
&& parent.kind === 235 /* ClassDeclaration */;
|
|
case 149 /* Parameter */:
|
|
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
|
|
return parent.body !== undefined
|
|
&& (parent.kind === 155 /* Constructor */
|
|
|| parent.kind === 154 /* MethodDeclaration */
|
|
|| parent.kind === 157 /* SetAccessor */)
|
|
&& grandparent.kind === 235 /* ClassDeclaration */;
|
|
}
|
|
return false;
|
|
}
|
|
ts.nodeCanBeDecorated = nodeCanBeDecorated;
|
|
function nodeIsDecorated(node, parent, grandparent) {
|
|
return node.decorators !== undefined
|
|
&& nodeCanBeDecorated(node, parent, grandparent); // TODO: GH#18217
|
|
}
|
|
ts.nodeIsDecorated = nodeIsDecorated;
|
|
function nodeOrChildIsDecorated(node, parent, grandparent) {
|
|
return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); // TODO: GH#18217
|
|
}
|
|
ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
|
|
function childIsDecorated(node, parent) {
|
|
switch (node.kind) {
|
|
case 235 /* ClassDeclaration */:
|
|
return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217
|
|
case 154 /* MethodDeclaration */:
|
|
case 157 /* SetAccessor */:
|
|
return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.childIsDecorated = childIsDecorated;
|
|
function isJSXTagName(node) {
|
|
var parent = node.parent;
|
|
if (parent.kind === 257 /* JsxOpeningElement */ ||
|
|
parent.kind === 256 /* JsxSelfClosingElement */ ||
|
|
parent.kind === 258 /* JsxClosingElement */) {
|
|
return parent.tagName === node;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isJSXTagName = isJSXTagName;
|
|
function isExpressionNode(node) {
|
|
switch (node.kind) {
|
|
case 97 /* SuperKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
case 12 /* RegularExpressionLiteral */:
|
|
case 183 /* ArrayLiteralExpression */:
|
|
case 184 /* ObjectLiteralExpression */:
|
|
case 185 /* PropertyAccessExpression */:
|
|
case 186 /* ElementAccessExpression */:
|
|
case 187 /* CallExpression */:
|
|
case 188 /* NewExpression */:
|
|
case 189 /* TaggedTemplateExpression */:
|
|
case 208 /* AsExpression */:
|
|
case 190 /* TypeAssertionExpression */:
|
|
case 209 /* NonNullExpression */:
|
|
case 191 /* ParenthesizedExpression */:
|
|
case 192 /* FunctionExpression */:
|
|
case 205 /* ClassExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 196 /* VoidExpression */:
|
|
case 194 /* DeleteExpression */:
|
|
case 195 /* TypeOfExpression */:
|
|
case 198 /* PrefixUnaryExpression */:
|
|
case 199 /* PostfixUnaryExpression */:
|
|
case 200 /* BinaryExpression */:
|
|
case 201 /* ConditionalExpression */:
|
|
case 204 /* SpreadElement */:
|
|
case 202 /* TemplateExpression */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 206 /* OmittedExpression */:
|
|
case 255 /* JsxElement */:
|
|
case 256 /* JsxSelfClosingElement */:
|
|
case 259 /* JsxFragment */:
|
|
case 203 /* YieldExpression */:
|
|
case 197 /* AwaitExpression */:
|
|
case 210 /* MetaProperty */:
|
|
return true;
|
|
case 146 /* QualifiedName */:
|
|
while (node.parent.kind === 146 /* QualifiedName */) {
|
|
node = node.parent;
|
|
}
|
|
return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node);
|
|
case 71 /* Identifier */:
|
|
if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) {
|
|
return true;
|
|
}
|
|
// falls through
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 99 /* ThisKeyword */:
|
|
return isInExpressionContext(node);
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isExpressionNode = isExpressionNode;
|
|
function isInExpressionContext(node) {
|
|
var parent = node.parent;
|
|
switch (parent.kind) {
|
|
case 232 /* VariableDeclaration */:
|
|
case 149 /* Parameter */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 273 /* EnumMember */:
|
|
case 270 /* PropertyAssignment */:
|
|
case 182 /* BindingElement */:
|
|
return parent.initializer === node;
|
|
case 216 /* ExpressionStatement */:
|
|
case 217 /* IfStatement */:
|
|
case 218 /* DoStatement */:
|
|
case 219 /* WhileStatement */:
|
|
case 225 /* ReturnStatement */:
|
|
case 226 /* WithStatement */:
|
|
case 227 /* SwitchStatement */:
|
|
case 266 /* CaseClause */:
|
|
case 229 /* ThrowStatement */:
|
|
return parent.expression === node;
|
|
case 220 /* ForStatement */:
|
|
var forStatement = parent;
|
|
return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) ||
|
|
forStatement.condition === node ||
|
|
forStatement.incrementor === node;
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
var forInStatement = parent;
|
|
return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) ||
|
|
forInStatement.expression === node;
|
|
case 190 /* TypeAssertionExpression */:
|
|
case 208 /* AsExpression */:
|
|
return node === parent.expression;
|
|
case 211 /* TemplateSpan */:
|
|
return node === parent.expression;
|
|
case 147 /* ComputedPropertyName */:
|
|
return node === parent.expression;
|
|
case 150 /* Decorator */:
|
|
case 265 /* JsxExpression */:
|
|
case 264 /* JsxSpreadAttribute */:
|
|
case 272 /* SpreadAssignment */:
|
|
return true;
|
|
case 207 /* ExpressionWithTypeArguments */:
|
|
return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
default:
|
|
return isExpressionNode(parent);
|
|
}
|
|
}
|
|
ts.isInExpressionContext = isInExpressionContext;
|
|
function isExternalModuleImportEqualsDeclaration(node) {
|
|
return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */;
|
|
}
|
|
ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
|
|
function getExternalModuleImportEqualsDeclarationExpression(node) {
|
|
ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
|
|
return node.moduleReference.expression;
|
|
}
|
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
|
|
function isInternalModuleImportEqualsDeclaration(node) {
|
|
return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */;
|
|
}
|
|
ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
|
|
function isSourceFileJavaScript(file) {
|
|
return isInJavaScriptFile(file);
|
|
}
|
|
ts.isSourceFileJavaScript = isSourceFileJavaScript;
|
|
function isSourceFileNotJavaScript(file) {
|
|
return !isInJavaScriptFile(file);
|
|
}
|
|
ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript;
|
|
function isInJavaScriptFile(node) {
|
|
return !!node && !!(node.flags & 65536 /* JavaScriptFile */);
|
|
}
|
|
ts.isInJavaScriptFile = isInJavaScriptFile;
|
|
function isInJsonFile(node) {
|
|
return !!node && !!(node.flags & 16777216 /* JsonFile */);
|
|
}
|
|
ts.isInJsonFile = isInJsonFile;
|
|
function isInJSDoc(node) {
|
|
return !!node && !!(node.flags & 2097152 /* JSDoc */);
|
|
}
|
|
ts.isInJSDoc = isInJSDoc;
|
|
function isJSDocIndexSignature(node) {
|
|
return ts.isTypeReferenceNode(node) &&
|
|
ts.isIdentifier(node.typeName) &&
|
|
node.typeName.escapedText === "Object" &&
|
|
node.typeArguments && node.typeArguments.length === 2 &&
|
|
(node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */);
|
|
}
|
|
ts.isJSDocIndexSignature = isJSDocIndexSignature;
|
|
function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) {
|
|
if (callExpression.kind !== 187 /* CallExpression */) {
|
|
return false;
|
|
}
|
|
var _a = callExpression, expression = _a.expression, args = _a.arguments;
|
|
if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") {
|
|
return false;
|
|
}
|
|
if (args.length !== 1) {
|
|
return false;
|
|
}
|
|
var arg = args[0];
|
|
return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg);
|
|
}
|
|
ts.isRequireCall = isRequireCall;
|
|
function isSingleOrDoubleQuote(charCode) {
|
|
return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
|
|
}
|
|
ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
|
|
function isStringDoubleQuoted(str, sourceFile) {
|
|
return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */;
|
|
}
|
|
ts.isStringDoubleQuoted = isStringDoubleQuoted;
|
|
function getDeclarationOfJSInitializer(node) {
|
|
if (!isInJavaScriptFile(node) || !node.parent) {
|
|
return undefined;
|
|
}
|
|
var name;
|
|
var decl;
|
|
if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
|
|
name = node.parent.name;
|
|
decl = node.parent;
|
|
}
|
|
else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) {
|
|
name = node.parent.left;
|
|
decl = name;
|
|
}
|
|
else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) {
|
|
if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) {
|
|
name = node.parent.parent.name;
|
|
decl = node.parent.parent;
|
|
}
|
|
else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) {
|
|
name = node.parent.parent.left;
|
|
decl = name;
|
|
}
|
|
if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) {
|
|
return undefined;
|
|
}
|
|
}
|
|
if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) {
|
|
return undefined;
|
|
}
|
|
return decl;
|
|
}
|
|
ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer;
|
|
/** Get the initializer, taking into account defaulted Javascript initializers */
|
|
function getEffectiveInitializer(node) {
|
|
if (isInJavaScriptFile(node) && node.initializer &&
|
|
ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ &&
|
|
node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
|
|
return node.initializer.right;
|
|
}
|
|
return node.initializer;
|
|
}
|
|
ts.getEffectiveInitializer = getEffectiveInitializer;
|
|
/**
|
|
* Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getJavascriptInitializer).
|
|
* We treat the right hand side of assignments with container-like initalizers as declarations.
|
|
*/
|
|
function getAssignedJavascriptInitializer(node) {
|
|
if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) {
|
|
var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
|
|
return getJavascriptInitializer(node.parent.right, isPrototypeAssignment) ||
|
|
getDefaultedJavascriptInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
|
|
}
|
|
}
|
|
ts.getAssignedJavascriptInitializer = getAssignedJavascriptInitializer;
|
|
/**
|
|
* Recognized Javascript container-like initializers are:
|
|
* 1. (function() {})() -- IIFEs
|
|
* 2. function() { } -- Function expressions
|
|
* 3. class { } -- Class expressions
|
|
* 4. {} -- Empty object literals
|
|
* 5. { ... } -- Non-empty object literals, when used to initialize a prototype, like `C.prototype = { m() { } }`
|
|
*
|
|
* This function returns the provided initializer, or undefined if it is not valid.
|
|
*/
|
|
function getJavascriptInitializer(initializer, isPrototypeAssignment) {
|
|
if (ts.isCallExpression(initializer)) {
|
|
var e = skipParentheses(initializer.expression);
|
|
return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined;
|
|
}
|
|
if (initializer.kind === 192 /* FunctionExpression */ ||
|
|
initializer.kind === 205 /* ClassExpression */ ||
|
|
initializer.kind === 193 /* ArrowFunction */) {
|
|
return initializer;
|
|
}
|
|
if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
|
|
return initializer;
|
|
}
|
|
}
|
|
ts.getJavascriptInitializer = getJavascriptInitializer;
|
|
/**
|
|
* A defaulted Javascript initializer matches the pattern
|
|
* `Lhs = Lhs || JavascriptInitializer`
|
|
* or `var Lhs = Lhs || JavascriptInitializer`
|
|
*
|
|
* The second Lhs is required to be the same as the first except that it may be prefixed with
|
|
* 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker.
|
|
*/
|
|
function getDefaultedJavascriptInitializer(name, initializer, isPrototypeAssignment) {
|
|
var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getJavascriptInitializer(initializer.right, isPrototypeAssignment);
|
|
if (e && isSameEntityName(name, initializer.left)) {
|
|
return e;
|
|
}
|
|
}
|
|
function isDefaultedJavascriptInitializer(node) {
|
|
var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
|
|
ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left :
|
|
undefined;
|
|
return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
|
|
}
|
|
ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer;
|
|
/** Given a Javascript initializer, return the outer name. That is, the lhs of the assignment or the declaration name. */
|
|
function getOuterNameOfJsInitializer(node) {
|
|
if (ts.isBinaryExpression(node.parent)) {
|
|
var parent = (node.parent.operatorToken.kind === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
|
|
if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) {
|
|
return parent.left;
|
|
}
|
|
}
|
|
else if (ts.isVariableDeclaration(node.parent)) {
|
|
return node.parent.name;
|
|
}
|
|
}
|
|
ts.getOuterNameOfJsInitializer = getOuterNameOfJsInitializer;
|
|
/**
|
|
* Is the 'declared' name the same as the one in the initializer?
|
|
* @return true for identical entity names, as well as ones where the initializer is prefixed with
|
|
* 'window', 'self' or 'global'. For example:
|
|
*
|
|
* var my = my || {}
|
|
* var min = window.min || {}
|
|
* my.app = self.my.app || class { }
|
|
*/
|
|
function isSameEntityName(name, initializer) {
|
|
if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) {
|
|
return name.escapedText === initializer.escapedText;
|
|
}
|
|
if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) {
|
|
return (initializer.expression.kind === 99 /* ThisKeyword */ ||
|
|
ts.isIdentifier(initializer.expression) &&
|
|
(initializer.expression.escapedText === "window" ||
|
|
initializer.expression.escapedText === "self" ||
|
|
initializer.expression.escapedText === "global")) &&
|
|
isSameEntityName(name, initializer.name);
|
|
}
|
|
if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) {
|
|
return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression);
|
|
}
|
|
return false;
|
|
}
|
|
function getRightMostAssignedExpression(node) {
|
|
while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) {
|
|
node = node.right;
|
|
}
|
|
return node;
|
|
}
|
|
ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
|
|
function isExportsIdentifier(node) {
|
|
return ts.isIdentifier(node) && node.escapedText === "exports";
|
|
}
|
|
ts.isExportsIdentifier = isExportsIdentifier;
|
|
function isModuleExportsPropertyAccessExpression(node) {
|
|
return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports";
|
|
}
|
|
ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression;
|
|
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
|
/// assignments we treat as special in the binder
|
|
function getSpecialPropertyAssignmentKind(expr) {
|
|
if (!isInJavaScriptFile(expr) ||
|
|
expr.operatorToken.kind !== 58 /* EqualsToken */ ||
|
|
!ts.isPropertyAccessExpression(expr.left)) {
|
|
return 0 /* None */;
|
|
}
|
|
var lhs = expr.left;
|
|
if (lhs.expression.kind === 99 /* ThisKeyword */) {
|
|
return 4 /* ThisProperty */;
|
|
}
|
|
else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") {
|
|
// module.exports = expr
|
|
return 2 /* ModuleExports */;
|
|
}
|
|
else if (isEntityNameExpression(lhs.expression)) {
|
|
if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
|
|
// F.prototype = { ... }
|
|
return 6 /* Prototype */;
|
|
}
|
|
else if (isPrototypeAccess(lhs.expression)) {
|
|
// F.G....prototype.x = expr
|
|
return 3 /* PrototypeProperty */;
|
|
}
|
|
var nextToLast = lhs;
|
|
while (ts.isPropertyAccessExpression(nextToLast.expression)) {
|
|
nextToLast = nextToLast.expression;
|
|
}
|
|
ts.Debug.assert(ts.isIdentifier(nextToLast.expression));
|
|
var id = nextToLast.expression;
|
|
if (id.escapedText === "exports" ||
|
|
id.escapedText === "module" && nextToLast.name.escapedText === "exports") {
|
|
// exports.name = expr OR module.exports.name = expr
|
|
return 1 /* ExportsProperty */;
|
|
}
|
|
// F.G...x = expr
|
|
return 5 /* Property */;
|
|
}
|
|
return 0 /* None */;
|
|
}
|
|
ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind;
|
|
function getInitializerOfBinaryExpression(expr) {
|
|
while (ts.isBinaryExpression(expr.right)) {
|
|
expr = expr.right;
|
|
}
|
|
return expr.right;
|
|
}
|
|
ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
|
|
function isPrototypePropertyAssignment(node) {
|
|
return ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 3 /* PrototypeProperty */;
|
|
}
|
|
ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
|
|
function isSpecialPropertyDeclaration(expr) {
|
|
return isInJavaScriptFile(expr) &&
|
|
expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ &&
|
|
!!ts.getJSDocTypeTag(expr.parent);
|
|
}
|
|
ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
|
|
function importFromModuleSpecifier(node) {
|
|
return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
|
|
}
|
|
ts.importFromModuleSpecifier = importFromModuleSpecifier;
|
|
function tryGetImportFromModuleSpecifier(node) {
|
|
switch (node.parent.kind) {
|
|
case 244 /* ImportDeclaration */:
|
|
case 250 /* ExportDeclaration */:
|
|
return node.parent;
|
|
case 254 /* ExternalModuleReference */:
|
|
return node.parent.parent;
|
|
case 187 /* CallExpression */:
|
|
return node.parent;
|
|
case 178 /* LiteralType */:
|
|
ts.Debug.assert(ts.isStringLiteral(node));
|
|
return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|
|
ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
|
|
function getExternalModuleName(node) {
|
|
switch (node.kind) {
|
|
case 244 /* ImportDeclaration */:
|
|
case 250 /* ExportDeclaration */:
|
|
return node.moduleSpecifier;
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined;
|
|
case 179 /* ImportType */:
|
|
return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
|
|
default:
|
|
return ts.Debug.assertNever(node);
|
|
}
|
|
}
|
|
ts.getExternalModuleName = getExternalModuleName;
|
|
function getNamespaceDeclarationNode(node) {
|
|
switch (node.kind) {
|
|
case 244 /* ImportDeclaration */:
|
|
return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
return node;
|
|
case 250 /* ExportDeclaration */:
|
|
return undefined;
|
|
default:
|
|
return ts.Debug.assertNever(node);
|
|
}
|
|
}
|
|
ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
|
|
function isDefaultImport(node) {
|
|
return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name;
|
|
}
|
|
ts.isDefaultImport = isDefaultImport;
|
|
function hasQuestionToken(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 149 /* Parameter */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 271 /* ShorthandPropertyAssignment */:
|
|
case 270 /* PropertyAssignment */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
return node.questionToken !== undefined;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.hasQuestionToken = hasQuestionToken;
|
|
function isJSDocConstructSignature(node) {
|
|
return node.kind === 284 /* JSDocFunctionType */ &&
|
|
node.parameters.length > 0 &&
|
|
node.parameters[0].name &&
|
|
node.parameters[0].name.escapedText === "new";
|
|
}
|
|
ts.isJSDocConstructSignature = isJSDocConstructSignature;
|
|
function isJSDocTypeAlias(node) {
|
|
return node.kind === 297 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */;
|
|
}
|
|
ts.isJSDocTypeAlias = isJSDocTypeAlias;
|
|
function isTypeAlias(node) {
|
|
return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
|
|
}
|
|
ts.isTypeAlias = isTypeAlias;
|
|
function getSourceOfAssignment(node) {
|
|
return ts.isExpressionStatement(node) &&
|
|
node.expression && ts.isBinaryExpression(node.expression) &&
|
|
node.expression.operatorToken.kind === 58 /* EqualsToken */
|
|
? node.expression.right
|
|
: undefined;
|
|
}
|
|
function getSourceOfDefaultedAssignment(node) {
|
|
return ts.isExpressionStatement(node) &&
|
|
ts.isBinaryExpression(node.expression) &&
|
|
getSpecialPropertyAssignmentKind(node.expression) !== 0 /* None */ &&
|
|
ts.isBinaryExpression(node.expression.right) &&
|
|
node.expression.right.operatorToken.kind === 54 /* BarBarToken */
|
|
? node.expression.right.right
|
|
: undefined;
|
|
}
|
|
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
|
|
switch (node.kind) {
|
|
case 214 /* VariableStatement */:
|
|
var v = getSingleVariableOfVariableStatement(node);
|
|
return v && v.initializer;
|
|
case 152 /* PropertyDeclaration */:
|
|
return node.initializer;
|
|
case 270 /* PropertyAssignment */:
|
|
return node.initializer;
|
|
}
|
|
}
|
|
function getSingleVariableOfVariableStatement(node) {
|
|
return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
|
|
}
|
|
function getNestedModuleDeclaration(node) {
|
|
return ts.isModuleDeclaration(node) &&
|
|
node.body &&
|
|
node.body.kind === 239 /* ModuleDeclaration */
|
|
? node.body
|
|
: undefined;
|
|
}
|
|
function getJSDocCommentsAndTags(hostNode) {
|
|
var result;
|
|
getJSDocCommentsAndTagsWorker(hostNode);
|
|
return result || ts.emptyArray;
|
|
function getJSDocCommentsAndTagsWorker(node) {
|
|
var parent = node.parent;
|
|
if (!parent)
|
|
return;
|
|
if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) {
|
|
getJSDocCommentsAndTagsWorker(parent);
|
|
}
|
|
// Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement.
|
|
// /**
|
|
// * @param {number} name
|
|
// * @returns {number}
|
|
// */
|
|
// var x = function(name) { return name.length; }
|
|
if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
|
|
getJSDocCommentsAndTagsWorker(parent.parent);
|
|
}
|
|
if (parent.parent && parent.parent.parent &&
|
|
(getSingleVariableOfVariableStatement(parent.parent.parent) ||
|
|
getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
|
|
getSourceOfDefaultedAssignment(parent.parent.parent))) {
|
|
getJSDocCommentsAndTagsWorker(parent.parent.parent);
|
|
}
|
|
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ ||
|
|
ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ ||
|
|
node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) {
|
|
getJSDocCommentsAndTagsWorker(parent);
|
|
}
|
|
// Pull parameter comments from declaring function as well
|
|
if (node.kind === 149 /* Parameter */) {
|
|
result = ts.addRange(result, ts.getJSDocParameterTags(node));
|
|
}
|
|
if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) {
|
|
result = ts.addRange(result, node.initializer.jsDoc);
|
|
}
|
|
if (ts.hasJSDocNodes(node)) {
|
|
result = ts.addRange(result, node.jsDoc);
|
|
}
|
|
}
|
|
}
|
|
ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
|
|
/** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */
|
|
function getParameterSymbolFromJSDoc(node) {
|
|
if (node.symbol) {
|
|
return node.symbol;
|
|
}
|
|
if (!ts.isIdentifier(node.name)) {
|
|
return undefined;
|
|
}
|
|
var name = node.name.escapedText;
|
|
var decl = getHostSignatureFromJSDoc(node);
|
|
if (!decl) {
|
|
return undefined;
|
|
}
|
|
var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; });
|
|
return parameter && parameter.symbol;
|
|
}
|
|
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
|
|
function getHostSignatureFromJSDoc(node) {
|
|
return getHostSignatureFromJSDocHost(getJSDocHost(node));
|
|
}
|
|
ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
|
|
function getHostSignatureFromJSDocHost(host) {
|
|
var decl = getSourceOfDefaultedAssignment(host) ||
|
|
getSourceOfAssignment(host) ||
|
|
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
|
|
getSingleVariableOfVariableStatement(host) ||
|
|
getNestedModuleDeclaration(host) ||
|
|
host;
|
|
return decl && ts.isFunctionLike(decl) ? decl : undefined;
|
|
}
|
|
ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
|
|
function getJSDocHost(node) {
|
|
return ts.Debug.assertDefined(findAncestor(node.parent, ts.isJSDoc)).parent;
|
|
}
|
|
ts.getJSDocHost = getJSDocHost;
|
|
function getTypeParameterFromJsDoc(node) {
|
|
var name = node.name.escapedText;
|
|
var typeParameters = node.parent.parent.parent.typeParameters;
|
|
return ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
|
|
}
|
|
ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
|
|
function hasRestParameter(s) {
|
|
var last = ts.lastOrUndefined(s.parameters);
|
|
return !!last && isRestParameter(last);
|
|
}
|
|
ts.hasRestParameter = hasRestParameter;
|
|
function isRestParameter(node) {
|
|
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */;
|
|
}
|
|
ts.isRestParameter = isRestParameter;
|
|
var AssignmentKind;
|
|
(function (AssignmentKind) {
|
|
AssignmentKind[AssignmentKind["None"] = 0] = "None";
|
|
AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite";
|
|
AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound";
|
|
})(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {}));
|
|
function getAssignmentTargetKind(node) {
|
|
var parent = node.parent;
|
|
while (true) {
|
|
switch (parent.kind) {
|
|
case 200 /* BinaryExpression */:
|
|
var binaryOperator = parent.operatorToken.kind;
|
|
return isAssignmentOperator(binaryOperator) && parent.left === node ?
|
|
binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ :
|
|
0 /* None */;
|
|
case 198 /* PrefixUnaryExpression */:
|
|
case 199 /* PostfixUnaryExpression */:
|
|
var unaryOperator = parent.operator;
|
|
return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
return parent.initializer === node ? 1 /* Definite */ : 0 /* None */;
|
|
case 191 /* ParenthesizedExpression */:
|
|
case 183 /* ArrayLiteralExpression */:
|
|
case 204 /* SpreadElement */:
|
|
case 209 /* NonNullExpression */:
|
|
node = parent;
|
|
break;
|
|
case 271 /* ShorthandPropertyAssignment */:
|
|
if (parent.name !== node) {
|
|
return 0 /* None */;
|
|
}
|
|
node = parent.parent;
|
|
break;
|
|
case 270 /* PropertyAssignment */:
|
|
if (parent.name === node) {
|
|
return 0 /* None */;
|
|
}
|
|
node = parent.parent;
|
|
break;
|
|
default:
|
|
return 0 /* None */;
|
|
}
|
|
parent = node.parent;
|
|
}
|
|
}
|
|
ts.getAssignmentTargetKind = getAssignmentTargetKind;
|
|
// A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property
|
|
// assignment in an object literal that is an assignment target, or if it is parented by an array literal that is
|
|
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'.
|
|
// (Note that `p` is not a target in the above examples, only `a`.)
|
|
function isAssignmentTarget(node) {
|
|
return getAssignmentTargetKind(node) !== 0 /* None */;
|
|
}
|
|
ts.isAssignmentTarget = isAssignmentTarget;
|
|
/**
|
|
* Indicates whether a node could contain a `var` VariableDeclarationList that contributes to
|
|
* the same `var` declaration scope as the node's parent.
|
|
*/
|
|
function isNodeWithPossibleHoistedDeclaration(node) {
|
|
switch (node.kind) {
|
|
case 213 /* Block */:
|
|
case 214 /* VariableStatement */:
|
|
case 226 /* WithStatement */:
|
|
case 217 /* IfStatement */:
|
|
case 227 /* SwitchStatement */:
|
|
case 241 /* CaseBlock */:
|
|
case 266 /* CaseClause */:
|
|
case 267 /* DefaultClause */:
|
|
case 228 /* LabeledStatement */:
|
|
case 220 /* ForStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
case 218 /* DoStatement */:
|
|
case 219 /* WhileStatement */:
|
|
case 230 /* TryStatement */:
|
|
case 269 /* CatchClause */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
|
|
function isValueSignatureDeclaration(node) {
|
|
return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
|
|
}
|
|
ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
|
|
function walkUp(node, kind) {
|
|
while (node && node.kind === kind) {
|
|
node = node.parent;
|
|
}
|
|
return node;
|
|
}
|
|
function walkUpParenthesizedTypes(node) {
|
|
return walkUp(node, 173 /* ParenthesizedType */);
|
|
}
|
|
ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
|
|
function walkUpParenthesizedExpressions(node) {
|
|
return walkUp(node, 191 /* ParenthesizedExpression */);
|
|
}
|
|
ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
|
|
function skipParentheses(node) {
|
|
while (node.kind === 191 /* ParenthesizedExpression */) {
|
|
node = node.expression;
|
|
}
|
|
return node;
|
|
}
|
|
ts.skipParentheses = skipParentheses;
|
|
// a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped
|
|
function isDeleteTarget(node) {
|
|
if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) {
|
|
return false;
|
|
}
|
|
node = walkUpParenthesizedExpressions(node.parent);
|
|
return node && node.kind === 194 /* DeleteExpression */;
|
|
}
|
|
ts.isDeleteTarget = isDeleteTarget;
|
|
function isNodeDescendantOf(node, ancestor) {
|
|
while (node) {
|
|
if (node === ancestor)
|
|
return true;
|
|
node = node.parent;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isNodeDescendantOf = isNodeDescendantOf;
|
|
// True if `name` is the name of a declaration node
|
|
function isDeclarationName(name) {
|
|
return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
|
|
}
|
|
ts.isDeclarationName = isDeclarationName;
|
|
// See GH#16030
|
|
function isAnyDeclarationName(name) {
|
|
switch (name.kind) {
|
|
case 71 /* Identifier */:
|
|
case 9 /* StringLiteral */:
|
|
case 8 /* NumericLiteral */: {
|
|
var parent = name.parent;
|
|
if (ts.isDeclaration(parent)) {
|
|
return parent.name === name;
|
|
}
|
|
else if (ts.isQualifiedName(name.parent)) {
|
|
var tag = name.parent.parent;
|
|
return ts.isJSDocParameterTag(tag) && tag.name === name.parent;
|
|
}
|
|
else {
|
|
var binExp = name.parent.parent;
|
|
return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 /* None */ && ts.getNameOfDeclaration(binExp) === name;
|
|
}
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isAnyDeclarationName = isAnyDeclarationName;
|
|
function isLiteralComputedPropertyDeclarationName(node) {
|
|
return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) &&
|
|
node.parent.kind === 147 /* ComputedPropertyName */ &&
|
|
ts.isDeclaration(node.parent.parent);
|
|
}
|
|
ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
|
|
// Return true if the given identifier is classified as an IdentifierName
|
|
function isIdentifierName(node) {
|
|
var parent = node.parent;
|
|
switch (parent.kind) {
|
|
case 152 /* PropertyDeclaration */:
|
|
case 151 /* PropertySignature */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 273 /* EnumMember */:
|
|
case 270 /* PropertyAssignment */:
|
|
case 185 /* PropertyAccessExpression */:
|
|
// Name in member declaration or property name in property access
|
|
return parent.name === node;
|
|
case 146 /* QualifiedName */:
|
|
// Name on right hand side of dot in a type query or type reference
|
|
if (parent.right === node) {
|
|
while (parent.kind === 146 /* QualifiedName */) {
|
|
parent = parent.parent;
|
|
}
|
|
return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */;
|
|
}
|
|
return false;
|
|
case 182 /* BindingElement */:
|
|
case 248 /* ImportSpecifier */:
|
|
// Property name in binding element or import specifier
|
|
return parent.propertyName === node;
|
|
case 252 /* ExportSpecifier */:
|
|
case 262 /* JsxAttribute */:
|
|
// Any name in an export specifier or JSX Attribute
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isIdentifierName = isIdentifierName;
|
|
// An alias symbol is created by one of the following declarations:
|
|
// import <symbol> = ...
|
|
// import <symbol> from ...
|
|
// import * as <symbol> from ...
|
|
// import { x as <symbol> } from ...
|
|
// export { x as <symbol> } from ...
|
|
// export = <EntityNameExpression>
|
|
// export default <EntityNameExpression>
|
|
function isAliasSymbolDeclaration(node) {
|
|
return node.kind === 243 /* ImportEqualsDeclaration */ ||
|
|
node.kind === 242 /* NamespaceExportDeclaration */ ||
|
|
node.kind === 245 /* ImportClause */ && !!node.name ||
|
|
node.kind === 246 /* NamespaceImport */ ||
|
|
node.kind === 248 /* ImportSpecifier */ ||
|
|
node.kind === 252 /* ExportSpecifier */ ||
|
|
node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
|
|
ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */;
|
|
}
|
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
function exportAssignmentIsAlias(node) {
|
|
var e = ts.isExportAssignment(node) ? node.expression : node.right;
|
|
return isEntityNameExpression(e) || ts.isClassExpression(e);
|
|
}
|
|
ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
|
|
function getClassExtendsHeritageClauseElement(node) {
|
|
var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */);
|
|
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
|
|
}
|
|
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement;
|
|
function getClassImplementsHeritageClauseElements(node) {
|
|
var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */);
|
|
return heritageClause ? heritageClause.types : undefined;
|
|
}
|
|
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
|
|
/** Returns the node in an `extends` or `implements` clause of a class or interface. */
|
|
function getAllSuperTypeNodes(node) {
|
|
return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray
|
|
: ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray
|
|
: ts.emptyArray;
|
|
}
|
|
ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
|
|
function getInterfaceBaseTypeNodes(node) {
|
|
var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */);
|
|
return heritageClause ? heritageClause.types : undefined;
|
|
}
|
|
ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
|
|
function getHeritageClause(clauses, kind) {
|
|
if (clauses) {
|
|
for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
|
|
var clause = clauses_1[_i];
|
|
if (clause.token === kind) {
|
|
return clause;
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getHeritageClause = getHeritageClause;
|
|
function tryResolveScriptReference(host, sourceFile, reference) {
|
|
if (!host.getCompilerOptions().noResolve) {
|
|
var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName);
|
|
return host.getSourceFile(referenceFileName);
|
|
}
|
|
}
|
|
ts.tryResolveScriptReference = tryResolveScriptReference;
|
|
function getAncestor(node, kind) {
|
|
while (node) {
|
|
if (node.kind === kind) {
|
|
return node;
|
|
}
|
|
node = node.parent;
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getAncestor = getAncestor;
|
|
function isKeyword(token) {
|
|
return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */;
|
|
}
|
|
ts.isKeyword = isKeyword;
|
|
function isContextualKeyword(token) {
|
|
return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */;
|
|
}
|
|
ts.isContextualKeyword = isContextualKeyword;
|
|
function isNonContextualKeyword(token) {
|
|
return isKeyword(token) && !isContextualKeyword(token);
|
|
}
|
|
ts.isNonContextualKeyword = isNonContextualKeyword;
|
|
function isStringANonContextualKeyword(name) {
|
|
var token = ts.stringToToken(name);
|
|
return token !== undefined && isNonContextualKeyword(token);
|
|
}
|
|
ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
|
|
function isTrivia(token) {
|
|
return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */;
|
|
}
|
|
ts.isTrivia = isTrivia;
|
|
var FunctionFlags;
|
|
(function (FunctionFlags) {
|
|
FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal";
|
|
FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator";
|
|
FunctionFlags[FunctionFlags["Async"] = 2] = "Async";
|
|
FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid";
|
|
FunctionFlags[FunctionFlags["AsyncGenerator"] = 3] = "AsyncGenerator";
|
|
})(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {}));
|
|
function getFunctionFlags(node) {
|
|
if (!node) {
|
|
return 4 /* Invalid */;
|
|
}
|
|
var flags = 0 /* Normal */;
|
|
switch (node.kind) {
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 154 /* MethodDeclaration */:
|
|
if (node.asteriskToken) {
|
|
flags |= 1 /* Generator */;
|
|
}
|
|
// falls through
|
|
case 193 /* ArrowFunction */:
|
|
if (hasModifier(node, 256 /* Async */)) {
|
|
flags |= 2 /* Async */;
|
|
}
|
|
break;
|
|
}
|
|
if (!node.body) {
|
|
flags |= 4 /* Invalid */;
|
|
}
|
|
return flags;
|
|
}
|
|
ts.getFunctionFlags = getFunctionFlags;
|
|
function isAsyncFunction(node) {
|
|
switch (node.kind) {
|
|
case 234 /* FunctionDeclaration */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 154 /* MethodDeclaration */:
|
|
return node.body !== undefined
|
|
&& node.asteriskToken === undefined
|
|
&& hasModifier(node, 256 /* Async */);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isAsyncFunction = isAsyncFunction;
|
|
function isStringOrNumericLiteral(node) {
|
|
var kind = node.kind;
|
|
return kind === 9 /* StringLiteral */
|
|
|| kind === 8 /* NumericLiteral */;
|
|
}
|
|
ts.isStringOrNumericLiteral = isStringOrNumericLiteral;
|
|
/**
|
|
* A declaration has a dynamic name if both of the following are true:
|
|
* 1. The declaration has a computed property name
|
|
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
|
* is a property of the Symbol constructor that denotes a built in
|
|
* Symbol.
|
|
*/
|
|
function hasDynamicName(declaration) {
|
|
var name = ts.getNameOfDeclaration(declaration);
|
|
return !!name && isDynamicName(name);
|
|
}
|
|
ts.hasDynamicName = hasDynamicName;
|
|
function isDynamicName(name) {
|
|
return name.kind === 147 /* ComputedPropertyName */ &&
|
|
!isStringOrNumericLiteral(name.expression) &&
|
|
!isWellKnownSymbolSyntactically(name.expression);
|
|
}
|
|
ts.isDynamicName = isDynamicName;
|
|
/**
|
|
* Checks if the expression is of the form:
|
|
* Symbol.name
|
|
* where Symbol is literally the word "Symbol", and name is any identifierName
|
|
*/
|
|
function isWellKnownSymbolSyntactically(node) {
|
|
return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
|
|
}
|
|
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
|
|
function getPropertyNameForPropertyNameNode(name) {
|
|
if (name.kind === 71 /* Identifier */) {
|
|
return name.escapedText;
|
|
}
|
|
if (name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) {
|
|
return escapeLeadingUnderscores(name.text);
|
|
}
|
|
if (name.kind === 147 /* ComputedPropertyName */) {
|
|
var nameExpression = name.expression;
|
|
if (isWellKnownSymbolSyntactically(nameExpression)) {
|
|
return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
|
|
}
|
|
else if (nameExpression.kind === 9 /* StringLiteral */ || nameExpression.kind === 8 /* NumericLiteral */) {
|
|
return escapeLeadingUnderscores(nameExpression.text);
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
|
|
function isPropertyNameLiteral(node) {
|
|
switch (node.kind) {
|
|
case 71 /* Identifier */:
|
|
case 9 /* StringLiteral */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isPropertyNameLiteral = isPropertyNameLiteral;
|
|
function getTextOfIdentifierOrLiteral(node) {
|
|
return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text;
|
|
}
|
|
ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
|
|
function getEscapedTextOfIdentifierOrLiteral(node) {
|
|
return node.kind === 71 /* Identifier */ ? node.escapedText : escapeLeadingUnderscores(node.text);
|
|
}
|
|
ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
|
|
function getPropertyNameForKnownSymbolName(symbolName) {
|
|
return "__@" + symbolName;
|
|
}
|
|
ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
|
|
function isKnownSymbol(symbol) {
|
|
return ts.startsWith(symbol.escapedName, "__@");
|
|
}
|
|
ts.isKnownSymbol = isKnownSymbol;
|
|
/**
|
|
* Includes the word "Symbol" with unicode escapes
|
|
*/
|
|
function isESSymbolIdentifier(node) {
|
|
return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol";
|
|
}
|
|
ts.isESSymbolIdentifier = isESSymbolIdentifier;
|
|
function isPushOrUnshiftIdentifier(node) {
|
|
return node.escapedText === "push" || node.escapedText === "unshift";
|
|
}
|
|
ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
|
|
function isParameterDeclaration(node) {
|
|
var root = getRootDeclaration(node);
|
|
return root.kind === 149 /* Parameter */;
|
|
}
|
|
ts.isParameterDeclaration = isParameterDeclaration;
|
|
function getRootDeclaration(node) {
|
|
while (node.kind === 182 /* BindingElement */) {
|
|
node = node.parent.parent;
|
|
}
|
|
return node;
|
|
}
|
|
ts.getRootDeclaration = getRootDeclaration;
|
|
function nodeStartsNewLexicalEnvironment(node) {
|
|
var kind = node.kind;
|
|
return kind === 155 /* Constructor */
|
|
|| kind === 192 /* FunctionExpression */
|
|
|| kind === 234 /* FunctionDeclaration */
|
|
|| kind === 193 /* ArrowFunction */
|
|
|| kind === 154 /* MethodDeclaration */
|
|
|| kind === 156 /* GetAccessor */
|
|
|| kind === 157 /* SetAccessor */
|
|
|| kind === 239 /* ModuleDeclaration */
|
|
|| kind === 274 /* SourceFile */;
|
|
}
|
|
ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
|
|
function nodeIsSynthesized(range) {
|
|
return ts.positionIsSynthesized(range.pos)
|
|
|| ts.positionIsSynthesized(range.end);
|
|
}
|
|
ts.nodeIsSynthesized = nodeIsSynthesized;
|
|
function getOriginalSourceFile(sourceFile) {
|
|
return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
|
|
}
|
|
ts.getOriginalSourceFile = getOriginalSourceFile;
|
|
var Associativity;
|
|
(function (Associativity) {
|
|
Associativity[Associativity["Left"] = 0] = "Left";
|
|
Associativity[Associativity["Right"] = 1] = "Right";
|
|
})(Associativity = ts.Associativity || (ts.Associativity = {}));
|
|
function getExpressionAssociativity(expression) {
|
|
var operator = getOperator(expression);
|
|
var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined;
|
|
return getOperatorAssociativity(expression.kind, operator, hasArguments);
|
|
}
|
|
ts.getExpressionAssociativity = getExpressionAssociativity;
|
|
function getOperatorAssociativity(kind, operator, hasArguments) {
|
|
switch (kind) {
|
|
case 188 /* NewExpression */:
|
|
return hasArguments ? 0 /* Left */ : 1 /* Right */;
|
|
case 198 /* PrefixUnaryExpression */:
|
|
case 195 /* TypeOfExpression */:
|
|
case 196 /* VoidExpression */:
|
|
case 194 /* DeleteExpression */:
|
|
case 197 /* AwaitExpression */:
|
|
case 201 /* ConditionalExpression */:
|
|
case 203 /* YieldExpression */:
|
|
return 1 /* Right */;
|
|
case 200 /* BinaryExpression */:
|
|
switch (operator) {
|
|
case 40 /* AsteriskAsteriskToken */:
|
|
case 58 /* EqualsToken */:
|
|
case 59 /* PlusEqualsToken */:
|
|
case 60 /* MinusEqualsToken */:
|
|
case 62 /* AsteriskAsteriskEqualsToken */:
|
|
case 61 /* AsteriskEqualsToken */:
|
|
case 63 /* SlashEqualsToken */:
|
|
case 64 /* PercentEqualsToken */:
|
|
case 65 /* LessThanLessThanEqualsToken */:
|
|
case 66 /* GreaterThanGreaterThanEqualsToken */:
|
|
case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
|
|
case 68 /* AmpersandEqualsToken */:
|
|
case 70 /* CaretEqualsToken */:
|
|
case 69 /* BarEqualsToken */:
|
|
return 1 /* Right */;
|
|
}
|
|
}
|
|
return 0 /* Left */;
|
|
}
|
|
ts.getOperatorAssociativity = getOperatorAssociativity;
|
|
function getExpressionPrecedence(expression) {
|
|
var operator = getOperator(expression);
|
|
var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined;
|
|
return getOperatorPrecedence(expression.kind, operator, hasArguments);
|
|
}
|
|
ts.getExpressionPrecedence = getExpressionPrecedence;
|
|
function getOperator(expression) {
|
|
if (expression.kind === 200 /* BinaryExpression */) {
|
|
return expression.operatorToken.kind;
|
|
}
|
|
else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) {
|
|
return expression.operator;
|
|
}
|
|
else {
|
|
return expression.kind;
|
|
}
|
|
}
|
|
ts.getOperator = getOperator;
|
|
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
|
|
switch (nodeKind) {
|
|
case 302 /* CommaListExpression */:
|
|
return 0;
|
|
case 204 /* SpreadElement */:
|
|
return 1;
|
|
case 203 /* YieldExpression */:
|
|
return 2;
|
|
case 201 /* ConditionalExpression */:
|
|
return 4;
|
|
case 200 /* BinaryExpression */:
|
|
switch (operatorKind) {
|
|
case 26 /* CommaToken */:
|
|
return 0;
|
|
case 58 /* EqualsToken */:
|
|
case 59 /* PlusEqualsToken */:
|
|
case 60 /* MinusEqualsToken */:
|
|
case 62 /* AsteriskAsteriskEqualsToken */:
|
|
case 61 /* AsteriskEqualsToken */:
|
|
case 63 /* SlashEqualsToken */:
|
|
case 64 /* PercentEqualsToken */:
|
|
case 65 /* LessThanLessThanEqualsToken */:
|
|
case 66 /* GreaterThanGreaterThanEqualsToken */:
|
|
case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
|
|
case 68 /* AmpersandEqualsToken */:
|
|
case 70 /* CaretEqualsToken */:
|
|
case 69 /* BarEqualsToken */:
|
|
return 3;
|
|
default:
|
|
return getBinaryOperatorPrecedence(operatorKind);
|
|
}
|
|
case 198 /* PrefixUnaryExpression */:
|
|
case 195 /* TypeOfExpression */:
|
|
case 196 /* VoidExpression */:
|
|
case 194 /* DeleteExpression */:
|
|
case 197 /* AwaitExpression */:
|
|
return 16;
|
|
case 199 /* PostfixUnaryExpression */:
|
|
return 17;
|
|
case 187 /* CallExpression */:
|
|
return 18;
|
|
case 188 /* NewExpression */:
|
|
return hasArguments ? 19 : 18;
|
|
case 189 /* TaggedTemplateExpression */:
|
|
case 185 /* PropertyAccessExpression */:
|
|
case 186 /* ElementAccessExpression */:
|
|
return 19;
|
|
case 99 /* ThisKeyword */:
|
|
case 97 /* SuperKeyword */:
|
|
case 71 /* Identifier */:
|
|
case 95 /* NullKeyword */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 183 /* ArrayLiteralExpression */:
|
|
case 184 /* ObjectLiteralExpression */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 205 /* ClassExpression */:
|
|
case 255 /* JsxElement */:
|
|
case 256 /* JsxSelfClosingElement */:
|
|
case 259 /* JsxFragment */:
|
|
case 12 /* RegularExpressionLiteral */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 202 /* TemplateExpression */:
|
|
case 191 /* ParenthesizedExpression */:
|
|
case 206 /* OmittedExpression */:
|
|
return 20;
|
|
default:
|
|
return -1;
|
|
}
|
|
}
|
|
ts.getOperatorPrecedence = getOperatorPrecedence;
|
|
/* @internal */
|
|
function getBinaryOperatorPrecedence(kind) {
|
|
switch (kind) {
|
|
case 54 /* BarBarToken */:
|
|
return 5;
|
|
case 53 /* AmpersandAmpersandToken */:
|
|
return 6;
|
|
case 49 /* BarToken */:
|
|
return 7;
|
|
case 50 /* CaretToken */:
|
|
return 8;
|
|
case 48 /* AmpersandToken */:
|
|
return 9;
|
|
case 32 /* EqualsEqualsToken */:
|
|
case 33 /* ExclamationEqualsToken */:
|
|
case 34 /* EqualsEqualsEqualsToken */:
|
|
case 35 /* ExclamationEqualsEqualsToken */:
|
|
return 10;
|
|
case 27 /* LessThanToken */:
|
|
case 29 /* GreaterThanToken */:
|
|
case 30 /* LessThanEqualsToken */:
|
|
case 31 /* GreaterThanEqualsToken */:
|
|
case 93 /* InstanceOfKeyword */:
|
|
case 92 /* InKeyword */:
|
|
case 118 /* AsKeyword */:
|
|
return 11;
|
|
case 45 /* LessThanLessThanToken */:
|
|
case 46 /* GreaterThanGreaterThanToken */:
|
|
case 47 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
return 12;
|
|
case 37 /* PlusToken */:
|
|
case 38 /* MinusToken */:
|
|
return 13;
|
|
case 39 /* AsteriskToken */:
|
|
case 41 /* SlashToken */:
|
|
case 42 /* PercentToken */:
|
|
return 14;
|
|
case 40 /* AsteriskAsteriskToken */:
|
|
return 15;
|
|
}
|
|
// -1 is lower than all other precedences. Returning it will cause binary expression
|
|
// parsing to stop.
|
|
return -1;
|
|
}
|
|
ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
|
|
function createDiagnosticCollection() {
|
|
var nonFileDiagnostics = []; // See GH#19873
|
|
var filesWithDiagnostics = [];
|
|
var fileDiagnostics = ts.createMap();
|
|
var hasReadNonFileDiagnostics = false;
|
|
return {
|
|
add: add,
|
|
getGlobalDiagnostics: getGlobalDiagnostics,
|
|
getDiagnostics: getDiagnostics,
|
|
reattachFileDiagnostics: reattachFileDiagnostics
|
|
};
|
|
function reattachFileDiagnostics(newFile) {
|
|
ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
|
|
}
|
|
function add(diagnostic) {
|
|
var diagnostics;
|
|
if (diagnostic.file) {
|
|
diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
|
|
if (!diagnostics) {
|
|
diagnostics = []; // See GH#19873
|
|
fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
|
|
ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
|
|
}
|
|
}
|
|
else {
|
|
// If we've already read the non-file diagnostics, do not modify the existing array.
|
|
if (hasReadNonFileDiagnostics) {
|
|
hasReadNonFileDiagnostics = false;
|
|
nonFileDiagnostics = nonFileDiagnostics.slice();
|
|
}
|
|
diagnostics = nonFileDiagnostics;
|
|
}
|
|
ts.insertSorted(diagnostics, diagnostic, ts.compareDiagnostics);
|
|
}
|
|
function getGlobalDiagnostics() {
|
|
hasReadNonFileDiagnostics = true;
|
|
return nonFileDiagnostics;
|
|
}
|
|
function getDiagnostics(fileName) {
|
|
if (fileName) {
|
|
return fileDiagnostics.get(fileName) || [];
|
|
}
|
|
var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
|
|
if (!nonFileDiagnostics.length) {
|
|
return fileDiags;
|
|
}
|
|
fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
|
|
return fileDiags;
|
|
}
|
|
}
|
|
ts.createDiagnosticCollection = createDiagnosticCollection;
|
|
// This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator,
|
|
// paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in
|
|
// the language service. These characters should be escaped when printing, and if any characters are added,
|
|
// the map below must be updated. Note that this regexp *does not* include the 'delete' character.
|
|
// There is no reason for this other than that JSON.stringify does not handle it either.
|
|
var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
|
var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
|
var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
|
var escapedCharsMap = ts.createMapFromTemplate({
|
|
"\t": "\\t",
|
|
"\v": "\\v",
|
|
"\f": "\\f",
|
|
"\b": "\\b",
|
|
"\r": "\\r",
|
|
"\n": "\\n",
|
|
"\\": "\\\\",
|
|
"\"": "\\\"",
|
|
"\'": "\\\'",
|
|
"\`": "\\\`",
|
|
"\u2028": "\\u2028",
|
|
"\u2029": "\\u2029",
|
|
"\u0085": "\\u0085" // nextLine
|
|
});
|
|
/**
|
|
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
|
|
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
|
|
* Note that this doesn't actually wrap the input in double quotes.
|
|
*/
|
|
function escapeString(s, quoteChar) {
|
|
var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp :
|
|
quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp :
|
|
doubleQuoteEscapedCharsRegExp;
|
|
return s.replace(escapedCharsRegExp, getReplacement);
|
|
}
|
|
ts.escapeString = escapeString;
|
|
function getReplacement(c, offset, input) {
|
|
if (c.charCodeAt(0) === 0 /* nullCharacter */) {
|
|
var lookAhead = input.charCodeAt(offset + c.length);
|
|
if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) {
|
|
// If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode)
|
|
return "\\x00";
|
|
}
|
|
// Otherwise, keep printing a literal \0 for the null character
|
|
return "\\0";
|
|
}
|
|
return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
|
|
}
|
|
function isIntrinsicJsxName(name) {
|
|
var ch = name.charCodeAt(0);
|
|
return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1;
|
|
}
|
|
ts.isIntrinsicJsxName = isIntrinsicJsxName;
|
|
function get16BitUnicodeEscapeSequence(charCode) {
|
|
var hexCharCode = charCode.toString(16).toUpperCase();
|
|
var paddedHexCode = ("0000" + hexCharCode).slice(-4);
|
|
return "\\u" + paddedHexCode;
|
|
}
|
|
var nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
|
function escapeNonAsciiString(s, quoteChar) {
|
|
s = escapeString(s, quoteChar);
|
|
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
|
|
// Otherwise just return the original string.
|
|
return nonAsciiCharacters.test(s) ?
|
|
s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) :
|
|
s;
|
|
}
|
|
ts.escapeNonAsciiString = escapeNonAsciiString;
|
|
var indentStrings = ["", " "];
|
|
function getIndentString(level) {
|
|
if (indentStrings[level] === undefined) {
|
|
indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
|
|
}
|
|
return indentStrings[level];
|
|
}
|
|
ts.getIndentString = getIndentString;
|
|
function getIndentSize() {
|
|
return indentStrings[1].length;
|
|
}
|
|
ts.getIndentSize = getIndentSize;
|
|
function createTextWriter(newLine) {
|
|
var output;
|
|
var indent;
|
|
var lineStart;
|
|
var lineCount;
|
|
var linePos;
|
|
function updateLineCountAndPosFor(s) {
|
|
var lineStartsOfS = ts.computeLineStarts(s);
|
|
if (lineStartsOfS.length > 1) {
|
|
lineCount = lineCount + lineStartsOfS.length - 1;
|
|
linePos = output.length - s.length + ts.last(lineStartsOfS);
|
|
lineStart = (linePos - output.length) === 0;
|
|
}
|
|
else {
|
|
lineStart = false;
|
|
}
|
|
}
|
|
function write(s) {
|
|
if (s && s.length) {
|
|
if (lineStart) {
|
|
s = getIndentString(indent) + s;
|
|
lineStart = false;
|
|
}
|
|
output += s;
|
|
updateLineCountAndPosFor(s);
|
|
}
|
|
}
|
|
function reset() {
|
|
output = "";
|
|
indent = 0;
|
|
lineStart = true;
|
|
lineCount = 0;
|
|
linePos = 0;
|
|
}
|
|
function rawWrite(s) {
|
|
if (s !== undefined) {
|
|
output += s;
|
|
updateLineCountAndPosFor(s);
|
|
}
|
|
}
|
|
function writeLiteral(s) {
|
|
if (s && s.length) {
|
|
write(s);
|
|
}
|
|
}
|
|
function writeLine() {
|
|
if (!lineStart) {
|
|
output += newLine;
|
|
lineCount++;
|
|
linePos = output.length;
|
|
lineStart = true;
|
|
}
|
|
}
|
|
function writeTextOfNode(text, node) {
|
|
var s = getTextOfNodeFromSourceText(text, node);
|
|
write(s);
|
|
updateLineCountAndPosFor(s);
|
|
}
|
|
reset();
|
|
return {
|
|
write: write,
|
|
rawWrite: rawWrite,
|
|
writeTextOfNode: writeTextOfNode,
|
|
writeLiteral: writeLiteral,
|
|
writeLine: writeLine,
|
|
increaseIndent: function () { indent++; },
|
|
decreaseIndent: function () { indent--; },
|
|
getIndent: function () { return indent; },
|
|
getTextPos: function () { return output.length; },
|
|
getLine: function () { return lineCount + 1; },
|
|
getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
|
|
getText: function () { return output; },
|
|
isAtStartOfLine: function () { return lineStart; },
|
|
clear: reset,
|
|
reportInaccessibleThisError: ts.noop,
|
|
reportPrivateInBaseOfClassExpression: ts.noop,
|
|
reportInaccessibleUniqueSymbolError: ts.noop,
|
|
trackSymbol: ts.noop,
|
|
writeKeyword: write,
|
|
writeOperator: write,
|
|
writeParameter: write,
|
|
writeProperty: write,
|
|
writePunctuation: write,
|
|
writeSpace: write,
|
|
writeStringLiteral: write,
|
|
writeSymbol: write
|
|
};
|
|
}
|
|
ts.createTextWriter = createTextWriter;
|
|
function getResolvedExternalModuleName(host, file, referenceFile) {
|
|
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
|
|
}
|
|
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
|
|
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
|
|
var file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
|
if (!file || file.isDeclarationFile) {
|
|
return undefined;
|
|
}
|
|
return getResolvedExternalModuleName(host, file);
|
|
}
|
|
ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
|
|
/**
|
|
* Resolves a local path to a path which is absolute to the base of the emit
|
|
*/
|
|
function getExternalModuleNameFromPath(host, fileName, referencePath) {
|
|
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
|
|
var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
|
|
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
|
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
var extensionless = ts.removeFileExtension(relativePath);
|
|
return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
|
|
}
|
|
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
|
|
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
|
|
var compilerOptions = host.getCompilerOptions();
|
|
var emitOutputFilePathWithoutExtension;
|
|
if (compilerOptions.outDir) {
|
|
emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir));
|
|
}
|
|
else {
|
|
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
|
}
|
|
return emitOutputFilePathWithoutExtension + extension;
|
|
}
|
|
ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
|
|
function getDeclarationEmitOutputFilePath(sourceFile, host) {
|
|
var options = host.getCompilerOptions();
|
|
var outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified
|
|
var path = outputDir
|
|
? getSourceFilePathInNewDir(sourceFile, host, outputDir)
|
|
: sourceFile.fileName;
|
|
return ts.removeFileExtension(path) + ".d.ts" /* Dts */;
|
|
}
|
|
ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
|
|
/**
|
|
* Gets the source files that are expected to have an emit output.
|
|
*
|
|
* Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support
|
|
* transformations.
|
|
*
|
|
* @param host An EmitHost.
|
|
* @param targetSourceFile An optional target source file to emit.
|
|
*/
|
|
function getSourceFilesToEmit(host, targetSourceFile) {
|
|
var options = host.getCompilerOptions();
|
|
var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); };
|
|
if (options.outFile || options.out) {
|
|
var moduleKind = ts.getEmitModuleKind(options);
|
|
var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
|
|
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
|
|
return ts.filter(host.getSourceFiles(), function (sourceFile) {
|
|
return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary);
|
|
});
|
|
}
|
|
else {
|
|
var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
|
|
return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); });
|
|
}
|
|
}
|
|
ts.getSourceFilesToEmit = getSourceFilesToEmit;
|
|
/** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
|
|
function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) {
|
|
return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile);
|
|
}
|
|
ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
|
|
function getSourceFilePathInNewDir(sourceFile, host, newDirPath) {
|
|
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory());
|
|
var commonSourceDirectory = host.getCommonSourceDirectory();
|
|
var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0;
|
|
sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
|
|
return ts.combinePaths(newDirPath, sourceFilePath);
|
|
}
|
|
ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
|
|
function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
|
|
host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
|
|
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
|
}, sourceFiles);
|
|
}
|
|
ts.writeFile = writeFile;
|
|
function getLineOfLocalPosition(currentSourceFile, pos) {
|
|
return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line;
|
|
}
|
|
ts.getLineOfLocalPosition = getLineOfLocalPosition;
|
|
function getLineOfLocalPositionFromLineMap(lineMap, pos) {
|
|
return ts.computeLineAndCharacterOfPosition(lineMap, pos).line;
|
|
}
|
|
ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
|
|
function getFirstConstructorWithBody(node) {
|
|
return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
|
|
}
|
|
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
|
|
function getSetAccessorValueParameter(accessor) {
|
|
if (accessor && accessor.parameters.length > 0) {
|
|
var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
|
|
return accessor.parameters[hasThis ? 1 : 0];
|
|
}
|
|
}
|
|
/** Get the type annotation for the value parameter. */
|
|
function getSetAccessorTypeAnnotationNode(accessor) {
|
|
var parameter = getSetAccessorValueParameter(accessor);
|
|
return parameter && parameter.type;
|
|
}
|
|
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
|
|
function getThisParameter(signature) {
|
|
// callback tags do not currently support this parameters
|
|
if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
|
|
var thisParameter = signature.parameters[0];
|
|
if (parameterIsThisKeyword(thisParameter)) {
|
|
return thisParameter;
|
|
}
|
|
}
|
|
}
|
|
ts.getThisParameter = getThisParameter;
|
|
function parameterIsThisKeyword(parameter) {
|
|
return isThisIdentifier(parameter.name);
|
|
}
|
|
ts.parameterIsThisKeyword = parameterIsThisKeyword;
|
|
function isThisIdentifier(node) {
|
|
return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node);
|
|
}
|
|
ts.isThisIdentifier = isThisIdentifier;
|
|
function identifierIsThisKeyword(id) {
|
|
return id.originalKeywordKind === 99 /* ThisKeyword */;
|
|
}
|
|
ts.identifierIsThisKeyword = identifierIsThisKeyword;
|
|
function getAllAccessorDeclarations(declarations, accessor) {
|
|
// TODO: GH#18217
|
|
var firstAccessor;
|
|
var secondAccessor;
|
|
var getAccessor;
|
|
var setAccessor;
|
|
if (hasDynamicName(accessor)) {
|
|
firstAccessor = accessor;
|
|
if (accessor.kind === 156 /* GetAccessor */) {
|
|
getAccessor = accessor;
|
|
}
|
|
else if (accessor.kind === 157 /* SetAccessor */) {
|
|
setAccessor = accessor;
|
|
}
|
|
else {
|
|
ts.Debug.fail("Accessor has wrong kind");
|
|
}
|
|
}
|
|
else {
|
|
ts.forEach(declarations, function (member) {
|
|
if ((member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */)
|
|
&& hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) {
|
|
var memberName = getPropertyNameForPropertyNameNode(member.name);
|
|
var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
|
if (memberName === accessorName) {
|
|
if (!firstAccessor) {
|
|
firstAccessor = member;
|
|
}
|
|
else if (!secondAccessor) {
|
|
secondAccessor = member;
|
|
}
|
|
if (member.kind === 156 /* GetAccessor */ && !getAccessor) {
|
|
getAccessor = member;
|
|
}
|
|
if (member.kind === 157 /* SetAccessor */ && !setAccessor) {
|
|
setAccessor = member;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return {
|
|
firstAccessor: firstAccessor,
|
|
secondAccessor: secondAccessor,
|
|
getAccessor: getAccessor,
|
|
setAccessor: setAccessor
|
|
};
|
|
}
|
|
ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
|
|
/**
|
|
* Gets the effective type annotation of a variable, parameter, or property. If the node was
|
|
* parsed in a JavaScript file, gets the type annotation from JSDoc.
|
|
*/
|
|
function getEffectiveTypeAnnotationNode(node) {
|
|
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocType(node) : undefined);
|
|
}
|
|
ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
|
|
function getTypeAnnotationNode(node) {
|
|
return node.type;
|
|
}
|
|
ts.getTypeAnnotationNode = getTypeAnnotationNode;
|
|
/**
|
|
* Gets the effective return type annotation of a signature. If the node was parsed in a
|
|
* JavaScript file, gets the return type annotation from JSDoc.
|
|
*/
|
|
function getEffectiveReturnTypeNode(node) {
|
|
if (ts.isJSDocSignature(node)) {
|
|
return node.type && node.type.typeExpression && node.type.typeExpression.type;
|
|
}
|
|
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
|
|
}
|
|
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
|
|
/**
|
|
* Gets the effective type parameters. If the node was parsed in a
|
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
*/
|
|
function getEffectiveTypeParameterDeclarations(node) {
|
|
if (ts.isJSDocSignature(node)) {
|
|
return ts.emptyArray;
|
|
}
|
|
if (isJSDocTypeAlias(node)) {
|
|
ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */);
|
|
return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
|
|
}
|
|
return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
|
|
}
|
|
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
|
|
function getJSDocTypeParameterDeclarations(node) {
|
|
return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
|
|
}
|
|
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
|
|
/** template tags are only available when a typedef isn't already using them */
|
|
function isNonTypeAliasTemplate(tag) {
|
|
return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias));
|
|
}
|
|
/**
|
|
* Gets the effective type annotation of the value parameter of a set accessor. If the node
|
|
* was parsed in a JavaScript file, gets the type annotation from JSDoc.
|
|
*/
|
|
function getEffectiveSetAccessorTypeAnnotationNode(node) {
|
|
var parameter = getSetAccessorValueParameter(node);
|
|
return parameter && getEffectiveTypeAnnotationNode(parameter);
|
|
}
|
|
ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
|
|
function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
|
|
emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
|
|
}
|
|
ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
|
|
function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
|
|
// If the leading comments start on different line than the start of node, write new line
|
|
if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
|
|
getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
|
|
writer.writeLine();
|
|
}
|
|
}
|
|
ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
|
|
function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
|
|
// If the leading comments start on different line than the start of node, write new line
|
|
if (pos !== commentPos &&
|
|
getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
|
|
writer.writeLine();
|
|
}
|
|
}
|
|
ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
|
|
function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
|
|
if (comments && comments.length > 0) {
|
|
if (leadingSeparator) {
|
|
writer.write(" ");
|
|
}
|
|
var emitInterveningSeparator = false;
|
|
for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
|
|
var comment = comments_1[_i];
|
|
if (emitInterveningSeparator) {
|
|
writer.write(" ");
|
|
emitInterveningSeparator = false;
|
|
}
|
|
writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
|
|
if (comment.hasTrailingNewLine) {
|
|
writer.writeLine();
|
|
}
|
|
else {
|
|
emitInterveningSeparator = true;
|
|
}
|
|
}
|
|
if (emitInterveningSeparator && trailingSeparator) {
|
|
writer.write(" ");
|
|
}
|
|
}
|
|
}
|
|
ts.emitComments = emitComments;
|
|
/**
|
|
* Detached comment is a comment at the top of file or function body that is separated from
|
|
* the next statement by space.
|
|
*/
|
|
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
|
|
var leadingComments;
|
|
var currentDetachedCommentInfo;
|
|
if (removeComments) {
|
|
// removeComments is true, only reserve pinned comment at the top of file
|
|
// For example:
|
|
// /*! Pinned Comment */
|
|
//
|
|
// var x = 10;
|
|
if (node.pos === 0) {
|
|
leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
|
|
}
|
|
}
|
|
else {
|
|
// removeComments is false, just get detached as normal and bypass the process to filter comment
|
|
leadingComments = ts.getLeadingCommentRanges(text, node.pos);
|
|
}
|
|
if (leadingComments) {
|
|
var detachedComments = [];
|
|
var lastComment = void 0;
|
|
for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
|
|
var comment = leadingComments_1[_i];
|
|
if (lastComment) {
|
|
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
|
|
var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
|
|
if (commentLine >= lastCommentLine + 2) {
|
|
// There was a blank line between the last comment and this comment. This
|
|
// comment is not part of the copyright comments. Return what we have so
|
|
// far.
|
|
break;
|
|
}
|
|
}
|
|
detachedComments.push(comment);
|
|
lastComment = comment;
|
|
}
|
|
if (detachedComments.length) {
|
|
// All comments look like they could have been part of the copyright header. Make
|
|
// sure there is at least one blank line between it and the node. If not, it's not
|
|
// a copyright header.
|
|
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
|
|
var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
|
|
if (nodeLine >= lastCommentLine + 2) {
|
|
// Valid detachedComments
|
|
emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
|
|
emitComments(text, lineMap, writer, detachedComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeComment);
|
|
currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
|
|
}
|
|
}
|
|
}
|
|
return currentDetachedCommentInfo;
|
|
function isPinnedCommentLocal(comment) {
|
|
return isPinnedComment(text, comment.pos);
|
|
}
|
|
}
|
|
ts.emitDetachedComments = emitDetachedComments;
|
|
function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
|
|
if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) {
|
|
var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
|
|
var lineCount = lineMap.length;
|
|
var firstCommentLineIndent = void 0;
|
|
for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
|
|
var nextLineStart = (currentLine + 1) === lineCount
|
|
? text.length + 1
|
|
: lineMap[currentLine + 1];
|
|
if (pos !== commentPos) {
|
|
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
|
if (firstCommentLineIndent === undefined) {
|
|
firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
|
|
}
|
|
// These are number of spaces writer is going to write at current indent
|
|
var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
|
|
// Number of spaces we want to be writing
|
|
// eg: Assume writer indent
|
|
// module m {
|
|
// /* starts at character 9 this is line 1
|
|
// * starts at character pos 4 line --1 = 8 - 8 + 3
|
|
// More left indented comment */ --2 = 8 - 8 + 2
|
|
// class c { }
|
|
// }
|
|
// module m {
|
|
// /* this is line 1 -- Assume current writer indent 8
|
|
// * line --3 = 8 - 4 + 5
|
|
// More right indented comment */ --4 = 8 - 4 + 11
|
|
// class c { }
|
|
// }
|
|
var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
|
|
if (spacesToEmit > 0) {
|
|
var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
|
|
var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
|
|
// Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces
|
|
writer.rawWrite(indentSizeSpaceString);
|
|
// Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces)
|
|
while (numberOfSingleSpacesToEmit) {
|
|
writer.rawWrite(" ");
|
|
numberOfSingleSpacesToEmit--;
|
|
}
|
|
}
|
|
else {
|
|
// No spaces to emit write empty string
|
|
writer.rawWrite("");
|
|
}
|
|
}
|
|
// Write the comment line text
|
|
writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
|
|
pos = nextLineStart;
|
|
}
|
|
}
|
|
else {
|
|
// Single line comment of style //....
|
|
writer.write(text.substring(commentPos, commentEnd));
|
|
}
|
|
}
|
|
ts.writeCommentRange = writeCommentRange;
|
|
function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
|
|
var end = Math.min(commentEnd, nextLineStart - 1);
|
|
var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
|
|
if (currentLineText) {
|
|
// trimmed forward and ending spaces text
|
|
writer.write(currentLineText);
|
|
if (end !== commentEnd) {
|
|
writer.writeLine();
|
|
}
|
|
}
|
|
else {
|
|
// Empty string - make sure we write empty line
|
|
writer.writeLiteral(newLine);
|
|
}
|
|
}
|
|
function calculateIndent(text, pos, end) {
|
|
var currentLineIndent = 0;
|
|
for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
|
|
if (text.charCodeAt(pos) === 9 /* tab */) {
|
|
// Tabs = TabSize = indent size and go to next tabStop
|
|
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
|
|
}
|
|
else {
|
|
// Single space
|
|
currentLineIndent++;
|
|
}
|
|
}
|
|
return currentLineIndent;
|
|
}
|
|
function hasModifiers(node) {
|
|
return getModifierFlags(node) !== 0 /* None */;
|
|
}
|
|
ts.hasModifiers = hasModifiers;
|
|
function hasModifier(node, flags) {
|
|
return !!getSelectedModifierFlags(node, flags);
|
|
}
|
|
ts.hasModifier = hasModifier;
|
|
function hasStaticModifier(node) {
|
|
return hasModifier(node, 32 /* Static */);
|
|
}
|
|
ts.hasStaticModifier = hasStaticModifier;
|
|
function hasReadonlyModifier(node) {
|
|
return hasModifier(node, 64 /* Readonly */);
|
|
}
|
|
ts.hasReadonlyModifier = hasReadonlyModifier;
|
|
function getSelectedModifierFlags(node, flags) {
|
|
return getModifierFlags(node) & flags;
|
|
}
|
|
ts.getSelectedModifierFlags = getSelectedModifierFlags;
|
|
function getModifierFlags(node) {
|
|
if (node.modifierFlagsCache & 536870912 /* HasComputedFlags */) {
|
|
return node.modifierFlagsCache & ~536870912 /* HasComputedFlags */;
|
|
}
|
|
var flags = getModifierFlagsNoCache(node);
|
|
node.modifierFlagsCache = flags | 536870912 /* HasComputedFlags */;
|
|
return flags;
|
|
}
|
|
ts.getModifierFlags = getModifierFlags;
|
|
function getModifierFlagsNoCache(node) {
|
|
var flags = 0 /* None */;
|
|
if (node.modifiers) {
|
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
var modifier = _a[_i];
|
|
flags |= modifierToFlag(modifier.kind);
|
|
}
|
|
}
|
|
if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) {
|
|
flags |= 1 /* Export */;
|
|
}
|
|
return flags;
|
|
}
|
|
ts.getModifierFlagsNoCache = getModifierFlagsNoCache;
|
|
function modifierToFlag(token) {
|
|
switch (token) {
|
|
case 115 /* StaticKeyword */: return 32 /* Static */;
|
|
case 114 /* PublicKeyword */: return 4 /* Public */;
|
|
case 113 /* ProtectedKeyword */: return 16 /* Protected */;
|
|
case 112 /* PrivateKeyword */: return 8 /* Private */;
|
|
case 117 /* AbstractKeyword */: return 128 /* Abstract */;
|
|
case 84 /* ExportKeyword */: return 1 /* Export */;
|
|
case 124 /* DeclareKeyword */: return 2 /* Ambient */;
|
|
case 76 /* ConstKeyword */: return 2048 /* Const */;
|
|
case 79 /* DefaultKeyword */: return 512 /* Default */;
|
|
case 120 /* AsyncKeyword */: return 256 /* Async */;
|
|
case 132 /* ReadonlyKeyword */: return 64 /* Readonly */;
|
|
}
|
|
return 0 /* None */;
|
|
}
|
|
ts.modifierToFlag = modifierToFlag;
|
|
function isLogicalOperator(token) {
|
|
return token === 54 /* BarBarToken */
|
|
|| token === 53 /* AmpersandAmpersandToken */
|
|
|| token === 51 /* ExclamationToken */;
|
|
}
|
|
ts.isLogicalOperator = isLogicalOperator;
|
|
function isAssignmentOperator(token) {
|
|
return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */;
|
|
}
|
|
ts.isAssignmentOperator = isAssignmentOperator;
|
|
/** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */
|
|
function tryGetClassExtendingExpressionWithTypeArguments(node) {
|
|
if (ts.isExpressionWithTypeArguments(node) &&
|
|
node.parent.token === 85 /* ExtendsKeyword */ &&
|
|
ts.isClassLike(node.parent.parent)) {
|
|
return node.parent.parent;
|
|
}
|
|
}
|
|
ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
|
|
function isAssignmentExpression(node, excludeCompoundAssignment) {
|
|
return ts.isBinaryExpression(node)
|
|
&& (excludeCompoundAssignment
|
|
? node.operatorToken.kind === 58 /* EqualsToken */
|
|
: isAssignmentOperator(node.operatorToken.kind))
|
|
&& ts.isLeftHandSideExpression(node.left);
|
|
}
|
|
ts.isAssignmentExpression = isAssignmentExpression;
|
|
function isDestructuringAssignment(node) {
|
|
if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) {
|
|
var kind = node.left.kind;
|
|
return kind === 184 /* ObjectLiteralExpression */
|
|
|| kind === 183 /* ArrayLiteralExpression */;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isDestructuringAssignment = isDestructuringAssignment;
|
|
function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
|
|
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
|
}
|
|
ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
|
|
function isExpressionWithTypeArgumentsInClassImplementsClause(node) {
|
|
return node.kind === 207 /* ExpressionWithTypeArguments */
|
|
&& isEntityNameExpression(node.expression)
|
|
&& node.parent
|
|
&& node.parent.token === 108 /* ImplementsKeyword */
|
|
&& node.parent.parent
|
|
&& ts.isClassLike(node.parent.parent);
|
|
}
|
|
ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause;
|
|
function isEntityNameExpression(node) {
|
|
return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node);
|
|
}
|
|
ts.isEntityNameExpression = isEntityNameExpression;
|
|
function isPropertyAccessEntityNameExpression(node) {
|
|
return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression);
|
|
}
|
|
ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
|
|
function isPrototypeAccess(node) {
|
|
return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype";
|
|
}
|
|
ts.isPrototypeAccess = isPrototypeAccess;
|
|
function isRightSideOfQualifiedNameOrPropertyAccess(node) {
|
|
return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) ||
|
|
(node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
}
|
|
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
|
|
function isEmptyObjectLiteral(expression) {
|
|
return expression.kind === 184 /* ObjectLiteralExpression */ &&
|
|
expression.properties.length === 0;
|
|
}
|
|
ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
|
|
function isEmptyArrayLiteral(expression) {
|
|
return expression.kind === 183 /* ArrayLiteralExpression */ &&
|
|
expression.elements.length === 0;
|
|
}
|
|
ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
|
|
function getLocalSymbolForExportDefault(symbol) {
|
|
return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
|
|
}
|
|
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
|
|
function isExportDefaultSymbol(symbol) {
|
|
return symbol && ts.length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], 512 /* Default */);
|
|
}
|
|
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
|
function tryExtractTypeScriptExtension(fileName) {
|
|
return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
}
|
|
ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension;
|
|
/**
|
|
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
|
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
|
*/
|
|
function getExpandedCharCodes(input) {
|
|
var output = [];
|
|
var length = input.length;
|
|
for (var i = 0; i < length; i++) {
|
|
var charCode = input.charCodeAt(i);
|
|
// handle utf8
|
|
if (charCode < 0x80) {
|
|
output.push(charCode);
|
|
}
|
|
else if (charCode < 0x800) {
|
|
output.push((charCode >> 6) | 192);
|
|
output.push((charCode & 63) | 128);
|
|
}
|
|
else if (charCode < 0x10000) {
|
|
output.push((charCode >> 12) | 224);
|
|
output.push(((charCode >> 6) & 63) | 128);
|
|
output.push((charCode & 63) | 128);
|
|
}
|
|
else if (charCode < 0x20000) {
|
|
output.push((charCode >> 18) | 240);
|
|
output.push(((charCode >> 12) & 63) | 128);
|
|
output.push(((charCode >> 6) & 63) | 128);
|
|
output.push((charCode & 63) | 128);
|
|
}
|
|
else {
|
|
ts.Debug.assert(false, "Unexpected code point");
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
/**
|
|
* Converts a string to a base-64 encoded ASCII string.
|
|
*/
|
|
function convertToBase64(input) {
|
|
var result = "";
|
|
var charCodes = getExpandedCharCodes(input);
|
|
var i = 0;
|
|
var length = charCodes.length;
|
|
var byte1, byte2, byte3, byte4;
|
|
while (i < length) {
|
|
// Convert every 6-bits in the input 3 character points
|
|
// into a base64 digit
|
|
byte1 = charCodes[i] >> 2;
|
|
byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
|
|
byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
|
|
byte4 = charCodes[i + 2] & 63;
|
|
// We are out of characters in the input, set the extra
|
|
// digits to 64 (padding character).
|
|
if (i + 1 >= length) {
|
|
byte3 = byte4 = 64;
|
|
}
|
|
else if (i + 2 >= length) {
|
|
byte4 = 64;
|
|
}
|
|
// Write to the output
|
|
result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
|
|
i += 3;
|
|
}
|
|
return result;
|
|
}
|
|
ts.convertToBase64 = convertToBase64;
|
|
function getStringFromExpandedCharCodes(codes) {
|
|
var output = "";
|
|
var i = 0;
|
|
var length = codes.length;
|
|
while (i < length) {
|
|
var charCode = codes[i];
|
|
if (charCode < 0x80) {
|
|
output += String.fromCharCode(charCode);
|
|
i++;
|
|
}
|
|
else if ((charCode & 192) === 192) {
|
|
var value = charCode & 63;
|
|
i++;
|
|
var nextCode = codes[i];
|
|
while ((nextCode & 192) === 128) {
|
|
value = (value << 6) | (nextCode & 63);
|
|
i++;
|
|
nextCode = codes[i];
|
|
}
|
|
// `value` may be greater than 10FFFF (the maximum unicode codepoint) - JS will just make this into an invalid character for us
|
|
output += String.fromCharCode(value);
|
|
}
|
|
else {
|
|
// We don't want to kill the process when decoding fails (due to a following char byte not
|
|
// following a leading char), so we just print the (bad) value
|
|
output += String.fromCharCode(charCode);
|
|
i++;
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
function base64encode(host, input) {
|
|
if (host && host.base64encode) {
|
|
return host.base64encode(input);
|
|
}
|
|
return convertToBase64(input);
|
|
}
|
|
ts.base64encode = base64encode;
|
|
function base64decode(host, input) {
|
|
if (host && host.base64decode) {
|
|
return host.base64decode(input);
|
|
}
|
|
var length = input.length;
|
|
var expandedCharCodes = [];
|
|
var i = 0;
|
|
while (i < length) {
|
|
// Stop decoding once padding characters are present
|
|
if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
|
|
break;
|
|
}
|
|
// convert 4 input digits into three characters, ignoring padding characters at the end
|
|
var ch1 = base64Digits.indexOf(input[i]);
|
|
var ch2 = base64Digits.indexOf(input[i + 1]);
|
|
var ch3 = base64Digits.indexOf(input[i + 2]);
|
|
var ch4 = base64Digits.indexOf(input[i + 3]);
|
|
var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
|
|
var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
|
|
var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
|
|
if (code2 === 0 && ch3 !== 0) { // code2 decoded to zero, but ch3 was padding - elide code2 and code3
|
|
expandedCharCodes.push(code1);
|
|
}
|
|
else if (code3 === 0 && ch4 !== 0) { // code3 decoded to zero, but ch4 was padding, elide code3
|
|
expandedCharCodes.push(code1, code2);
|
|
}
|
|
else {
|
|
expandedCharCodes.push(code1, code2, code3);
|
|
}
|
|
i += 4;
|
|
}
|
|
return getStringFromExpandedCharCodes(expandedCharCodes);
|
|
}
|
|
ts.base64decode = base64decode;
|
|
var carriageReturnLineFeed = "\r\n";
|
|
var lineFeed = "\n";
|
|
function getNewLineCharacter(options, getNewLine) {
|
|
switch (options.newLine) {
|
|
case 0 /* CarriageReturnLineFeed */:
|
|
return carriageReturnLineFeed;
|
|
case 1 /* LineFeed */:
|
|
return lineFeed;
|
|
}
|
|
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
|
|
}
|
|
ts.getNewLineCharacter = getNewLineCharacter;
|
|
/**
|
|
* Formats an enum value as a string for debugging and debug assertions.
|
|
*/
|
|
function formatEnum(value, enumObject, isFlags) {
|
|
if (value === void 0) { value = 0; }
|
|
var members = getEnumMembers(enumObject);
|
|
if (value === 0) {
|
|
return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
|
|
}
|
|
if (isFlags) {
|
|
var result = "";
|
|
var remainingFlags = value;
|
|
for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
|
|
var _a = members[i], enumValue = _a[0], enumName = _a[1];
|
|
if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
|
|
remainingFlags &= ~enumValue;
|
|
result = "" + enumName + (result ? ", " : "") + result;
|
|
}
|
|
}
|
|
if (remainingFlags === 0) {
|
|
return result;
|
|
}
|
|
}
|
|
else {
|
|
for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
|
|
var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
|
|
if (enumValue === value) {
|
|
return enumName;
|
|
}
|
|
}
|
|
}
|
|
return value.toString();
|
|
}
|
|
function getEnumMembers(enumObject) {
|
|
var result = [];
|
|
for (var name in enumObject) {
|
|
var value = enumObject[name];
|
|
if (typeof value === "number") {
|
|
result.push([value, name]);
|
|
}
|
|
}
|
|
return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
|
|
}
|
|
function formatSyntaxKind(kind) {
|
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
}
|
|
ts.formatSyntaxKind = formatSyntaxKind;
|
|
function formatModifierFlags(flags) {
|
|
return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatModifierFlags = formatModifierFlags;
|
|
function formatTransformFlags(flags) {
|
|
return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatTransformFlags = formatTransformFlags;
|
|
function formatEmitFlags(flags) {
|
|
return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatEmitFlags = formatEmitFlags;
|
|
function formatSymbolFlags(flags) {
|
|
return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatSymbolFlags = formatSymbolFlags;
|
|
function formatTypeFlags(flags) {
|
|
return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatTypeFlags = formatTypeFlags;
|
|
function formatObjectFlags(flags) {
|
|
return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
|
|
}
|
|
ts.formatObjectFlags = formatObjectFlags;
|
|
/**
|
|
* Creates a new TextRange from the provided pos and end.
|
|
*
|
|
* @param pos The start position.
|
|
* @param end The end position.
|
|
*/
|
|
function createRange(pos, end) {
|
|
return { pos: pos, end: end };
|
|
}
|
|
ts.createRange = createRange;
|
|
/**
|
|
* Creates a new TextRange from a provided range with a new end position.
|
|
*
|
|
* @param range A TextRange.
|
|
* @param end The new end position.
|
|
*/
|
|
function moveRangeEnd(range, end) {
|
|
return createRange(range.pos, end);
|
|
}
|
|
ts.moveRangeEnd = moveRangeEnd;
|
|
/**
|
|
* Creates a new TextRange from a provided range with a new start position.
|
|
*
|
|
* @param range A TextRange.
|
|
* @param pos The new Start position.
|
|
*/
|
|
function moveRangePos(range, pos) {
|
|
return createRange(pos, range.end);
|
|
}
|
|
ts.moveRangePos = moveRangePos;
|
|
/**
|
|
* Moves the start position of a range past any decorators.
|
|
*/
|
|
function moveRangePastDecorators(node) {
|
|
return node.decorators && node.decorators.length > 0
|
|
? moveRangePos(node, node.decorators.end)
|
|
: node;
|
|
}
|
|
ts.moveRangePastDecorators = moveRangePastDecorators;
|
|
/**
|
|
* Moves the start position of a range past any decorators or modifiers.
|
|
*/
|
|
function moveRangePastModifiers(node) {
|
|
return node.modifiers && node.modifiers.length > 0
|
|
? moveRangePos(node, node.modifiers.end)
|
|
: moveRangePastDecorators(node);
|
|
}
|
|
ts.moveRangePastModifiers = moveRangePastModifiers;
|
|
/**
|
|
* Determines whether a TextRange has the same start and end positions.
|
|
*
|
|
* @param range A TextRange.
|
|
*/
|
|
function isCollapsedRange(range) {
|
|
return range.pos === range.end;
|
|
}
|
|
ts.isCollapsedRange = isCollapsedRange;
|
|
/**
|
|
* Creates a new TextRange for a token at the provides start position.
|
|
*
|
|
* @param pos The start position.
|
|
* @param token The token.
|
|
*/
|
|
function createTokenRange(pos, token) {
|
|
return createRange(pos, pos + ts.tokenToString(token).length);
|
|
}
|
|
ts.createTokenRange = createTokenRange;
|
|
function rangeIsOnSingleLine(range, sourceFile) {
|
|
return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
|
|
}
|
|
ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
|
|
function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
|
|
return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile);
|
|
}
|
|
ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
|
|
function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
|
|
return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
|
|
}
|
|
ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
|
|
function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
|
|
return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile);
|
|
}
|
|
ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
|
|
function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
|
|
return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile);
|
|
}
|
|
ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
|
|
function positionsAreOnSameLine(pos1, pos2, sourceFile) {
|
|
return pos1 === pos2 ||
|
|
getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2);
|
|
}
|
|
ts.positionsAreOnSameLine = positionsAreOnSameLine;
|
|
function getStartPositionOfRange(range, sourceFile) {
|
|
return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos);
|
|
}
|
|
ts.getStartPositionOfRange = getStartPositionOfRange;
|
|
/**
|
|
* Determines whether a name was originally the declaration name of an enum or namespace
|
|
* declaration.
|
|
*/
|
|
function isDeclarationNameOfEnumOrNamespace(node) {
|
|
var parseNode = ts.getParseTreeNode(node);
|
|
if (parseNode) {
|
|
switch (parseNode.parent.kind) {
|
|
case 238 /* EnumDeclaration */:
|
|
case 239 /* ModuleDeclaration */:
|
|
return parseNode === parseNode.parent.name;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
|
|
function getInitializedVariables(node) {
|
|
return ts.filter(node.declarations, isInitializedVariable);
|
|
}
|
|
ts.getInitializedVariables = getInitializedVariables;
|
|
function isInitializedVariable(node) {
|
|
return node.initializer !== undefined;
|
|
}
|
|
function isWatchSet(options) {
|
|
// Firefox has Object.prototype.watch
|
|
return options.watch && options.hasOwnProperty("watch");
|
|
}
|
|
ts.isWatchSet = isWatchSet;
|
|
function getCheckFlags(symbol) {
|
|
return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0;
|
|
}
|
|
ts.getCheckFlags = getCheckFlags;
|
|
function getDeclarationModifierFlagsFromSymbol(s) {
|
|
if (s.valueDeclaration) {
|
|
var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
|
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
}
|
|
if (getCheckFlags(s) & 6 /* Synthetic */) {
|
|
var checkFlags = s.checkFlags;
|
|
var accessModifier = checkFlags & 256 /* ContainsPrivate */ ? 8 /* Private */ :
|
|
checkFlags & 64 /* ContainsPublic */ ? 4 /* Public */ :
|
|
16 /* Protected */;
|
|
var staticModifier = checkFlags & 512 /* ContainsStatic */ ? 32 /* Static */ : 0;
|
|
return accessModifier | staticModifier;
|
|
}
|
|
if (s.flags & 4194304 /* Prototype */) {
|
|
return 4 /* Public */ | 32 /* Static */;
|
|
}
|
|
return 0;
|
|
}
|
|
ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
|
|
function skipAlias(symbol, checker) {
|
|
return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
|
|
}
|
|
ts.skipAlias = skipAlias;
|
|
/** See comment on `declareModuleMember` in `binder.ts`. */
|
|
function getCombinedLocalAndExportSymbolFlags(symbol) {
|
|
return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
|
|
}
|
|
ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
|
|
function isWriteOnlyAccess(node) {
|
|
return accessKind(node) === 1 /* Write */;
|
|
}
|
|
ts.isWriteOnlyAccess = isWriteOnlyAccess;
|
|
function isWriteAccess(node) {
|
|
return accessKind(node) !== 0 /* Read */;
|
|
}
|
|
ts.isWriteAccess = isWriteAccess;
|
|
var AccessKind;
|
|
(function (AccessKind) {
|
|
/** Only reads from a variable. */
|
|
AccessKind[AccessKind["Read"] = 0] = "Read";
|
|
/** Only writes to a variable without using the result. E.g.: `x++;`. */
|
|
AccessKind[AccessKind["Write"] = 1] = "Write";
|
|
/** Writes to a variable and uses the result as an expression. E.g.: `f(x++);`. */
|
|
AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite";
|
|
})(AccessKind || (AccessKind = {}));
|
|
function accessKind(node) {
|
|
var parent = node.parent;
|
|
if (!parent)
|
|
return 0 /* Read */;
|
|
switch (parent.kind) {
|
|
case 199 /* PostfixUnaryExpression */:
|
|
case 198 /* PrefixUnaryExpression */:
|
|
var operator = parent.operator;
|
|
return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */;
|
|
case 200 /* BinaryExpression */:
|
|
var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
|
|
return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */;
|
|
case 185 /* PropertyAccessExpression */:
|
|
return parent.name !== node ? 0 /* Read */ : accessKind(parent);
|
|
default:
|
|
return 0 /* Read */;
|
|
}
|
|
function writeOrReadWrite() {
|
|
// If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect.
|
|
return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */;
|
|
}
|
|
}
|
|
function compareDataObjects(dst, src) {
|
|
if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
|
|
return false;
|
|
}
|
|
for (var e in dst) {
|
|
if (typeof dst[e] === "object") {
|
|
if (!compareDataObjects(dst[e], src[e])) {
|
|
return false;
|
|
}
|
|
}
|
|
else if (typeof dst[e] !== "function") {
|
|
if (dst[e] !== src[e]) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.compareDataObjects = compareDataObjects;
|
|
/**
|
|
* clears already present map by calling onDeleteExistingValue callback before deleting that key/value
|
|
*/
|
|
function clearMap(map, onDeleteValue) {
|
|
// Remove all
|
|
map.forEach(onDeleteValue);
|
|
map.clear();
|
|
}
|
|
ts.clearMap = clearMap;
|
|
/**
|
|
* Mutates the map with newMap such that keys in map will be same as newMap.
|
|
*/
|
|
function mutateMap(map, newMap, options) {
|
|
var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
|
|
// Needs update
|
|
map.forEach(function (existingValue, key) {
|
|
var valueInNewMap = newMap.get(key);
|
|
// Not present any more in new map, remove it
|
|
if (valueInNewMap === undefined) {
|
|
map.delete(key);
|
|
onDeleteValue(existingValue, key);
|
|
}
|
|
// If present notify about existing values
|
|
else if (onExistingValue) {
|
|
onExistingValue(existingValue, valueInNewMap, key);
|
|
}
|
|
});
|
|
// Add new values that are not already present
|
|
newMap.forEach(function (valueInNewMap, key) {
|
|
if (!map.has(key)) {
|
|
// New values
|
|
map.set(key, createNewValue(key, valueInNewMap));
|
|
}
|
|
});
|
|
}
|
|
ts.mutateMap = mutateMap;
|
|
/** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */
|
|
function forEachAncestorDirectory(directory, callback) {
|
|
while (true) {
|
|
var result = callback(directory);
|
|
if (result !== undefined) {
|
|
return result;
|
|
}
|
|
var parentPath = ts.getDirectoryPath(directory);
|
|
if (parentPath === directory) {
|
|
return undefined;
|
|
}
|
|
directory = parentPath;
|
|
}
|
|
}
|
|
ts.forEachAncestorDirectory = forEachAncestorDirectory;
|
|
// Return true if the given type is the constructor type for an abstract class
|
|
function isAbstractConstructorType(type) {
|
|
return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
|
|
}
|
|
ts.isAbstractConstructorType = isAbstractConstructorType;
|
|
function isAbstractConstructorSymbol(symbol) {
|
|
if (symbol.flags & 32 /* Class */) {
|
|
var declaration = getClassLikeDeclarationOfSymbol(symbol);
|
|
return !!declaration && hasModifier(declaration, 128 /* Abstract */);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
|
|
function getClassLikeDeclarationOfSymbol(symbol) {
|
|
return ts.find(symbol.declarations, ts.isClassLike);
|
|
}
|
|
ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
|
|
function getObjectFlags(type) {
|
|
return type.flags & 131072 /* Object */ ? type.objectFlags : 0;
|
|
}
|
|
ts.getObjectFlags = getObjectFlags;
|
|
function typeHasCallOrConstructSignatures(type, checker) {
|
|
return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0;
|
|
}
|
|
ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
|
|
function forSomeAncestorDirectory(directory, callback) {
|
|
return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
|
|
}
|
|
ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
|
|
function isUMDExportSymbol(symbol) {
|
|
return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
}
|
|
ts.isUMDExportSymbol = isUMDExportSymbol;
|
|
function showModuleSpecifier(_a) {
|
|
var moduleSpecifier = _a.moduleSpecifier;
|
|
return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
|
|
}
|
|
ts.showModuleSpecifier = showModuleSpecifier;
|
|
function getLastChild(node) {
|
|
var lastChild;
|
|
ts.forEachChild(node, function (child) {
|
|
if (nodeIsPresent(child))
|
|
lastChild = child;
|
|
}, function (children) {
|
|
// As an optimization, jump straight to the end of the list.
|
|
for (var i = children.length - 1; i >= 0; i--) {
|
|
if (nodeIsPresent(children[i])) {
|
|
lastChild = children[i];
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
return lastChild;
|
|
}
|
|
ts.getLastChild = getLastChild;
|
|
function addToSeen(seen, key, value) {
|
|
if (value === void 0) { value = true; }
|
|
key = String(key);
|
|
if (seen.has(key)) {
|
|
return false;
|
|
}
|
|
seen.set(key, value);
|
|
return true;
|
|
}
|
|
ts.addToSeen = addToSeen;
|
|
function isObjectTypeDeclaration(node) {
|
|
return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
|
|
}
|
|
ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
|
|
})(ts || (ts = {}));
|
|
(function (ts) {
|
|
function getDefaultLibFileName(options) {
|
|
switch (options.target) {
|
|
case 6 /* ESNext */:
|
|
return "lib.esnext.full.d.ts";
|
|
case 4 /* ES2017 */:
|
|
return "lib.es2017.full.d.ts";
|
|
case 3 /* ES2016 */:
|
|
return "lib.es2016.full.d.ts";
|
|
case 2 /* ES2015 */:
|
|
return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change.
|
|
default:
|
|
return "lib.d.ts";
|
|
}
|
|
}
|
|
ts.getDefaultLibFileName = getDefaultLibFileName;
|
|
function textSpanEnd(span) {
|
|
return span.start + span.length;
|
|
}
|
|
ts.textSpanEnd = textSpanEnd;
|
|
function textSpanIsEmpty(span) {
|
|
return span.length === 0;
|
|
}
|
|
ts.textSpanIsEmpty = textSpanIsEmpty;
|
|
function textSpanContainsPosition(span, position) {
|
|
return position >= span.start && position < textSpanEnd(span);
|
|
}
|
|
ts.textSpanContainsPosition = textSpanContainsPosition;
|
|
// Returns true if 'span' contains 'other'.
|
|
function textSpanContainsTextSpan(span, other) {
|
|
return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
|
|
}
|
|
ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
|
|
function textSpanOverlapsWith(span, other) {
|
|
return textSpanOverlap(span, other) !== undefined;
|
|
}
|
|
ts.textSpanOverlapsWith = textSpanOverlapsWith;
|
|
function textSpanOverlap(span1, span2) {
|
|
var overlap = textSpanIntersection(span1, span2);
|
|
return overlap && overlap.length === 0 ? undefined : overlap;
|
|
}
|
|
ts.textSpanOverlap = textSpanOverlap;
|
|
function textSpanIntersectsWithTextSpan(span, other) {
|
|
return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
|
|
}
|
|
ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
|
|
function textSpanIntersectsWith(span, start, length) {
|
|
return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
|
|
}
|
|
ts.textSpanIntersectsWith = textSpanIntersectsWith;
|
|
function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
|
|
var end1 = start1 + length1;
|
|
var end2 = start2 + length2;
|
|
return start2 <= end1 && end2 >= start1;
|
|
}
|
|
ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
|
|
function textSpanIntersectsWithPosition(span, position) {
|
|
return position <= textSpanEnd(span) && position >= span.start;
|
|
}
|
|
ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
|
|
function textSpanIntersection(span1, span2) {
|
|
var start = Math.max(span1.start, span2.start);
|
|
var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
|
return start <= end ? createTextSpanFromBounds(start, end) : undefined;
|
|
}
|
|
ts.textSpanIntersection = textSpanIntersection;
|
|
function createTextSpan(start, length) {
|
|
if (start < 0) {
|
|
throw new Error("start < 0");
|
|
}
|
|
if (length < 0) {
|
|
throw new Error("length < 0");
|
|
}
|
|
return { start: start, length: length };
|
|
}
|
|
ts.createTextSpan = createTextSpan;
|
|
/* @internal */
|
|
function createTextRange(pos, end) {
|
|
if (end === void 0) { end = pos; }
|
|
ts.Debug.assert(end >= pos);
|
|
return { pos: pos, end: end };
|
|
}
|
|
ts.createTextRange = createTextRange;
|
|
function createTextSpanFromBounds(start, end) {
|
|
return createTextSpan(start, end - start);
|
|
}
|
|
ts.createTextSpanFromBounds = createTextSpanFromBounds;
|
|
function textChangeRangeNewSpan(range) {
|
|
return createTextSpan(range.span.start, range.newLength);
|
|
}
|
|
ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
|
|
function textChangeRangeIsUnchanged(range) {
|
|
return textSpanIsEmpty(range.span) && range.newLength === 0;
|
|
}
|
|
ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
|
|
function createTextChangeRange(span, newLength) {
|
|
if (newLength < 0) {
|
|
throw new Error("newLength < 0");
|
|
}
|
|
return { span: span, newLength: newLength };
|
|
}
|
|
ts.createTextChangeRange = createTextChangeRange;
|
|
ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
|
/**
|
|
* Called to merge all the changes that occurred across several versions of a script snapshot
|
|
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
|
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
|
*
|
|
* This function will then merge those changes into a single change range valid between V1 and
|
|
* Vn.
|
|
*/
|
|
function collapseTextChangeRangesAcrossMultipleVersions(changes) {
|
|
if (changes.length === 0) {
|
|
return ts.unchangedTextChangeRange;
|
|
}
|
|
if (changes.length === 1) {
|
|
return changes[0];
|
|
}
|
|
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
|
|
// as it makes things much easier to reason about.
|
|
var change0 = changes[0];
|
|
var oldStartN = change0.span.start;
|
|
var oldEndN = textSpanEnd(change0.span);
|
|
var newEndN = oldStartN + change0.newLength;
|
|
for (var i = 1; i < changes.length; i++) {
|
|
var nextChange = changes[i];
|
|
// Consider the following case:
|
|
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
|
|
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
|
|
// i.e. the span starting at 30 with length 30 is increased to length 40.
|
|
//
|
|
// 0 10 20 30 40 50 60 70 80 90 100
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// | /
|
|
// | /----
|
|
// T1 | /----
|
|
// | /----
|
|
// | /----
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// | \
|
|
// | \
|
|
// T2 | \
|
|
// | \
|
|
// | \
|
|
// -------------------------------------------------------------------------------------------------------
|
|
//
|
|
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
|
|
// it's just the min of the old and new starts. i.e.:
|
|
//
|
|
// 0 10 20 30 40 50 60 70 80 90 100
|
|
// ------------------------------------------------------------*------------------------------------------
|
|
// | /
|
|
// | /----
|
|
// T1 | /----
|
|
// | /----
|
|
// | /----
|
|
// ----------------------------------------$-------------------$------------------------------------------
|
|
// . | \
|
|
// . | \
|
|
// T2 . | \
|
|
// . | \
|
|
// . | \
|
|
// ----------------------------------------------------------------------*--------------------------------
|
|
//
|
|
// (Note the dots represent the newly inferred start.
|
|
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
|
|
// absolute positions at the asterisks, and the relative change between the dollar signs. Basically, we see
|
|
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
|
|
// means:
|
|
//
|
|
// 0 10 20 30 40 50 60 70 80 90 100
|
|
// --------------------------------------------------------------------------------*----------------------
|
|
// | /
|
|
// | /----
|
|
// T1 | /----
|
|
// | /----
|
|
// | /----
|
|
// ------------------------------------------------------------$------------------------------------------
|
|
// . | \
|
|
// . | \
|
|
// T2 . | \
|
|
// . | \
|
|
// . | \
|
|
// ----------------------------------------------------------------------*--------------------------------
|
|
//
|
|
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
|
|
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
|
|
// that's the same as if we started at char 80 instead of 60.
|
|
//
|
|
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rather
|
|
// than pushing the first edit forward to match the second, we'll push the second edit forward to match the
|
|
// first.
|
|
//
|
|
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
|
|
// semantics: { { start: 10, length: 70 }, newLength: 60 }
|
|
//
|
|
// The math then works out as follows.
|
|
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
|
// final result like so:
|
|
//
|
|
// {
|
|
// oldStart3: Min(oldStart1, oldStart2),
|
|
// oldEnd3: Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
|
|
// newEnd3: Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
|
|
// }
|
|
var oldStart1 = oldStartN;
|
|
var oldEnd1 = oldEndN;
|
|
var newEnd1 = newEndN;
|
|
var oldStart2 = nextChange.span.start;
|
|
var oldEnd2 = textSpanEnd(nextChange.span);
|
|
var newEnd2 = oldStart2 + nextChange.newLength;
|
|
oldStartN = Math.min(oldStart1, oldStart2);
|
|
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
|
|
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
|
|
}
|
|
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN);
|
|
}
|
|
ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
|
|
function getTypeParameterOwner(d) {
|
|
if (d && d.kind === 148 /* TypeParameter */) {
|
|
for (var current = d; current; current = current.parent) {
|
|
if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) {
|
|
return current;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ts.getTypeParameterOwner = getTypeParameterOwner;
|
|
function isParameterPropertyDeclaration(node) {
|
|
return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */;
|
|
}
|
|
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
|
|
function isEmptyBindingPattern(node) {
|
|
if (ts.isBindingPattern(node)) {
|
|
return ts.every(node.elements, isEmptyBindingElement);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isEmptyBindingPattern = isEmptyBindingPattern;
|
|
function isEmptyBindingElement(node) {
|
|
if (ts.isOmittedExpression(node)) {
|
|
return true;
|
|
}
|
|
return isEmptyBindingPattern(node.name);
|
|
}
|
|
ts.isEmptyBindingElement = isEmptyBindingElement;
|
|
function walkUpBindingElementsAndPatterns(node) {
|
|
while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) {
|
|
node = node.parent;
|
|
}
|
|
return node;
|
|
}
|
|
function getCombinedModifierFlags(node) {
|
|
node = walkUpBindingElementsAndPatterns(node);
|
|
var flags = ts.getModifierFlags(node);
|
|
if (node.kind === 232 /* VariableDeclaration */) {
|
|
node = node.parent;
|
|
}
|
|
if (node && node.kind === 233 /* VariableDeclarationList */) {
|
|
flags |= ts.getModifierFlags(node);
|
|
node = node.parent;
|
|
}
|
|
if (node && node.kind === 214 /* VariableStatement */) {
|
|
flags |= ts.getModifierFlags(node);
|
|
}
|
|
return flags;
|
|
}
|
|
ts.getCombinedModifierFlags = getCombinedModifierFlags;
|
|
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
|
// nodes like variable declarations and binding elements can returned a view of their flags
|
|
// that includes the modifiers from their container. i.e. flags like export/declare aren't
|
|
// stored on the variable declaration directly, but on the containing variable statement
|
|
// (if it has one). Similarly, flags for let/const are store on the variable declaration
|
|
// list. By calling this function, all those flags are combined so that the client can treat
|
|
// the node as if it actually had those flags.
|
|
function getCombinedNodeFlags(node) {
|
|
node = walkUpBindingElementsAndPatterns(node);
|
|
var flags = node.flags;
|
|
if (node.kind === 232 /* VariableDeclaration */) {
|
|
node = node.parent;
|
|
}
|
|
if (node && node.kind === 233 /* VariableDeclarationList */) {
|
|
flags |= node.flags;
|
|
node = node.parent;
|
|
}
|
|
if (node && node.kind === 214 /* VariableStatement */) {
|
|
flags |= node.flags;
|
|
}
|
|
return flags;
|
|
}
|
|
ts.getCombinedNodeFlags = getCombinedNodeFlags;
|
|
/**
|
|
* Checks to see if the locale is in the appropriate format,
|
|
* and if it is, attempts to set the appropriate language.
|
|
*/
|
|
function validateLocaleAndSetLanguage(locale, sys, errors) {
|
|
var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
|
if (!matchResult) {
|
|
if (errors) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
|
|
}
|
|
return;
|
|
}
|
|
var language = matchResult[1];
|
|
var territory = matchResult[3];
|
|
// First try the entire locale, then fall back to just language if that's all we have.
|
|
// Either ways do not fail, and fallback to the English diagnostic strings.
|
|
if (!trySetLanguageAndTerritory(language, territory, errors)) {
|
|
trySetLanguageAndTerritory(language, /*territory*/ undefined, errors);
|
|
}
|
|
// Set the UI locale for string collation
|
|
ts.setUILocale(locale);
|
|
function trySetLanguageAndTerritory(language, territory, errors) {
|
|
var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
|
|
var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
|
|
var filePath = ts.combinePaths(containingDirectoryPath, language);
|
|
if (territory) {
|
|
filePath = filePath + "-" + territory;
|
|
}
|
|
filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
|
|
if (!sys.fileExists(filePath)) {
|
|
return false;
|
|
}
|
|
// TODO: Add codePage support for readFile?
|
|
var fileContents = "";
|
|
try {
|
|
fileContents = sys.readFile(filePath);
|
|
}
|
|
catch (e) {
|
|
if (errors) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
|
|
}
|
|
return false;
|
|
}
|
|
try {
|
|
// tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!)
|
|
ts.localizedDiagnosticMessages = JSON.parse(fileContents);
|
|
}
|
|
catch (_a) {
|
|
if (errors) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
|
|
function getOriginalNode(node, nodeTest) {
|
|
if (node) {
|
|
while (node.original !== undefined) {
|
|
node = node.original;
|
|
}
|
|
}
|
|
return !nodeTest || nodeTest(node) ? node : undefined;
|
|
}
|
|
ts.getOriginalNode = getOriginalNode;
|
|
/**
|
|
* Gets a value indicating whether a node originated in the parse tree.
|
|
*
|
|
* @param node The node to test.
|
|
*/
|
|
function isParseTreeNode(node) {
|
|
return (node.flags & 8 /* Synthesized */) === 0;
|
|
}
|
|
ts.isParseTreeNode = isParseTreeNode;
|
|
function getParseTreeNode(node, nodeTest) {
|
|
if (node === undefined || isParseTreeNode(node)) {
|
|
return node;
|
|
}
|
|
node = getOriginalNode(node);
|
|
if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) {
|
|
return node;
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getParseTreeNode = getParseTreeNode;
|
|
/**
|
|
* Remove extra underscore from escaped identifier text content.
|
|
*
|
|
* @param identifier The escaped identifier text.
|
|
* @returns The unescaped identifier text.
|
|
*/
|
|
function unescapeLeadingUnderscores(identifier) {
|
|
var id = identifier;
|
|
return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id;
|
|
}
|
|
ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
|
|
function idText(identifier) {
|
|
return unescapeLeadingUnderscores(identifier.escapedText);
|
|
}
|
|
ts.idText = idText;
|
|
function symbolName(symbol) {
|
|
return unescapeLeadingUnderscores(symbol.escapedName);
|
|
}
|
|
ts.symbolName = symbolName;
|
|
/**
|
|
* Remove extra underscore from escaped identifier text content.
|
|
* @deprecated Use `id.text` for the unescaped text.
|
|
* @param identifier The escaped identifier text.
|
|
* @returns The unescaped identifier text.
|
|
*/
|
|
function unescapeIdentifier(id) {
|
|
return id;
|
|
}
|
|
ts.unescapeIdentifier = unescapeIdentifier;
|
|
/**
|
|
* A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should
|
|
* attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol
|
|
* will be merged with)
|
|
*/
|
|
function nameForNamelessJSDocTypedef(declaration) {
|
|
var hostNode = declaration.parent.parent;
|
|
if (!hostNode) {
|
|
return undefined;
|
|
}
|
|
// Covers classes, functions - any named declaration host node
|
|
if (ts.isDeclaration(hostNode)) {
|
|
return getDeclarationIdentifier(hostNode);
|
|
}
|
|
// Covers remaining cases
|
|
switch (hostNode.kind) {
|
|
case 214 /* VariableStatement */:
|
|
if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
|
|
return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
|
|
}
|
|
return undefined;
|
|
case 216 /* ExpressionStatement */:
|
|
var expr = hostNode.expression;
|
|
switch (expr.kind) {
|
|
case 185 /* PropertyAccessExpression */:
|
|
return expr.name;
|
|
case 186 /* ElementAccessExpression */:
|
|
var arg = expr.argumentExpression;
|
|
if (ts.isIdentifier(arg)) {
|
|
return arg;
|
|
}
|
|
}
|
|
return undefined;
|
|
case 1 /* EndOfFileToken */:
|
|
return undefined;
|
|
case 191 /* ParenthesizedExpression */: {
|
|
return getDeclarationIdentifier(hostNode.expression);
|
|
}
|
|
case 228 /* LabeledStatement */: {
|
|
if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) {
|
|
return getDeclarationIdentifier(hostNode.statement);
|
|
}
|
|
return undefined;
|
|
}
|
|
default:
|
|
ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!");
|
|
}
|
|
}
|
|
function getDeclarationIdentifier(node) {
|
|
var name = getNameOfDeclaration(node);
|
|
return ts.isIdentifier(name) ? name : undefined;
|
|
}
|
|
function getNameOfJSDocTypedef(declaration) {
|
|
return declaration.name || nameForNamelessJSDocTypedef(declaration);
|
|
}
|
|
ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
|
|
/** @internal */
|
|
function isNamedDeclaration(node) {
|
|
return !!node.name; // A 'name' property should always be a DeclarationName.
|
|
}
|
|
ts.isNamedDeclaration = isNamedDeclaration;
|
|
// TODO: GH#18217 This is often used as if it returns a defined result
|
|
function getNameOfDeclaration(declaration) {
|
|
if (!declaration) {
|
|
return undefined;
|
|
}
|
|
switch (declaration.kind) {
|
|
case 205 /* ClassExpression */:
|
|
case 192 /* FunctionExpression */:
|
|
if (!declaration.name) {
|
|
return getAssignedName(declaration);
|
|
}
|
|
break;
|
|
case 71 /* Identifier */:
|
|
return declaration;
|
|
case 298 /* JSDocPropertyTag */:
|
|
case 293 /* JSDocParameterTag */: {
|
|
var name = declaration.name;
|
|
if (name.kind === 146 /* QualifiedName */) {
|
|
return name.right;
|
|
}
|
|
break;
|
|
}
|
|
case 200 /* BinaryExpression */: {
|
|
var expr = declaration;
|
|
switch (ts.getSpecialPropertyAssignmentKind(expr)) {
|
|
case 1 /* ExportsProperty */:
|
|
case 4 /* ThisProperty */:
|
|
case 5 /* Property */:
|
|
case 3 /* PrototypeProperty */:
|
|
return expr.left.name;
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|
|
case 292 /* JSDocCallbackTag */:
|
|
return declaration.name;
|
|
case 297 /* JSDocTypedefTag */:
|
|
return getNameOfJSDocTypedef(declaration);
|
|
case 249 /* ExportAssignment */: {
|
|
var expression = declaration.expression;
|
|
return ts.isIdentifier(expression) ? expression : undefined;
|
|
}
|
|
}
|
|
return declaration.name;
|
|
}
|
|
ts.getNameOfDeclaration = getNameOfDeclaration;
|
|
function getAssignedName(node) {
|
|
if (!node.parent) {
|
|
return undefined;
|
|
}
|
|
else if (ts.isPropertyAssignment(node.parent) || ts.isBindingElement(node.parent)) {
|
|
return node.parent.name;
|
|
}
|
|
else if (ts.isBinaryExpression(node.parent) && node === node.parent.right) {
|
|
if (ts.isIdentifier(node.parent.left)) {
|
|
return node.parent.left;
|
|
}
|
|
else if (ts.isPropertyAccessExpression(node.parent.left)) {
|
|
return node.parent.left.name;
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Gets the JSDoc parameter tags for the node if present.
|
|
*
|
|
* @remarks Returns any JSDoc param tag that matches the provided
|
|
* parameter, whether a param tag on a containing function
|
|
* expression, or a param tag on a variable declaration whose
|
|
* initializer is the containing function. The tags closest to the
|
|
* node are returned first, so in the previous example, the param
|
|
* tag on the containing function expression would be first.
|
|
*
|
|
* Does not return tags for binding patterns, because JSDoc matches
|
|
* parameters by name and binding patterns do not have a name.
|
|
*/
|
|
function getJSDocParameterTags(param) {
|
|
if (param.name) {
|
|
if (ts.isIdentifier(param.name)) {
|
|
var name_1 = param.name.escapedText;
|
|
return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; });
|
|
}
|
|
else {
|
|
var i = param.parent.parameters.indexOf(param);
|
|
ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
|
|
var paramTags = getJSDocTags(param.parent).filter(ts.isJSDocParameterTag);
|
|
if (i < paramTags.length) {
|
|
return [paramTags[i]];
|
|
}
|
|
}
|
|
}
|
|
// return empty array for: out-of-order binding patterns and JSDoc function syntax, which has un-named parameters
|
|
return ts.emptyArray;
|
|
}
|
|
ts.getJSDocParameterTags = getJSDocParameterTags;
|
|
/**
|
|
* Return true if the node has JSDoc parameter tags.
|
|
*
|
|
* @remarks Includes parameter tags that are not directly on the node,
|
|
* for example on a variable declaration whose initializer is a function expression.
|
|
*/
|
|
function hasJSDocParameterTags(node) {
|
|
return !!getFirstJSDocTag(node, ts.isJSDocParameterTag);
|
|
}
|
|
ts.hasJSDocParameterTags = hasJSDocParameterTags;
|
|
/** Gets the JSDoc augments tag for the node if present */
|
|
function getJSDocAugmentsTag(node) {
|
|
return getFirstJSDocTag(node, ts.isJSDocAugmentsTag);
|
|
}
|
|
ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
|
|
/** Gets the JSDoc class tag for the node if present */
|
|
function getJSDocClassTag(node) {
|
|
return getFirstJSDocTag(node, ts.isJSDocClassTag);
|
|
}
|
|
ts.getJSDocClassTag = getJSDocClassTag;
|
|
/** Gets the JSDoc return tag for the node if present */
|
|
function getJSDocReturnTag(node) {
|
|
return getFirstJSDocTag(node, ts.isJSDocReturnTag);
|
|
}
|
|
ts.getJSDocReturnTag = getJSDocReturnTag;
|
|
/** Gets the JSDoc template tag for the node if present */
|
|
function getJSDocTemplateTag(node) {
|
|
return getFirstJSDocTag(node, ts.isJSDocTemplateTag);
|
|
}
|
|
ts.getJSDocTemplateTag = getJSDocTemplateTag;
|
|
/** Gets the JSDoc type tag for the node if present and valid */
|
|
function getJSDocTypeTag(node) {
|
|
// We should have already issued an error if there were multiple type jsdocs, so just use the first one.
|
|
var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
|
|
if (tag && tag.typeExpression && tag.typeExpression.type) {
|
|
return tag;
|
|
}
|
|
return undefined;
|
|
}
|
|
ts.getJSDocTypeTag = getJSDocTypeTag;
|
|
/**
|
|
* Gets the type node for the node if provided via JSDoc.
|
|
*
|
|
* @remarks The search includes any JSDoc param tag that relates
|
|
* to the provided parameter, for example a type tag on the
|
|
* parameter itself, or a param tag on a containing function
|
|
* expression, or a param tag on a variable declaration whose
|
|
* initializer is the containing function. The tags closest to the
|
|
* node are examined first, so in the previous example, the type
|
|
* tag directly on the node would be returned.
|
|
*/
|
|
function getJSDocType(node) {
|
|
var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
|
|
if (!tag && ts.isParameter(node)) {
|
|
tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
|
|
}
|
|
return tag && tag.typeExpression && tag.typeExpression.type;
|
|
}
|
|
ts.getJSDocType = getJSDocType;
|
|
/**
|
|
* Gets the return type node for the node if provided via JSDoc's return tag.
|
|
*
|
|
* @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function
|
|
* gets the type from inside the braces.
|
|
*/
|
|
function getJSDocReturnType(node) {
|
|
var returnTag = getJSDocReturnTag(node);
|
|
return returnTag && returnTag.typeExpression && returnTag.typeExpression.type;
|
|
}
|
|
ts.getJSDocReturnType = getJSDocReturnType;
|
|
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
|
function getJSDocTags(node) {
|
|
var tags = node.jsDocCache;
|
|
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
|
|
if (tags === undefined) {
|
|
var comments = ts.getJSDocCommentsAndTags(node);
|
|
ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
|
|
node.jsDocCache = tags = ts.flatMap(comments, function (j) { return ts.isJSDoc(j) ? j.tags : j; });
|
|
}
|
|
return tags;
|
|
}
|
|
ts.getJSDocTags = getJSDocTags;
|
|
/** Get the first JSDoc tag of a specified kind, or undefined if not present. */
|
|
function getFirstJSDocTag(node, predicate) {
|
|
return ts.find(getJSDocTags(node), predicate);
|
|
}
|
|
/** Gets all JSDoc tags of a specified kind, or undefined if not present. */
|
|
function getAllJSDocTagsOfKind(node, kind) {
|
|
return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
|
|
}
|
|
ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
|
|
})(ts || (ts = {}));
|
|
// Simple node tests of the form `node.kind === SyntaxKind.Foo`.
|
|
(function (ts) {
|
|
// Literals
|
|
function isNumericLiteral(node) {
|
|
return node.kind === 8 /* NumericLiteral */;
|
|
}
|
|
ts.isNumericLiteral = isNumericLiteral;
|
|
function isStringLiteral(node) {
|
|
return node.kind === 9 /* StringLiteral */;
|
|
}
|
|
ts.isStringLiteral = isStringLiteral;
|
|
function isJsxText(node) {
|
|
return node.kind === 10 /* JsxText */;
|
|
}
|
|
ts.isJsxText = isJsxText;
|
|
function isRegularExpressionLiteral(node) {
|
|
return node.kind === 12 /* RegularExpressionLiteral */;
|
|
}
|
|
ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
|
|
function isNoSubstitutionTemplateLiteral(node) {
|
|
return node.kind === 13 /* NoSubstitutionTemplateLiteral */;
|
|
}
|
|
ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
|
|
// Pseudo-literals
|
|
function isTemplateHead(node) {
|
|
return node.kind === 14 /* TemplateHead */;
|
|
}
|
|
ts.isTemplateHead = isTemplateHead;
|
|
function isTemplateMiddle(node) {
|
|
return node.kind === 15 /* TemplateMiddle */;
|
|
}
|
|
ts.isTemplateMiddle = isTemplateMiddle;
|
|
function isTemplateTail(node) {
|
|
return node.kind === 16 /* TemplateTail */;
|
|
}
|
|
ts.isTemplateTail = isTemplateTail;
|
|
function isIdentifier(node) {
|
|
return node.kind === 71 /* Identifier */;
|
|
}
|
|
ts.isIdentifier = isIdentifier;
|
|
// Names
|
|
function isQualifiedName(node) {
|
|
return node.kind === 146 /* QualifiedName */;
|
|
}
|
|
ts.isQualifiedName = isQualifiedName;
|
|
function isComputedPropertyName(node) {
|
|
return node.kind === 147 /* ComputedPropertyName */;
|
|
}
|
|
ts.isComputedPropertyName = isComputedPropertyName;
|
|
// Signature elements
|
|
function isTypeParameterDeclaration(node) {
|
|
return node.kind === 148 /* TypeParameter */;
|
|
}
|
|
ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
|
|
function isParameter(node) {
|
|
return node.kind === 149 /* Parameter */;
|
|
}
|
|
ts.isParameter = isParameter;
|
|
function isDecorator(node) {
|
|
return node.kind === 150 /* Decorator */;
|
|
}
|
|
ts.isDecorator = isDecorator;
|
|
// TypeMember
|
|
function isPropertySignature(node) {
|
|
return node.kind === 151 /* PropertySignature */;
|
|
}
|
|
ts.isPropertySignature = isPropertySignature;
|
|
function isPropertyDeclaration(node) {
|
|
return node.kind === 152 /* PropertyDeclaration */;
|
|
}
|
|
ts.isPropertyDeclaration = isPropertyDeclaration;
|
|
function isMethodSignature(node) {
|
|
return node.kind === 153 /* MethodSignature */;
|
|
}
|
|
ts.isMethodSignature = isMethodSignature;
|
|
function isMethodDeclaration(node) {
|
|
return node.kind === 154 /* MethodDeclaration */;
|
|
}
|
|
ts.isMethodDeclaration = isMethodDeclaration;
|
|
function isConstructorDeclaration(node) {
|
|
return node.kind === 155 /* Constructor */;
|
|
}
|
|
ts.isConstructorDeclaration = isConstructorDeclaration;
|
|
function isGetAccessorDeclaration(node) {
|
|
return node.kind === 156 /* GetAccessor */;
|
|
}
|
|
ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
|
|
function isSetAccessorDeclaration(node) {
|
|
return node.kind === 157 /* SetAccessor */;
|
|
}
|
|
ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
|
|
function isCallSignatureDeclaration(node) {
|
|
return node.kind === 158 /* CallSignature */;
|
|
}
|
|
ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
|
|
function isConstructSignatureDeclaration(node) {
|
|
return node.kind === 159 /* ConstructSignature */;
|
|
}
|
|
ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
|
|
function isIndexSignatureDeclaration(node) {
|
|
return node.kind === 160 /* IndexSignature */;
|
|
}
|
|
ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
|
|
/* @internal */
|
|
function isGetOrSetAccessorDeclaration(node) {
|
|
return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */;
|
|
}
|
|
ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
|
|
// Type
|
|
function isTypePredicateNode(node) {
|
|
return node.kind === 161 /* TypePredicate */;
|
|
}
|
|
ts.isTypePredicateNode = isTypePredicateNode;
|
|
function isTypeReferenceNode(node) {
|
|
return node.kind === 162 /* TypeReference */;
|
|
}
|
|
ts.isTypeReferenceNode = isTypeReferenceNode;
|
|
function isFunctionTypeNode(node) {
|
|
return node.kind === 163 /* FunctionType */;
|
|
}
|
|
ts.isFunctionTypeNode = isFunctionTypeNode;
|
|
function isConstructorTypeNode(node) {
|
|
return node.kind === 164 /* ConstructorType */;
|
|
}
|
|
ts.isConstructorTypeNode = isConstructorTypeNode;
|
|
function isTypeQueryNode(node) {
|
|
return node.kind === 165 /* TypeQuery */;
|
|
}
|
|
ts.isTypeQueryNode = isTypeQueryNode;
|
|
function isTypeLiteralNode(node) {
|
|
return node.kind === 166 /* TypeLiteral */;
|
|
}
|
|
ts.isTypeLiteralNode = isTypeLiteralNode;
|
|
function isArrayTypeNode(node) {
|
|
return node.kind === 167 /* ArrayType */;
|
|
}
|
|
ts.isArrayTypeNode = isArrayTypeNode;
|
|
function isTupleTypeNode(node) {
|
|
return node.kind === 168 /* TupleType */;
|
|
}
|
|
ts.isTupleTypeNode = isTupleTypeNode;
|
|
function isUnionTypeNode(node) {
|
|
return node.kind === 169 /* UnionType */;
|
|
}
|
|
ts.isUnionTypeNode = isUnionTypeNode;
|
|
function isIntersectionTypeNode(node) {
|
|
return node.kind === 170 /* IntersectionType */;
|
|
}
|
|
ts.isIntersectionTypeNode = isIntersectionTypeNode;
|
|
function isConditionalTypeNode(node) {
|
|
return node.kind === 171 /* ConditionalType */;
|
|
}
|
|
ts.isConditionalTypeNode = isConditionalTypeNode;
|
|
function isInferTypeNode(node) {
|
|
return node.kind === 172 /* InferType */;
|
|
}
|
|
ts.isInferTypeNode = isInferTypeNode;
|
|
function isParenthesizedTypeNode(node) {
|
|
return node.kind === 173 /* ParenthesizedType */;
|
|
}
|
|
ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
|
|
function isThisTypeNode(node) {
|
|
return node.kind === 174 /* ThisType */;
|
|
}
|
|
ts.isThisTypeNode = isThisTypeNode;
|
|
function isTypeOperatorNode(node) {
|
|
return node.kind === 175 /* TypeOperator */;
|
|
}
|
|
ts.isTypeOperatorNode = isTypeOperatorNode;
|
|
function isIndexedAccessTypeNode(node) {
|
|
return node.kind === 176 /* IndexedAccessType */;
|
|
}
|
|
ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
|
|
function isMappedTypeNode(node) {
|
|
return node.kind === 177 /* MappedType */;
|
|
}
|
|
ts.isMappedTypeNode = isMappedTypeNode;
|
|
function isLiteralTypeNode(node) {
|
|
return node.kind === 178 /* LiteralType */;
|
|
}
|
|
ts.isLiteralTypeNode = isLiteralTypeNode;
|
|
function isImportTypeNode(node) {
|
|
return node.kind === 179 /* ImportType */;
|
|
}
|
|
ts.isImportTypeNode = isImportTypeNode;
|
|
// Binding patterns
|
|
function isObjectBindingPattern(node) {
|
|
return node.kind === 180 /* ObjectBindingPattern */;
|
|
}
|
|
ts.isObjectBindingPattern = isObjectBindingPattern;
|
|
function isArrayBindingPattern(node) {
|
|
return node.kind === 181 /* ArrayBindingPattern */;
|
|
}
|
|
ts.isArrayBindingPattern = isArrayBindingPattern;
|
|
function isBindingElement(node) {
|
|
return node.kind === 182 /* BindingElement */;
|
|
}
|
|
ts.isBindingElement = isBindingElement;
|
|
// Expression
|
|
function isArrayLiteralExpression(node) {
|
|
return node.kind === 183 /* ArrayLiteralExpression */;
|
|
}
|
|
ts.isArrayLiteralExpression = isArrayLiteralExpression;
|
|
function isObjectLiteralExpression(node) {
|
|
return node.kind === 184 /* ObjectLiteralExpression */;
|
|
}
|
|
ts.isObjectLiteralExpression = isObjectLiteralExpression;
|
|
function isPropertyAccessExpression(node) {
|
|
return node.kind === 185 /* PropertyAccessExpression */;
|
|
}
|
|
ts.isPropertyAccessExpression = isPropertyAccessExpression;
|
|
function isElementAccessExpression(node) {
|
|
return node.kind === 186 /* ElementAccessExpression */;
|
|
}
|
|
ts.isElementAccessExpression = isElementAccessExpression;
|
|
function isCallExpression(node) {
|
|
return node.kind === 187 /* CallExpression */;
|
|
}
|
|
ts.isCallExpression = isCallExpression;
|
|
function isNewExpression(node) {
|
|
return node.kind === 188 /* NewExpression */;
|
|
}
|
|
ts.isNewExpression = isNewExpression;
|
|
function isTaggedTemplateExpression(node) {
|
|
return node.kind === 189 /* TaggedTemplateExpression */;
|
|
}
|
|
ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
|
|
function isTypeAssertion(node) {
|
|
return node.kind === 190 /* TypeAssertionExpression */;
|
|
}
|
|
ts.isTypeAssertion = isTypeAssertion;
|
|
function isParenthesizedExpression(node) {
|
|
return node.kind === 191 /* ParenthesizedExpression */;
|
|
}
|
|
ts.isParenthesizedExpression = isParenthesizedExpression;
|
|
function skipPartiallyEmittedExpressions(node) {
|
|
while (node.kind === 301 /* PartiallyEmittedExpression */) {
|
|
node = node.expression;
|
|
}
|
|
return node;
|
|
}
|
|
ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
|
|
function isFunctionExpression(node) {
|
|
return node.kind === 192 /* FunctionExpression */;
|
|
}
|
|
ts.isFunctionExpression = isFunctionExpression;
|
|
function isArrowFunction(node) {
|
|
return node.kind === 193 /* ArrowFunction */;
|
|
}
|
|
ts.isArrowFunction = isArrowFunction;
|
|
function isDeleteExpression(node) {
|
|
return node.kind === 194 /* DeleteExpression */;
|
|
}
|
|
ts.isDeleteExpression = isDeleteExpression;
|
|
function isTypeOfExpression(node) {
|
|
return node.kind === 195 /* TypeOfExpression */;
|
|
}
|
|
ts.isTypeOfExpression = isTypeOfExpression;
|
|
function isVoidExpression(node) {
|
|
return node.kind === 196 /* VoidExpression */;
|
|
}
|
|
ts.isVoidExpression = isVoidExpression;
|
|
function isAwaitExpression(node) {
|
|
return node.kind === 197 /* AwaitExpression */;
|
|
}
|
|
ts.isAwaitExpression = isAwaitExpression;
|
|
function isPrefixUnaryExpression(node) {
|
|
return node.kind === 198 /* PrefixUnaryExpression */;
|
|
}
|
|
ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
|
|
function isPostfixUnaryExpression(node) {
|
|
return node.kind === 199 /* PostfixUnaryExpression */;
|
|
}
|
|
ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
|
|
function isBinaryExpression(node) {
|
|
return node.kind === 200 /* BinaryExpression */;
|
|
}
|
|
ts.isBinaryExpression = isBinaryExpression;
|
|
function isConditionalExpression(node) {
|
|
return node.kind === 201 /* ConditionalExpression */;
|
|
}
|
|
ts.isConditionalExpression = isConditionalExpression;
|
|
function isTemplateExpression(node) {
|
|
return node.kind === 202 /* TemplateExpression */;
|
|
}
|
|
ts.isTemplateExpression = isTemplateExpression;
|
|
function isYieldExpression(node) {
|
|
return node.kind === 203 /* YieldExpression */;
|
|
}
|
|
ts.isYieldExpression = isYieldExpression;
|
|
function isSpreadElement(node) {
|
|
return node.kind === 204 /* SpreadElement */;
|
|
}
|
|
ts.isSpreadElement = isSpreadElement;
|
|
function isClassExpression(node) {
|
|
return node.kind === 205 /* ClassExpression */;
|
|
}
|
|
ts.isClassExpression = isClassExpression;
|
|
function isOmittedExpression(node) {
|
|
return node.kind === 206 /* OmittedExpression */;
|
|
}
|
|
ts.isOmittedExpression = isOmittedExpression;
|
|
function isExpressionWithTypeArguments(node) {
|
|
return node.kind === 207 /* ExpressionWithTypeArguments */;
|
|
}
|
|
ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
|
|
function isAsExpression(node) {
|
|
return node.kind === 208 /* AsExpression */;
|
|
}
|
|
ts.isAsExpression = isAsExpression;
|
|
function isNonNullExpression(node) {
|
|
return node.kind === 209 /* NonNullExpression */;
|
|
}
|
|
ts.isNonNullExpression = isNonNullExpression;
|
|
function isMetaProperty(node) {
|
|
return node.kind === 210 /* MetaProperty */;
|
|
}
|
|
ts.isMetaProperty = isMetaProperty;
|
|
// Misc
|
|
function isTemplateSpan(node) {
|
|
return node.kind === 211 /* TemplateSpan */;
|
|
}
|
|
ts.isTemplateSpan = isTemplateSpan;
|
|
function isSemicolonClassElement(node) {
|
|
return node.kind === 212 /* SemicolonClassElement */;
|
|
}
|
|
ts.isSemicolonClassElement = isSemicolonClassElement;
|
|
// Block
|
|
function isBlock(node) {
|
|
return node.kind === 213 /* Block */;
|
|
}
|
|
ts.isBlock = isBlock;
|
|
function isVariableStatement(node) {
|
|
return node.kind === 214 /* VariableStatement */;
|
|
}
|
|
ts.isVariableStatement = isVariableStatement;
|
|
function isEmptyStatement(node) {
|
|
return node.kind === 215 /* EmptyStatement */;
|
|
}
|
|
ts.isEmptyStatement = isEmptyStatement;
|
|
function isExpressionStatement(node) {
|
|
return node.kind === 216 /* ExpressionStatement */;
|
|
}
|
|
ts.isExpressionStatement = isExpressionStatement;
|
|
function isIfStatement(node) {
|
|
return node.kind === 217 /* IfStatement */;
|
|
}
|
|
ts.isIfStatement = isIfStatement;
|
|
function isDoStatement(node) {
|
|
return node.kind === 218 /* DoStatement */;
|
|
}
|
|
ts.isDoStatement = isDoStatement;
|
|
function isWhileStatement(node) {
|
|
return node.kind === 219 /* WhileStatement */;
|
|
}
|
|
ts.isWhileStatement = isWhileStatement;
|
|
function isForStatement(node) {
|
|
return node.kind === 220 /* ForStatement */;
|
|
}
|
|
ts.isForStatement = isForStatement;
|
|
function isForInStatement(node) {
|
|
return node.kind === 221 /* ForInStatement */;
|
|
}
|
|
ts.isForInStatement = isForInStatement;
|
|
function isForOfStatement(node) {
|
|
return node.kind === 222 /* ForOfStatement */;
|
|
}
|
|
ts.isForOfStatement = isForOfStatement;
|
|
function isContinueStatement(node) {
|
|
return node.kind === 223 /* ContinueStatement */;
|
|
}
|
|
ts.isContinueStatement = isContinueStatement;
|
|
function isBreakStatement(node) {
|
|
return node.kind === 224 /* BreakStatement */;
|
|
}
|
|
ts.isBreakStatement = isBreakStatement;
|
|
function isBreakOrContinueStatement(node) {
|
|
return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */;
|
|
}
|
|
ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
|
|
function isReturnStatement(node) {
|
|
return node.kind === 225 /* ReturnStatement */;
|
|
}
|
|
ts.isReturnStatement = isReturnStatement;
|
|
function isWithStatement(node) {
|
|
return node.kind === 226 /* WithStatement */;
|
|
}
|
|
ts.isWithStatement = isWithStatement;
|
|
function isSwitchStatement(node) {
|
|
return node.kind === 227 /* SwitchStatement */;
|
|
}
|
|
ts.isSwitchStatement = isSwitchStatement;
|
|
function isLabeledStatement(node) {
|
|
return node.kind === 228 /* LabeledStatement */;
|
|
}
|
|
ts.isLabeledStatement = isLabeledStatement;
|
|
function isThrowStatement(node) {
|
|
return node.kind === 229 /* ThrowStatement */;
|
|
}
|
|
ts.isThrowStatement = isThrowStatement;
|
|
function isTryStatement(node) {
|
|
return node.kind === 230 /* TryStatement */;
|
|
}
|
|
ts.isTryStatement = isTryStatement;
|
|
function isDebuggerStatement(node) {
|
|
return node.kind === 231 /* DebuggerStatement */;
|
|
}
|
|
ts.isDebuggerStatement = isDebuggerStatement;
|
|
function isVariableDeclaration(node) {
|
|
return node.kind === 232 /* VariableDeclaration */;
|
|
}
|
|
ts.isVariableDeclaration = isVariableDeclaration;
|
|
function isVariableDeclarationList(node) {
|
|
return node.kind === 233 /* VariableDeclarationList */;
|
|
}
|
|
ts.isVariableDeclarationList = isVariableDeclarationList;
|
|
function isFunctionDeclaration(node) {
|
|
return node.kind === 234 /* FunctionDeclaration */;
|
|
}
|
|
ts.isFunctionDeclaration = isFunctionDeclaration;
|
|
function isClassDeclaration(node) {
|
|
return node.kind === 235 /* ClassDeclaration */;
|
|
}
|
|
ts.isClassDeclaration = isClassDeclaration;
|
|
function isInterfaceDeclaration(node) {
|
|
return node.kind === 236 /* InterfaceDeclaration */;
|
|
}
|
|
ts.isInterfaceDeclaration = isInterfaceDeclaration;
|
|
function isTypeAliasDeclaration(node) {
|
|
return node.kind === 237 /* TypeAliasDeclaration */;
|
|
}
|
|
ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
|
|
function isEnumDeclaration(node) {
|
|
return node.kind === 238 /* EnumDeclaration */;
|
|
}
|
|
ts.isEnumDeclaration = isEnumDeclaration;
|
|
function isModuleDeclaration(node) {
|
|
return node.kind === 239 /* ModuleDeclaration */;
|
|
}
|
|
ts.isModuleDeclaration = isModuleDeclaration;
|
|
function isModuleBlock(node) {
|
|
return node.kind === 240 /* ModuleBlock */;
|
|
}
|
|
ts.isModuleBlock = isModuleBlock;
|
|
function isCaseBlock(node) {
|
|
return node.kind === 241 /* CaseBlock */;
|
|
}
|
|
ts.isCaseBlock = isCaseBlock;
|
|
function isNamespaceExportDeclaration(node) {
|
|
return node.kind === 242 /* NamespaceExportDeclaration */;
|
|
}
|
|
ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
|
|
function isImportEqualsDeclaration(node) {
|
|
return node.kind === 243 /* ImportEqualsDeclaration */;
|
|
}
|
|
ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
|
|
function isImportDeclaration(node) {
|
|
return node.kind === 244 /* ImportDeclaration */;
|
|
}
|
|
ts.isImportDeclaration = isImportDeclaration;
|
|
function isImportClause(node) {
|
|
return node.kind === 245 /* ImportClause */;
|
|
}
|
|
ts.isImportClause = isImportClause;
|
|
function isNamespaceImport(node) {
|
|
return node.kind === 246 /* NamespaceImport */;
|
|
}
|
|
ts.isNamespaceImport = isNamespaceImport;
|
|
function isNamedImports(node) {
|
|
return node.kind === 247 /* NamedImports */;
|
|
}
|
|
ts.isNamedImports = isNamedImports;
|
|
function isImportSpecifier(node) {
|
|
return node.kind === 248 /* ImportSpecifier */;
|
|
}
|
|
ts.isImportSpecifier = isImportSpecifier;
|
|
function isExportAssignment(node) {
|
|
return node.kind === 249 /* ExportAssignment */;
|
|
}
|
|
ts.isExportAssignment = isExportAssignment;
|
|
function isExportDeclaration(node) {
|
|
return node.kind === 250 /* ExportDeclaration */;
|
|
}
|
|
ts.isExportDeclaration = isExportDeclaration;
|
|
function isNamedExports(node) {
|
|
return node.kind === 251 /* NamedExports */;
|
|
}
|
|
ts.isNamedExports = isNamedExports;
|
|
function isExportSpecifier(node) {
|
|
return node.kind === 252 /* ExportSpecifier */;
|
|
}
|
|
ts.isExportSpecifier = isExportSpecifier;
|
|
function isMissingDeclaration(node) {
|
|
return node.kind === 253 /* MissingDeclaration */;
|
|
}
|
|
ts.isMissingDeclaration = isMissingDeclaration;
|
|
// Module References
|
|
function isExternalModuleReference(node) {
|
|
return node.kind === 254 /* ExternalModuleReference */;
|
|
}
|
|
ts.isExternalModuleReference = isExternalModuleReference;
|
|
// JSX
|
|
function isJsxElement(node) {
|
|
return node.kind === 255 /* JsxElement */;
|
|
}
|
|
ts.isJsxElement = isJsxElement;
|
|
function isJsxSelfClosingElement(node) {
|
|
return node.kind === 256 /* JsxSelfClosingElement */;
|
|
}
|
|
ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
|
|
function isJsxOpeningElement(node) {
|
|
return node.kind === 257 /* JsxOpeningElement */;
|
|
}
|
|
ts.isJsxOpeningElement = isJsxOpeningElement;
|
|
function isJsxClosingElement(node) {
|
|
return node.kind === 258 /* JsxClosingElement */;
|
|
}
|
|
ts.isJsxClosingElement = isJsxClosingElement;
|
|
function isJsxFragment(node) {
|
|
return node.kind === 259 /* JsxFragment */;
|
|
}
|
|
ts.isJsxFragment = isJsxFragment;
|
|
function isJsxOpeningFragment(node) {
|
|
return node.kind === 260 /* JsxOpeningFragment */;
|
|
}
|
|
ts.isJsxOpeningFragment = isJsxOpeningFragment;
|
|
function isJsxClosingFragment(node) {
|
|
return node.kind === 261 /* JsxClosingFragment */;
|
|
}
|
|
ts.isJsxClosingFragment = isJsxClosingFragment;
|
|
function isJsxAttribute(node) {
|
|
return node.kind === 262 /* JsxAttribute */;
|
|
}
|
|
ts.isJsxAttribute = isJsxAttribute;
|
|
function isJsxAttributes(node) {
|
|
return node.kind === 263 /* JsxAttributes */;
|
|
}
|
|
ts.isJsxAttributes = isJsxAttributes;
|
|
function isJsxSpreadAttribute(node) {
|
|
return node.kind === 264 /* JsxSpreadAttribute */;
|
|
}
|
|
ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
|
|
function isJsxExpression(node) {
|
|
return node.kind === 265 /* JsxExpression */;
|
|
}
|
|
ts.isJsxExpression = isJsxExpression;
|
|
// Clauses
|
|
function isCaseClause(node) {
|
|
return node.kind === 266 /* CaseClause */;
|
|
}
|
|
ts.isCaseClause = isCaseClause;
|
|
function isDefaultClause(node) {
|
|
return node.kind === 267 /* DefaultClause */;
|
|
}
|
|
ts.isDefaultClause = isDefaultClause;
|
|
function isHeritageClause(node) {
|
|
return node.kind === 268 /* HeritageClause */;
|
|
}
|
|
ts.isHeritageClause = isHeritageClause;
|
|
function isCatchClause(node) {
|
|
return node.kind === 269 /* CatchClause */;
|
|
}
|
|
ts.isCatchClause = isCatchClause;
|
|
// Property assignments
|
|
function isPropertyAssignment(node) {
|
|
return node.kind === 270 /* PropertyAssignment */;
|
|
}
|
|
ts.isPropertyAssignment = isPropertyAssignment;
|
|
function isShorthandPropertyAssignment(node) {
|
|
return node.kind === 271 /* ShorthandPropertyAssignment */;
|
|
}
|
|
ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
|
|
function isSpreadAssignment(node) {
|
|
return node.kind === 272 /* SpreadAssignment */;
|
|
}
|
|
ts.isSpreadAssignment = isSpreadAssignment;
|
|
// Enum
|
|
function isEnumMember(node) {
|
|
return node.kind === 273 /* EnumMember */;
|
|
}
|
|
ts.isEnumMember = isEnumMember;
|
|
// Top-level nodes
|
|
function isSourceFile(node) {
|
|
return node.kind === 274 /* SourceFile */;
|
|
}
|
|
ts.isSourceFile = isSourceFile;
|
|
function isBundle(node) {
|
|
return node.kind === 275 /* Bundle */;
|
|
}
|
|
ts.isBundle = isBundle;
|
|
function isUnparsedSource(node) {
|
|
return node.kind === 276 /* UnparsedSource */;
|
|
}
|
|
ts.isUnparsedSource = isUnparsedSource;
|
|
// JSDoc
|
|
function isJSDocTypeExpression(node) {
|
|
return node.kind === 278 /* JSDocTypeExpression */;
|
|
}
|
|
ts.isJSDocTypeExpression = isJSDocTypeExpression;
|
|
function isJSDocAllType(node) {
|
|
return node.kind === 279 /* JSDocAllType */;
|
|
}
|
|
ts.isJSDocAllType = isJSDocAllType;
|
|
function isJSDocUnknownType(node) {
|
|
return node.kind === 280 /* JSDocUnknownType */;
|
|
}
|
|
ts.isJSDocUnknownType = isJSDocUnknownType;
|
|
function isJSDocNullableType(node) {
|
|
return node.kind === 281 /* JSDocNullableType */;
|
|
}
|
|
ts.isJSDocNullableType = isJSDocNullableType;
|
|
function isJSDocNonNullableType(node) {
|
|
return node.kind === 282 /* JSDocNonNullableType */;
|
|
}
|
|
ts.isJSDocNonNullableType = isJSDocNonNullableType;
|
|
function isJSDocOptionalType(node) {
|
|
return node.kind === 283 /* JSDocOptionalType */;
|
|
}
|
|
ts.isJSDocOptionalType = isJSDocOptionalType;
|
|
function isJSDocFunctionType(node) {
|
|
return node.kind === 284 /* JSDocFunctionType */;
|
|
}
|
|
ts.isJSDocFunctionType = isJSDocFunctionType;
|
|
function isJSDocVariadicType(node) {
|
|
return node.kind === 285 /* JSDocVariadicType */;
|
|
}
|
|
ts.isJSDocVariadicType = isJSDocVariadicType;
|
|
function isJSDoc(node) {
|
|
return node.kind === 286 /* JSDocComment */;
|
|
}
|
|
ts.isJSDoc = isJSDoc;
|
|
function isJSDocAugmentsTag(node) {
|
|
return node.kind === 290 /* JSDocAugmentsTag */;
|
|
}
|
|
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
|
|
function isJSDocClassTag(node) {
|
|
return node.kind === 291 /* JSDocClassTag */;
|
|
}
|
|
ts.isJSDocClassTag = isJSDocClassTag;
|
|
function isJSDocParameterTag(node) {
|
|
return node.kind === 293 /* JSDocParameterTag */;
|
|
}
|
|
ts.isJSDocParameterTag = isJSDocParameterTag;
|
|
function isJSDocReturnTag(node) {
|
|
return node.kind === 294 /* JSDocReturnTag */;
|
|
}
|
|
ts.isJSDocReturnTag = isJSDocReturnTag;
|
|
function isJSDocTypeTag(node) {
|
|
return node.kind === 295 /* JSDocTypeTag */;
|
|
}
|
|
ts.isJSDocTypeTag = isJSDocTypeTag;
|
|
function isJSDocTemplateTag(node) {
|
|
return node.kind === 296 /* JSDocTemplateTag */;
|
|
}
|
|
ts.isJSDocTemplateTag = isJSDocTemplateTag;
|
|
function isJSDocTypedefTag(node) {
|
|
return node.kind === 297 /* JSDocTypedefTag */;
|
|
}
|
|
ts.isJSDocTypedefTag = isJSDocTypedefTag;
|
|
function isJSDocPropertyTag(node) {
|
|
return node.kind === 298 /* JSDocPropertyTag */;
|
|
}
|
|
ts.isJSDocPropertyTag = isJSDocPropertyTag;
|
|
function isJSDocPropertyLikeTag(node) {
|
|
return node.kind === 298 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */;
|
|
}
|
|
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
|
|
function isJSDocTypeLiteral(node) {
|
|
return node.kind === 287 /* JSDocTypeLiteral */;
|
|
}
|
|
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
|
|
function isJSDocCallbackTag(node) {
|
|
return node.kind === 292 /* JSDocCallbackTag */;
|
|
}
|
|
ts.isJSDocCallbackTag = isJSDocCallbackTag;
|
|
function isJSDocSignature(node) {
|
|
return node.kind === 288 /* JSDocSignature */;
|
|
}
|
|
ts.isJSDocSignature = isJSDocSignature;
|
|
})(ts || (ts = {}));
|
|
// Node tests
|
|
//
|
|
// All node tests in the following list should *not* reference parent pointers so that
|
|
// they may be used with transformations.
|
|
(function (ts) {
|
|
/* @internal */
|
|
function isSyntaxList(n) {
|
|
return n.kind === 299 /* SyntaxList */;
|
|
}
|
|
ts.isSyntaxList = isSyntaxList;
|
|
/* @internal */
|
|
function isNode(node) {
|
|
return isNodeKind(node.kind);
|
|
}
|
|
ts.isNode = isNode;
|
|
/* @internal */
|
|
function isNodeKind(kind) {
|
|
return kind >= 146 /* FirstNode */;
|
|
}
|
|
ts.isNodeKind = isNodeKind;
|
|
/**
|
|
* True if node is of some token syntax kind.
|
|
* For example, this is true for an IfKeyword but not for an IfStatement.
|
|
* Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail.
|
|
*/
|
|
function isToken(n) {
|
|
return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */;
|
|
}
|
|
ts.isToken = isToken;
|
|
// Node Arrays
|
|
/* @internal */
|
|
function isNodeArray(array) {
|
|
return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
|
|
}
|
|
ts.isNodeArray = isNodeArray;
|
|
// Literals
|
|
/* @internal */
|
|
function isLiteralKind(kind) {
|
|
return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */;
|
|
}
|
|
ts.isLiteralKind = isLiteralKind;
|
|
function isLiteralExpression(node) {
|
|
return isLiteralKind(node.kind);
|
|
}
|
|
ts.isLiteralExpression = isLiteralExpression;
|
|
// Pseudo-literals
|
|
/* @internal */
|
|
function isTemplateLiteralKind(kind) {
|
|
return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */;
|
|
}
|
|
ts.isTemplateLiteralKind = isTemplateLiteralKind;
|
|
function isTemplateLiteralToken(node) {
|
|
return isTemplateLiteralKind(node.kind);
|
|
}
|
|
ts.isTemplateLiteralToken = isTemplateLiteralToken;
|
|
function isTemplateMiddleOrTemplateTail(node) {
|
|
var kind = node.kind;
|
|
return kind === 15 /* TemplateMiddle */
|
|
|| kind === 16 /* TemplateTail */;
|
|
}
|
|
ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
|
|
function isStringTextContainingNode(node) {
|
|
return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind);
|
|
}
|
|
ts.isStringTextContainingNode = isStringTextContainingNode;
|
|
// Identifiers
|
|
/* @internal */
|
|
function isGeneratedIdentifier(node) {
|
|
return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */;
|
|
}
|
|
ts.isGeneratedIdentifier = isGeneratedIdentifier;
|
|
// Keywords
|
|
/* @internal */
|
|
function isModifierKind(token) {
|
|
switch (token) {
|
|
case 117 /* AbstractKeyword */:
|
|
case 120 /* AsyncKeyword */:
|
|
case 76 /* ConstKeyword */:
|
|
case 124 /* DeclareKeyword */:
|
|
case 79 /* DefaultKeyword */:
|
|
case 84 /* ExportKeyword */:
|
|
case 114 /* PublicKeyword */:
|
|
case 112 /* PrivateKeyword */:
|
|
case 113 /* ProtectedKeyword */:
|
|
case 132 /* ReadonlyKeyword */:
|
|
case 115 /* StaticKeyword */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isModifierKind = isModifierKind;
|
|
/* @internal */
|
|
function isParameterPropertyModifier(kind) {
|
|
return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */);
|
|
}
|
|
ts.isParameterPropertyModifier = isParameterPropertyModifier;
|
|
/* @internal */
|
|
function isClassMemberModifier(idToken) {
|
|
return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */;
|
|
}
|
|
ts.isClassMemberModifier = isClassMemberModifier;
|
|
function isModifier(node) {
|
|
return isModifierKind(node.kind);
|
|
}
|
|
ts.isModifier = isModifier;
|
|
function isEntityName(node) {
|
|
var kind = node.kind;
|
|
return kind === 146 /* QualifiedName */
|
|
|| kind === 71 /* Identifier */;
|
|
}
|
|
ts.isEntityName = isEntityName;
|
|
function isPropertyName(node) {
|
|
var kind = node.kind;
|
|
return kind === 71 /* Identifier */
|
|
|| kind === 9 /* StringLiteral */
|
|
|| kind === 8 /* NumericLiteral */
|
|
|| kind === 147 /* ComputedPropertyName */;
|
|
}
|
|
ts.isPropertyName = isPropertyName;
|
|
function isBindingName(node) {
|
|
var kind = node.kind;
|
|
return kind === 71 /* Identifier */
|
|
|| kind === 180 /* ObjectBindingPattern */
|
|
|| kind === 181 /* ArrayBindingPattern */;
|
|
}
|
|
ts.isBindingName = isBindingName;
|
|
// Functions
|
|
function isFunctionLike(node) {
|
|
return node && isFunctionLikeKind(node.kind);
|
|
}
|
|
ts.isFunctionLike = isFunctionLike;
|
|
/* @internal */
|
|
function isFunctionLikeDeclaration(node) {
|
|
return node && isFunctionLikeDeclarationKind(node.kind);
|
|
}
|
|
ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
|
|
function isFunctionLikeDeclarationKind(kind) {
|
|
switch (kind) {
|
|
case 234 /* FunctionDeclaration */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
/* @internal */
|
|
function isFunctionLikeKind(kind) {
|
|
switch (kind) {
|
|
case 153 /* MethodSignature */:
|
|
case 158 /* CallSignature */:
|
|
case 288 /* JSDocSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 160 /* IndexSignature */:
|
|
case 163 /* FunctionType */:
|
|
case 284 /* JSDocFunctionType */:
|
|
case 164 /* ConstructorType */:
|
|
return true;
|
|
default:
|
|
return isFunctionLikeDeclarationKind(kind);
|
|
}
|
|
}
|
|
ts.isFunctionLikeKind = isFunctionLikeKind;
|
|
/* @internal */
|
|
function isFunctionOrModuleBlock(node) {
|
|
return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent);
|
|
}
|
|
ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
|
|
// Classes
|
|
function isClassElement(node) {
|
|
var kind = node.kind;
|
|
return kind === 155 /* Constructor */
|
|
|| kind === 152 /* PropertyDeclaration */
|
|
|| kind === 154 /* MethodDeclaration */
|
|
|| kind === 156 /* GetAccessor */
|
|
|| kind === 157 /* SetAccessor */
|
|
|| kind === 160 /* IndexSignature */
|
|
|| kind === 212 /* SemicolonClassElement */;
|
|
}
|
|
ts.isClassElement = isClassElement;
|
|
function isClassLike(node) {
|
|
return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */);
|
|
}
|
|
ts.isClassLike = isClassLike;
|
|
function isAccessor(node) {
|
|
return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */);
|
|
}
|
|
ts.isAccessor = isAccessor;
|
|
/* @internal */
|
|
function isMethodOrAccessor(node) {
|
|
switch (node.kind) {
|
|
case 154 /* MethodDeclaration */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isMethodOrAccessor = isMethodOrAccessor;
|
|
// Type members
|
|
function isTypeElement(node) {
|
|
var kind = node.kind;
|
|
return kind === 159 /* ConstructSignature */
|
|
|| kind === 158 /* CallSignature */
|
|
|| kind === 151 /* PropertySignature */
|
|
|| kind === 153 /* MethodSignature */
|
|
|| kind === 160 /* IndexSignature */;
|
|
}
|
|
ts.isTypeElement = isTypeElement;
|
|
function isClassOrTypeElement(node) {
|
|
return isTypeElement(node) || isClassElement(node);
|
|
}
|
|
ts.isClassOrTypeElement = isClassOrTypeElement;
|
|
function isObjectLiteralElementLike(node) {
|
|
var kind = node.kind;
|
|
return kind === 270 /* PropertyAssignment */
|
|
|| kind === 271 /* ShorthandPropertyAssignment */
|
|
|| kind === 272 /* SpreadAssignment */
|
|
|| kind === 154 /* MethodDeclaration */
|
|
|| kind === 156 /* GetAccessor */
|
|
|| kind === 157 /* SetAccessor */;
|
|
}
|
|
ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
|
|
// Type
|
|
function isTypeNodeKind(kind) {
|
|
return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */)
|
|
|| kind === 119 /* AnyKeyword */
|
|
|| kind === 142 /* UnknownKeyword */
|
|
|| kind === 134 /* NumberKeyword */
|
|
|| kind === 135 /* ObjectKeyword */
|
|
|| kind === 122 /* BooleanKeyword */
|
|
|| kind === 137 /* StringKeyword */
|
|
|| kind === 138 /* SymbolKeyword */
|
|
|| kind === 99 /* ThisKeyword */
|
|
|| kind === 105 /* VoidKeyword */
|
|
|| kind === 140 /* UndefinedKeyword */
|
|
|| kind === 95 /* NullKeyword */
|
|
|| kind === 131 /* NeverKeyword */
|
|
|| kind === 207 /* ExpressionWithTypeArguments */
|
|
|| kind === 279 /* JSDocAllType */
|
|
|| kind === 280 /* JSDocUnknownType */
|
|
|| kind === 281 /* JSDocNullableType */
|
|
|| kind === 282 /* JSDocNonNullableType */
|
|
|| kind === 283 /* JSDocOptionalType */
|
|
|| kind === 284 /* JSDocFunctionType */
|
|
|| kind === 285 /* JSDocVariadicType */;
|
|
}
|
|
/**
|
|
* Node test that determines whether a node is a valid type node.
|
|
* This differs from the `isPartOfTypeNode` function which determines whether a node is *part*
|
|
* of a TypeNode.
|
|
*/
|
|
function isTypeNode(node) {
|
|
return isTypeNodeKind(node.kind);
|
|
}
|
|
ts.isTypeNode = isTypeNode;
|
|
function isFunctionOrConstructorTypeNode(node) {
|
|
switch (node.kind) {
|
|
case 163 /* FunctionType */:
|
|
case 164 /* ConstructorType */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
|
|
// Binding patterns
|
|
/* @internal */
|
|
function isBindingPattern(node) {
|
|
if (node) {
|
|
var kind = node.kind;
|
|
return kind === 181 /* ArrayBindingPattern */
|
|
|| kind === 180 /* ObjectBindingPattern */;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isBindingPattern = isBindingPattern;
|
|
/* @internal */
|
|
function isAssignmentPattern(node) {
|
|
var kind = node.kind;
|
|
return kind === 183 /* ArrayLiteralExpression */
|
|
|| kind === 184 /* ObjectLiteralExpression */;
|
|
}
|
|
ts.isAssignmentPattern = isAssignmentPattern;
|
|
/* @internal */
|
|
function isArrayBindingElement(node) {
|
|
var kind = node.kind;
|
|
return kind === 182 /* BindingElement */
|
|
|| kind === 206 /* OmittedExpression */;
|
|
}
|
|
ts.isArrayBindingElement = isArrayBindingElement;
|
|
/**
|
|
* Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration
|
|
*/
|
|
/* @internal */
|
|
function isDeclarationBindingElement(bindingElement) {
|
|
switch (bindingElement.kind) {
|
|
case 232 /* VariableDeclaration */:
|
|
case 149 /* Parameter */:
|
|
case 182 /* BindingElement */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isDeclarationBindingElement = isDeclarationBindingElement;
|
|
/**
|
|
* Determines whether a node is a BindingOrAssignmentPattern
|
|
*/
|
|
/* @internal */
|
|
function isBindingOrAssignmentPattern(node) {
|
|
return isObjectBindingOrAssignmentPattern(node)
|
|
|| isArrayBindingOrAssignmentPattern(node);
|
|
}
|
|
ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
|
|
/**
|
|
* Determines whether a node is an ObjectBindingOrAssignmentPattern
|
|
*/
|
|
/* @internal */
|
|
function isObjectBindingOrAssignmentPattern(node) {
|
|
switch (node.kind) {
|
|
case 180 /* ObjectBindingPattern */:
|
|
case 184 /* ObjectLiteralExpression */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
|
|
/**
|
|
* Determines whether a node is an ArrayBindingOrAssignmentPattern
|
|
*/
|
|
/* @internal */
|
|
function isArrayBindingOrAssignmentPattern(node) {
|
|
switch (node.kind) {
|
|
case 181 /* ArrayBindingPattern */:
|
|
case 183 /* ArrayLiteralExpression */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
|
|
/* @internal */
|
|
function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
|
|
var kind = node.kind;
|
|
return kind === 185 /* PropertyAccessExpression */
|
|
|| kind === 146 /* QualifiedName */
|
|
|| kind === 179 /* ImportType */;
|
|
}
|
|
ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
|
|
// Expression
|
|
function isPropertyAccessOrQualifiedName(node) {
|
|
var kind = node.kind;
|
|
return kind === 185 /* PropertyAccessExpression */
|
|
|| kind === 146 /* QualifiedName */;
|
|
}
|
|
ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
|
|
function isCallLikeExpression(node) {
|
|
switch (node.kind) {
|
|
case 257 /* JsxOpeningElement */:
|
|
case 256 /* JsxSelfClosingElement */:
|
|
case 187 /* CallExpression */:
|
|
case 188 /* NewExpression */:
|
|
case 189 /* TaggedTemplateExpression */:
|
|
case 150 /* Decorator */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isCallLikeExpression = isCallLikeExpression;
|
|
function isCallOrNewExpression(node) {
|
|
return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */;
|
|
}
|
|
ts.isCallOrNewExpression = isCallOrNewExpression;
|
|
function isTemplateLiteral(node) {
|
|
var kind = node.kind;
|
|
return kind === 202 /* TemplateExpression */
|
|
|| kind === 13 /* NoSubstitutionTemplateLiteral */;
|
|
}
|
|
ts.isTemplateLiteral = isTemplateLiteral;
|
|
/* @internal */
|
|
function isLeftHandSideExpression(node) {
|
|
return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind);
|
|
}
|
|
ts.isLeftHandSideExpression = isLeftHandSideExpression;
|
|
function isLeftHandSideExpressionKind(kind) {
|
|
switch (kind) {
|
|
case 185 /* PropertyAccessExpression */:
|
|
case 186 /* ElementAccessExpression */:
|
|
case 188 /* NewExpression */:
|
|
case 187 /* CallExpression */:
|
|
case 255 /* JsxElement */:
|
|
case 256 /* JsxSelfClosingElement */:
|
|
case 259 /* JsxFragment */:
|
|
case 189 /* TaggedTemplateExpression */:
|
|
case 183 /* ArrayLiteralExpression */:
|
|
case 191 /* ParenthesizedExpression */:
|
|
case 184 /* ObjectLiteralExpression */:
|
|
case 205 /* ClassExpression */:
|
|
case 192 /* FunctionExpression */:
|
|
case 71 /* Identifier */:
|
|
case 12 /* RegularExpressionLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 202 /* TemplateExpression */:
|
|
case 86 /* FalseKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
case 99 /* ThisKeyword */:
|
|
case 101 /* TrueKeyword */:
|
|
case 97 /* SuperKeyword */:
|
|
case 209 /* NonNullExpression */:
|
|
case 210 /* MetaProperty */:
|
|
case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
/* @internal */
|
|
function isUnaryExpression(node) {
|
|
return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind);
|
|
}
|
|
ts.isUnaryExpression = isUnaryExpression;
|
|
function isUnaryExpressionKind(kind) {
|
|
switch (kind) {
|
|
case 198 /* PrefixUnaryExpression */:
|
|
case 199 /* PostfixUnaryExpression */:
|
|
case 194 /* DeleteExpression */:
|
|
case 195 /* TypeOfExpression */:
|
|
case 196 /* VoidExpression */:
|
|
case 197 /* AwaitExpression */:
|
|
case 190 /* TypeAssertionExpression */:
|
|
return true;
|
|
default:
|
|
return isLeftHandSideExpressionKind(kind);
|
|
}
|
|
}
|
|
/* @internal */
|
|
function isUnaryExpressionWithWrite(expr) {
|
|
switch (expr.kind) {
|
|
case 199 /* PostfixUnaryExpression */:
|
|
return true;
|
|
case 198 /* PrefixUnaryExpression */:
|
|
return expr.operator === 43 /* PlusPlusToken */ ||
|
|
expr.operator === 44 /* MinusMinusToken */;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
|
|
/* @internal */
|
|
/**
|
|
* Determines whether a node is an expression based only on its kind.
|
|
* Use `isExpressionNode` if not in transforms.
|
|
*/
|
|
function isExpression(node) {
|
|
return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind);
|
|
}
|
|
ts.isExpression = isExpression;
|
|
function isExpressionKind(kind) {
|
|
switch (kind) {
|
|
case 201 /* ConditionalExpression */:
|
|
case 203 /* YieldExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 200 /* BinaryExpression */:
|
|
case 204 /* SpreadElement */:
|
|
case 208 /* AsExpression */:
|
|
case 206 /* OmittedExpression */:
|
|
case 302 /* CommaListExpression */:
|
|
case 301 /* PartiallyEmittedExpression */:
|
|
return true;
|
|
default:
|
|
return isUnaryExpressionKind(kind);
|
|
}
|
|
}
|
|
function isAssertionExpression(node) {
|
|
var kind = node.kind;
|
|
return kind === 190 /* TypeAssertionExpression */
|
|
|| kind === 208 /* AsExpression */;
|
|
}
|
|
ts.isAssertionExpression = isAssertionExpression;
|
|
/* @internal */
|
|
function isPartiallyEmittedExpression(node) {
|
|
return node.kind === 301 /* PartiallyEmittedExpression */;
|
|
}
|
|
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
|
|
/* @internal */
|
|
function isNotEmittedStatement(node) {
|
|
return node.kind === 300 /* NotEmittedStatement */;
|
|
}
|
|
ts.isNotEmittedStatement = isNotEmittedStatement;
|
|
/* @internal */
|
|
function isNotEmittedOrPartiallyEmittedNode(node) {
|
|
return isNotEmittedStatement(node)
|
|
|| isPartiallyEmittedExpression(node);
|
|
}
|
|
ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
|
|
function isIterationStatement(node, lookInLabeledStatements) {
|
|
switch (node.kind) {
|
|
case 220 /* ForStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
case 218 /* DoStatement */:
|
|
case 219 /* WhileStatement */:
|
|
return true;
|
|
case 228 /* LabeledStatement */:
|
|
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
|
|
}
|
|
return false;
|
|
}
|
|
ts.isIterationStatement = isIterationStatement;
|
|
/* @internal */
|
|
function isForInOrOfStatement(node) {
|
|
return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */;
|
|
}
|
|
ts.isForInOrOfStatement = isForInOrOfStatement;
|
|
// Element
|
|
/* @internal */
|
|
function isConciseBody(node) {
|
|
return ts.isBlock(node)
|
|
|| isExpression(node);
|
|
}
|
|
ts.isConciseBody = isConciseBody;
|
|
/* @internal */
|
|
function isFunctionBody(node) {
|
|
return ts.isBlock(node);
|
|
}
|
|
ts.isFunctionBody = isFunctionBody;
|
|
/* @internal */
|
|
function isForInitializer(node) {
|
|
return ts.isVariableDeclarationList(node)
|
|
|| isExpression(node);
|
|
}
|
|
ts.isForInitializer = isForInitializer;
|
|
/* @internal */
|
|
function isModuleBody(node) {
|
|
var kind = node.kind;
|
|
return kind === 240 /* ModuleBlock */
|
|
|| kind === 239 /* ModuleDeclaration */
|
|
|| kind === 71 /* Identifier */;
|
|
}
|
|
ts.isModuleBody = isModuleBody;
|
|
/* @internal */
|
|
function isNamespaceBody(node) {
|
|
var kind = node.kind;
|
|
return kind === 240 /* ModuleBlock */
|
|
|| kind === 239 /* ModuleDeclaration */;
|
|
}
|
|
ts.isNamespaceBody = isNamespaceBody;
|
|
/* @internal */
|
|
function isJSDocNamespaceBody(node) {
|
|
var kind = node.kind;
|
|
return kind === 71 /* Identifier */
|
|
|| kind === 239 /* ModuleDeclaration */;
|
|
}
|
|
ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
|
|
/* @internal */
|
|
function isNamedImportBindings(node) {
|
|
var kind = node.kind;
|
|
return kind === 247 /* NamedImports */
|
|
|| kind === 246 /* NamespaceImport */;
|
|
}
|
|
ts.isNamedImportBindings = isNamedImportBindings;
|
|
/* @internal */
|
|
function isModuleOrEnumDeclaration(node) {
|
|
return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */;
|
|
}
|
|
ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
|
|
function isDeclarationKind(kind) {
|
|
return kind === 193 /* ArrowFunction */
|
|
|| kind === 182 /* BindingElement */
|
|
|| kind === 235 /* ClassDeclaration */
|
|
|| kind === 205 /* ClassExpression */
|
|
|| kind === 155 /* Constructor */
|
|
|| kind === 238 /* EnumDeclaration */
|
|
|| kind === 273 /* EnumMember */
|
|
|| kind === 252 /* ExportSpecifier */
|
|
|| kind === 234 /* FunctionDeclaration */
|
|
|| kind === 192 /* FunctionExpression */
|
|
|| kind === 156 /* GetAccessor */
|
|
|| kind === 245 /* ImportClause */
|
|
|| kind === 243 /* ImportEqualsDeclaration */
|
|
|| kind === 248 /* ImportSpecifier */
|
|
|| kind === 236 /* InterfaceDeclaration */
|
|
|| kind === 262 /* JsxAttribute */
|
|
|| kind === 154 /* MethodDeclaration */
|
|
|| kind === 153 /* MethodSignature */
|
|
|| kind === 239 /* ModuleDeclaration */
|
|
|| kind === 242 /* NamespaceExportDeclaration */
|
|
|| kind === 246 /* NamespaceImport */
|
|
|| kind === 149 /* Parameter */
|
|
|| kind === 270 /* PropertyAssignment */
|
|
|| kind === 152 /* PropertyDeclaration */
|
|
|| kind === 151 /* PropertySignature */
|
|
|| kind === 157 /* SetAccessor */
|
|
|| kind === 271 /* ShorthandPropertyAssignment */
|
|
|| kind === 237 /* TypeAliasDeclaration */
|
|
|| kind === 148 /* TypeParameter */
|
|
|| kind === 232 /* VariableDeclaration */
|
|
|| kind === 297 /* JSDocTypedefTag */
|
|
|| kind === 292 /* JSDocCallbackTag */
|
|
|| kind === 298 /* JSDocPropertyTag */;
|
|
}
|
|
function isDeclarationStatementKind(kind) {
|
|
return kind === 234 /* FunctionDeclaration */
|
|
|| kind === 253 /* MissingDeclaration */
|
|
|| kind === 235 /* ClassDeclaration */
|
|
|| kind === 236 /* InterfaceDeclaration */
|
|
|| kind === 237 /* TypeAliasDeclaration */
|
|
|| kind === 238 /* EnumDeclaration */
|
|
|| kind === 239 /* ModuleDeclaration */
|
|
|| kind === 244 /* ImportDeclaration */
|
|
|| kind === 243 /* ImportEqualsDeclaration */
|
|
|| kind === 250 /* ExportDeclaration */
|
|
|| kind === 249 /* ExportAssignment */
|
|
|| kind === 242 /* NamespaceExportDeclaration */;
|
|
}
|
|
function isStatementKindButNotDeclarationKind(kind) {
|
|
return kind === 224 /* BreakStatement */
|
|
|| kind === 223 /* ContinueStatement */
|
|
|| kind === 231 /* DebuggerStatement */
|
|
|| kind === 218 /* DoStatement */
|
|
|| kind === 216 /* ExpressionStatement */
|
|
|| kind === 215 /* EmptyStatement */
|
|
|| kind === 221 /* ForInStatement */
|
|
|| kind === 222 /* ForOfStatement */
|
|
|| kind === 220 /* ForStatement */
|
|
|| kind === 217 /* IfStatement */
|
|
|| kind === 228 /* LabeledStatement */
|
|
|| kind === 225 /* ReturnStatement */
|
|
|| kind === 227 /* SwitchStatement */
|
|
|| kind === 229 /* ThrowStatement */
|
|
|| kind === 230 /* TryStatement */
|
|
|| kind === 214 /* VariableStatement */
|
|
|| kind === 219 /* WhileStatement */
|
|
|| kind === 226 /* WithStatement */
|
|
|| kind === 300 /* NotEmittedStatement */
|
|
|| kind === 304 /* EndOfDeclarationMarker */
|
|
|| kind === 303 /* MergeDeclarationMarker */;
|
|
}
|
|
/* @internal */
|
|
function isDeclaration(node) {
|
|
if (node.kind === 148 /* TypeParameter */) {
|
|
return node.parent.kind !== 296 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
|
|
}
|
|
return isDeclarationKind(node.kind);
|
|
}
|
|
ts.isDeclaration = isDeclaration;
|
|
/* @internal */
|
|
function isDeclarationStatement(node) {
|
|
return isDeclarationStatementKind(node.kind);
|
|
}
|
|
ts.isDeclarationStatement = isDeclarationStatement;
|
|
/**
|
|
* Determines whether the node is a statement that is not also a declaration
|
|
*/
|
|
/* @internal */
|
|
function isStatementButNotDeclaration(node) {
|
|
return isStatementKindButNotDeclarationKind(node.kind);
|
|
}
|
|
ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
|
|
/* @internal */
|
|
function isStatement(node) {
|
|
var kind = node.kind;
|
|
return isStatementKindButNotDeclarationKind(kind)
|
|
|| isDeclarationStatementKind(kind)
|
|
|| isBlockStatement(node);
|
|
}
|
|
ts.isStatement = isStatement;
|
|
function isBlockStatement(node) {
|
|
if (node.kind !== 213 /* Block */)
|
|
return false;
|
|
if (node.parent !== undefined) {
|
|
if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) {
|
|
return false;
|
|
}
|
|
}
|
|
return !ts.isFunctionBlock(node);
|
|
}
|
|
// Module references
|
|
/* @internal */
|
|
function isModuleReference(node) {
|
|
var kind = node.kind;
|
|
return kind === 254 /* ExternalModuleReference */
|
|
|| kind === 146 /* QualifiedName */
|
|
|| kind === 71 /* Identifier */;
|
|
}
|
|
ts.isModuleReference = isModuleReference;
|
|
// JSX
|
|
/* @internal */
|
|
function isJsxTagNameExpression(node) {
|
|
var kind = node.kind;
|
|
return kind === 99 /* ThisKeyword */
|
|
|| kind === 71 /* Identifier */
|
|
|| kind === 185 /* PropertyAccessExpression */;
|
|
}
|
|
ts.isJsxTagNameExpression = isJsxTagNameExpression;
|
|
/* @internal */
|
|
function isJsxChild(node) {
|
|
var kind = node.kind;
|
|
return kind === 255 /* JsxElement */
|
|
|| kind === 265 /* JsxExpression */
|
|
|| kind === 256 /* JsxSelfClosingElement */
|
|
|| kind === 10 /* JsxText */
|
|
|| kind === 259 /* JsxFragment */;
|
|
}
|
|
ts.isJsxChild = isJsxChild;
|
|
/* @internal */
|
|
function isJsxAttributeLike(node) {
|
|
var kind = node.kind;
|
|
return kind === 262 /* JsxAttribute */
|
|
|| kind === 264 /* JsxSpreadAttribute */;
|
|
}
|
|
ts.isJsxAttributeLike = isJsxAttributeLike;
|
|
/* @internal */
|
|
function isStringLiteralOrJsxExpression(node) {
|
|
var kind = node.kind;
|
|
return kind === 9 /* StringLiteral */
|
|
|| kind === 265 /* JsxExpression */;
|
|
}
|
|
ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
|
|
function isJsxOpeningLikeElement(node) {
|
|
var kind = node.kind;
|
|
return kind === 257 /* JsxOpeningElement */
|
|
|| kind === 256 /* JsxSelfClosingElement */;
|
|
}
|
|
ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
|
|
// Clauses
|
|
function isCaseOrDefaultClause(node) {
|
|
var kind = node.kind;
|
|
return kind === 266 /* CaseClause */
|
|
|| kind === 267 /* DefaultClause */;
|
|
}
|
|
ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
|
|
// JSDoc
|
|
/** True if node is of some JSDoc syntax kind. */
|
|
/* @internal */
|
|
function isJSDocNode(node) {
|
|
return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 298 /* LastJSDocNode */;
|
|
}
|
|
ts.isJSDocNode = isJSDocNode;
|
|
/** True if node is of a kind that may contain comment text. */
|
|
function isJSDocCommentContainingNode(node) {
|
|
return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
|
|
}
|
|
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
|
|
// TODO: determine what this does before making it public.
|
|
/* @internal */
|
|
function isJSDocTag(node) {
|
|
return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 298 /* LastJSDocTagNode */;
|
|
}
|
|
ts.isJSDocTag = isJSDocTag;
|
|
function isSetAccessor(node) {
|
|
return node.kind === 157 /* SetAccessor */;
|
|
}
|
|
ts.isSetAccessor = isSetAccessor;
|
|
function isGetAccessor(node) {
|
|
return node.kind === 156 /* GetAccessor */;
|
|
}
|
|
ts.isGetAccessor = isGetAccessor;
|
|
/** True if has jsdoc nodes attached to it. */
|
|
/* @internal */
|
|
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
|
|
function hasJSDocNodes(node) {
|
|
var jsDoc = node.jsDoc;
|
|
return !!jsDoc && jsDoc.length > 0;
|
|
}
|
|
ts.hasJSDocNodes = hasJSDocNodes;
|
|
/** True if has type node attached to it. */
|
|
/* @internal */
|
|
function hasType(node) {
|
|
return !!node.type;
|
|
}
|
|
ts.hasType = hasType;
|
|
/* True if the node could have a type node a `.type` */
|
|
/* @internal */
|
|
function couldHaveType(node) {
|
|
switch (node.kind) {
|
|
case 149 /* Parameter */:
|
|
case 151 /* PropertySignature */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 158 /* CallSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 160 /* IndexSignature */:
|
|
case 161 /* TypePredicate */:
|
|
case 163 /* FunctionType */:
|
|
case 164 /* ConstructorType */:
|
|
case 173 /* ParenthesizedType */:
|
|
case 175 /* TypeOperator */:
|
|
case 177 /* MappedType */:
|
|
case 190 /* TypeAssertionExpression */:
|
|
case 192 /* FunctionExpression */:
|
|
case 193 /* ArrowFunction */:
|
|
case 208 /* AsExpression */:
|
|
case 232 /* VariableDeclaration */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
case 278 /* JSDocTypeExpression */:
|
|
case 281 /* JSDocNullableType */:
|
|
case 282 /* JSDocNonNullableType */:
|
|
case 283 /* JSDocOptionalType */:
|
|
case 284 /* JSDocFunctionType */:
|
|
case 285 /* JSDocVariadicType */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
ts.couldHaveType = couldHaveType;
|
|
/** True if has initializer node attached to it. */
|
|
/* @internal */
|
|
function hasInitializer(node) {
|
|
return !!node.initializer;
|
|
}
|
|
ts.hasInitializer = hasInitializer;
|
|
/** True if has initializer node attached to it. */
|
|
/* @internal */
|
|
function hasOnlyExpressionInitializer(node) {
|
|
return hasInitializer(node) && !ts.isForStatement(node) && !ts.isForInStatement(node) && !ts.isForOfStatement(node) && !ts.isJsxAttribute(node);
|
|
}
|
|
ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
|
|
function isObjectLiteralElement(node) {
|
|
switch (node.kind) {
|
|
case 262 /* JsxAttribute */:
|
|
case 264 /* JsxSpreadAttribute */:
|
|
case 270 /* PropertyAssignment */:
|
|
case 271 /* ShorthandPropertyAssignment */:
|
|
case 154 /* MethodDeclaration */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
ts.isObjectLiteralElement = isObjectLiteralElement;
|
|
/* @internal */
|
|
function isTypeReferenceType(node) {
|
|
return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */;
|
|
}
|
|
ts.isTypeReferenceType = isTypeReferenceType;
|
|
var MAX_SMI_X86 = 1073741823;
|
|
/* @internal */
|
|
function guessIndentation(lines) {
|
|
var indentation = MAX_SMI_X86;
|
|
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
var line = lines_1[_i];
|
|
if (!line.length) {
|
|
continue;
|
|
}
|
|
var i = 0;
|
|
for (; i < line.length && i < indentation; i++) {
|
|
if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
|
|
break;
|
|
}
|
|
}
|
|
if (i < indentation) {
|
|
indentation = i;
|
|
}
|
|
if (indentation === 0) {
|
|
return 0;
|
|
}
|
|
}
|
|
return indentation === MAX_SMI_X86 ? undefined : indentation;
|
|
}
|
|
ts.guessIndentation = guessIndentation;
|
|
function isStringLiteralLike(node) {
|
|
return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */;
|
|
}
|
|
ts.isStringLiteralLike = isStringLiteralLike;
|
|
/** @internal */
|
|
function isNamedImportsOrExports(node) {
|
|
return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */;
|
|
}
|
|
ts.isNamedImportsOrExports = isNamedImportsOrExports;
|
|
function Symbol(flags, name) {
|
|
this.flags = flags;
|
|
this.escapedName = name;
|
|
this.declarations = undefined;
|
|
this.valueDeclaration = undefined;
|
|
this.id = undefined;
|
|
this.mergeId = undefined;
|
|
this.parent = undefined;
|
|
}
|
|
function Type(checker, flags) {
|
|
this.flags = flags;
|
|
if (Debug.isDebugging) {
|
|
this.checker = checker;
|
|
}
|
|
}
|
|
function Signature() { } // tslint:disable-line no-empty
|
|
function Node(kind, pos, end) {
|
|
this.pos = pos;
|
|
this.end = end;
|
|
this.kind = kind;
|
|
this.id = 0;
|
|
this.flags = 0 /* None */;
|
|
this.modifierFlagsCache = 0 /* None */;
|
|
this.transformFlags = 0 /* None */;
|
|
this.parent = undefined;
|
|
this.original = undefined;
|
|
}
|
|
function SourceMapSource(fileName, text, skipTrivia) {
|
|
this.fileName = fileName;
|
|
this.text = text;
|
|
this.skipTrivia = skipTrivia || (function (pos) { return pos; });
|
|
}
|
|
ts.objectAllocator = {
|
|
getNodeConstructor: function () { return Node; },
|
|
getTokenConstructor: function () { return Node; },
|
|
getIdentifierConstructor: function () { return Node; },
|
|
getSourceFileConstructor: function () { return Node; },
|
|
getSymbolConstructor: function () { return Symbol; },
|
|
getTypeConstructor: function () { return Type; },
|
|
getSignatureConstructor: function () { return Signature; },
|
|
getSourceMapSourceConstructor: function () { return SourceMapSource; },
|
|
};
|
|
function formatStringFromArgs(text, args, baseIndex) {
|
|
if (baseIndex === void 0) { baseIndex = 0; }
|
|
return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); });
|
|
}
|
|
ts.formatStringFromArgs = formatStringFromArgs;
|
|
function getLocaleSpecificMessage(message) {
|
|
return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
|
|
}
|
|
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
|
|
function createFileDiagnostic(file, start, length, message) {
|
|
Debug.assertGreaterThanOrEqual(start, 0);
|
|
Debug.assertGreaterThanOrEqual(length, 0);
|
|
if (file) {
|
|
Debug.assertLessThanOrEqual(start, file.text.length);
|
|
Debug.assertLessThanOrEqual(start + length, file.text.length);
|
|
}
|
|
var text = getLocaleSpecificMessage(message);
|
|
if (arguments.length > 4) {
|
|
text = formatStringFromArgs(text, arguments, 4);
|
|
}
|
|
return {
|
|
file: file,
|
|
start: start,
|
|
length: length,
|
|
messageText: text,
|
|
category: message.category,
|
|
code: message.code,
|
|
reportsUnnecessary: message.reportsUnnecessary,
|
|
};
|
|
}
|
|
ts.createFileDiagnostic = createFileDiagnostic;
|
|
/* @internal */
|
|
function formatMessage(_dummy, message) {
|
|
var text = getLocaleSpecificMessage(message);
|
|
if (arguments.length > 2) {
|
|
text = formatStringFromArgs(text, arguments, 2);
|
|
}
|
|
return text;
|
|
}
|
|
ts.formatMessage = formatMessage;
|
|
function createCompilerDiagnostic(message) {
|
|
var text = getLocaleSpecificMessage(message);
|
|
if (arguments.length > 1) {
|
|
text = formatStringFromArgs(text, arguments, 1);
|
|
}
|
|
return {
|
|
file: undefined,
|
|
start: undefined,
|
|
length: undefined,
|
|
messageText: text,
|
|
category: message.category,
|
|
code: message.code,
|
|
reportsUnnecessary: message.reportsUnnecessary,
|
|
};
|
|
}
|
|
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
|
function createCompilerDiagnosticFromMessageChain(chain) {
|
|
return {
|
|
file: undefined,
|
|
start: undefined,
|
|
length: undefined,
|
|
code: chain.code,
|
|
category: chain.category,
|
|
messageText: chain.next ? chain : chain.messageText,
|
|
};
|
|
}
|
|
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
|
function chainDiagnosticMessages(details, message) {
|
|
var text = getLocaleSpecificMessage(message);
|
|
if (arguments.length > 2) {
|
|
text = formatStringFromArgs(text, arguments, 2);
|
|
}
|
|
return {
|
|
messageText: text,
|
|
category: message.category,
|
|
code: message.code,
|
|
next: details
|
|
};
|
|
}
|
|
ts.chainDiagnosticMessages = chainDiagnosticMessages;
|
|
function concatenateDiagnosticMessageChains(headChain, tailChain) {
|
|
var lastChain = headChain;
|
|
while (lastChain.next) {
|
|
lastChain = lastChain.next;
|
|
}
|
|
lastChain.next = tailChain;
|
|
return headChain;
|
|
}
|
|
ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
|
|
function getDiagnosticFilePath(diagnostic) {
|
|
return diagnostic.file ? diagnostic.file.path : undefined;
|
|
}
|
|
function compareDiagnostics(d1, d2) {
|
|
return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
|
|
ts.compareValues(d1.start, d2.start) ||
|
|
ts.compareValues(d1.length, d2.length) ||
|
|
ts.compareValues(d1.code, d2.code) ||
|
|
compareMessageText(d1.messageText, d2.messageText) ||
|
|
0 /* EqualTo */;
|
|
}
|
|
ts.compareDiagnostics = compareDiagnostics;
|
|
function compareMessageText(t1, t2) {
|
|
var text1 = t1;
|
|
var text2 = t2;
|
|
while (text1 && text2) {
|
|
// We still have both chains.
|
|
var string1 = ts.isString(text1) ? text1 : text1.messageText;
|
|
var string2 = ts.isString(text2) ? text2 : text2.messageText;
|
|
var res = ts.compareStringsCaseSensitive(string1, string2);
|
|
if (res) {
|
|
return res;
|
|
}
|
|
text1 = ts.isString(text1) ? undefined : text1.next;
|
|
text2 = ts.isString(text2) ? undefined : text2.next;
|
|
}
|
|
if (!text1 && !text2) {
|
|
// if the chains are done, then these messages are the same.
|
|
return 0 /* EqualTo */;
|
|
}
|
|
// We still have one chain remaining. The shorter chain should come first.
|
|
return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */;
|
|
}
|
|
function getEmitScriptTarget(compilerOptions) {
|
|
return compilerOptions.target || 0 /* ES3 */;
|
|
}
|
|
ts.getEmitScriptTarget = getEmitScriptTarget;
|
|
function getEmitModuleKind(compilerOptions) {
|
|
return typeof compilerOptions.module === "number" ?
|
|
compilerOptions.module :
|
|
getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
|
|
}
|
|
ts.getEmitModuleKind = getEmitModuleKind;
|
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
if (moduleResolution === undefined) {
|
|
moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
|
|
}
|
|
return moduleResolution;
|
|
}
|
|
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
|
|
function unreachableCodeIsError(options) {
|
|
return options.allowUnreachableCode === false;
|
|
}
|
|
ts.unreachableCodeIsError = unreachableCodeIsError;
|
|
function unusedLabelIsError(options) {
|
|
return options.allowUnusedLabels === false;
|
|
}
|
|
ts.unusedLabelIsError = unusedLabelIsError;
|
|
function getAreDeclarationMapsEnabled(options) {
|
|
return !!(options.declaration && options.declarationMap);
|
|
}
|
|
ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
|
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
var moduleKind = getEmitModuleKind(compilerOptions);
|
|
return compilerOptions.allowSyntheticDefaultImports !== undefined
|
|
? compilerOptions.allowSyntheticDefaultImports
|
|
: compilerOptions.esModuleInterop
|
|
? moduleKind !== ts.ModuleKind.None && moduleKind < ts.ModuleKind.ES2015
|
|
: moduleKind === ts.ModuleKind.System;
|
|
}
|
|
ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
|
|
function getEmitDeclarations(compilerOptions) {
|
|
return !!(compilerOptions.declaration || compilerOptions.composite);
|
|
}
|
|
ts.getEmitDeclarations = getEmitDeclarations;
|
|
function getStrictOptionValue(compilerOptions, flag) {
|
|
return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
|
|
}
|
|
ts.getStrictOptionValue = getStrictOptionValue;
|
|
function hasZeroOrOneAsteriskCharacter(str) {
|
|
var seenAsterisk = false;
|
|
for (var i = 0; i < str.length; i++) {
|
|
if (str.charCodeAt(i) === 42 /* asterisk */) {
|
|
if (!seenAsterisk) {
|
|
seenAsterisk = true;
|
|
}
|
|
else {
|
|
// have already seen asterisk
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
|
|
/**
|
|
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
* we expect the host to correctly handle paths in our specified format.
|
|
*/
|
|
ts.directorySeparator = "/";
|
|
var altDirectorySeparator = "\\";
|
|
var urlSchemeSeparator = "://";
|
|
var backslashRegExp = /\\/g;
|
|
/**
|
|
* Normalize path separators.
|
|
*/
|
|
function normalizeSlashes(path) {
|
|
return path.replace(backslashRegExp, ts.directorySeparator);
|
|
}
|
|
ts.normalizeSlashes = normalizeSlashes;
|
|
function isVolumeCharacter(charCode) {
|
|
return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
|
|
(charCode >= 65 /* A */ && charCode <= 90 /* Z */);
|
|
}
|
|
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
var ch0 = url.charCodeAt(start);
|
|
if (ch0 === 58 /* colon */)
|
|
return start + 1;
|
|
if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
|
|
var ch2 = url.charCodeAt(start + 2);
|
|
if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
|
|
return start + 3;
|
|
}
|
|
return -1;
|
|
}
|
|
/**
|
|
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
*/
|
|
function getEncodedRootLength(path) {
|
|
if (!path)
|
|
return 0;
|
|
var ch0 = path.charCodeAt(0);
|
|
// POSIX or UNC
|
|
if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
|
|
if (path.charCodeAt(1) !== ch0)
|
|
return 1; // POSIX: "/" (or non-normalized "\")
|
|
var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2);
|
|
if (p1 < 0)
|
|
return path.length; // UNC: "//server" or "\\server"
|
|
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
}
|
|
// DOS
|
|
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
|
|
var ch2 = path.charCodeAt(2);
|
|
if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
|
|
return 3; // DOS: "c:/" or "c:\"
|
|
if (path.length === 2)
|
|
return 2; // DOS: "c:" (but not "c:d")
|
|
}
|
|
// URL
|
|
var schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
if (schemeEnd !== -1) {
|
|
var authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
|
|
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
// For local "file" URLs, include the leading DOS volume (if present).
|
|
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
var scheme = path.slice(0, schemeEnd);
|
|
var authority = path.slice(authorityStart, authorityEnd);
|
|
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
if (volumeSeparatorEnd !== -1) {
|
|
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
|
|
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
return ~(volumeSeparatorEnd + 1);
|
|
}
|
|
if (volumeSeparatorEnd === path.length) {
|
|
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
// but not "file:///c:d" or "file:///c%3ad"
|
|
return ~volumeSeparatorEnd;
|
|
}
|
|
}
|
|
}
|
|
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
}
|
|
return ~path.length; // URL: "file://server", "http://server"
|
|
}
|
|
// relative
|
|
return 0;
|
|
}
|
|
/**
|
|
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
*
|
|
* For example:
|
|
* ```ts
|
|
* getRootLength("a") === 0 // ""
|
|
* getRootLength("/") === 1 // "/"
|
|
* getRootLength("c:") === 2 // "c:"
|
|
* getRootLength("c:d") === 0 // ""
|
|
* getRootLength("c:/") === 3 // "c:/"
|
|
* getRootLength("c:\\") === 3 // "c:\\"
|
|
* getRootLength("//server") === 7 // "//server"
|
|
* getRootLength("//server/share") === 8 // "//server/"
|
|
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
* getRootLength("file:///path") === 8 // "file:///"
|
|
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
* getRootLength("file://server") === 13 // "file://server"
|
|
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
* getRootLength("http://server") === 13 // "http://server"
|
|
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
* ```
|
|
*/
|
|
function getRootLength(path) {
|
|
var rootLength = getEncodedRootLength(path);
|
|
return rootLength < 0 ? ~rootLength : rootLength;
|
|
}
|
|
ts.getRootLength = getRootLength;
|
|
// TODO(rbuckton): replace references with `resolvePath`
|
|
function normalizePath(path) {
|
|
return resolvePath(path);
|
|
}
|
|
ts.normalizePath = normalizePath;
|
|
function normalizePathAndParts(path) {
|
|
path = normalizeSlashes(path);
|
|
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
if (parts.length) {
|
|
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
}
|
|
else {
|
|
return { path: root, parts: parts };
|
|
}
|
|
}
|
|
ts.normalizePathAndParts = normalizePathAndParts;
|
|
function getDirectoryPath(path) {
|
|
path = normalizeSlashes(path);
|
|
// If the path provided is itself the root, then return it.
|
|
var rootLength = getRootLength(path);
|
|
if (rootLength === path.length)
|
|
return path;
|
|
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
// but not including any trailing directory separator.
|
|
path = removeTrailingDirectorySeparator(path);
|
|
return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
|
|
}
|
|
ts.getDirectoryPath = getDirectoryPath;
|
|
function isUrl(path) {
|
|
return getEncodedRootLength(path) < 0;
|
|
}
|
|
ts.isUrl = isUrl;
|
|
function pathIsRelative(path) {
|
|
return /^\.\.?($|[\\/])/.test(path);
|
|
}
|
|
ts.pathIsRelative = pathIsRelative;
|
|
/**
|
|
* Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path
|
|
* like `c:`, `c:\` or `c:/`).
|
|
*/
|
|
function isRootedDiskPath(path) {
|
|
return getEncodedRootLength(path) > 0;
|
|
}
|
|
ts.isRootedDiskPath = isRootedDiskPath;
|
|
/**
|
|
* Determines whether a path consists only of a path root.
|
|
*/
|
|
function isDiskPathRoot(path) {
|
|
var rootLength = getEncodedRootLength(path);
|
|
return rootLength > 0 && rootLength === path.length;
|
|
}
|
|
ts.isDiskPathRoot = isDiskPathRoot;
|
|
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
return !isRootedDiskPath(absoluteOrRelativePath)
|
|
? absoluteOrRelativePath
|
|
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
}
|
|
ts.convertToRelativePath = convertToRelativePath;
|
|
function pathComponents(path, rootLength) {
|
|
var root = path.substring(0, rootLength);
|
|
var rest = path.substring(rootLength).split(ts.directorySeparator);
|
|
if (rest.length && !ts.lastOrUndefined(rest))
|
|
rest.pop();
|
|
return [root].concat(rest);
|
|
}
|
|
/**
|
|
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
* components (at indices > 0). The result is not normalized.
|
|
* If the path is relative, the root component is `""`.
|
|
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
*/
|
|
function getPathComponents(path, currentDirectory) {
|
|
if (currentDirectory === void 0) { currentDirectory = ""; }
|
|
path = combinePaths(currentDirectory, path);
|
|
var rootLength = getRootLength(path);
|
|
return pathComponents(path, rootLength);
|
|
}
|
|
ts.getPathComponents = getPathComponents;
|
|
/**
|
|
* Reduce an array of path components to a more simplified path by navigating any
|
|
* `"."` or `".."` entries in the path.
|
|
*/
|
|
function reducePathComponents(components) {
|
|
if (!ts.some(components))
|
|
return [];
|
|
var reduced = [components[0]];
|
|
for (var i = 1; i < components.length; i++) {
|
|
var component = components[i];
|
|
if (!component)
|
|
continue;
|
|
if (component === ".")
|
|
continue;
|
|
if (component === "..") {
|
|
if (reduced.length > 1) {
|
|
if (reduced[reduced.length - 1] !== "..") {
|
|
reduced.pop();
|
|
continue;
|
|
}
|
|
}
|
|
else if (reduced[0])
|
|
continue;
|
|
}
|
|
reduced.push(component);
|
|
}
|
|
return reduced;
|
|
}
|
|
ts.reducePathComponents = reducePathComponents;
|
|
/**
|
|
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
* components (at indices > 0). The result is normalized.
|
|
* If the path is relative, the root component is `""`.
|
|
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
*/
|
|
function getNormalizedPathComponents(path, currentDirectory) {
|
|
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
}
|
|
ts.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
function getNormalizedAbsolutePath(fileName, currentDirectory) {
|
|
return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
|
}
|
|
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
|
|
/**
|
|
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
* segments (at indices > 0).
|
|
*/
|
|
function getPathFromPathComponents(pathComponents) {
|
|
if (pathComponents.length === 0)
|
|
return "";
|
|
var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
if (pathComponents.length === 1)
|
|
return root;
|
|
return root + pathComponents.slice(1).join(ts.directorySeparator);
|
|
}
|
|
ts.getPathFromPathComponents = getPathFromPathComponents;
|
|
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
|
|
var fromComponents = reducePathComponents(getPathComponents(from));
|
|
var toComponents = reducePathComponents(getPathComponents(to));
|
|
var start;
|
|
for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
|
|
var fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
var toComponent = getCanonicalFileName(toComponents[start]);
|
|
var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
|
|
if (!comparer(fromComponent, toComponent))
|
|
break;
|
|
}
|
|
if (start === 0) {
|
|
return toComponents;
|
|
}
|
|
var components = toComponents.slice(start);
|
|
var relative = [];
|
|
for (; start < fromComponents.length; start++) {
|
|
relative.push("..");
|
|
}
|
|
return [""].concat(relative, components);
|
|
}
|
|
function getRelativePathFromFile(from, to, getCanonicalFileName) {
|
|
return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
|
|
}
|
|
ts.getRelativePathFromFile = getRelativePathFromFile;
|
|
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
|
|
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
|
|
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
|
|
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
return getPathFromPathComponents(pathComponents);
|
|
}
|
|
ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
|
|
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
|
|
var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
var firstComponent = pathComponents[0];
|
|
if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
|
|
var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
|
|
pathComponents[0] = prefix + firstComponent;
|
|
}
|
|
return getPathFromPathComponents(pathComponents);
|
|
}
|
|
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
|
|
/**
|
|
* Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
|
|
* with `./` or `../`) so as not to be confused with an unprefixed module name.
|
|
*/
|
|
function ensurePathIsNonModuleName(path) {
|
|
return getRootLength(path) === 0 && !pathIsRelative(path) ? "./" + path : path;
|
|
}
|
|
ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
|
|
function getBaseFileName(path, extensions, ignoreCase) {
|
|
path = normalizeSlashes(path);
|
|
// if the path provided is itself the root, then it has not file name.
|
|
var rootLength = getRootLength(path);
|
|
if (rootLength === path.length)
|
|
return "";
|
|
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
// separator but not including any trailing directory separator.
|
|
path = removeTrailingDirectorySeparator(path);
|
|
var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
|
|
var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
}
|
|
ts.getBaseFileName = getBaseFileName;
|
|
/**
|
|
* Combines paths. If a path is absolute, it replaces any previous path.
|
|
*/
|
|
function combinePaths(path) {
|
|
var paths = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
paths[_i - 1] = arguments[_i];
|
|
}
|
|
if (path)
|
|
path = normalizeSlashes(path);
|
|
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
|
|
var relativePath = paths_1[_a];
|
|
if (!relativePath)
|
|
continue;
|
|
relativePath = normalizeSlashes(relativePath);
|
|
if (!path || getRootLength(relativePath) !== 0) {
|
|
path = relativePath;
|
|
}
|
|
else {
|
|
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
}
|
|
}
|
|
return path;
|
|
}
|
|
ts.combinePaths = combinePaths;
|
|
/**
|
|
* Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
|
|
* `.` and `..` path components are resolved.
|
|
*/
|
|
function resolvePath(path) {
|
|
var paths = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
paths[_i - 1] = arguments[_i];
|
|
}
|
|
var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : normalizeSlashes(path);
|
|
var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(combined)));
|
|
return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
}
|
|
ts.resolvePath = resolvePath;
|
|
/**
|
|
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
*/
|
|
function hasTrailingDirectorySeparator(path) {
|
|
if (path.length === 0)
|
|
return false;
|
|
var ch = path.charCodeAt(path.length - 1);
|
|
return ch === 47 /* slash */ || ch === 92 /* backslash */;
|
|
}
|
|
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
|
|
function removeTrailingDirectorySeparator(path) {
|
|
if (hasTrailingDirectorySeparator(path)) {
|
|
return path.substr(0, path.length - 1);
|
|
}
|
|
return path;
|
|
}
|
|
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
function ensureTrailingDirectorySeparator(path) {
|
|
if (!hasTrailingDirectorySeparator(path)) {
|
|
return path + ts.directorySeparator;
|
|
}
|
|
return path;
|
|
}
|
|
ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
|
|
function comparePathsWorker(a, b, componentComparer) {
|
|
if (a === b)
|
|
return 0 /* EqualTo */;
|
|
if (a === undefined)
|
|
return -1 /* LessThan */;
|
|
if (b === undefined)
|
|
return 1 /* GreaterThan */;
|
|
var aComponents = reducePathComponents(getPathComponents(a));
|
|
var bComponents = reducePathComponents(getPathComponents(b));
|
|
var sharedLength = Math.min(aComponents.length, bComponents.length);
|
|
for (var i = 0; i < sharedLength; i++) {
|
|
var stringComparer = i === 0 ? ts.compareStringsCaseInsensitive : componentComparer;
|
|
var result = stringComparer(aComponents[i], bComponents[i]);
|
|
if (result !== 0 /* EqualTo */) {
|
|
return result;
|
|
}
|
|
}
|
|
return ts.compareValues(aComponents.length, bComponents.length);
|
|
}
|
|
/**
|
|
* Performs a case-sensitive comparison of two paths.
|
|
*/
|
|
function comparePathsCaseSensitive(a, b) {
|
|
return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
|
|
}
|
|
ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
|
|
/**
|
|
* Performs a case-insensitive comparison of two paths.
|
|
*/
|
|
function comparePathsCaseInsensitive(a, b) {
|
|
return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
|
|
}
|
|
ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
|
|
function comparePaths(a, b, currentDirectory, ignoreCase) {
|
|
if (typeof currentDirectory === "string") {
|
|
a = combinePaths(currentDirectory, a);
|
|
b = combinePaths(currentDirectory, b);
|
|
}
|
|
else if (typeof currentDirectory === "boolean") {
|
|
ignoreCase = currentDirectory;
|
|
}
|
|
return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
|
|
}
|
|
ts.comparePaths = comparePaths;
|
|
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
if (typeof currentDirectory === "string") {
|
|
parent = combinePaths(currentDirectory, parent);
|
|
child = combinePaths(currentDirectory, child);
|
|
}
|
|
else if (typeof currentDirectory === "boolean") {
|
|
ignoreCase = currentDirectory;
|
|
}
|
|
if (parent === undefined || child === undefined)
|
|
return false;
|
|
if (parent === child)
|
|
return true;
|
|
var parentComponents = reducePathComponents(getPathComponents(parent));
|
|
var childComponents = reducePathComponents(getPathComponents(child));
|
|
if (childComponents.length < parentComponents.length) {
|
|
return false;
|
|
}
|
|
var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
|
|
for (var i = 0; i < parentComponents.length; i++) {
|
|
var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
ts.containsPath = containsPath;
|
|
function tryRemoveDirectoryPrefix(path, dirPath) {
|
|
var a = ts.tryRemovePrefix(path, dirPath);
|
|
if (a === undefined)
|
|
return undefined;
|
|
switch (a.charCodeAt(0)) {
|
|
case 47 /* slash */:
|
|
case 92 /* backslash */:
|
|
return a.slice(1);
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|
|
ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
|
|
// Reserved characters, forces escaping of any non-word (or digit), non-whitespace character.
|
|
// It may be inefficient (we could just match (/[-[\]{}()*+?.,\\^$|#\s]/g), but this is future
|
|
// proof.
|
|
var reservedCharacterPattern = /[^\w\s\/]/g;
|
|
var wildcardCharCodes = [42 /* asterisk */, 63 /* question */];
|
|
function hasExtension(fileName) {
|
|
return ts.stringContains(getBaseFileName(fileName), ".");
|
|
}
|
|
ts.hasExtension = hasExtension;
|
|
ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
|
|
var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
|
|
var filesMatcher = {
|
|
/**
|
|
* Matches any single directory segment unless it is the last segment and a .min.js file
|
|
* Breakdown:
|
|
* [^./] # matches everything up to the first . character (excluding directory separators)
|
|
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
|
|
*/
|
|
singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
|
|
/**
|
|
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
|
|
* files or directories, does not match subdirectories that start with a . character
|
|
*/
|
|
doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
|
|
replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
|
|
};
|
|
var directoriesMatcher = {
|
|
singleAsteriskRegexFragment: "[^/]*",
|
|
/**
|
|
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
|
|
* files or directories, does not match subdirectories that start with a . character
|
|
*/
|
|
doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
|
|
replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
|
|
};
|
|
var excludeMatcher = {
|
|
singleAsteriskRegexFragment: "[^/]*",
|
|
doubleAsteriskRegexFragment: "(/.+?)?",
|
|
replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
|
|
};
|
|
var wildcardMatchers = {
|
|
files: filesMatcher,
|
|
directories: directoriesMatcher,
|
|
exclude: excludeMatcher
|
|
};
|
|
function getRegularExpressionForWildcard(specs, basePath, usage) {
|
|
var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
|
|
if (!patterns || !patterns.length) {
|
|
return undefined;
|
|
}
|
|
var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
|
|
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
|
|
var terminator = usage === "exclude" ? "($|/)" : "$";
|
|
return "^(" + pattern + ")" + terminator;
|
|
}
|
|
ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
|
|
function getRegularExpressionsForWildcards(specs, basePath, usage) {
|
|
if (specs === undefined || specs.length === 0) {
|
|
return undefined;
|
|
}
|
|
return ts.flatMap(specs, function (spec) {
|
|
return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
|
|
});
|
|
}
|
|
/**
|
|
* An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension,
|
|
* and does not contain any glob characters itself.
|
|
*/
|
|
function isImplicitGlob(lastPathComponent) {
|
|
return !/[.*?]/.test(lastPathComponent);
|
|
}
|
|
ts.isImplicitGlob = isImplicitGlob;
|
|
function getSubPatternFromSpec(spec, basePath, usage, _a) {
|
|
var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
|
|
var subpattern = "";
|
|
var hasWrittenComponent = false;
|
|
var components = getNormalizedPathComponents(spec, basePath);
|
|
var lastComponent = ts.last(components);
|
|
if (usage !== "exclude" && lastComponent === "**") {
|
|
return undefined;
|
|
}
|
|
// getNormalizedPathComponents includes the separator for the root component.
|
|
// We need to remove to create our regex correctly.
|
|
components[0] = removeTrailingDirectorySeparator(components[0]);
|
|
if (isImplicitGlob(lastComponent)) {
|
|
components.push("**", "*");
|
|
}
|
|
var optionalCount = 0;
|
|
for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
|
|
var component = components_1[_i];
|
|
if (component === "**") {
|
|
subpattern += doubleAsteriskRegexFragment;
|
|
}
|
|
else {
|
|
if (usage === "directories") {
|
|
subpattern += "(";
|
|
optionalCount++;
|
|
}
|
|
if (hasWrittenComponent) {
|
|
subpattern += ts.directorySeparator;
|
|
}
|
|
if (usage !== "exclude") {
|
|
var componentPattern = "";
|
|
// The * and ? wildcards should not match directories or files that start with . if they
|
|
// appear first in a component. Dotted directories and files can be included explicitly
|
|
// like so: **/.*/.*
|
|
if (component.charCodeAt(0) === 42 /* asterisk */) {
|
|
componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
|
|
component = component.substr(1);
|
|
}
|
|
else if (component.charCodeAt(0) === 63 /* question */) {
|
|
componentPattern += "[^./]";
|
|
component = component.substr(1);
|
|
}
|
|
componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
|
// Patterns should not include subfolders like node_modules unless they are
|
|
// explicitly included as part of the path.
|
|
//
|
|
// As an optimization, if the component pattern is the same as the component,
|
|
// then there definitely were no wildcard characters and we do not need to
|
|
// add the exclusion pattern.
|
|
if (componentPattern !== component) {
|
|
subpattern += implicitExcludePathRegexPattern;
|
|
}
|
|
subpattern += componentPattern;
|
|
}
|
|
else {
|
|
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
|
}
|
|
}
|
|
hasWrittenComponent = true;
|
|
}
|
|
while (optionalCount > 0) {
|
|
subpattern += ")?";
|
|
optionalCount--;
|
|
}
|
|
return subpattern;
|
|
}
|
|
function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
|
|
return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
|
|
}
|
|
/** @param path directory of the tsconfig.json */
|
|
function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
|
|
path = normalizePath(path);
|
|
currentDirectory = normalizePath(currentDirectory);
|
|
var absolutePath = combinePaths(currentDirectory, path);
|
|
return {
|
|
includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
|
|
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
|
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
|
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
|
basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
|
|
};
|
|
}
|
|
ts.getFileMatcherPatterns = getFileMatcherPatterns;
|
|
function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
|
|
return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
|
|
}
|
|
ts.getRegexFromPattern = getRegexFromPattern;
|
|
/** @param path directory of the tsconfig.json */
|
|
function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) {
|
|
path = normalizePath(path);
|
|
currentDirectory = normalizePath(currentDirectory);
|
|
var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
|
var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
|
|
var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
|
|
var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
|
|
// Associate an array of results with each include regex. This keeps results in order of the "include" order.
|
|
// If there are no "includes", then just put everything in results[0].
|
|
var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
|
|
for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
|
|
var basePath = _a[_i];
|
|
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
|
|
}
|
|
return ts.flatten(results);
|
|
function visitDirectory(path, absolutePath, depth) {
|
|
var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
|
|
var _loop_1 = function (current) {
|
|
var name = combinePaths(path, current);
|
|
var absoluteName = combinePaths(absolutePath, current);
|
|
if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
|
|
return "continue";
|
|
if (excludeRegex && excludeRegex.test(absoluteName))
|
|
return "continue";
|
|
if (!includeFileRegexes) {
|
|
results[0].push(name);
|
|
}
|
|
else {
|
|
var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
|
|
if (includeIndex !== -1) {
|
|
results[includeIndex].push(name);
|
|
}
|
|
}
|
|
};
|
|
for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
|
|
var current = _b[_i];
|
|
_loop_1(current);
|
|
}
|
|
if (depth !== undefined) {
|
|
depth--;
|
|
if (depth === 0) {
|
|
return;
|
|
}
|
|
}
|
|
for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
|
|
var current = _d[_c];
|
|
var name = combinePaths(path, current);
|
|
var absoluteName = combinePaths(absolutePath, current);
|
|
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
|
|
(!excludeRegex || !excludeRegex.test(absoluteName))) {
|
|
visitDirectory(name, absoluteName, depth);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ts.matchFiles = matchFiles;
|
|
/**
|
|
* Computes the unique non-wildcard base paths amongst the provided include patterns.
|
|
*/
|
|
function getBasePaths(path, includes, useCaseSensitiveFileNames) {
|
|
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
|
var basePaths = [path];
|
|
if (includes) {
|
|
// Storage for literal base paths amongst the include patterns.
|
|
var includeBasePaths = [];
|
|
for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
|
|
var include = includes_1[_i];
|
|
// We also need to check the relative paths by converting them to absolute and normalizing
|
|
// in case they escape the base path (e.g "..\somedirectory")
|
|
var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
|
|
// Append the literal and canonical candidate base paths.
|
|
includeBasePaths.push(getIncludeBasePath(absolute));
|
|
}
|
|
// Sort the offsets array using either the literal or canonical path representations.
|
|
includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
|
|
var _loop_2 = function (includeBasePath) {
|
|
if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
|
|
basePaths.push(includeBasePath);
|
|
}
|
|
};
|
|
// Iterate over each include base path and include unique base paths that are not a
|
|
// subpath of an existing base path
|
|
for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
|
|
var includeBasePath = includeBasePaths_1[_a];
|
|
_loop_2(includeBasePath);
|
|
}
|
|
}
|
|
return basePaths;
|
|
}
|
|
function getIncludeBasePath(absolute) {
|
|
var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
|
|
if (wildcardOffset < 0) {
|
|
// No "*" or "?" in the path
|
|
return !hasExtension(absolute)
|
|
? absolute
|
|
: removeTrailingDirectorySeparator(getDirectoryPath(absolute));
|
|
}
|
|
return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
|
|
}
|
|
function ensureScriptKind(fileName, scriptKind) {
|
|
// Using scriptKind as a condition handles both:
|
|
// - 'scriptKind' is unspecified and thus it is `undefined`
|
|
// - 'scriptKind' is set and it is `Unknown` (0)
|
|
// If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt
|
|
// to get the ScriptKind from the file name. If it cannot be resolved
|
|
// from the file name then the default 'TS' script kind is returned.
|
|
return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */;
|
|
}
|
|
ts.ensureScriptKind = ensureScriptKind;
|
|
function getScriptKindFromFileName(fileName) {
|
|
var ext = fileName.substr(fileName.lastIndexOf("."));
|
|
switch (ext.toLowerCase()) {
|
|
case ".js" /* Js */:
|
|
return 1 /* JS */;
|
|
case ".jsx" /* Jsx */:
|
|
return 2 /* JSX */;
|
|
case ".ts" /* Ts */:
|
|
return 3 /* TS */;
|
|
case ".tsx" /* Tsx */:
|
|
return 4 /* TSX */;
|
|
case ".json" /* Json */:
|
|
return 6 /* JSON */;
|
|
default:
|
|
return 0 /* Unknown */;
|
|
}
|
|
}
|
|
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
/**
|
|
* List of supported extensions in order of file resolution precedence.
|
|
*/
|
|
ts.supportedTypeScriptExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */];
|
|
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
|
ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */];
|
|
ts.supportedJavascriptExtensions = [".js" /* Js */, ".jsx" /* Jsx */];
|
|
var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions);
|
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
var needJsExtensions = options && options.allowJs;
|
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
return needJsExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions;
|
|
}
|
|
var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJavaScriptLike(x.scriptKind) ? x.extension : undefined; }));
|
|
return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
|
|
}
|
|
ts.getSupportedExtensions = getSupportedExtensions;
|
|
function isJavaScriptLike(scriptKind) {
|
|
return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
|
|
}
|
|
function hasJavaScriptFileExtension(fileName) {
|
|
return ts.some(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
}
|
|
ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension;
|
|
function hasTypeScriptFileExtension(fileName) {
|
|
return ts.some(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
}
|
|
ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension;
|
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
if (!fileName) {
|
|
return false;
|
|
}
|
|
for (var _i = 0, _a = getSupportedExtensions(compilerOptions, extraFileExtensions); _i < _a.length; _i++) {
|
|
var extension = _a[_i];
|
|
if (ts.fileExtensionIs(fileName, extension)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
ts.isSupportedSourceFileName = isSupportedSourceFileName;
|
|
/**
|
|
* Extension boundaries by priority. Lower numbers indicate higher priorities, and are
|
|
* aligned to the offset of the highest priority extension in the
|
|
* allSupportedExtensions array.
|
|
*/
|
|
var ExtensionPriority;
|
|
(function (ExtensionPriority) {
|
|
ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles";
|
|
ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles";
|
|
ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest";
|
|
ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest";
|
|
})(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {}));
|
|
function getExtensionPriority(path, supportedExtensions) {
|
|
for (var i = supportedExtensions.length - 1; i >= 0; i--) {
|
|
if (ts.fileExtensionIs(path, supportedExtensions[i])) {
|
|
return adjustExtensionPriority(i, supportedExtensions);
|
|
}
|
|
}
|
|
// If its not in the list of supported extensions, this is likely a
|
|
// TypeScript file with a non-ts extension
|
|
return 0 /* Highest */;
|
|
}
|
|
ts.getExtensionPriority = getExtensionPriority;
|
|
/**
|
|
* Adjusts an extension priority to be the highest priority within the same range.
|
|
*/
|
|
function adjustExtensionPriority(extensionPriority, supportedExtensions) {
|
|
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
return 0 /* TypeScriptFiles */;
|
|
}
|
|
else if (extensionPriority < supportedExtensions.length) {
|
|
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
}
|
|
else {
|
|
return supportedExtensions.length;
|
|
}
|
|
}
|
|
ts.adjustExtensionPriority = adjustExtensionPriority;
|
|
/**
|
|
* Gets the next lowest extension priority for a given priority.
|
|
*/
|
|
function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
|
|
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
}
|
|
else {
|
|
return supportedExtensions.length;
|
|
}
|
|
}
|
|
ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
|
|
var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
function removeFileExtension(path) {
|
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
|
|
var ext = extensionsToRemove_1[_i];
|
|
var extensionless = tryRemoveExtension(path, ext);
|
|
if (extensionless !== undefined) {
|
|
return extensionless;
|
|
}
|
|
}
|
|
return path;
|
|
}
|
|
ts.removeFileExtension = removeFileExtension;
|
|
function tryRemoveExtension(path, extension) {
|
|
return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
|
|
}
|
|
ts.tryRemoveExtension = tryRemoveExtension;
|
|
function removeExtension(path, extension) {
|
|
return path.substring(0, path.length - extension.length);
|
|
}
|
|
ts.removeExtension = removeExtension;
|
|
function changeExtension(path, newExtension) {
|
|
return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false);
|
|
}
|
|
ts.changeExtension = changeExtension;
|
|
function changeAnyExtension(path, ext, extensions, ignoreCase) {
|
|
var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
|
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
|
|
}
|
|
ts.changeAnyExtension = changeAnyExtension;
|
|
var Debug;
|
|
(function (Debug) {
|
|
function showSymbol(symbol) {
|
|
var symbolFlags = ts.SymbolFlags;
|
|
return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
|
|
}
|
|
Debug.showSymbol = showSymbol;
|
|
function showFlags(flags, flagsEnum) {
|
|
var out = [];
|
|
for (var pow = 0; pow <= 30; pow++) {
|
|
var n = 1 << pow;
|
|
if (flags & n) {
|
|
out.push(flagsEnum[n]);
|
|
}
|
|
}
|
|
return out.join("|");
|
|
}
|
|
function showSyntaxKind(node) {
|
|
var syntaxKind = ts.SyntaxKind;
|
|
return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
|
|
}
|
|
Debug.showSyntaxKind = showSyntaxKind;
|
|
})(Debug = ts.Debug || (ts.Debug = {}));
|
|
function tryParsePattern(pattern) {
|
|
// This should be verified outside of here and a proper error thrown.
|
|
Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
|
|
var indexOfStar = pattern.indexOf("*");
|
|
return indexOfStar === -1 ? undefined : {
|
|
prefix: pattern.substr(0, indexOfStar),
|
|
suffix: pattern.substr(indexOfStar + 1)
|
|
};
|
|
}
|
|
ts.tryParsePattern = tryParsePattern;
|
|
function positionIsSynthesized(pos) {
|
|
// This is a fast way of testing the following conditions:
|
|
// pos === undefined || pos === null || isNaN(pos) || pos < 0;
|
|
return !(pos >= 0);
|
|
}
|
|
ts.positionIsSynthesized = positionIsSynthesized;
|
|
/** True if an extension is one of the supported TypeScript extensions. */
|
|
function extensionIsTypeScript(ext) {
|
|
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */;
|
|
}
|
|
ts.extensionIsTypeScript = extensionIsTypeScript;
|
|
function resolutionExtensionIsTypeScriptOrJson(ext) {
|
|
return extensionIsTypeScript(ext) || ext === ".json" /* Json */;
|
|
}
|
|
ts.resolutionExtensionIsTypeScriptOrJson = resolutionExtensionIsTypeScriptOrJson;
|
|
/**
|
|
* Gets the extension from a path.
|
|
* Path must have a valid extension.
|
|
*/
|
|
function extensionFromPath(path) {
|
|
var ext = tryGetExtensionFromPath(path);
|
|
return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
|
|
}
|
|
ts.extensionFromPath = extensionFromPath;
|
|
function isAnySupportedFileExtension(path) {
|
|
return tryGetExtensionFromPath(path) !== undefined;
|
|
}
|
|
ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
|
|
function tryGetExtensionFromPath(path) {
|
|
return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return ts.fileExtensionIs(path, e); }) || ts.find(ts.supportedJavascriptExtensions, function (e) { return ts.fileExtensionIs(path, e); });
|
|
}
|
|
ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
|
|
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
if (typeof extensions === "string")
|
|
extensions = [extensions];
|
|
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
var extension = extensions_1[_i];
|
|
if (!ts.startsWith(extension, "."))
|
|
extension = "." + extension;
|
|
if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") {
|
|
var pathExtension = path.slice(path.length - extension.length);
|
|
if (stringEqualityComparer(pathExtension, extension)) {
|
|
return pathExtension;
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
// Retrieves any string from the final "." onwards from a base file name.
|
|
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
if (extensions) {
|
|
return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
|
|
}
|
|
var baseFileName = getBaseFileName(path);
|
|
var extensionIndex = baseFileName.lastIndexOf(".");
|
|
if (extensionIndex >= 0) {
|
|
return baseFileName.substring(extensionIndex);
|
|
}
|
|
return "";
|
|
}
|
|
ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
|
|
function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
|
|
return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
|
|
}
|
|
ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
|
|
ts.emptyFileSystemEntries = {
|
|
files: ts.emptyArray,
|
|
directories: ts.emptyArray
|
|
};
|
|
/**
|
|
* patternStrings contains both pattern strings (containing "*") and regular strings.
|
|
* Return an exact match if possible, or a pattern match, or undefined.
|
|
* (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.)
|
|
*/
|
|
function matchPatternOrExact(patternStrings, candidate) {
|
|
var patterns = [];
|
|
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
|
|
var patternString = patternStrings_1[_i];
|
|
var pattern = tryParsePattern(patternString);
|
|
if (pattern) {
|
|
patterns.push(pattern);
|
|
}
|
|
else if (patternString === candidate) {
|
|
// pattern was matched as is - no need to search further
|
|
return patternString;
|
|
}
|
|
}
|
|
return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
|
|
}
|
|
ts.matchPatternOrExact = matchPatternOrExact;
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
var SignatureFlags;
|
|
(function (SignatureFlags) {
|
|
SignatureFlags[SignatureFlags["None"] = 0] = "None";
|
|
SignatureFlags[SignatureFlags["Yield"] = 1] = "Yield";
|
|
SignatureFlags[SignatureFlags["Await"] = 2] = "Await";
|
|
SignatureFlags[SignatureFlags["Type"] = 4] = "Type";
|
|
SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace";
|
|
SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc";
|
|
})(SignatureFlags || (SignatureFlags = {}));
|
|
// tslint:disable variable-name
|
|
var NodeConstructor;
|
|
var TokenConstructor;
|
|
var IdentifierConstructor;
|
|
var SourceFileConstructor;
|
|
// tslint:enable variable-name
|
|
function createNode(kind, pos, end) {
|
|
if (kind === 274 /* SourceFile */) {
|
|
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
|
|
}
|
|
else if (kind === 71 /* Identifier */) {
|
|
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
|
|
}
|
|
else if (!ts.isNodeKind(kind)) {
|
|
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
|
|
}
|
|
else {
|
|
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
|
|
}
|
|
}
|
|
ts.createNode = createNode;
|
|
function visitNode(cbNode, node) {
|
|
return node && cbNode(node);
|
|
}
|
|
function visitNodes(cbNode, cbNodes, nodes) {
|
|
if (nodes) {
|
|
if (cbNodes) {
|
|
return cbNodes(nodes);
|
|
}
|
|
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
var node = nodes_1[_i];
|
|
var result = cbNode(node);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/*@internal*/
|
|
function isJSDocLikeText(text, start) {
|
|
return text.charCodeAt(start + 1) === 42 /* asterisk */ &&
|
|
text.charCodeAt(start + 2) === 42 /* asterisk */ &&
|
|
text.charCodeAt(start + 3) !== 47 /* slash */;
|
|
}
|
|
ts.isJSDocLikeText = isJSDocLikeText;
|
|
/**
|
|
* Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
|
|
* stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
|
* embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
|
* a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
|
|
*
|
|
* @param node a given node to visit its children
|
|
* @param cbNode a callback to be invoked for all child nodes
|
|
* @param cbNodes a callback to be invoked for embedded array
|
|
*
|
|
* @remarks `forEachChild` must visit the children of a node in the order
|
|
* that they appear in the source code. The language service depends on this property to locate nodes by position.
|
|
*/
|
|
function forEachChild(node, cbNode, cbNodes) {
|
|
if (!node || node.kind <= 145 /* LastToken */) {
|
|
return;
|
|
}
|
|
switch (node.kind) {
|
|
case 146 /* QualifiedName */:
|
|
return visitNode(cbNode, node.left) ||
|
|
visitNode(cbNode, node.right);
|
|
case 148 /* TypeParameter */:
|
|
return visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.constraint) ||
|
|
visitNode(cbNode, node.default) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 271 /* ShorthandPropertyAssignment */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.equalsToken) ||
|
|
visitNode(cbNode, node.objectAssignmentInitializer);
|
|
case 272 /* SpreadAssignment */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 149 /* Parameter */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.dotDotDotToken) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 152 /* PropertyDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.exclamationToken) ||
|
|
visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 151 /* PropertySignature */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 270 /* PropertyAssignment */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 232 /* VariableDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.exclamationToken) ||
|
|
visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 182 /* BindingElement */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.dotDotDotToken) ||
|
|
visitNode(cbNode, node.propertyName) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 163 /* FunctionType */:
|
|
case 164 /* ConstructorType */:
|
|
case 158 /* CallSignature */:
|
|
case 159 /* ConstructSignature */:
|
|
case 160 /* IndexSignature */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
visitNode(cbNode, node.type);
|
|
case 154 /* MethodDeclaration */:
|
|
case 153 /* MethodSignature */:
|
|
case 155 /* Constructor */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 192 /* FunctionExpression */:
|
|
case 234 /* FunctionDeclaration */:
|
|
case 193 /* ArrowFunction */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.asteriskToken) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.equalsGreaterThanToken) ||
|
|
visitNode(cbNode, node.body);
|
|
case 162 /* TypeReference */:
|
|
return visitNode(cbNode, node.typeName) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
case 161 /* TypePredicate */:
|
|
return visitNode(cbNode, node.parameterName) ||
|
|
visitNode(cbNode, node.type);
|
|
case 165 /* TypeQuery */:
|
|
return visitNode(cbNode, node.exprName);
|
|
case 166 /* TypeLiteral */:
|
|
return visitNodes(cbNode, cbNodes, node.members);
|
|
case 167 /* ArrayType */:
|
|
return visitNode(cbNode, node.elementType);
|
|
case 168 /* TupleType */:
|
|
return visitNodes(cbNode, cbNodes, node.elementTypes);
|
|
case 169 /* UnionType */:
|
|
case 170 /* IntersectionType */:
|
|
return visitNodes(cbNode, cbNodes, node.types);
|
|
case 171 /* ConditionalType */:
|
|
return visitNode(cbNode, node.checkType) ||
|
|
visitNode(cbNode, node.extendsType) ||
|
|
visitNode(cbNode, node.trueType) ||
|
|
visitNode(cbNode, node.falseType);
|
|
case 172 /* InferType */:
|
|
return visitNode(cbNode, node.typeParameter);
|
|
case 179 /* ImportType */:
|
|
return visitNode(cbNode, node.argument) ||
|
|
visitNode(cbNode, node.qualifier) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
case 173 /* ParenthesizedType */:
|
|
case 175 /* TypeOperator */:
|
|
return visitNode(cbNode, node.type);
|
|
case 176 /* IndexedAccessType */:
|
|
return visitNode(cbNode, node.objectType) ||
|
|
visitNode(cbNode, node.indexType);
|
|
case 177 /* MappedType */:
|
|
return visitNode(cbNode, node.readonlyToken) ||
|
|
visitNode(cbNode, node.typeParameter) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.type);
|
|
case 178 /* LiteralType */:
|
|
return visitNode(cbNode, node.literal);
|
|
case 180 /* ObjectBindingPattern */:
|
|
case 181 /* ArrayBindingPattern */:
|
|
return visitNodes(cbNode, cbNodes, node.elements);
|
|
case 183 /* ArrayLiteralExpression */:
|
|
return visitNodes(cbNode, cbNodes, node.elements);
|
|
case 184 /* ObjectLiteralExpression */:
|
|
return visitNodes(cbNode, cbNodes, node.properties);
|
|
case 185 /* PropertyAccessExpression */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.name);
|
|
case 186 /* ElementAccessExpression */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.argumentExpression);
|
|
case 187 /* CallExpression */:
|
|
case 188 /* NewExpression */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments) ||
|
|
visitNodes(cbNode, cbNodes, node.arguments);
|
|
case 189 /* TaggedTemplateExpression */:
|
|
return visitNode(cbNode, node.tag) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments) ||
|
|
visitNode(cbNode, node.template);
|
|
case 190 /* TypeAssertionExpression */:
|
|
return visitNode(cbNode, node.type) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 191 /* ParenthesizedExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 194 /* DeleteExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 195 /* TypeOfExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 196 /* VoidExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 198 /* PrefixUnaryExpression */:
|
|
return visitNode(cbNode, node.operand);
|
|
case 203 /* YieldExpression */:
|
|
return visitNode(cbNode, node.asteriskToken) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 197 /* AwaitExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 199 /* PostfixUnaryExpression */:
|
|
return visitNode(cbNode, node.operand);
|
|
case 200 /* BinaryExpression */:
|
|
return visitNode(cbNode, node.left) ||
|
|
visitNode(cbNode, node.operatorToken) ||
|
|
visitNode(cbNode, node.right);
|
|
case 208 /* AsExpression */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.type);
|
|
case 209 /* NonNullExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 210 /* MetaProperty */:
|
|
return visitNode(cbNode, node.name);
|
|
case 201 /* ConditionalExpression */:
|
|
return visitNode(cbNode, node.condition) ||
|
|
visitNode(cbNode, node.questionToken) ||
|
|
visitNode(cbNode, node.whenTrue) ||
|
|
visitNode(cbNode, node.colonToken) ||
|
|
visitNode(cbNode, node.whenFalse);
|
|
case 204 /* SpreadElement */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 213 /* Block */:
|
|
case 240 /* ModuleBlock */:
|
|
return visitNodes(cbNode, cbNodes, node.statements);
|
|
case 274 /* SourceFile */:
|
|
return visitNodes(cbNode, cbNodes, node.statements) ||
|
|
visitNode(cbNode, node.endOfFileToken);
|
|
case 214 /* VariableStatement */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.declarationList);
|
|
case 233 /* VariableDeclarationList */:
|
|
return visitNodes(cbNode, cbNodes, node.declarations);
|
|
case 216 /* ExpressionStatement */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 217 /* IfStatement */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.thenStatement) ||
|
|
visitNode(cbNode, node.elseStatement);
|
|
case 218 /* DoStatement */:
|
|
return visitNode(cbNode, node.statement) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 219 /* WhileStatement */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 220 /* ForStatement */:
|
|
return visitNode(cbNode, node.initializer) ||
|
|
visitNode(cbNode, node.condition) ||
|
|
visitNode(cbNode, node.incrementor) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 221 /* ForInStatement */:
|
|
return visitNode(cbNode, node.initializer) ||
|
|
visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 222 /* ForOfStatement */:
|
|
return visitNode(cbNode, node.awaitModifier) ||
|
|
visitNode(cbNode, node.initializer) ||
|
|
visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 223 /* ContinueStatement */:
|
|
case 224 /* BreakStatement */:
|
|
return visitNode(cbNode, node.label);
|
|
case 225 /* ReturnStatement */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 226 /* WithStatement */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 227 /* SwitchStatement */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNode(cbNode, node.caseBlock);
|
|
case 241 /* CaseBlock */:
|
|
return visitNodes(cbNode, cbNodes, node.clauses);
|
|
case 266 /* CaseClause */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNodes(cbNode, cbNodes, node.statements);
|
|
case 267 /* DefaultClause */:
|
|
return visitNodes(cbNode, cbNodes, node.statements);
|
|
case 228 /* LabeledStatement */:
|
|
return visitNode(cbNode, node.label) ||
|
|
visitNode(cbNode, node.statement);
|
|
case 229 /* ThrowStatement */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 230 /* TryStatement */:
|
|
return visitNode(cbNode, node.tryBlock) ||
|
|
visitNode(cbNode, node.catchClause) ||
|
|
visitNode(cbNode, node.finallyBlock);
|
|
case 269 /* CatchClause */:
|
|
return visitNode(cbNode, node.variableDeclaration) ||
|
|
visitNode(cbNode, node.block);
|
|
case 150 /* Decorator */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 235 /* ClassDeclaration */:
|
|
case 205 /* ClassExpression */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNodes(cbNode, cbNodes, node.heritageClauses) ||
|
|
visitNodes(cbNode, cbNodes, node.members);
|
|
case 236 /* InterfaceDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNodes(cbNode, cbNodes, node.heritageClauses) ||
|
|
visitNodes(cbNode, cbNodes, node.members);
|
|
case 237 /* TypeAliasDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNode(cbNode, node.type);
|
|
case 238 /* EnumDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNodes(cbNode, cbNodes, node.members);
|
|
case 273 /* EnumMember */:
|
|
return visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 239 /* ModuleDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.body);
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.moduleReference);
|
|
case 244 /* ImportDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.importClause) ||
|
|
visitNode(cbNode, node.moduleSpecifier);
|
|
case 245 /* ImportClause */:
|
|
return visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.namedBindings);
|
|
case 242 /* NamespaceExportDeclaration */:
|
|
return visitNode(cbNode, node.name);
|
|
case 246 /* NamespaceImport */:
|
|
return visitNode(cbNode, node.name);
|
|
case 247 /* NamedImports */:
|
|
case 251 /* NamedExports */:
|
|
return visitNodes(cbNode, cbNodes, node.elements);
|
|
case 250 /* ExportDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.exportClause) ||
|
|
visitNode(cbNode, node.moduleSpecifier);
|
|
case 248 /* ImportSpecifier */:
|
|
case 252 /* ExportSpecifier */:
|
|
return visitNode(cbNode, node.propertyName) ||
|
|
visitNode(cbNode, node.name);
|
|
case 249 /* ExportAssignment */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 202 /* TemplateExpression */:
|
|
return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
|
|
case 211 /* TemplateSpan */:
|
|
return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
|
|
case 147 /* ComputedPropertyName */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 268 /* HeritageClause */:
|
|
return visitNodes(cbNode, cbNodes, node.types);
|
|
case 207 /* ExpressionWithTypeArguments */:
|
|
return visitNode(cbNode, node.expression) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
case 254 /* ExternalModuleReference */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 253 /* MissingDeclaration */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators);
|
|
case 302 /* CommaListExpression */:
|
|
return visitNodes(cbNode, cbNodes, node.elements);
|
|
case 255 /* JsxElement */:
|
|
return visitNode(cbNode, node.openingElement) ||
|
|
visitNodes(cbNode, cbNodes, node.children) ||
|
|
visitNode(cbNode, node.closingElement);
|
|
case 259 /* JsxFragment */:
|
|
return visitNode(cbNode, node.openingFragment) ||
|
|
visitNodes(cbNode, cbNodes, node.children) ||
|
|
visitNode(cbNode, node.closingFragment);
|
|
case 256 /* JsxSelfClosingElement */:
|
|
case 257 /* JsxOpeningElement */:
|
|
return visitNode(cbNode, node.tagName) ||
|
|
visitNodes(cbNode, cbNodes, node.typeArguments) ||
|
|
visitNode(cbNode, node.attributes);
|
|
case 263 /* JsxAttributes */:
|
|
return visitNodes(cbNode, cbNodes, node.properties);
|
|
case 262 /* JsxAttribute */:
|
|
return visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.initializer);
|
|
case 264 /* JsxSpreadAttribute */:
|
|
return visitNode(cbNode, node.expression);
|
|
case 265 /* JsxExpression */:
|
|
return visitNode(cbNode, node.dotDotDotToken) ||
|
|
visitNode(cbNode, node.expression);
|
|
case 258 /* JsxClosingElement */:
|
|
return visitNode(cbNode, node.tagName);
|
|
case 278 /* JSDocTypeExpression */:
|
|
return visitNode(cbNode, node.type);
|
|
case 282 /* JSDocNonNullableType */:
|
|
return visitNode(cbNode, node.type);
|
|
case 281 /* JSDocNullableType */:
|
|
return visitNode(cbNode, node.type);
|
|
case 283 /* JSDocOptionalType */:
|
|
return visitNode(cbNode, node.type);
|
|
case 284 /* JSDocFunctionType */:
|
|
return visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
visitNode(cbNode, node.type);
|
|
case 285 /* JSDocVariadicType */:
|
|
return visitNode(cbNode, node.type);
|
|
case 286 /* JSDocComment */:
|
|
return visitNodes(cbNode, cbNodes, node.tags);
|
|
case 293 /* JSDocParameterTag */:
|
|
case 298 /* JSDocPropertyTag */:
|
|
if (node.isNameFirst) {
|
|
return visitNode(cbNode, node.name) ||
|
|
visitNode(cbNode, node.typeExpression);
|
|
}
|
|
else {
|
|
return visitNode(cbNode, node.typeExpression) ||
|
|
visitNode(cbNode, node.name);
|
|
}
|
|
case 294 /* JSDocReturnTag */:
|
|
return visitNode(cbNode, node.typeExpression);
|
|
case 295 /* JSDocTypeTag */:
|
|
return visitNode(cbNode, node.typeExpression);
|
|
case 290 /* JSDocAugmentsTag */:
|
|
return visitNode(cbNode, node.class);
|
|
case 296 /* JSDocTemplateTag */:
|
|
return visitNodes(cbNode, cbNodes, node.typeParameters);
|
|
case 297 /* JSDocTypedefTag */:
|
|
if (node.typeExpression &&
|
|
node.typeExpression.kind === 278 /* JSDocTypeExpression */) {
|
|
return visitNode(cbNode, node.typeExpression) ||
|
|
visitNode(cbNode, node.fullName);
|
|
}
|
|
else {
|
|
return visitNode(cbNode, node.fullName) ||
|
|
visitNode(cbNode, node.typeExpression);
|
|
}
|
|
case 292 /* JSDocCallbackTag */:
|
|
return visitNode(cbNode, node.fullName) ||
|
|
visitNode(cbNode, node.typeExpression);
|
|
case 288 /* JSDocSignature */:
|
|
return visitNodes(cbNode, cbNodes, node.decorators) ||
|
|
visitNodes(cbNode, cbNodes, node.modifiers) ||
|
|
visitNodes(cbNode, cbNodes, node.typeParameters) ||
|
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
visitNode(cbNode, node.type);
|
|
case 287 /* JSDocTypeLiteral */:
|
|
if (node.jsDocPropertyTags) {
|
|
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
|
|
var tag = _a[_i];
|
|
visitNode(cbNode, tag);
|
|
}
|
|
}
|
|
return;
|
|
case 301 /* PartiallyEmittedExpression */:
|
|
return visitNode(cbNode, node.expression);
|
|
}
|
|
}
|
|
ts.forEachChild = forEachChild;
|
|
function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
|
|
if (setParentNodes === void 0) { setParentNodes = false; }
|
|
ts.performance.mark("beforeParse");
|
|
var result;
|
|
if (languageVersion === 100 /* JSON */) {
|
|
result = Parser.parseJsonText(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes);
|
|
}
|
|
else {
|
|
result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
|
|
}
|
|
ts.performance.mark("afterParse");
|
|
ts.performance.measure("Parse", "beforeParse", "afterParse");
|
|
return result;
|
|
}
|
|
ts.createSourceFile = createSourceFile;
|
|
function parseIsolatedEntityName(text, languageVersion) {
|
|
return Parser.parseIsolatedEntityName(text, languageVersion);
|
|
}
|
|
ts.parseIsolatedEntityName = parseIsolatedEntityName;
|
|
/**
|
|
* Parse json text into SyntaxTree and return node and parse errors if any
|
|
* @param fileName
|
|
* @param sourceText
|
|
*/
|
|
function parseJsonText(fileName, sourceText) {
|
|
return Parser.parseJsonText(fileName, sourceText);
|
|
}
|
|
ts.parseJsonText = parseJsonText;
|
|
// See also `isExternalOrCommonJsModule` in utilities.ts
|
|
function isExternalModule(file) {
|
|
return file.externalModuleIndicator !== undefined;
|
|
}
|
|
ts.isExternalModule = isExternalModule;
|
|
// Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter
|
|
// indicates what changed between the 'text' that this SourceFile has and the 'newText'.
|
|
// The SourceFile will be created with the compiler attempting to reuse as many nodes from
|
|
// this file as possible.
|
|
//
|
|
// Note: this function mutates nodes from this SourceFile. That means any existing nodes
|
|
// from this SourceFile that are being held onto may change as a result (including
|
|
// becoming detached from any SourceFile). It is recommended that this SourceFile not
|
|
// be used once 'update' is called on it.
|
|
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
|
|
if (aggressiveChecks === void 0) { aggressiveChecks = false; }
|
|
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
// Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
|
|
// We will manually port the flag to the new source file.
|
|
newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */);
|
|
return newSourceFile;
|
|
}
|
|
ts.updateSourceFile = updateSourceFile;
|
|
/* @internal */
|
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
|
|
if (result && result.jsDoc) {
|
|
// because the jsDocComment was parsed out of the source file, it might
|
|
// not be covered by the fixupParentReferences.
|
|
Parser.fixupParentReferences(result.jsDoc);
|
|
}
|
|
return result;
|
|
}
|
|
ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
|
|
/* @internal */
|
|
// Exposed only for testing.
|
|
function parseJSDocTypeExpressionForTests(content, start, length) {
|
|
return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
|
|
}
|
|
ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
|
|
// Implement the parser as a singleton module. We do this for perf reasons because creating
|
|
// parser instances can actually be expensive enough to impact us on projects with many source
|
|
// files.
|
|
var Parser;
|
|
(function (Parser) {
|
|
// Share a single scanner across all calls to parse a source file. This helps speed things
|
|
// up by avoiding the cost of creating/compiling scanners over and over again.
|
|
var scanner = ts.createScanner(6 /* Latest */, /*skipTrivia*/ true);
|
|
var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */;
|
|
// capture constructors in 'initializeState' to avoid null checks
|
|
// tslint:disable variable-name
|
|
var NodeConstructor;
|
|
var TokenConstructor;
|
|
var IdentifierConstructor;
|
|
var SourceFileConstructor;
|
|
// tslint:enable variable-name
|
|
var sourceFile;
|
|
var parseDiagnostics;
|
|
var syntaxCursor;
|
|
var currentToken;
|
|
var sourceText;
|
|
var nodeCount;
|
|
var identifiers;
|
|
var identifierCount;
|
|
var parsingContext;
|
|
// Flags that dictate what parsing context we're in. For example:
|
|
// Whether or not we are in strict parsing mode. All that changes in strict parsing mode is
|
|
// that some tokens that would be considered identifiers may be considered keywords.
|
|
//
|
|
// When adding more parser context flags, consider which is the more common case that the
|
|
// flag will be in. This should be the 'false' state for that flag. The reason for this is
|
|
// that we don't store data in our nodes unless the value is in the *non-default* state. So,
|
|
// for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for
|
|
// 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost
|
|
// all nodes would need extra state on them to store this info.
|
|
//
|
|
// Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6
|
|
// grammar specification.
|
|
//
|
|
// An important thing about these context concepts. By default they are effectively inherited
|
|
// while parsing through every grammar production. i.e. if you don't change them, then when
|
|
// you parse a sub-production, it will have the same context values as the parent production.
|
|
// This is great most of the time. After all, consider all the 'expression' grammar productions
|
|
// and how nearly all of them pass along the 'in' and 'yield' context values:
|
|
//
|
|
// EqualityExpression[In, Yield] :
|
|
// RelationalExpression[?In, ?Yield]
|
|
// EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield]
|
|
// EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield]
|
|
// EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield]
|
|
// EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield]
|
|
//
|
|
// Where you have to be careful is then understanding what the points are in the grammar
|
|
// where the values are *not* passed along. For example:
|
|
//
|
|
// SingleNameBinding[Yield,GeneratorParameter]
|
|
// [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt
|
|
// [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt
|
|
//
|
|
// Here this is saying that if the GeneratorParameter context flag is set, that we should
|
|
// explicitly set the 'yield' context flag to false before calling into the BindingIdentifier
|
|
// and we should explicitly unset the 'yield' context flag before calling into the Initializer.
|
|
// production. Conversely, if the GeneratorParameter context flag is not set, then we
|
|
// should leave the 'yield' context flag alone.
|
|
//
|
|
// Getting this all correct is tricky and requires careful reading of the grammar to
|
|
// understand when these values should be changed versus when they should be inherited.
|
|
//
|
|
// Note: it should not be necessary to save/restore these flags during speculative/lookahead
|
|
// parsing. These context flags are naturally stored and restored through normal recursive
|
|
// descent parsing and unwinding.
|
|
var contextFlags;
|
|
// Whether or not we've had a parse error since creating the last AST node. If we have
|
|
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
|
// can be broken down into three categories:
|
|
//
|
|
// 1) An error that occurred during scanning. For example, an unterminated literal, or a
|
|
// character that was completely not understood.
|
|
//
|
|
// 2) A token was expected, but was not present. This type of error is commonly produced
|
|
// by the 'parseExpected' function.
|
|
//
|
|
// 3) A token was present that no parsing function was able to consume. This type of error
|
|
// only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser
|
|
// decides to skip the token.
|
|
//
|
|
// In all of these cases, we want to mark the next node as having had an error before it.
|
|
// With this mark, we can know in incremental settings if this node can be reused, or if
|
|
// we have to reparse it. If we don't keep this information around, we may just reuse the
|
|
// node. in that event we would then not produce the same errors as we did before, causing
|
|
// significant confusion problems.
|
|
//
|
|
// Note: it is necessary that this value be saved/restored during speculative/lookahead
|
|
// parsing. During lookahead parsing, we will often create a node. That node will have
|
|
// this value attached, and then this value will be set back to 'false'. If we decide to
|
|
// rewind, we must get back to the same value we had prior to the lookahead.
|
|
//
|
|
// Note: any errors at the end of the file that do not precede a regular node, should get
|
|
// attached to the EOF token.
|
|
var parseErrorBeforeNextFinishedNode = false;
|
|
function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
|
|
if (setParentNodes === void 0) { setParentNodes = false; }
|
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
if (scriptKind === 6 /* JSON */) {
|
|
var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
|
|
ts.convertToObjectWorker(result_1, result_1.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined);
|
|
result_1.typeReferenceDirectives = ts.emptyArray;
|
|
result_1.amdDependencies = ts.emptyArray;
|
|
return result_1;
|
|
}
|
|
initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
|
|
var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
|
|
clearState();
|
|
return result;
|
|
}
|
|
Parser.parseSourceFile = parseSourceFile;
|
|
function parseIsolatedEntityName(content, languageVersion) {
|
|
// Choice of `isDeclarationFile` should be arbitrary
|
|
initializeState(content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
// Prime the scanner.
|
|
nextToken();
|
|
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
clearState();
|
|
return isInvalid ? entityName : undefined;
|
|
}
|
|
Parser.parseIsolatedEntityName = parseIsolatedEntityName;
|
|
function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
|
|
if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; }
|
|
initializeState(sourceText, languageVersion, syntaxCursor, 6 /* JSON */);
|
|
// Set source file so that errors will be reported with this file name
|
|
sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false);
|
|
sourceFile.flags = contextFlags;
|
|
// Prime the scanner.
|
|
nextToken();
|
|
var pos = getNodePos();
|
|
if (token() === 1 /* EndOfFileToken */) {
|
|
sourceFile.statements = createNodeArray([], pos, pos);
|
|
sourceFile.endOfFileToken = parseTokenNode();
|
|
}
|
|
else {
|
|
var statement = createNode(216 /* ExpressionStatement */);
|
|
switch (token()) {
|
|
case 21 /* OpenBracketToken */:
|
|
statement.expression = parseArrayLiteralExpression();
|
|
break;
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
statement.expression = parseTokenNode();
|
|
break;
|
|
case 38 /* MinusToken */:
|
|
if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) {
|
|
statement.expression = parsePrefixUnaryExpression();
|
|
}
|
|
else {
|
|
statement.expression = parseObjectLiteralExpression();
|
|
}
|
|
break;
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) {
|
|
statement.expression = parseLiteralNode();
|
|
break;
|
|
}
|
|
// falls through
|
|
default:
|
|
statement.expression = parseObjectLiteralExpression();
|
|
break;
|
|
}
|
|
finishNode(statement);
|
|
sourceFile.statements = createNodeArray([statement], pos);
|
|
sourceFile.endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
|
|
}
|
|
if (setParentNodes) {
|
|
fixupParentReferences(sourceFile);
|
|
}
|
|
sourceFile.parseDiagnostics = parseDiagnostics;
|
|
var result = sourceFile;
|
|
clearState();
|
|
return result;
|
|
}
|
|
Parser.parseJsonText = parseJsonText;
|
|
function getLanguageVariant(scriptKind) {
|
|
// .tsx and .jsx files are treated as jsx language variant.
|
|
return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
|
|
}
|
|
function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) {
|
|
NodeConstructor = ts.objectAllocator.getNodeConstructor();
|
|
TokenConstructor = ts.objectAllocator.getTokenConstructor();
|
|
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
|
|
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
|
|
sourceText = _sourceText;
|
|
syntaxCursor = _syntaxCursor;
|
|
parseDiagnostics = [];
|
|
parsingContext = 0;
|
|
identifiers = ts.createMap();
|
|
identifierCount = 0;
|
|
nodeCount = 0;
|
|
switch (scriptKind) {
|
|
case 1 /* JS */:
|
|
case 2 /* JSX */:
|
|
contextFlags = 65536 /* JavaScriptFile */;
|
|
break;
|
|
case 6 /* JSON */:
|
|
contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */;
|
|
break;
|
|
default:
|
|
contextFlags = 0 /* None */;
|
|
break;
|
|
}
|
|
parseErrorBeforeNextFinishedNode = false;
|
|
// Initialize and prime the scanner before parsing the source elements.
|
|
scanner.setText(sourceText);
|
|
scanner.setOnError(scanError);
|
|
scanner.setScriptTarget(languageVersion);
|
|
scanner.setLanguageVariant(getLanguageVariant(scriptKind));
|
|
}
|
|
function clearState() {
|
|
// Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily.
|
|
scanner.setText("");
|
|
scanner.setOnError(undefined);
|
|
// Clear any data. We don't want to accidentally hold onto it for too long.
|
|
parseDiagnostics = undefined;
|
|
sourceFile = undefined;
|
|
identifiers = undefined;
|
|
syntaxCursor = undefined;
|
|
sourceText = undefined;
|
|
}
|
|
function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) {
|
|
var isDeclarationFile = isDeclarationFileName(fileName);
|
|
if (isDeclarationFile) {
|
|
contextFlags |= 4194304 /* Ambient */;
|
|
}
|
|
sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
|
|
sourceFile.flags = contextFlags;
|
|
// Prime the scanner.
|
|
nextToken();
|
|
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
|
processCommentPragmas(sourceFile, sourceText);
|
|
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
|
sourceFile.statements = parseList(0 /* SourceElements */, parseStatement);
|
|
ts.Debug.assert(token() === 1 /* EndOfFileToken */);
|
|
sourceFile.endOfFileToken = addJSDocComment(parseTokenNode());
|
|
setExternalModuleIndicator(sourceFile);
|
|
sourceFile.nodeCount = nodeCount;
|
|
sourceFile.identifierCount = identifierCount;
|
|
sourceFile.identifiers = identifiers;
|
|
sourceFile.parseDiagnostics = parseDiagnostics;
|
|
if (setParentNodes) {
|
|
fixupParentReferences(sourceFile);
|
|
}
|
|
return sourceFile;
|
|
function reportPragmaDiagnostic(pos, end, diagnostic) {
|
|
parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, pos, end, diagnostic));
|
|
}
|
|
}
|
|
function addJSDocComment(node) {
|
|
var comments = ts.getJSDocCommentRanges(node, sourceFile.text);
|
|
if (comments) {
|
|
for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) {
|
|
var comment = comments_2[_i];
|
|
node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function fixupParentReferences(rootNode) {
|
|
// normally parent references are set during binding. However, for clients that only need
|
|
// a syntax tree, and no semantic features, then the binding process is an unnecessary
|
|
// overhead. This functions allows us to set all the parents, without all the expense of
|
|
// binding.
|
|
var parent = rootNode;
|
|
forEachChild(rootNode, visitNode);
|
|
return;
|
|
function visitNode(n) {
|
|
// walk down setting parents that differ from the parent we think it should be. This
|
|
// allows us to quickly bail out of setting parents for subtrees during incremental
|
|
// parsing
|
|
if (n.parent !== parent) {
|
|
n.parent = parent;
|
|
var saveParent = parent;
|
|
parent = n;
|
|
forEachChild(n, visitNode);
|
|
if (ts.hasJSDocNodes(n)) {
|
|
for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) {
|
|
var jsDoc = _a[_i];
|
|
jsDoc.parent = n;
|
|
parent = jsDoc;
|
|
forEachChild(jsDoc, visitNode);
|
|
}
|
|
}
|
|
parent = saveParent;
|
|
}
|
|
}
|
|
}
|
|
Parser.fixupParentReferences = fixupParentReferences;
|
|
function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) {
|
|
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
|
|
// this is quite rare comparing to other nodes and createNode should be as fast as possible
|
|
var sourceFile = new SourceFileConstructor(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length);
|
|
nodeCount++;
|
|
sourceFile.text = sourceText;
|
|
sourceFile.bindDiagnostics = [];
|
|
sourceFile.bindSuggestionDiagnostics = undefined;
|
|
sourceFile.languageVersion = languageVersion;
|
|
sourceFile.fileName = ts.normalizePath(fileName);
|
|
sourceFile.languageVariant = getLanguageVariant(scriptKind);
|
|
sourceFile.isDeclarationFile = isDeclarationFile;
|
|
sourceFile.scriptKind = scriptKind;
|
|
return sourceFile;
|
|
}
|
|
function setContextFlag(val, flag) {
|
|
if (val) {
|
|
contextFlags |= flag;
|
|
}
|
|
else {
|
|
contextFlags &= ~flag;
|
|
}
|
|
}
|
|
function setDisallowInContext(val) {
|
|
setContextFlag(val, 2048 /* DisallowInContext */);
|
|
}
|
|
function setYieldContext(val) {
|
|
setContextFlag(val, 4096 /* YieldContext */);
|
|
}
|
|
function setDecoratorContext(val) {
|
|
setContextFlag(val, 8192 /* DecoratorContext */);
|
|
}
|
|
function setAwaitContext(val) {
|
|
setContextFlag(val, 16384 /* AwaitContext */);
|
|
}
|
|
function doOutsideOfContext(context, func) {
|
|
// contextFlagsToClear will contain only the context flags that are
|
|
// currently set that we need to temporarily clear
|
|
// We don't just blindly reset to the previous flags to ensure
|
|
// that we do not mutate cached flags for the incremental
|
|
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
|
// HasAggregatedChildData).
|
|
var contextFlagsToClear = context & contextFlags;
|
|
if (contextFlagsToClear) {
|
|
// clear the requested context flags
|
|
setContextFlag(/*val*/ false, contextFlagsToClear);
|
|
var result = func();
|
|
// restore the context flags we just cleared
|
|
setContextFlag(/*val*/ true, contextFlagsToClear);
|
|
return result;
|
|
}
|
|
// no need to do anything special as we are not in any of the requested contexts
|
|
return func();
|
|
}
|
|
function doInsideOfContext(context, func) {
|
|
// contextFlagsToSet will contain only the context flags that
|
|
// are not currently set that we need to temporarily enable.
|
|
// We don't just blindly reset to the previous flags to ensure
|
|
// that we do not mutate cached flags for the incremental
|
|
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
|
// HasAggregatedChildData).
|
|
var contextFlagsToSet = context & ~contextFlags;
|
|
if (contextFlagsToSet) {
|
|
// set the requested context flags
|
|
setContextFlag(/*val*/ true, contextFlagsToSet);
|
|
var result = func();
|
|
// reset the context flags we just set
|
|
setContextFlag(/*val*/ false, contextFlagsToSet);
|
|
return result;
|
|
}
|
|
// no need to do anything special as we are already in all of the requested contexts
|
|
return func();
|
|
}
|
|
function allowInAnd(func) {
|
|
return doOutsideOfContext(2048 /* DisallowInContext */, func);
|
|
}
|
|
function disallowInAnd(func) {
|
|
return doInsideOfContext(2048 /* DisallowInContext */, func);
|
|
}
|
|
function doInYieldContext(func) {
|
|
return doInsideOfContext(4096 /* YieldContext */, func);
|
|
}
|
|
function doInDecoratorContext(func) {
|
|
return doInsideOfContext(8192 /* DecoratorContext */, func);
|
|
}
|
|
function doInAwaitContext(func) {
|
|
return doInsideOfContext(16384 /* AwaitContext */, func);
|
|
}
|
|
function doOutsideOfAwaitContext(func) {
|
|
return doOutsideOfContext(16384 /* AwaitContext */, func);
|
|
}
|
|
function doInYieldAndAwaitContext(func) {
|
|
return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func);
|
|
}
|
|
function inContext(flags) {
|
|
return (contextFlags & flags) !== 0;
|
|
}
|
|
function inYieldContext() {
|
|
return inContext(4096 /* YieldContext */);
|
|
}
|
|
function inDisallowInContext() {
|
|
return inContext(2048 /* DisallowInContext */);
|
|
}
|
|
function inDecoratorContext() {
|
|
return inContext(8192 /* DecoratorContext */);
|
|
}
|
|
function inAwaitContext() {
|
|
return inContext(16384 /* AwaitContext */);
|
|
}
|
|
function parseErrorAtCurrentToken(message, arg0) {
|
|
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
|
|
}
|
|
function parseErrorAtPosition(start, length, message, arg0) {
|
|
// Don't report another error if it would just be at the same position as the last error.
|
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
if (!lastError || start !== lastError.start) {
|
|
parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0));
|
|
}
|
|
// Mark that we've encountered an error. We'll set an appropriate bit on the next
|
|
// node we finish so that it can't be reused incrementally.
|
|
parseErrorBeforeNextFinishedNode = true;
|
|
}
|
|
function parseErrorAt(start, end, message, arg0) {
|
|
parseErrorAtPosition(start, end - start, message, arg0);
|
|
}
|
|
function parseErrorAtRange(range, message, arg0) {
|
|
parseErrorAt(range.pos, range.end, message, arg0);
|
|
}
|
|
function scanError(message, length) {
|
|
parseErrorAtPosition(scanner.getTextPos(), length, message);
|
|
}
|
|
function getNodePos() {
|
|
return scanner.getStartPos();
|
|
}
|
|
// Use this function to access the current token instead of reading the currentToken
|
|
// variable. Since function results aren't narrowed in control flow analysis, this ensures
|
|
// that the type checker doesn't make wrong assumptions about the type of the current
|
|
// token (e.g. a call to nextToken() changes the current token but the checker doesn't
|
|
// reason about this side effect). Mainstream VMs inline simple functions like this, so
|
|
// there is no performance penalty.
|
|
function token() {
|
|
return currentToken;
|
|
}
|
|
function nextToken() {
|
|
return currentToken = scanner.scan();
|
|
}
|
|
function reScanGreaterToken() {
|
|
return currentToken = scanner.reScanGreaterToken();
|
|
}
|
|
function reScanSlashToken() {
|
|
return currentToken = scanner.reScanSlashToken();
|
|
}
|
|
function reScanTemplateToken() {
|
|
return currentToken = scanner.reScanTemplateToken();
|
|
}
|
|
function scanJsxIdentifier() {
|
|
return currentToken = scanner.scanJsxIdentifier();
|
|
}
|
|
function scanJsxText() {
|
|
return currentToken = scanner.scanJsxToken();
|
|
}
|
|
function scanJsxAttributeValue() {
|
|
return currentToken = scanner.scanJsxAttributeValue();
|
|
}
|
|
function speculationHelper(callback, isLookAhead) {
|
|
// Keep track of the state we'll need to rollback to if lookahead fails (or if the
|
|
// caller asked us to always reset our state).
|
|
var saveToken = currentToken;
|
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
// Note: it is not actually necessary to save/restore the context flags here. That's
|
|
// because the saving/restoring of these flags happens naturally through the recursive
|
|
// descent nature of our parser. However, we still store this here just so we can
|
|
// assert that invariant holds.
|
|
var saveContextFlags = contextFlags;
|
|
// If we're only looking ahead, then tell the scanner to only lookahead as well.
|
|
// Otherwise, if we're actually speculatively parsing, then tell the scanner to do the
|
|
// same.
|
|
var result = isLookAhead
|
|
? scanner.lookAhead(callback)
|
|
: scanner.tryScan(callback);
|
|
ts.Debug.assert(saveContextFlags === contextFlags);
|
|
// If our callback returned something 'falsy' or we're just looking ahead,
|
|
// then unconditionally restore us to where we were.
|
|
if (!result || isLookAhead) {
|
|
currentToken = saveToken;
|
|
parseDiagnostics.length = saveParseDiagnosticsLength;
|
|
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
|
|
}
|
|
return result;
|
|
}
|
|
/** Invokes the provided callback then unconditionally restores the parser to the state it
|
|
* was in immediately prior to invoking the callback. The result of invoking the callback
|
|
* is returned from this function.
|
|
*/
|
|
function lookAhead(callback) {
|
|
return speculationHelper(callback, /*isLookAhead*/ true);
|
|
}
|
|
/** Invokes the provided callback. If the callback returns something falsy, then it restores
|
|
* the parser to the state it was in immediately prior to invoking the callback. If the
|
|
* callback returns something truthy, then the parser state is not rolled back. The result
|
|
* of invoking the callback is returned from this function.
|
|
*/
|
|
function tryParse(callback) {
|
|
return speculationHelper(callback, /*isLookAhead*/ false);
|
|
}
|
|
// Ignore strict mode flag because we will report an error in type checker instead.
|
|
function isIdentifier() {
|
|
if (token() === 71 /* Identifier */) {
|
|
return true;
|
|
}
|
|
// If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is
|
|
// considered a keyword and is not an identifier.
|
|
if (token() === 116 /* YieldKeyword */ && inYieldContext()) {
|
|
return false;
|
|
}
|
|
// If we have a 'await' keyword, and we're in the [Await] context, then 'await' is
|
|
// considered a keyword and is not an identifier.
|
|
if (token() === 121 /* AwaitKeyword */ && inAwaitContext()) {
|
|
return false;
|
|
}
|
|
return token() > 107 /* LastReservedWord */;
|
|
}
|
|
function parseExpected(kind, diagnosticMessage, shouldAdvance) {
|
|
if (shouldAdvance === void 0) { shouldAdvance = true; }
|
|
if (token() === kind) {
|
|
if (shouldAdvance) {
|
|
nextToken();
|
|
}
|
|
return true;
|
|
}
|
|
// Report specific message if provided with one. Otherwise, report generic fallback message.
|
|
if (diagnosticMessage) {
|
|
parseErrorAtCurrentToken(diagnosticMessage);
|
|
}
|
|
else {
|
|
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
|
|
}
|
|
return false;
|
|
}
|
|
function parseOptional(t) {
|
|
if (token() === t) {
|
|
nextToken();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function parseOptionalToken(t) {
|
|
if (token() === t) {
|
|
return parseTokenNode();
|
|
}
|
|
return undefined;
|
|
}
|
|
function parseExpectedToken(t, diagnosticMessage, arg0) {
|
|
return parseOptionalToken(t) ||
|
|
createMissingNode(t, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
|
|
}
|
|
function parseTokenNode() {
|
|
var node = createNode(token());
|
|
nextToken();
|
|
return finishNode(node);
|
|
}
|
|
function canParseSemicolon() {
|
|
// If there's a real semicolon, then we can always parse it out.
|
|
if (token() === 25 /* SemicolonToken */) {
|
|
return true;
|
|
}
|
|
// We can parse out an optional semicolon in ASI cases in the following cases.
|
|
return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak();
|
|
}
|
|
function parseSemicolon() {
|
|
if (canParseSemicolon()) {
|
|
if (token() === 25 /* SemicolonToken */) {
|
|
// consume the semicolon if it was explicitly provided.
|
|
nextToken();
|
|
}
|
|
return true;
|
|
}
|
|
else {
|
|
return parseExpected(25 /* SemicolonToken */);
|
|
}
|
|
}
|
|
function createNode(kind, pos) {
|
|
nodeCount++;
|
|
var p = pos >= 0 ? pos : scanner.getStartPos();
|
|
return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) :
|
|
kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) :
|
|
new TokenConstructor(kind, p, p);
|
|
}
|
|
function createNodeWithJSDoc(kind, pos) {
|
|
var node = createNode(kind, pos);
|
|
if (scanner.getTokenFlags() & 2 /* PrecedingJSDocComment */) {
|
|
addJSDocComment(node);
|
|
}
|
|
return node;
|
|
}
|
|
function createNodeArray(elements, pos, end) {
|
|
// Since the element list of a node array is typically created by starting with an empty array and
|
|
// repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for
|
|
// small arrays (1 to 4 elements) to give the VM a chance to allocate an optimal representation.
|
|
var length = elements.length;
|
|
var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
|
|
array.pos = pos;
|
|
array.end = end === undefined ? scanner.getStartPos() : end;
|
|
return array;
|
|
}
|
|
function finishNode(node, end) {
|
|
node.end = end === undefined ? scanner.getStartPos() : end;
|
|
if (contextFlags) {
|
|
node.flags |= contextFlags;
|
|
}
|
|
// Keep track on the node if we encountered an error while parsing it. If we did, then
|
|
// we cannot reuse the node incrementally. Once we've marked this node, clear out the
|
|
// flag so that we don't mark any subsequent nodes.
|
|
if (parseErrorBeforeNextFinishedNode) {
|
|
parseErrorBeforeNextFinishedNode = false;
|
|
node.flags |= 32768 /* ThisNodeHasError */;
|
|
}
|
|
return node;
|
|
}
|
|
function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
|
|
if (reportAtCurrentPosition) {
|
|
parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
|
|
}
|
|
else if (diagnosticMessage) {
|
|
parseErrorAtCurrentToken(diagnosticMessage, arg0);
|
|
}
|
|
var result = createNode(kind);
|
|
if (kind === 71 /* Identifier */) {
|
|
result.escapedText = "";
|
|
}
|
|
else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) {
|
|
result.text = "";
|
|
}
|
|
return finishNode(result);
|
|
}
|
|
function internIdentifier(text) {
|
|
var identifier = identifiers.get(text);
|
|
if (identifier === undefined) {
|
|
identifiers.set(text, identifier = text);
|
|
}
|
|
return identifier;
|
|
}
|
|
// An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues
|
|
// with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for
|
|
// each identifier in order to reduce memory consumption.
|
|
function createIdentifier(isIdentifier, diagnosticMessage) {
|
|
identifierCount++;
|
|
if (isIdentifier) {
|
|
var node = createNode(71 /* Identifier */);
|
|
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
|
if (token() !== 71 /* Identifier */) {
|
|
node.originalKeywordKind = token();
|
|
}
|
|
node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
|
|
nextToken();
|
|
return finishNode(node);
|
|
}
|
|
// Only for end of file because the error gets reported incorrectly on embedded script tags.
|
|
var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */;
|
|
return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected);
|
|
}
|
|
function parseIdentifier(diagnosticMessage) {
|
|
return createIdentifier(isIdentifier(), diagnosticMessage);
|
|
}
|
|
function parseIdentifierName(diagnosticMessage) {
|
|
return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
|
|
}
|
|
function isLiteralPropertyName() {
|
|
return ts.tokenIsIdentifierOrKeyword(token()) ||
|
|
token() === 9 /* StringLiteral */ ||
|
|
token() === 8 /* NumericLiteral */;
|
|
}
|
|
function parsePropertyNameWorker(allowComputedPropertyNames) {
|
|
if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) {
|
|
var node = parseLiteralNode();
|
|
node.text = internIdentifier(node.text);
|
|
return node;
|
|
}
|
|
if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) {
|
|
return parseComputedPropertyName();
|
|
}
|
|
return parseIdentifierName();
|
|
}
|
|
function parsePropertyName() {
|
|
return parsePropertyNameWorker(/*allowComputedPropertyNames*/ true);
|
|
}
|
|
function parseComputedPropertyName() {
|
|
// PropertyName [Yield]:
|
|
// LiteralPropertyName
|
|
// ComputedPropertyName[?Yield]
|
|
var node = createNode(147 /* ComputedPropertyName */);
|
|
parseExpected(21 /* OpenBracketToken */);
|
|
// We parse any expression (including a comma expression). But the grammar
|
|
// says that only an assignment expression is allowed, so the grammar checker
|
|
// will error if it sees a comma expression.
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseContextualModifier(t) {
|
|
return token() === t && tryParse(nextTokenCanFollowModifier);
|
|
}
|
|
function nextTokenIsOnSameLineAndCanFollowModifier() {
|
|
nextToken();
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
return false;
|
|
}
|
|
return canFollowModifier();
|
|
}
|
|
function nextTokenCanFollowModifier() {
|
|
switch (token()) {
|
|
case 76 /* ConstKeyword */:
|
|
// 'const' is only a modifier if followed by 'enum'.
|
|
return nextToken() === 83 /* EnumKeyword */;
|
|
case 84 /* ExportKeyword */:
|
|
nextToken();
|
|
if (token() === 79 /* DefaultKeyword */) {
|
|
return lookAhead(nextTokenCanFollowDefaultKeyword);
|
|
}
|
|
return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier();
|
|
case 79 /* DefaultKeyword */:
|
|
return nextTokenCanFollowDefaultKeyword();
|
|
case 115 /* StaticKeyword */:
|
|
case 125 /* GetKeyword */:
|
|
case 136 /* SetKeyword */:
|
|
nextToken();
|
|
return canFollowModifier();
|
|
default:
|
|
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
}
|
|
}
|
|
function parseAnyContextualModifier() {
|
|
return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
|
|
}
|
|
function canFollowModifier() {
|
|
return token() === 21 /* OpenBracketToken */
|
|
|| token() === 17 /* OpenBraceToken */
|
|
|| token() === 39 /* AsteriskToken */
|
|
|| token() === 24 /* DotDotDotToken */
|
|
|| isLiteralPropertyName();
|
|
}
|
|
function nextTokenCanFollowDefaultKeyword() {
|
|
nextToken();
|
|
return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ ||
|
|
token() === 109 /* InterfaceKeyword */ ||
|
|
(token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
|
|
(token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
|
|
}
|
|
// True if positioned at the start of a list element
|
|
function isListElement(parsingContext, inErrorRecovery) {
|
|
var node = currentNode(parsingContext);
|
|
if (node) {
|
|
return true;
|
|
}
|
|
switch (parsingContext) {
|
|
case 0 /* SourceElements */:
|
|
case 1 /* BlockStatements */:
|
|
case 3 /* SwitchClauseStatements */:
|
|
// If we're in error recovery, then we don't want to treat ';' as an empty statement.
|
|
// The problem is that ';' can show up in far too many contexts, and if we see one
|
|
// and assume it's a statement, then we may bail out inappropriately from whatever
|
|
// we're parsing. For example, if we have a semicolon in the middle of a class, then
|
|
// we really don't want to assume the class is over and we're on a statement in the
|
|
// outer module. We just want to consume and move on.
|
|
return !(token() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement();
|
|
case 2 /* SwitchClauses */:
|
|
return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */;
|
|
case 4 /* TypeMembers */:
|
|
return lookAhead(isTypeMemberStart);
|
|
case 5 /* ClassMembers */:
|
|
// We allow semicolons as class elements (as specified by ES6) as long as we're
|
|
// not in error recovery. If we're in error recovery, we don't want an errant
|
|
// semicolon to be treated as a class member (since they're almost always used
|
|
// for statements.
|
|
return lookAhead(isClassMemberStart) || (token() === 25 /* SemicolonToken */ && !inErrorRecovery);
|
|
case 6 /* EnumMembers */:
|
|
// Include open bracket computed properties. This technically also lets in indexers,
|
|
// which would be a candidate for improved error reporting.
|
|
return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName();
|
|
case 12 /* ObjectLiteralMembers */:
|
|
return token() === 21 /* OpenBracketToken */ || token() === 39 /* AsteriskToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName();
|
|
case 17 /* RestProperties */:
|
|
return isLiteralPropertyName();
|
|
case 9 /* ObjectBindingElements */:
|
|
return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName();
|
|
case 7 /* HeritageClauseElement */:
|
|
// If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{`
|
|
// That way we won't consume the body of a class in its heritage clause.
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
return lookAhead(isValidHeritageClauseObjectLiteral);
|
|
}
|
|
if (!inErrorRecovery) {
|
|
return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
|
|
}
|
|
else {
|
|
// If we're in error recovery we tighten up what we're willing to match.
|
|
// That way we don't treat something like "this" as a valid heritage clause
|
|
// element during recovery.
|
|
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
|
}
|
|
case 8 /* VariableDeclarations */:
|
|
return isIdentifierOrPattern();
|
|
case 10 /* ArrayBindingElements */:
|
|
return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern();
|
|
case 18 /* TypeParameters */:
|
|
return isIdentifier();
|
|
case 15 /* ArrayLiteralMembers */:
|
|
if (token() === 26 /* CommaToken */) {
|
|
return true;
|
|
}
|
|
// falls through
|
|
case 11 /* ArgumentExpressions */:
|
|
return token() === 24 /* DotDotDotToken */ || isStartOfExpression();
|
|
case 16 /* Parameters */:
|
|
return isStartOfParameter();
|
|
case 19 /* TypeArguments */:
|
|
case 20 /* TupleElementTypes */:
|
|
return token() === 26 /* CommaToken */ || isStartOfType();
|
|
case 21 /* HeritageClauses */:
|
|
return isHeritageClause();
|
|
case 22 /* ImportOrExportSpecifiers */:
|
|
return ts.tokenIsIdentifierOrKeyword(token());
|
|
case 13 /* JsxAttributes */:
|
|
return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */;
|
|
case 14 /* JsxChildren */:
|
|
return true;
|
|
}
|
|
return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
|
|
}
|
|
function isValidHeritageClauseObjectLiteral() {
|
|
ts.Debug.assert(token() === 17 /* OpenBraceToken */);
|
|
if (nextToken() === 18 /* CloseBraceToken */) {
|
|
// if we see "extends {}" then only treat the {} as what we're extending (and not
|
|
// the class body) if we have:
|
|
//
|
|
// extends {} {
|
|
// extends {},
|
|
// extends {} extends
|
|
// extends {} implements
|
|
var next = nextToken();
|
|
return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */;
|
|
}
|
|
return true;
|
|
}
|
|
function nextTokenIsIdentifier() {
|
|
nextToken();
|
|
return isIdentifier();
|
|
}
|
|
function nextTokenIsIdentifierOrKeyword() {
|
|
nextToken();
|
|
return ts.tokenIsIdentifierOrKeyword(token());
|
|
}
|
|
function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
|
|
nextToken();
|
|
return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
|
|
}
|
|
function isHeritageClauseExtendsOrImplementsKeyword() {
|
|
if (token() === 108 /* ImplementsKeyword */ ||
|
|
token() === 85 /* ExtendsKeyword */) {
|
|
return lookAhead(nextTokenIsStartOfExpression);
|
|
}
|
|
return false;
|
|
}
|
|
function nextTokenIsStartOfExpression() {
|
|
nextToken();
|
|
return isStartOfExpression();
|
|
}
|
|
function nextTokenIsStartOfType() {
|
|
nextToken();
|
|
return isStartOfType();
|
|
}
|
|
// True if positioned at a list terminator
|
|
function isListTerminator(kind) {
|
|
if (token() === 1 /* EndOfFileToken */) {
|
|
// Being at the end of the file ends all lists.
|
|
return true;
|
|
}
|
|
switch (kind) {
|
|
case 1 /* BlockStatements */:
|
|
case 2 /* SwitchClauses */:
|
|
case 4 /* TypeMembers */:
|
|
case 5 /* ClassMembers */:
|
|
case 6 /* EnumMembers */:
|
|
case 12 /* ObjectLiteralMembers */:
|
|
case 9 /* ObjectBindingElements */:
|
|
case 22 /* ImportOrExportSpecifiers */:
|
|
return token() === 18 /* CloseBraceToken */;
|
|
case 3 /* SwitchClauseStatements */:
|
|
return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */;
|
|
case 7 /* HeritageClauseElement */:
|
|
return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */;
|
|
case 8 /* VariableDeclarations */:
|
|
return isVariableDeclaratorListTerminator();
|
|
case 18 /* TypeParameters */:
|
|
// Tokens other than '>' are here for better error recovery
|
|
return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */;
|
|
case 11 /* ArgumentExpressions */:
|
|
// Tokens other than ')' are here for better error recovery
|
|
return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */;
|
|
case 15 /* ArrayLiteralMembers */:
|
|
case 20 /* TupleElementTypes */:
|
|
case 10 /* ArrayBindingElements */:
|
|
return token() === 22 /* CloseBracketToken */;
|
|
case 16 /* Parameters */:
|
|
case 17 /* RestProperties */:
|
|
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery
|
|
return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/;
|
|
case 19 /* TypeArguments */:
|
|
// All other tokens should cause the type-argument to terminate except comma token
|
|
return token() !== 26 /* CommaToken */;
|
|
case 21 /* HeritageClauses */:
|
|
return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */;
|
|
case 13 /* JsxAttributes */:
|
|
return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */;
|
|
case 14 /* JsxChildren */:
|
|
return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash);
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function isVariableDeclaratorListTerminator() {
|
|
// If we can consume a semicolon (either explicitly, or with ASI), then consider us done
|
|
// with parsing the list of variable declarators.
|
|
if (canParseSemicolon()) {
|
|
return true;
|
|
}
|
|
// in the case where we're parsing the variable declarator of a 'for-in' statement, we
|
|
// are done if we see an 'in' keyword in front of us. Same with for-of
|
|
if (isInOrOfKeyword(token())) {
|
|
return true;
|
|
}
|
|
// ERROR RECOVERY TWEAK:
|
|
// For better error recovery, if we see an '=>' then we just stop immediately. We've got an
|
|
// arrow function here and it's going to be very unlikely that we'll resynchronize and get
|
|
// another variable declaration.
|
|
if (token() === 36 /* EqualsGreaterThanToken */) {
|
|
return true;
|
|
}
|
|
// Keep trying to parse out variable declarators.
|
|
return false;
|
|
}
|
|
// True if positioned at element or terminator of the current list or any enclosing list
|
|
function isInSomeParsingContext() {
|
|
for (var kind = 0; kind < 23 /* Count */; kind++) {
|
|
if (parsingContext & (1 << kind)) {
|
|
if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
// Parses a list of elements
|
|
function parseList(kind, parseElement) {
|
|
var saveParsingContext = parsingContext;
|
|
parsingContext |= 1 << kind;
|
|
var list = [];
|
|
var listPos = getNodePos();
|
|
while (!isListTerminator(kind)) {
|
|
if (isListElement(kind, /*inErrorRecovery*/ false)) {
|
|
var element = parseListElement(kind, parseElement);
|
|
list.push(element);
|
|
continue;
|
|
}
|
|
if (abortParsingListOrMoveToNextToken(kind)) {
|
|
break;
|
|
}
|
|
}
|
|
parsingContext = saveParsingContext;
|
|
return createNodeArray(list, listPos);
|
|
}
|
|
function parseListElement(parsingContext, parseElement) {
|
|
var node = currentNode(parsingContext);
|
|
if (node) {
|
|
return consumeNode(node);
|
|
}
|
|
return parseElement();
|
|
}
|
|
function currentNode(parsingContext) {
|
|
// If there is an outstanding parse error that we've encountered, but not attached to
|
|
// some node, then we cannot get a node from the old source tree. This is because we
|
|
// want to mark the next node we encounter as being unusable.
|
|
//
|
|
// Note: This may be too conservative. Perhaps we could reuse the node and set the bit
|
|
// on it (or its leftmost child) as having the error. For now though, being conservative
|
|
// is nice and likely won't ever affect perf.
|
|
if (parseErrorBeforeNextFinishedNode) {
|
|
return undefined;
|
|
}
|
|
if (!syntaxCursor) {
|
|
// if we don't have a cursor, we could never return a node from the old tree.
|
|
return undefined;
|
|
}
|
|
var node = syntaxCursor.currentNode(scanner.getStartPos());
|
|
// Can't reuse a missing node.
|
|
if (ts.nodeIsMissing(node)) {
|
|
return undefined;
|
|
}
|
|
// Can't reuse a node that intersected the change range.
|
|
if (node.intersectsChange) {
|
|
return undefined;
|
|
}
|
|
// Can't reuse a node that contains a parse error. This is necessary so that we
|
|
// produce the same set of errors again.
|
|
if (ts.containsParseError(node)) {
|
|
return undefined;
|
|
}
|
|
// We can only reuse a node if it was parsed under the same strict mode that we're
|
|
// currently in. i.e. if we originally parsed a node in non-strict mode, but then
|
|
// the user added 'using strict' at the top of the file, then we can't use that node
|
|
// again as the presence of strict mode may cause us to parse the tokens in the file
|
|
// differently.
|
|
//
|
|
// Note: we *can* reuse tokens when the strict mode changes. That's because tokens
|
|
// are unaffected by strict mode. It's just the parser will decide what to do with it
|
|
// differently depending on what mode it is in.
|
|
//
|
|
// This also applies to all our other context flags as well.
|
|
var nodeContextFlags = node.flags & 12679168 /* ContextFlags */;
|
|
if (nodeContextFlags !== contextFlags) {
|
|
return undefined;
|
|
}
|
|
// Ok, we have a node that looks like it could be reused. Now verify that it is valid
|
|
// in the current list parsing context that we're currently at.
|
|
if (!canReuseNode(node, parsingContext)) {
|
|
return undefined;
|
|
}
|
|
if (node.jsDocCache) {
|
|
// jsDocCache may include tags from parent nodes, which might have been modified.
|
|
node.jsDocCache = undefined;
|
|
}
|
|
return node;
|
|
}
|
|
function consumeNode(node) {
|
|
// Move the scanner so it is after the node we just consumed.
|
|
scanner.setTextPos(node.end);
|
|
nextToken();
|
|
return node;
|
|
}
|
|
function canReuseNode(node, parsingContext) {
|
|
switch (parsingContext) {
|
|
case 5 /* ClassMembers */:
|
|
return isReusableClassMember(node);
|
|
case 2 /* SwitchClauses */:
|
|
return isReusableSwitchClause(node);
|
|
case 0 /* SourceElements */:
|
|
case 1 /* BlockStatements */:
|
|
case 3 /* SwitchClauseStatements */:
|
|
return isReusableStatement(node);
|
|
case 6 /* EnumMembers */:
|
|
return isReusableEnumMember(node);
|
|
case 4 /* TypeMembers */:
|
|
return isReusableTypeMember(node);
|
|
case 8 /* VariableDeclarations */:
|
|
return isReusableVariableDeclaration(node);
|
|
case 16 /* Parameters */:
|
|
return isReusableParameter(node);
|
|
case 17 /* RestProperties */:
|
|
return false;
|
|
// Any other lists we do not care about reusing nodes in. But feel free to add if
|
|
// you can do so safely. Danger areas involve nodes that may involve speculative
|
|
// parsing. If speculative parsing is involved with the node, then the range the
|
|
// parser reached while looking ahead might be in the edited range (see the example
|
|
// in canReuseVariableDeclaratorNode for a good case of this).
|
|
case 21 /* HeritageClauses */:
|
|
// This would probably be safe to reuse. There is no speculative parsing with
|
|
// heritage clauses.
|
|
case 18 /* TypeParameters */:
|
|
// This would probably be safe to reuse. There is no speculative parsing with
|
|
// type parameters. Note that that's because type *parameters* only occur in
|
|
// unambiguous *type* contexts. While type *arguments* occur in very ambiguous
|
|
// *expression* contexts.
|
|
case 20 /* TupleElementTypes */:
|
|
// This would probably be safe to reuse. There is no speculative parsing with
|
|
// tuple types.
|
|
// Technically, type argument list types are probably safe to reuse. While
|
|
// speculative parsing is involved with them (since type argument lists are only
|
|
// produced from speculative parsing a < as a type argument list), we only have
|
|
// the types because speculative parsing succeeded. Thus, the lookahead never
|
|
// went past the end of the list and rewound.
|
|
case 19 /* TypeArguments */:
|
|
// Note: these are almost certainly not safe to ever reuse. Expressions commonly
|
|
// need a large amount of lookahead, and we should not reuse them as they may
|
|
// have actually intersected the edit.
|
|
case 11 /* ArgumentExpressions */:
|
|
// This is not safe to reuse for the same reason as the 'AssignmentExpression'
|
|
// cases. i.e. a property assignment may end with an expression, and thus might
|
|
// have lookahead far beyond it's old node.
|
|
case 12 /* ObjectLiteralMembers */:
|
|
// This is probably not safe to reuse. There can be speculative parsing with
|
|
// type names in a heritage clause. There can be generic names in the type
|
|
// name list, and there can be left hand side expressions (which can have type
|
|
// arguments.)
|
|
case 7 /* HeritageClauseElement */:
|
|
// Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes
|
|
// on any given element. Same for children.
|
|
case 13 /* JsxAttributes */:
|
|
case 14 /* JsxChildren */:
|
|
}
|
|
return false;
|
|
}
|
|
function isReusableClassMember(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 155 /* Constructor */:
|
|
case 160 /* IndexSignature */:
|
|
case 156 /* GetAccessor */:
|
|
case 157 /* SetAccessor */:
|
|
case 152 /* PropertyDeclaration */:
|
|
case 212 /* SemicolonClassElement */:
|
|
return true;
|
|
case 154 /* MethodDeclaration */:
|
|
// Method declarations are not necessarily reusable. An object-literal
|
|
// may have a method calls "constructor(...)" and we must reparse that
|
|
// into an actual .ConstructorDeclaration.
|
|
var methodDeclaration = node;
|
|
var nameIsConstructor = methodDeclaration.name.kind === 71 /* Identifier */ &&
|
|
methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */;
|
|
return !nameIsConstructor;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function isReusableSwitchClause(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 266 /* CaseClause */:
|
|
case 267 /* DefaultClause */:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function isReusableStatement(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 234 /* FunctionDeclaration */:
|
|
case 214 /* VariableStatement */:
|
|
case 213 /* Block */:
|
|
case 217 /* IfStatement */:
|
|
case 216 /* ExpressionStatement */:
|
|
case 229 /* ThrowStatement */:
|
|
case 225 /* ReturnStatement */:
|
|
case 227 /* SwitchStatement */:
|
|
case 224 /* BreakStatement */:
|
|
case 223 /* ContinueStatement */:
|
|
case 221 /* ForInStatement */:
|
|
case 222 /* ForOfStatement */:
|
|
case 220 /* ForStatement */:
|
|
case 219 /* WhileStatement */:
|
|
case 226 /* WithStatement */:
|
|
case 215 /* EmptyStatement */:
|
|
case 230 /* TryStatement */:
|
|
case 228 /* LabeledStatement */:
|
|
case 218 /* DoStatement */:
|
|
case 231 /* DebuggerStatement */:
|
|
case 244 /* ImportDeclaration */:
|
|
case 243 /* ImportEqualsDeclaration */:
|
|
case 250 /* ExportDeclaration */:
|
|
case 249 /* ExportAssignment */:
|
|
case 239 /* ModuleDeclaration */:
|
|
case 235 /* ClassDeclaration */:
|
|
case 236 /* InterfaceDeclaration */:
|
|
case 238 /* EnumDeclaration */:
|
|
case 237 /* TypeAliasDeclaration */:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function isReusableEnumMember(node) {
|
|
return node.kind === 273 /* EnumMember */;
|
|
}
|
|
function isReusableTypeMember(node) {
|
|
if (node) {
|
|
switch (node.kind) {
|
|
case 159 /* ConstructSignature */:
|
|
case 153 /* MethodSignature */:
|
|
case 160 /* IndexSignature */:
|
|
case 151 /* PropertySignature */:
|
|
case 158 /* CallSignature */:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function isReusableVariableDeclaration(node) {
|
|
if (node.kind !== 232 /* VariableDeclaration */) {
|
|
return false;
|
|
}
|
|
// Very subtle incremental parsing bug. Consider the following code:
|
|
//
|
|
// let v = new List < A, B
|
|
//
|
|
// This is actually legal code. It's a list of variable declarators "v = new List<A"
|
|
// on one side and "B" on the other. If you then change that to:
|
|
//
|
|
// let v = new List < A, B >()
|
|
//
|
|
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we
|
|
// start reparsing at "B" and we completely fail to handle this properly.
|
|
//
|
|
// In order to prevent this, we do not allow a variable declarator to be reused if it
|
|
// has an initializer.
|
|
var variableDeclarator = node;
|
|
return variableDeclarator.initializer === undefined;
|
|
}
|
|
function isReusableParameter(node) {
|
|
if (node.kind !== 149 /* Parameter */) {
|
|
return false;
|
|
}
|
|
// See the comment in isReusableVariableDeclaration for why we do this.
|
|
var parameter = node;
|
|
return parameter.initializer === undefined;
|
|
}
|
|
// Returns true if we should abort parsing.
|
|
function abortParsingListOrMoveToNextToken(kind) {
|
|
parseErrorAtCurrentToken(parsingContextErrors(kind));
|
|
if (isInSomeParsingContext()) {
|
|
return true;
|
|
}
|
|
nextToken();
|
|
return false;
|
|
}
|
|
function parsingContextErrors(context) {
|
|
switch (context) {
|
|
case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected;
|
|
case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected;
|
|
case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected;
|
|
case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected;
|
|
case 17 /* RestProperties */: // fallthrough
|
|
case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected;
|
|
case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
|
|
case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected;
|
|
case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected;
|
|
case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected;
|
|
case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected;
|
|
case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected;
|
|
case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected;
|
|
case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected;
|
|
case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected;
|
|
case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected;
|
|
case 18 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected;
|
|
case 19 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected;
|
|
case 20 /* TupleElementTypes */: return ts.Diagnostics.Type_expected;
|
|
case 21 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected;
|
|
case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected;
|
|
case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected;
|
|
case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected;
|
|
default: return undefined; // TODO: GH#18217 `default: Debug.assertNever(context);`
|
|
}
|
|
}
|
|
// Parses a comma-delimited list of elements
|
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
var saveParsingContext = parsingContext;
|
|
parsingContext |= 1 << kind;
|
|
var list = [];
|
|
var listPos = getNodePos();
|
|
var commaStart = -1; // Meaning the previous token was not a comma
|
|
while (true) {
|
|
if (isListElement(kind, /*inErrorRecovery*/ false)) {
|
|
var startPos = scanner.getStartPos();
|
|
list.push(parseListElement(kind, parseElement));
|
|
commaStart = scanner.getTokenPos();
|
|
if (parseOptional(26 /* CommaToken */)) {
|
|
// No need to check for a zero length node since we know we parsed a comma
|
|
continue;
|
|
}
|
|
commaStart = -1; // Back to the state where the last token was not a comma
|
|
if (isListTerminator(kind)) {
|
|
break;
|
|
}
|
|
// We didn't get a comma, and the list wasn't terminated, explicitly parse
|
|
// out a comma so we give a good error message.
|
|
parseExpected(26 /* CommaToken */);
|
|
// If the token was a semicolon, and the caller allows that, then skip it and
|
|
// continue. This ensures we get back on track and don't result in tons of
|
|
// parse errors. For example, this can happen when people do things like use
|
|
// a semicolon to delimit object literal members. Note: we'll have already
|
|
// reported an error when we called parseExpected above.
|
|
if (considerSemicolonAsDelimiter && token() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
nextToken();
|
|
}
|
|
if (startPos === scanner.getStartPos()) {
|
|
// What we're parsing isn't actually remotely recognizable as a element and we've consumed no tokens whatsoever
|
|
// Consume a token to advance the parser in some way and avoid an infinite loop
|
|
// This can happen when we're speculatively parsing parenthesized expressions which we think may be arrow functions,
|
|
// or when a modifier keyword which is disallowed as a parameter name (ie, `static` in strict mode) is supplied
|
|
nextToken();
|
|
}
|
|
continue;
|
|
}
|
|
if (isListTerminator(kind)) {
|
|
break;
|
|
}
|
|
if (abortParsingListOrMoveToNextToken(kind)) {
|
|
break;
|
|
}
|
|
}
|
|
parsingContext = saveParsingContext;
|
|
var result = createNodeArray(list, listPos);
|
|
// Recording the trailing comma is deliberately done after the previous
|
|
// loop, and not just if we see a list terminator. This is because the list
|
|
// may have ended incorrectly, but it is still important to know if there
|
|
// was a trailing comma.
|
|
// Check if the last token was a comma.
|
|
if (commaStart >= 0) {
|
|
// Always preserve a trailing comma by marking it on the NodeArray
|
|
result.hasTrailingComma = true;
|
|
}
|
|
return result;
|
|
}
|
|
function createMissingList() {
|
|
return createNodeArray([], getNodePos());
|
|
}
|
|
function parseBracketedList(kind, parseElement, open, close) {
|
|
if (parseExpected(open)) {
|
|
var result = parseDelimitedList(kind, parseElement);
|
|
parseExpected(close);
|
|
return result;
|
|
}
|
|
return createMissingList();
|
|
}
|
|
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
var dotPos = scanner.getStartPos();
|
|
while (parseOptional(23 /* DotToken */)) {
|
|
if (token() === 27 /* LessThanToken */) {
|
|
// the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting
|
|
entity.jsdocDotPos = dotPos;
|
|
break;
|
|
}
|
|
dotPos = scanner.getStartPos();
|
|
entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords));
|
|
}
|
|
return entity;
|
|
}
|
|
function createQualifiedName(entity, name) {
|
|
var node = createNode(146 /* QualifiedName */, entity.pos);
|
|
node.left = entity;
|
|
node.right = name;
|
|
return finishNode(node);
|
|
}
|
|
function parseRightSideOfDot(allowIdentifierNames) {
|
|
// Technically a keyword is valid here as all identifiers and keywords are identifier names.
|
|
// However, often we'll encounter this in error situations when the identifier or keyword
|
|
// is actually starting another valid construct.
|
|
//
|
|
// So, we check for the following specific case:
|
|
//
|
|
// name.
|
|
// identifierOrKeyword identifierNameOrKeyword
|
|
//
|
|
// Note: the newlines are important here. For example, if that above code
|
|
// were rewritten into:
|
|
//
|
|
// name.identifierOrKeyword
|
|
// identifierNameOrKeyword
|
|
//
|
|
// Then we would consider it valid. That's because ASI would take effect and
|
|
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
|
|
// In the first case though, ASI will not take effect because there is not a
|
|
// line terminator after the identifier or keyword.
|
|
if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
|
|
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
|
|
if (matchesPattern) {
|
|
// Report that we need an identifier. However, report it right after the dot,
|
|
// and not on the next token. This is because the next token might actually
|
|
// be an identifier and the error would be quite confusing.
|
|
return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
|
|
}
|
|
}
|
|
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
|
|
}
|
|
function parseTemplateExpression() {
|
|
var template = createNode(202 /* TemplateExpression */);
|
|
template.head = parseTemplateHead();
|
|
ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind");
|
|
var list = [];
|
|
var listPos = getNodePos();
|
|
do {
|
|
list.push(parseTemplateSpan());
|
|
} while (ts.last(list).literal.kind === 15 /* TemplateMiddle */);
|
|
template.templateSpans = createNodeArray(list, listPos);
|
|
return finishNode(template);
|
|
}
|
|
function parseTemplateSpan() {
|
|
var span = createNode(211 /* TemplateSpan */);
|
|
span.expression = allowInAnd(parseExpression);
|
|
var literal;
|
|
if (token() === 18 /* CloseBraceToken */) {
|
|
reScanTemplateToken();
|
|
literal = parseTemplateMiddleOrTemplateTail();
|
|
}
|
|
else {
|
|
literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */));
|
|
}
|
|
span.literal = literal;
|
|
return finishNode(span);
|
|
}
|
|
function parseLiteralNode() {
|
|
return parseLiteralLikeNode(token());
|
|
}
|
|
function parseTemplateHead() {
|
|
var fragment = parseLiteralLikeNode(token());
|
|
ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind");
|
|
return fragment;
|
|
}
|
|
function parseTemplateMiddleOrTemplateTail() {
|
|
var fragment = parseLiteralLikeNode(token());
|
|
ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind");
|
|
return fragment;
|
|
}
|
|
function parseLiteralLikeNode(kind) {
|
|
var node = createNode(kind);
|
|
var text = scanner.getTokenValue();
|
|
node.text = text;
|
|
if (scanner.hasExtendedUnicodeEscape()) {
|
|
node.hasExtendedUnicodeEscape = true;
|
|
}
|
|
if (scanner.isUnterminated()) {
|
|
node.isUnterminated = true;
|
|
}
|
|
// Octal literals are not allowed in strict mode or ES5
|
|
// Note that theoretically the following condition would hold true literals like 009,
|
|
// which is not octal.But because of how the scanner separates the tokens, we would
|
|
// never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
|
|
// We also do not need to check for negatives because any prefix operator would be part of a
|
|
// parent unary expression.
|
|
if (node.kind === 8 /* NumericLiteral */) {
|
|
node.numericLiteralFlags = scanner.getTokenFlags() & 1008 /* NumericLiteralFlags */;
|
|
}
|
|
nextToken();
|
|
finishNode(node);
|
|
return node;
|
|
}
|
|
// TYPES
|
|
function parseTypeReference() {
|
|
var node = createNode(162 /* TypeReference */);
|
|
node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) {
|
|
node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
// If true, we should abort parsing an error function.
|
|
function typeHasArrowFunctionBlockingParseError(node) {
|
|
switch (node.kind) {
|
|
case 162 /* TypeReference */:
|
|
return ts.nodeIsMissing(node.typeName);
|
|
case 163 /* FunctionType */:
|
|
case 164 /* ConstructorType */: {
|
|
var _a = node, parameters = _a.parameters, type = _a.type;
|
|
// parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()`
|
|
return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type);
|
|
}
|
|
case 173 /* ParenthesizedType */:
|
|
return typeHasArrowFunctionBlockingParseError(node.type);
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function parseThisTypePredicate(lhs) {
|
|
nextToken();
|
|
var node = createNode(161 /* TypePredicate */, lhs.pos);
|
|
node.parameterName = lhs;
|
|
node.type = parseType();
|
|
return finishNode(node);
|
|
}
|
|
function parseThisTypeNode() {
|
|
var node = createNode(174 /* ThisType */);
|
|
nextToken();
|
|
return finishNode(node);
|
|
}
|
|
function parseJSDocAllType(postFixEquals) {
|
|
var result = createNode(279 /* JSDocAllType */);
|
|
if (postFixEquals) {
|
|
return createJSDocPostfixType(283 /* JSDocOptionalType */, result);
|
|
}
|
|
else {
|
|
nextToken();
|
|
}
|
|
return finishNode(result);
|
|
}
|
|
function parseJSDocNonNullableType() {
|
|
var result = createNode(282 /* JSDocNonNullableType */);
|
|
nextToken();
|
|
result.type = parseNonArrayType();
|
|
return finishNode(result);
|
|
}
|
|
function parseJSDocUnknownOrNullableType() {
|
|
var pos = scanner.getStartPos();
|
|
// skip the ?
|
|
nextToken();
|
|
// Need to lookahead to decide if this is a nullable or unknown type.
|
|
// Here are cases where we'll pick the unknown type:
|
|
//
|
|
// Foo(?,
|
|
// { a: ? }
|
|
// Foo(?)
|
|
// Foo<?>
|
|
// Foo(?=
|
|
// (?|
|
|
if (token() === 26 /* CommaToken */ ||
|
|
token() === 18 /* CloseBraceToken */ ||
|
|
token() === 20 /* CloseParenToken */ ||
|
|
token() === 29 /* GreaterThanToken */ ||
|
|
token() === 58 /* EqualsToken */ ||
|
|
token() === 49 /* BarToken */) {
|
|
var result = createNode(280 /* JSDocUnknownType */, pos);
|
|
return finishNode(result);
|
|
}
|
|
else {
|
|
var result = createNode(281 /* JSDocNullableType */, pos);
|
|
result.type = parseType();
|
|
return finishNode(result);
|
|
}
|
|
}
|
|
function parseJSDocFunctionType() {
|
|
if (lookAhead(nextTokenIsOpenParen)) {
|
|
var result = createNodeWithJSDoc(284 /* JSDocFunctionType */);
|
|
nextToken();
|
|
fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result);
|
|
return finishNode(result);
|
|
}
|
|
var node = createNode(162 /* TypeReference */);
|
|
node.typeName = parseIdentifierName();
|
|
return finishNode(node);
|
|
}
|
|
function parseJSDocParameter() {
|
|
var parameter = createNode(149 /* Parameter */);
|
|
if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) {
|
|
parameter.name = parseIdentifierName();
|
|
parseExpected(56 /* ColonToken */);
|
|
}
|
|
parameter.type = parseJSDocType();
|
|
return finishNode(parameter);
|
|
}
|
|
function parseJSDocType() {
|
|
var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */);
|
|
var type = parseType();
|
|
if (dotdotdot) {
|
|
var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos);
|
|
variadic.type = type;
|
|
type = finishNode(variadic);
|
|
}
|
|
if (token() === 58 /* EqualsToken */) {
|
|
return createJSDocPostfixType(283 /* JSDocOptionalType */, type);
|
|
}
|
|
return type;
|
|
}
|
|
function parseTypeQuery() {
|
|
var node = createNode(165 /* TypeQuery */);
|
|
parseExpected(103 /* TypeOfKeyword */);
|
|
node.exprName = parseEntityName(/*allowReservedWords*/ true);
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeParameter() {
|
|
var node = createNode(148 /* TypeParameter */);
|
|
node.name = parseIdentifier();
|
|
if (parseOptional(85 /* ExtendsKeyword */)) {
|
|
// It's not uncommon for people to write improper constraints to a generic. If the
|
|
// user writes a constraint that is an expression and not an actual type, then parse
|
|
// it out as an expression (so we can recover well), but report that a type is needed
|
|
// instead.
|
|
if (isStartOfType() || !isStartOfExpression()) {
|
|
node.constraint = parseType();
|
|
}
|
|
else {
|
|
// It was not a type, and it looked like an expression. Parse out an expression
|
|
// here so we recover well. Note: it is important that we call parseUnaryExpression
|
|
// and not parseExpression here. If the user has:
|
|
//
|
|
// <T extends "">
|
|
//
|
|
// We do *not* want to consume the `>` as we're consuming the expression for "".
|
|
node.expression = parseUnaryExpressionOrHigher();
|
|
}
|
|
}
|
|
if (parseOptional(58 /* EqualsToken */)) {
|
|
node.default = parseType();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeParameters() {
|
|
if (token() === 27 /* LessThanToken */) {
|
|
return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */);
|
|
}
|
|
}
|
|
function parseParameterType() {
|
|
if (parseOptional(56 /* ColonToken */)) {
|
|
return parseType();
|
|
}
|
|
return undefined;
|
|
}
|
|
function isStartOfParameter() {
|
|
return token() === 24 /* DotDotDotToken */ ||
|
|
isIdentifierOrPattern() ||
|
|
ts.isModifierKind(token()) ||
|
|
token() === 57 /* AtToken */ ||
|
|
isStartOfType(/*inStartOfParameter*/ true);
|
|
}
|
|
function parseParameter() {
|
|
var node = createNodeWithJSDoc(149 /* Parameter */);
|
|
if (token() === 99 /* ThisKeyword */) {
|
|
node.name = createIdentifier(/*isIdentifier*/ true);
|
|
node.type = parseParameterType();
|
|
return finishNode(node);
|
|
}
|
|
node.decorators = parseDecorators();
|
|
node.modifiers = parseModifiers();
|
|
node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */);
|
|
// FormalParameter [Yield,Await]:
|
|
// BindingElement[?Yield,?Await]
|
|
node.name = parseIdentifierOrPattern();
|
|
if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) {
|
|
// in cases like
|
|
// 'use strict'
|
|
// function foo(static)
|
|
// isParameter('static') === true, because of isModifier('static')
|
|
// however 'static' is not a legal identifier in a strict mode.
|
|
// so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined)
|
|
// and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM)
|
|
// to avoid this we'll advance cursor to the next token.
|
|
nextToken();
|
|
}
|
|
node.questionToken = parseOptionalToken(55 /* QuestionToken */);
|
|
node.type = parseParameterType();
|
|
node.initializer = parseInitializer();
|
|
return finishNode(node);
|
|
}
|
|
/**
|
|
* Note: If returnToken is EqualsGreaterThanToken, `signature.type` will always be defined.
|
|
* @returns If return type parsing succeeds
|
|
*/
|
|
function fillSignature(returnToken, flags, signature) {
|
|
if (!(flags & 32 /* JSDoc */)) {
|
|
signature.typeParameters = parseTypeParameters();
|
|
}
|
|
var parametersParsedSuccessfully = parseParameterList(signature, flags);
|
|
if (shouldParseReturnType(returnToken, !!(flags & 4 /* Type */))) {
|
|
signature.type = parseTypeOrTypePredicate();
|
|
if (typeHasArrowFunctionBlockingParseError(signature.type))
|
|
return false;
|
|
}
|
|
return parametersParsedSuccessfully;
|
|
}
|
|
function shouldParseReturnType(returnToken, isType) {
|
|
if (returnToken === 36 /* EqualsGreaterThanToken */) {
|
|
parseExpected(returnToken);
|
|
return true;
|
|
}
|
|
else if (parseOptional(56 /* ColonToken */)) {
|
|
return true;
|
|
}
|
|
else if (isType && token() === 36 /* EqualsGreaterThanToken */) {
|
|
// This is easy to get backward, especially in type contexts, so parse the type anyway
|
|
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */));
|
|
nextToken();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
// Returns true on success.
|
|
function parseParameterList(signature, flags) {
|
|
// FormalParameters [Yield,Await]: (modified)
|
|
// [empty]
|
|
// FormalParameterList[?Yield,Await]
|
|
//
|
|
// FormalParameter[Yield,Await]: (modified)
|
|
// BindingElement[?Yield,Await]
|
|
//
|
|
// BindingElement [Yield,Await]: (modified)
|
|
// SingleNameBinding[?Yield,?Await]
|
|
// BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt
|
|
//
|
|
// SingleNameBinding [Yield,Await]:
|
|
// BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt
|
|
if (!parseExpected(19 /* OpenParenToken */)) {
|
|
signature.parameters = createMissingList();
|
|
return false;
|
|
}
|
|
var savedYieldContext = inYieldContext();
|
|
var savedAwaitContext = inAwaitContext();
|
|
setYieldContext(!!(flags & 1 /* Yield */));
|
|
setAwaitContext(!!(flags & 2 /* Await */));
|
|
signature.parameters = parseDelimitedList(16 /* Parameters */, flags & 32 /* JSDoc */ ? parseJSDocParameter : parseParameter);
|
|
setYieldContext(savedYieldContext);
|
|
setAwaitContext(savedAwaitContext);
|
|
return parseExpected(20 /* CloseParenToken */);
|
|
}
|
|
function parseTypeMemberSemicolon() {
|
|
// We allow type members to be separated by commas or (possibly ASI) semicolons.
|
|
// First check if it was a comma. If so, we're done with the member.
|
|
if (parseOptional(26 /* CommaToken */)) {
|
|
return;
|
|
}
|
|
// Didn't have a comma. We must have a (possible ASI) semicolon.
|
|
parseSemicolon();
|
|
}
|
|
function parseSignatureMember(kind) {
|
|
var node = createNodeWithJSDoc(kind);
|
|
if (kind === 159 /* ConstructSignature */) {
|
|
parseExpected(94 /* NewKeyword */);
|
|
}
|
|
fillSignature(56 /* ColonToken */, 4 /* Type */, node);
|
|
parseTypeMemberSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function isIndexSignature() {
|
|
return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature);
|
|
}
|
|
function isUnambiguouslyIndexSignature() {
|
|
// The only allowed sequence is:
|
|
//
|
|
// [id:
|
|
//
|
|
// However, for error recovery, we also check the following cases:
|
|
//
|
|
// [...
|
|
// [id,
|
|
// [id?,
|
|
// [id?:
|
|
// [id?]
|
|
// [public id
|
|
// [private id
|
|
// [protected id
|
|
// []
|
|
//
|
|
nextToken();
|
|
if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) {
|
|
return true;
|
|
}
|
|
if (ts.isModifierKind(token())) {
|
|
nextToken();
|
|
if (isIdentifier()) {
|
|
return true;
|
|
}
|
|
}
|
|
else if (!isIdentifier()) {
|
|
return false;
|
|
}
|
|
else {
|
|
// Skip the identifier
|
|
nextToken();
|
|
}
|
|
// A colon signifies a well formed indexer
|
|
// A comma should be a badly formed indexer because comma expressions are not allowed
|
|
// in computed properties.
|
|
if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) {
|
|
return true;
|
|
}
|
|
// Question mark could be an indexer with an optional property,
|
|
// or it could be a conditional expression in a computed property.
|
|
if (token() !== 55 /* QuestionToken */) {
|
|
return false;
|
|
}
|
|
// If any of the following tokens are after the question mark, it cannot
|
|
// be a conditional expression, so treat it as an indexer.
|
|
nextToken();
|
|
return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */;
|
|
}
|
|
function parseIndexSignatureDeclaration(node) {
|
|
node.kind = 160 /* IndexSignature */;
|
|
node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */);
|
|
node.type = parseTypeAnnotation();
|
|
parseTypeMemberSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parsePropertyOrMethodSignature(node) {
|
|
node.name = parsePropertyName();
|
|
node.questionToken = parseOptionalToken(55 /* QuestionToken */);
|
|
if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) {
|
|
node.kind = 153 /* MethodSignature */;
|
|
// Method signatures don't exist in expression contexts. So they have neither
|
|
// [Yield] nor [Await]
|
|
fillSignature(56 /* ColonToken */, 4 /* Type */, node);
|
|
}
|
|
else {
|
|
node.kind = 151 /* PropertySignature */;
|
|
node.type = parseTypeAnnotation();
|
|
if (token() === 58 /* EqualsToken */) {
|
|
// Although type literal properties cannot not have initializers, we attempt
|
|
// to parse an initializer so we can report in the checker that an interface
|
|
// property or type literal property cannot have an initializer.
|
|
node.initializer = parseInitializer();
|
|
}
|
|
}
|
|
parseTypeMemberSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function isTypeMemberStart() {
|
|
// Return true if we have the start of a signature member
|
|
if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) {
|
|
return true;
|
|
}
|
|
var idToken = false;
|
|
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier
|
|
while (ts.isModifierKind(token())) {
|
|
idToken = true;
|
|
nextToken();
|
|
}
|
|
// Index signatures and computed property names are type members
|
|
if (token() === 21 /* OpenBracketToken */) {
|
|
return true;
|
|
}
|
|
// Try to get the first property-like token following all modifiers
|
|
if (isLiteralPropertyName()) {
|
|
idToken = true;
|
|
nextToken();
|
|
}
|
|
// If we were able to get any potential identifier, check that it is
|
|
// the start of a member declaration
|
|
if (idToken) {
|
|
return token() === 19 /* OpenParenToken */ ||
|
|
token() === 27 /* LessThanToken */ ||
|
|
token() === 55 /* QuestionToken */ ||
|
|
token() === 56 /* ColonToken */ ||
|
|
token() === 26 /* CommaToken */ ||
|
|
canParseSemicolon();
|
|
}
|
|
return false;
|
|
}
|
|
function parseTypeMember() {
|
|
if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) {
|
|
return parseSignatureMember(158 /* CallSignature */);
|
|
}
|
|
if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) {
|
|
return parseSignatureMember(159 /* ConstructSignature */);
|
|
}
|
|
var node = createNodeWithJSDoc(0 /* Unknown */);
|
|
node.modifiers = parseModifiers();
|
|
if (isIndexSignature()) {
|
|
return parseIndexSignatureDeclaration(node);
|
|
}
|
|
return parsePropertyOrMethodSignature(node);
|
|
}
|
|
function nextTokenIsOpenParenOrLessThan() {
|
|
nextToken();
|
|
return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */;
|
|
}
|
|
function nextTokenIsDot() {
|
|
return nextToken() === 23 /* DotToken */;
|
|
}
|
|
function nextTokenIsOpenParenOrLessThanOrDot() {
|
|
switch (nextToken()) {
|
|
case 19 /* OpenParenToken */:
|
|
case 27 /* LessThanToken */:
|
|
case 23 /* DotToken */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function parseTypeLiteral() {
|
|
var node = createNode(166 /* TypeLiteral */);
|
|
node.members = parseObjectTypeMembers();
|
|
return finishNode(node);
|
|
}
|
|
function parseObjectTypeMembers() {
|
|
var members;
|
|
if (parseExpected(17 /* OpenBraceToken */)) {
|
|
members = parseList(4 /* TypeMembers */, parseTypeMember);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
members = createMissingList();
|
|
}
|
|
return members;
|
|
}
|
|
function isStartOfMappedType() {
|
|
nextToken();
|
|
if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) {
|
|
return nextToken() === 132 /* ReadonlyKeyword */;
|
|
}
|
|
if (token() === 132 /* ReadonlyKeyword */) {
|
|
nextToken();
|
|
}
|
|
return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */;
|
|
}
|
|
function parseMappedTypeParameter() {
|
|
var node = createNode(148 /* TypeParameter */);
|
|
node.name = parseIdentifier();
|
|
parseExpected(92 /* InKeyword */);
|
|
node.constraint = parseType();
|
|
return finishNode(node);
|
|
}
|
|
function parseMappedType() {
|
|
var node = createNode(177 /* MappedType */);
|
|
parseExpected(17 /* OpenBraceToken */);
|
|
if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) {
|
|
node.readonlyToken = parseTokenNode();
|
|
if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) {
|
|
parseExpectedToken(132 /* ReadonlyKeyword */);
|
|
}
|
|
}
|
|
parseExpected(21 /* OpenBracketToken */);
|
|
node.typeParameter = parseMappedTypeParameter();
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) {
|
|
node.questionToken = parseTokenNode();
|
|
if (node.questionToken.kind !== 55 /* QuestionToken */) {
|
|
parseExpectedToken(55 /* QuestionToken */);
|
|
}
|
|
}
|
|
node.type = parseTypeAnnotation();
|
|
parseSemicolon();
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseTupleType() {
|
|
var node = createNode(168 /* TupleType */);
|
|
node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseParenthesizedType() {
|
|
var node = createNode(173 /* ParenthesizedType */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.type = parseType();
|
|
parseExpected(20 /* CloseParenToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseFunctionOrConstructorType() {
|
|
var pos = getNodePos();
|
|
var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */;
|
|
var node = createNodeWithJSDoc(kind, pos);
|
|
fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node);
|
|
return finishNode(node);
|
|
}
|
|
function parseKeywordAndNoDot() {
|
|
var node = parseTokenNode();
|
|
return token() === 23 /* DotToken */ ? undefined : node;
|
|
}
|
|
function parseLiteralTypeNode(negative) {
|
|
var node = createNode(178 /* LiteralType */);
|
|
var unaryMinusExpression;
|
|
if (negative) {
|
|
unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */);
|
|
unaryMinusExpression.operator = 38 /* MinusToken */;
|
|
nextToken();
|
|
}
|
|
var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */
|
|
? parseTokenNode()
|
|
: parseLiteralLikeNode(token());
|
|
if (negative) {
|
|
unaryMinusExpression.operand = expression;
|
|
finishNode(unaryMinusExpression);
|
|
expression = unaryMinusExpression;
|
|
}
|
|
node.literal = expression;
|
|
return finishNode(node);
|
|
}
|
|
function isStartOfTypeOfImportType() {
|
|
nextToken();
|
|
return token() === 91 /* ImportKeyword */;
|
|
}
|
|
function parseImportType() {
|
|
sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */;
|
|
var node = createNode(179 /* ImportType */);
|
|
if (parseOptional(103 /* TypeOfKeyword */)) {
|
|
node.isTypeOf = true;
|
|
}
|
|
parseExpected(91 /* ImportKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.argument = parseType();
|
|
parseExpected(20 /* CloseParenToken */);
|
|
if (parseOptional(23 /* DotToken */)) {
|
|
node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
}
|
|
node.typeArguments = tryParseTypeArguments();
|
|
return finishNode(node);
|
|
}
|
|
function nextTokenIsNumericLiteral() {
|
|
return nextToken() === 8 /* NumericLiteral */;
|
|
}
|
|
function parseNonArrayType() {
|
|
switch (token()) {
|
|
case 119 /* AnyKeyword */:
|
|
case 142 /* UnknownKeyword */:
|
|
case 137 /* StringKeyword */:
|
|
case 134 /* NumberKeyword */:
|
|
case 138 /* SymbolKeyword */:
|
|
case 122 /* BooleanKeyword */:
|
|
case 140 /* UndefinedKeyword */:
|
|
case 131 /* NeverKeyword */:
|
|
case 135 /* ObjectKeyword */:
|
|
// If these are followed by a dot, then parse these out as a dotted type reference instead.
|
|
return tryParse(parseKeywordAndNoDot) || parseTypeReference();
|
|
case 39 /* AsteriskToken */:
|
|
return parseJSDocAllType(/*postfixEquals*/ false);
|
|
case 61 /* AsteriskEqualsToken */:
|
|
return parseJSDocAllType(/*postfixEquals*/ true);
|
|
case 55 /* QuestionToken */:
|
|
return parseJSDocUnknownOrNullableType();
|
|
case 89 /* FunctionKeyword */:
|
|
return parseJSDocFunctionType();
|
|
case 51 /* ExclamationToken */:
|
|
return parseJSDocNonNullableType();
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
return parseLiteralTypeNode();
|
|
case 38 /* MinusToken */:
|
|
return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference();
|
|
case 105 /* VoidKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
return parseTokenNode();
|
|
case 99 /* ThisKeyword */: {
|
|
var thisKeyword = parseThisTypeNode();
|
|
if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
|
|
return parseThisTypePredicate(thisKeyword);
|
|
}
|
|
else {
|
|
return thisKeyword;
|
|
}
|
|
}
|
|
case 103 /* TypeOfKeyword */:
|
|
return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
|
|
case 17 /* OpenBraceToken */:
|
|
return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
|
|
case 21 /* OpenBracketToken */:
|
|
return parseTupleType();
|
|
case 19 /* OpenParenToken */:
|
|
return parseParenthesizedType();
|
|
case 91 /* ImportKeyword */:
|
|
return parseImportType();
|
|
default:
|
|
return parseTypeReference();
|
|
}
|
|
}
|
|
function isStartOfType(inStartOfParameter) {
|
|
switch (token()) {
|
|
case 119 /* AnyKeyword */:
|
|
case 142 /* UnknownKeyword */:
|
|
case 137 /* StringKeyword */:
|
|
case 134 /* NumberKeyword */:
|
|
case 122 /* BooleanKeyword */:
|
|
case 138 /* SymbolKeyword */:
|
|
case 141 /* UniqueKeyword */:
|
|
case 105 /* VoidKeyword */:
|
|
case 140 /* UndefinedKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
case 99 /* ThisKeyword */:
|
|
case 103 /* TypeOfKeyword */:
|
|
case 131 /* NeverKeyword */:
|
|
case 17 /* OpenBraceToken */:
|
|
case 21 /* OpenBracketToken */:
|
|
case 27 /* LessThanToken */:
|
|
case 49 /* BarToken */:
|
|
case 48 /* AmpersandToken */:
|
|
case 94 /* NewKeyword */:
|
|
case 9 /* StringLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
case 135 /* ObjectKeyword */:
|
|
case 39 /* AsteriskToken */:
|
|
case 55 /* QuestionToken */:
|
|
case 51 /* ExclamationToken */:
|
|
case 24 /* DotDotDotToken */:
|
|
case 126 /* InferKeyword */:
|
|
case 91 /* ImportKeyword */:
|
|
return true;
|
|
case 38 /* MinusToken */:
|
|
return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral);
|
|
case 19 /* OpenParenToken */:
|
|
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
|
|
// or something that starts a type. We don't want to consider things like '(1)' a type.
|
|
return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
|
|
default:
|
|
return isIdentifier();
|
|
}
|
|
}
|
|
function isStartOfParenthesizedOrFunctionType() {
|
|
nextToken();
|
|
return token() === 20 /* CloseParenToken */ || isStartOfParameter() || isStartOfType();
|
|
}
|
|
function parsePostfixTypeOrHigher() {
|
|
var type = parseNonArrayType();
|
|
while (!scanner.hasPrecedingLineBreak()) {
|
|
switch (token()) {
|
|
case 51 /* ExclamationToken */:
|
|
type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type);
|
|
break;
|
|
case 55 /* QuestionToken */:
|
|
// If not in JSDoc and next token is start of a type we have a conditional type
|
|
if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) {
|
|
return type;
|
|
}
|
|
type = createJSDocPostfixType(281 /* JSDocNullableType */, type);
|
|
break;
|
|
case 21 /* OpenBracketToken */:
|
|
parseExpected(21 /* OpenBracketToken */);
|
|
if (isStartOfType()) {
|
|
var node = createNode(176 /* IndexedAccessType */, type.pos);
|
|
node.objectType = type;
|
|
node.indexType = parseType();
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
type = finishNode(node);
|
|
}
|
|
else {
|
|
var node = createNode(167 /* ArrayType */, type.pos);
|
|
node.elementType = type;
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
type = finishNode(node);
|
|
}
|
|
break;
|
|
default:
|
|
return type;
|
|
}
|
|
}
|
|
return type;
|
|
}
|
|
function createJSDocPostfixType(kind, type) {
|
|
nextToken();
|
|
var postfix = createNode(kind, type.pos);
|
|
postfix.type = type;
|
|
return finishNode(postfix);
|
|
}
|
|
function parseTypeOperator(operator) {
|
|
var node = createNode(175 /* TypeOperator */);
|
|
parseExpected(operator);
|
|
node.operator = operator;
|
|
node.type = parseTypeOperatorOrHigher();
|
|
return finishNode(node);
|
|
}
|
|
function parseInferType() {
|
|
var node = createNode(172 /* InferType */);
|
|
parseExpected(126 /* InferKeyword */);
|
|
var typeParameter = createNode(148 /* TypeParameter */);
|
|
typeParameter.name = parseIdentifier();
|
|
node.typeParameter = finishNode(typeParameter);
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeOperatorOrHigher() {
|
|
var operator = token();
|
|
switch (operator) {
|
|
case 128 /* KeyOfKeyword */:
|
|
case 141 /* UniqueKeyword */:
|
|
return parseTypeOperator(operator);
|
|
case 126 /* InferKeyword */:
|
|
return parseInferType();
|
|
}
|
|
return parsePostfixTypeOrHigher();
|
|
}
|
|
function parseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
parseOptional(operator);
|
|
var type = parseConstituentType();
|
|
if (token() === operator) {
|
|
var types = [type];
|
|
while (parseOptional(operator)) {
|
|
types.push(parseConstituentType());
|
|
}
|
|
var node = createNode(kind, type.pos);
|
|
node.types = createNodeArray(types, type.pos);
|
|
type = finishNode(node);
|
|
}
|
|
return type;
|
|
}
|
|
function parseIntersectionTypeOrHigher() {
|
|
return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */);
|
|
}
|
|
function parseUnionTypeOrHigher() {
|
|
return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */);
|
|
}
|
|
function isStartOfFunctionType() {
|
|
if (token() === 27 /* LessThanToken */) {
|
|
return true;
|
|
}
|
|
return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType);
|
|
}
|
|
function skipParameterStart() {
|
|
if (ts.isModifierKind(token())) {
|
|
// Skip modifiers
|
|
parseModifiers();
|
|
}
|
|
if (isIdentifier() || token() === 99 /* ThisKeyword */) {
|
|
nextToken();
|
|
return true;
|
|
}
|
|
if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) {
|
|
// Return true if we can parse an array or object binding pattern with no errors
|
|
var previousErrorCount = parseDiagnostics.length;
|
|
parseIdentifierOrPattern();
|
|
return previousErrorCount === parseDiagnostics.length;
|
|
}
|
|
return false;
|
|
}
|
|
function isUnambiguouslyStartOfFunctionType() {
|
|
nextToken();
|
|
if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) {
|
|
// ( )
|
|
// ( ...
|
|
return true;
|
|
}
|
|
if (skipParameterStart()) {
|
|
// We successfully skipped modifiers (if any) and an identifier or binding pattern,
|
|
// now see if we have something that indicates a parameter declaration
|
|
if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ ||
|
|
token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) {
|
|
// ( xxx :
|
|
// ( xxx ,
|
|
// ( xxx ?
|
|
// ( xxx =
|
|
return true;
|
|
}
|
|
if (token() === 20 /* CloseParenToken */) {
|
|
nextToken();
|
|
if (token() === 36 /* EqualsGreaterThanToken */) {
|
|
// ( xxx ) =>
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function parseTypeOrTypePredicate() {
|
|
var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
|
|
var type = parseType();
|
|
if (typePredicateVariable) {
|
|
var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos);
|
|
node.parameterName = typePredicateVariable;
|
|
node.type = type;
|
|
return finishNode(node);
|
|
}
|
|
else {
|
|
return type;
|
|
}
|
|
}
|
|
function parseTypePredicatePrefix() {
|
|
var id = parseIdentifier();
|
|
if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
|
|
nextToken();
|
|
return id;
|
|
}
|
|
}
|
|
function parseType() {
|
|
// The rules about 'yield' only apply to actual code/expression contexts. They don't
|
|
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
|
return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker);
|
|
}
|
|
function parseTypeWorker(noConditionalTypes) {
|
|
if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) {
|
|
return parseFunctionOrConstructorType();
|
|
}
|
|
var type = parseUnionTypeOrHigher();
|
|
if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) {
|
|
var node = createNode(171 /* ConditionalType */, type.pos);
|
|
node.checkType = type;
|
|
// The type following 'extends' is not permitted to be another conditional type
|
|
node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
|
|
parseExpected(55 /* QuestionToken */);
|
|
node.trueType = parseTypeWorker();
|
|
parseExpected(56 /* ColonToken */);
|
|
node.falseType = parseTypeWorker();
|
|
return finishNode(node);
|
|
}
|
|
return type;
|
|
}
|
|
function parseTypeAnnotation() {
|
|
return parseOptional(56 /* ColonToken */) ? parseType() : undefined;
|
|
}
|
|
// EXPRESSIONS
|
|
function isStartOfLeftHandSideExpression() {
|
|
switch (token()) {
|
|
case 99 /* ThisKeyword */:
|
|
case 97 /* SuperKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
case 14 /* TemplateHead */:
|
|
case 19 /* OpenParenToken */:
|
|
case 21 /* OpenBracketToken */:
|
|
case 17 /* OpenBraceToken */:
|
|
case 89 /* FunctionKeyword */:
|
|
case 75 /* ClassKeyword */:
|
|
case 94 /* NewKeyword */:
|
|
case 41 /* SlashToken */:
|
|
case 63 /* SlashEqualsToken */:
|
|
case 71 /* Identifier */:
|
|
return true;
|
|
case 91 /* ImportKeyword */:
|
|
return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
|
|
default:
|
|
return isIdentifier();
|
|
}
|
|
}
|
|
function isStartOfExpression() {
|
|
if (isStartOfLeftHandSideExpression()) {
|
|
return true;
|
|
}
|
|
switch (token()) {
|
|
case 37 /* PlusToken */:
|
|
case 38 /* MinusToken */:
|
|
case 52 /* TildeToken */:
|
|
case 51 /* ExclamationToken */:
|
|
case 80 /* DeleteKeyword */:
|
|
case 103 /* TypeOfKeyword */:
|
|
case 105 /* VoidKeyword */:
|
|
case 43 /* PlusPlusToken */:
|
|
case 44 /* MinusMinusToken */:
|
|
case 27 /* LessThanToken */:
|
|
case 121 /* AwaitKeyword */:
|
|
case 116 /* YieldKeyword */:
|
|
// Yield/await always starts an expression. Either it is an identifier (in which case
|
|
// it is definitely an expression). Or it's a keyword (either because we're in
|
|
// a generator or async function, or in strict mode (or both)) and it started a yield or await expression.
|
|
return true;
|
|
default:
|
|
// Error tolerance. If we see the start of some binary operator, we consider
|
|
// that the start of an expression. That way we'll parse out a missing identifier,
|
|
// give a good message about an identifier being missing, and then consume the
|
|
// rest of the binary expression.
|
|
if (isBinaryOperator()) {
|
|
return true;
|
|
}
|
|
return isIdentifier();
|
|
}
|
|
}
|
|
function isStartOfExpressionStatement() {
|
|
// As per the grammar, none of '{' or 'function' or 'class' can start an expression statement.
|
|
return token() !== 17 /* OpenBraceToken */ &&
|
|
token() !== 89 /* FunctionKeyword */ &&
|
|
token() !== 75 /* ClassKeyword */ &&
|
|
token() !== 57 /* AtToken */ &&
|
|
isStartOfExpression();
|
|
}
|
|
function parseExpression() {
|
|
// Expression[in]:
|
|
// AssignmentExpression[in]
|
|
// Expression[in] , AssignmentExpression[in]
|
|
// clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator
|
|
var saveDecoratorContext = inDecoratorContext();
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ false);
|
|
}
|
|
var expr = parseAssignmentExpressionOrHigher();
|
|
var operatorToken;
|
|
while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) {
|
|
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
|
|
}
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ true);
|
|
}
|
|
return expr;
|
|
}
|
|
function parseInitializer() {
|
|
return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
}
|
|
function parseAssignmentExpressionOrHigher() {
|
|
// AssignmentExpression[in,yield]:
|
|
// 1) ConditionalExpression[?in,?yield]
|
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
// 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield]
|
|
// 4) ArrowFunctionExpression[?in,?yield]
|
|
// 5) AsyncArrowFunctionExpression[in,yield,await]
|
|
// 6) [+Yield] YieldExpression[?In]
|
|
//
|
|
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
|
|
// (i.e. they're both BinaryExpressions with an assignment operator in it).
|
|
// First, do the simple check if we have a YieldExpression (production '6').
|
|
if (isYieldExpression()) {
|
|
return parseYieldExpression();
|
|
}
|
|
// Then, check if we have an arrow function (production '4' and '5') that starts with a parenthesized
|
|
// parameter list or is an async arrow function.
|
|
// AsyncArrowFunctionExpression:
|
|
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
|
|
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
|
|
// Production (1) of AsyncArrowFunctionExpression is parsed in "tryParseAsyncSimpleArrowFunctionExpression".
|
|
// And production (2) is parsed in "tryParseParenthesizedArrowFunctionExpression".
|
|
//
|
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
// with AssignmentExpression if we see one.
|
|
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
if (arrowExpression) {
|
|
return arrowExpression;
|
|
}
|
|
// Now try to see if we're in production '1', '2' or '3'. A conditional expression can
|
|
// start with a LogicalOrExpression, while the assignment productions can only start with
|
|
// LeftHandSideExpressions.
|
|
//
|
|
// So, first, we try to just parse out a BinaryExpression. If we get something that is a
|
|
// LeftHandSide or higher, then we can try to parse out the assignment expression part.
|
|
// Otherwise, we try to parse out the conditional expression bit. We want to allow any
|
|
// binary expression here, so we pass in the 'lowest' precedence here so that it matches
|
|
// and consumes anything.
|
|
var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0);
|
|
// To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized
|
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
// identifier and the current token is an arrow.
|
|
if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) {
|
|
return parseSimpleArrowFunctionExpression(expr);
|
|
}
|
|
// Now see if we might be in cases '2' or '3'.
|
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
// we're in '2' or '3'. Consume the assignment and return.
|
|
//
|
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
// for cases like `> > =` becoming `>>=`
|
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
|
|
}
|
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
return parseConditionalExpressionRest(expr);
|
|
}
|
|
function isYieldExpression() {
|
|
if (token() === 116 /* YieldKeyword */) {
|
|
// If we have a 'yield' keyword, and this is a context where yield expressions are
|
|
// allowed, then definitely parse out a yield expression.
|
|
if (inYieldContext()) {
|
|
return true;
|
|
}
|
|
// We're in a context where 'yield expr' is not allowed. However, if we can
|
|
// definitely tell that the user was trying to parse a 'yield expr' and not
|
|
// just a normal expr that start with a 'yield' identifier, then parse out
|
|
// a 'yield expr'. We can then report an error later that they are only
|
|
// allowed in generator expressions.
|
|
//
|
|
// for example, if we see 'yield(foo)', then we'll have to treat that as an
|
|
// invocation expression of something called 'yield'. However, if we have
|
|
// 'yield foo' then that is not legal as a normal expression, so we can
|
|
// definitely recognize this as a yield expression.
|
|
//
|
|
// for now we just check if the next token is an identifier. More heuristics
|
|
// can be added here later as necessary. We just need to make sure that we
|
|
// don't accidentally consume something legal.
|
|
return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
|
|
}
|
|
return false;
|
|
}
|
|
function nextTokenIsIdentifierOnSameLine() {
|
|
nextToken();
|
|
return !scanner.hasPrecedingLineBreak() && isIdentifier();
|
|
}
|
|
function parseYieldExpression() {
|
|
var node = createNode(203 /* YieldExpression */);
|
|
// YieldExpression[In] :
|
|
// yield
|
|
// yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
|
|
// yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
|
|
nextToken();
|
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
(token() === 39 /* AsteriskToken */ || isStartOfExpression())) {
|
|
node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */);
|
|
node.expression = parseAssignmentExpressionOrHigher();
|
|
return finishNode(node);
|
|
}
|
|
else {
|
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
// the start of an expression, then this is just a simple "yield" expression.
|
|
return finishNode(node);
|
|
}
|
|
}
|
|
function parseSimpleArrowFunctionExpression(identifier, asyncModifier) {
|
|
ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
var node;
|
|
if (asyncModifier) {
|
|
node = createNode(193 /* ArrowFunction */, asyncModifier.pos);
|
|
node.modifiers = asyncModifier;
|
|
}
|
|
else {
|
|
node = createNode(193 /* ArrowFunction */, identifier.pos);
|
|
}
|
|
var parameter = createNode(149 /* Parameter */, identifier.pos);
|
|
parameter.name = identifier;
|
|
finishNode(parameter);
|
|
node.parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */);
|
|
node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
return addJSDocComment(finishNode(node));
|
|
}
|
|
function tryParseParenthesizedArrowFunctionExpression() {
|
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
if (triState === 0 /* False */) {
|
|
// It's definitely not a parenthesized arrow function expression.
|
|
return undefined;
|
|
}
|
|
// If we definitely have an arrow function, then we can just parse one, not requiring a
|
|
// following => or { token. Otherwise, we *might* have an arrow function. Try to parse
|
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
// expression instead.
|
|
var arrowFunction = triState === 1 /* True */
|
|
? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true)
|
|
: tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead);
|
|
if (!arrowFunction) {
|
|
// Didn't appear to actually be a parenthesized arrow function. Just bail out.
|
|
return undefined;
|
|
}
|
|
var isAsync = ts.hasModifier(arrowFunction, 256 /* Async */);
|
|
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
|
|
// have an opening brace, just in case we're in an error state.
|
|
var lastToken = token();
|
|
arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */);
|
|
arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */)
|
|
? parseArrowFunctionExpressionBody(isAsync)
|
|
: parseIdentifier();
|
|
return finishNode(arrowFunction);
|
|
}
|
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
// Unknown -> There *might* be a parenthesized arrow function here.
|
|
// Speculatively look ahead to be sure, and rollback if not.
|
|
function isParenthesizedArrowFunctionExpression() {
|
|
if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) {
|
|
return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
|
|
}
|
|
if (token() === 36 /* EqualsGreaterThanToken */) {
|
|
// ERROR RECOVERY TWEAK:
|
|
// If we see a standalone => try to parse it as an arrow function expression as that's
|
|
// likely what the user intended to write.
|
|
return 1 /* True */;
|
|
}
|
|
// Definitely not a parenthesized arrow function.
|
|
return 0 /* False */;
|
|
}
|
|
function isParenthesizedArrowFunctionExpressionWorker() {
|
|
if (token() === 120 /* AsyncKeyword */) {
|
|
nextToken();
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
return 0 /* False */;
|
|
}
|
|
if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) {
|
|
return 0 /* False */;
|
|
}
|
|
}
|
|
var first = token();
|
|
var second = nextToken();
|
|
if (first === 19 /* OpenParenToken */) {
|
|
if (second === 20 /* CloseParenToken */) {
|
|
// Simple cases: "() =>", "(): ", and "() {".
|
|
// This is an arrow function with no parameters.
|
|
// The last one is not actually an arrow function,
|
|
// but this is probably what the user intended.
|
|
var third = nextToken();
|
|
switch (third) {
|
|
case 36 /* EqualsGreaterThanToken */:
|
|
case 56 /* ColonToken */:
|
|
case 17 /* OpenBraceToken */:
|
|
return 1 /* True */;
|
|
default:
|
|
return 0 /* False */;
|
|
}
|
|
}
|
|
// If encounter "([" or "({", this could be the start of a binding pattern.
|
|
// Examples:
|
|
// ([ x ]) => { }
|
|
// ({ x }) => { }
|
|
// ([ x ])
|
|
// ({ x })
|
|
if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) {
|
|
return 2 /* Unknown */;
|
|
}
|
|
// Simple case: "(..."
|
|
// This is an arrow function with a rest parameter.
|
|
if (second === 24 /* DotDotDotToken */) {
|
|
return 1 /* True */;
|
|
}
|
|
// Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This
|
|
// isn't actually allowed, but we want to treat it as a lambda so we can provide
|
|
// a good error message.
|
|
if (ts.isModifierKind(second) && second !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) {
|
|
return 1 /* True */;
|
|
}
|
|
// If we had "(" followed by something that's not an identifier,
|
|
// then this definitely doesn't look like a lambda.
|
|
if (!isIdentifier()) {
|
|
return 0 /* False */;
|
|
}
|
|
switch (nextToken()) {
|
|
case 56 /* ColonToken */:
|
|
// If we have something like "(a:", then we must have a
|
|
// type-annotated parameter in an arrow function expression.
|
|
return 1 /* True */;
|
|
case 55 /* QuestionToken */:
|
|
nextToken();
|
|
// If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda.
|
|
if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) {
|
|
return 1 /* True */;
|
|
}
|
|
// Otherwise it is definitely not a lambda.
|
|
return 0 /* False */;
|
|
case 26 /* CommaToken */:
|
|
case 58 /* EqualsToken */:
|
|
case 20 /* CloseParenToken */:
|
|
// If we have "(a," or "(a=" or "(a)" this *could* be an arrow function
|
|
return 2 /* Unknown */;
|
|
}
|
|
// It is definitely not an arrow function
|
|
return 0 /* False */;
|
|
}
|
|
else {
|
|
ts.Debug.assert(first === 27 /* LessThanToken */);
|
|
// If we have "<" not followed by an identifier,
|
|
// then this definitely is not an arrow function.
|
|
if (!isIdentifier()) {
|
|
return 0 /* False */;
|
|
}
|
|
// JSX overrides
|
|
if (sourceFile.languageVariant === 1 /* JSX */) {
|
|
var isArrowFunctionInJsx = lookAhead(function () {
|
|
var third = nextToken();
|
|
if (third === 85 /* ExtendsKeyword */) {
|
|
var fourth = nextToken();
|
|
switch (fourth) {
|
|
case 58 /* EqualsToken */:
|
|
case 29 /* GreaterThanToken */:
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
else if (third === 26 /* CommaToken */) {
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
if (isArrowFunctionInJsx) {
|
|
return 1 /* True */;
|
|
}
|
|
return 0 /* False */;
|
|
}
|
|
// This *could* be a parenthesized arrow function.
|
|
return 2 /* Unknown */;
|
|
}
|
|
}
|
|
function parsePossibleParenthesizedArrowFunctionExpressionHead() {
|
|
return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false);
|
|
}
|
|
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
if (token() === 120 /* AsyncKeyword */) {
|
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0);
|
|
return parseSimpleArrowFunctionExpression(expr, asyncModifier);
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
function isUnParenthesizedAsyncArrowFunctionWorker() {
|
|
// AsyncArrowFunctionExpression:
|
|
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
|
|
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
|
|
if (token() === 120 /* AsyncKeyword */) {
|
|
nextToken();
|
|
// If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function
|
|
// but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher"
|
|
if (scanner.hasPrecedingLineBreak() || token() === 36 /* EqualsGreaterThanToken */) {
|
|
return 0 /* False */;
|
|
}
|
|
// Check for un-parenthesized AsyncArrowFunction
|
|
var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0);
|
|
if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) {
|
|
return 1 /* True */;
|
|
}
|
|
}
|
|
return 0 /* False */;
|
|
}
|
|
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
|
|
var node = createNodeWithJSDoc(193 /* ArrowFunction */);
|
|
node.modifiers = parseModifiersForArrowFunction();
|
|
var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */;
|
|
// Arrow functions are never generators.
|
|
//
|
|
// If we're speculatively parsing a signature for a parenthesized arrow function, then
|
|
// we have to have a complete parameter list. Otherwise we might see something like
|
|
// a => (b => c)
|
|
// And think that "(b =>" was actually a parenthesized arrow function with a missing
|
|
// close paren.
|
|
if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) {
|
|
return undefined;
|
|
}
|
|
// Parsing a signature isn't enough.
|
|
// Parenthesized arrow signatures often look like other valid expressions.
|
|
// For instance:
|
|
// - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value.
|
|
// - "(x,y)" is a comma expression parsed as a signature with two parameters.
|
|
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
|
|
//
|
|
// So we need just a bit of lookahead to ensure that it can only be a signature.
|
|
if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) {
|
|
// Returning undefined here will cause our caller to rewind to where we started from.
|
|
return undefined;
|
|
}
|
|
return node;
|
|
}
|
|
function parseArrowFunctionExpressionBody(isAsync) {
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
}
|
|
if (token() !== 25 /* SemicolonToken */ &&
|
|
token() !== 89 /* FunctionKeyword */ &&
|
|
token() !== 75 /* ClassKeyword */ &&
|
|
isStartOfStatement() &&
|
|
!isStartOfExpressionStatement()) {
|
|
// Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations)
|
|
//
|
|
// Here we try to recover from a potential error situation in the case where the
|
|
// user meant to supply a block. For example, if the user wrote:
|
|
//
|
|
// a =>
|
|
// let v = 0;
|
|
// }
|
|
//
|
|
// they may be missing an open brace. Check to see if that's the case so we can
|
|
// try to recover better. If we don't do this, then the next close curly we see may end
|
|
// up preemptively closing the containing construct.
|
|
//
|
|
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
|
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
|
}
|
|
return isAsync
|
|
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
}
|
|
function parseConditionalExpressionRest(leftOperand) {
|
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
|
var questionToken = parseOptionalToken(55 /* QuestionToken */);
|
|
if (!questionToken) {
|
|
return leftOperand;
|
|
}
|
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
// we do not that for the 'whenFalse' part.
|
|
var node = createNode(201 /* ConditionalExpression */, leftOperand.pos);
|
|
node.condition = leftOperand;
|
|
node.questionToken = questionToken;
|
|
node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
|
|
node.colonToken = parseExpectedToken(56 /* ColonToken */);
|
|
node.whenFalse = ts.nodeIsPresent(node.colonToken)
|
|
? parseAssignmentExpressionOrHigher()
|
|
: createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */));
|
|
return finishNode(node);
|
|
}
|
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
var leftOperand = parseUnaryExpressionOrHigher();
|
|
return parseBinaryExpressionRest(precedence, leftOperand);
|
|
}
|
|
function isInOrOfKeyword(t) {
|
|
return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */;
|
|
}
|
|
function parseBinaryExpressionRest(precedence, leftOperand) {
|
|
while (true) {
|
|
// We either have a binary operator here, or we're finished. We call
|
|
// reScanGreaterToken so that we merge token sequences like > and = into >=
|
|
reScanGreaterToken();
|
|
var newPrecedence = ts.getBinaryOperatorPrecedence(token());
|
|
// Check the precedence to see if we should "take" this operator
|
|
// - For left associative operator (all operator but **), consume the operator,
|
|
// recursively call the function below, and parse binaryExpression as a rightOperand
|
|
// of the caller if the new precedence of the operator is greater then or equal to the current precedence.
|
|
// For example:
|
|
// a - b - c;
|
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand
|
|
// a * b - c
|
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand
|
|
// a - b * c;
|
|
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand
|
|
// - For right associative operator (**), consume the operator, recursively call the function
|
|
// and parse binaryExpression as a rightOperand of the caller if the new precedence of
|
|
// the operator is strictly grater than the current precedence
|
|
// For example:
|
|
// a ** b ** c;
|
|
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
|
|
// a - b ** c;
|
|
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
|
|
// a ** b - c
|
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand
|
|
var consumeCurrentOperator = token() === 40 /* AsteriskAsteriskToken */ ?
|
|
newPrecedence >= precedence :
|
|
newPrecedence > precedence;
|
|
if (!consumeCurrentOperator) {
|
|
break;
|
|
}
|
|
if (token() === 92 /* InKeyword */ && inDisallowInContext()) {
|
|
break;
|
|
}
|
|
if (token() === 118 /* AsKeyword */) {
|
|
// Make sure we *do* perform ASI for constructs like this:
|
|
// var x = foo
|
|
// as (Bar)
|
|
// This should be parsed as an initialized variable, followed
|
|
// by a function call to 'as' with the argument 'Bar'
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
break;
|
|
}
|
|
else {
|
|
nextToken();
|
|
leftOperand = makeAsExpression(leftOperand, parseType());
|
|
}
|
|
}
|
|
else {
|
|
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
|
}
|
|
}
|
|
return leftOperand;
|
|
}
|
|
function isBinaryOperator() {
|
|
if (inDisallowInContext() && token() === 92 /* InKeyword */) {
|
|
return false;
|
|
}
|
|
return ts.getBinaryOperatorPrecedence(token()) > 0;
|
|
}
|
|
function makeBinaryExpression(left, operatorToken, right) {
|
|
var node = createNode(200 /* BinaryExpression */, left.pos);
|
|
node.left = left;
|
|
node.operatorToken = operatorToken;
|
|
node.right = right;
|
|
return finishNode(node);
|
|
}
|
|
function makeAsExpression(left, right) {
|
|
var node = createNode(208 /* AsExpression */, left.pos);
|
|
node.expression = left;
|
|
node.type = right;
|
|
return finishNode(node);
|
|
}
|
|
function parsePrefixUnaryExpression() {
|
|
var node = createNode(198 /* PrefixUnaryExpression */);
|
|
node.operator = token();
|
|
nextToken();
|
|
node.operand = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
function parseDeleteExpression() {
|
|
var node = createNode(194 /* DeleteExpression */);
|
|
nextToken();
|
|
node.expression = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeOfExpression() {
|
|
var node = createNode(195 /* TypeOfExpression */);
|
|
nextToken();
|
|
node.expression = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
function parseVoidExpression() {
|
|
var node = createNode(196 /* VoidExpression */);
|
|
nextToken();
|
|
node.expression = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
function isAwaitExpression() {
|
|
if (token() === 121 /* AwaitKeyword */) {
|
|
if (inAwaitContext()) {
|
|
return true;
|
|
}
|
|
// here we are using similar heuristics as 'isYieldExpression'
|
|
return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
|
|
}
|
|
return false;
|
|
}
|
|
function parseAwaitExpression() {
|
|
var node = createNode(197 /* AwaitExpression */);
|
|
nextToken();
|
|
node.expression = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
/**
|
|
* Parse ES7 exponential expression and await expression
|
|
*
|
|
* ES7 ExponentiationExpression:
|
|
* 1) UnaryExpression[?Yield]
|
|
* 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
|
|
*
|
|
*/
|
|
function parseUnaryExpressionOrHigher() {
|
|
/**
|
|
* ES7 UpdateExpression:
|
|
* 1) LeftHandSideExpression[?Yield]
|
|
* 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
|
|
* 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
|
|
* 4) ++UnaryExpression[?Yield]
|
|
* 5) --UnaryExpression[?Yield]
|
|
*/
|
|
if (isUpdateExpression()) {
|
|
var updateExpression = parseUpdateExpression();
|
|
return token() === 40 /* AsteriskAsteriskToken */ ?
|
|
parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) :
|
|
updateExpression;
|
|
}
|
|
/**
|
|
* ES7 UnaryExpression:
|
|
* 1) UpdateExpression[?yield]
|
|
* 2) delete UpdateExpression[?yield]
|
|
* 3) void UpdateExpression[?yield]
|
|
* 4) typeof UpdateExpression[?yield]
|
|
* 5) + UpdateExpression[?yield]
|
|
* 6) - UpdateExpression[?yield]
|
|
* 7) ~ UpdateExpression[?yield]
|
|
* 8) ! UpdateExpression[?yield]
|
|
*/
|
|
var unaryOperator = token();
|
|
var simpleUnaryExpression = parseSimpleUnaryExpression();
|
|
if (token() === 40 /* AsteriskAsteriskToken */) {
|
|
var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
|
|
var end = simpleUnaryExpression.end;
|
|
if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) {
|
|
parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
|
|
}
|
|
else {
|
|
parseErrorAt(pos, end, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator));
|
|
}
|
|
}
|
|
return simpleUnaryExpression;
|
|
}
|
|
/**
|
|
* Parse ES7 simple-unary expression or higher:
|
|
*
|
|
* ES7 UnaryExpression:
|
|
* 1) UpdateExpression[?yield]
|
|
* 2) delete UnaryExpression[?yield]
|
|
* 3) void UnaryExpression[?yield]
|
|
* 4) typeof UnaryExpression[?yield]
|
|
* 5) + UnaryExpression[?yield]
|
|
* 6) - UnaryExpression[?yield]
|
|
* 7) ~ UnaryExpression[?yield]
|
|
* 8) ! UnaryExpression[?yield]
|
|
* 9) [+Await] await UnaryExpression[?yield]
|
|
*/
|
|
function parseSimpleUnaryExpression() {
|
|
switch (token()) {
|
|
case 37 /* PlusToken */:
|
|
case 38 /* MinusToken */:
|
|
case 52 /* TildeToken */:
|
|
case 51 /* ExclamationToken */:
|
|
return parsePrefixUnaryExpression();
|
|
case 80 /* DeleteKeyword */:
|
|
return parseDeleteExpression();
|
|
case 103 /* TypeOfKeyword */:
|
|
return parseTypeOfExpression();
|
|
case 105 /* VoidKeyword */:
|
|
return parseVoidExpression();
|
|
case 27 /* LessThanToken */:
|
|
// This is modified UnaryExpression grammar in TypeScript
|
|
// UnaryExpression (modified):
|
|
// < type > UnaryExpression
|
|
return parseTypeAssertion();
|
|
case 121 /* AwaitKeyword */:
|
|
if (isAwaitExpression()) {
|
|
return parseAwaitExpression();
|
|
}
|
|
// falls through
|
|
default:
|
|
return parseUpdateExpression();
|
|
}
|
|
}
|
|
/**
|
|
* Check if the current token can possibly be an ES7 increment expression.
|
|
*
|
|
* ES7 UpdateExpression:
|
|
* LeftHandSideExpression[?Yield]
|
|
* LeftHandSideExpression[?Yield][no LineTerminator here]++
|
|
* LeftHandSideExpression[?Yield][no LineTerminator here]--
|
|
* ++LeftHandSideExpression[?Yield]
|
|
* --LeftHandSideExpression[?Yield]
|
|
*/
|
|
function isUpdateExpression() {
|
|
// This function is called inside parseUnaryExpression to decide
|
|
// whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly
|
|
switch (token()) {
|
|
case 37 /* PlusToken */:
|
|
case 38 /* MinusToken */:
|
|
case 52 /* TildeToken */:
|
|
case 51 /* ExclamationToken */:
|
|
case 80 /* DeleteKeyword */:
|
|
case 103 /* TypeOfKeyword */:
|
|
case 105 /* VoidKeyword */:
|
|
case 121 /* AwaitKeyword */:
|
|
return false;
|
|
case 27 /* LessThanToken */:
|
|
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression
|
|
if (sourceFile.languageVariant !== 1 /* JSX */) {
|
|
return false;
|
|
}
|
|
// We are in JSX context and the token is part of JSXElement.
|
|
// falls through
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
/**
|
|
* Parse ES7 UpdateExpression. UpdateExpression is used instead of ES6's PostFixExpression.
|
|
*
|
|
* ES7 UpdateExpression[yield]:
|
|
* 1) LeftHandSideExpression[?yield]
|
|
* 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++
|
|
* 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]--
|
|
* 4) ++LeftHandSideExpression[?yield]
|
|
* 5) --LeftHandSideExpression[?yield]
|
|
* In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression
|
|
*/
|
|
function parseUpdateExpression() {
|
|
if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) {
|
|
var node = createNode(198 /* PrefixUnaryExpression */);
|
|
node.operator = token();
|
|
nextToken();
|
|
node.operand = parseLeftHandSideExpressionOrHigher();
|
|
return finishNode(node);
|
|
}
|
|
else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
|
|
// JSXElement is part of primaryExpression
|
|
return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true);
|
|
}
|
|
var expression = parseLeftHandSideExpressionOrHigher();
|
|
ts.Debug.assert(ts.isLeftHandSideExpression(expression));
|
|
if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) {
|
|
var node = createNode(199 /* PostfixUnaryExpression */, expression.pos);
|
|
node.operand = expression;
|
|
node.operator = token();
|
|
nextToken();
|
|
return finishNode(node);
|
|
}
|
|
return expression;
|
|
}
|
|
function parseLeftHandSideExpressionOrHigher() {
|
|
// Original Ecma:
|
|
// LeftHandSideExpression: See 11.2
|
|
// NewExpression
|
|
// CallExpression
|
|
//
|
|
// Our simplification:
|
|
//
|
|
// LeftHandSideExpression: See 11.2
|
|
// MemberExpression
|
|
// CallExpression
|
|
//
|
|
// See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with
|
|
// MemberExpression to make our lives easier.
|
|
//
|
|
// to best understand the below code, it's important to see how CallExpression expands
|
|
// out into its own productions:
|
|
//
|
|
// CallExpression:
|
|
// MemberExpression Arguments
|
|
// CallExpression Arguments
|
|
// CallExpression[Expression]
|
|
// CallExpression.IdentifierName
|
|
// import (AssignmentExpression)
|
|
// super Arguments
|
|
// super.IdentifierName
|
|
//
|
|
// Because of the recursion in these calls, we need to bottom out first. There are three
|
|
// bottom out states we can run into: 1) We see 'super' which must start either of
|
|
// the last two CallExpression productions. 2) We see 'import' which must start import call.
|
|
// 3)we have a MemberExpression which either completes the LeftHandSideExpression,
|
|
// or starts the beginning of the first four CallExpression productions.
|
|
var expression;
|
|
if (token() === 91 /* ImportKeyword */) {
|
|
if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
|
|
// We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "("
|
|
// For example:
|
|
// var foo3 = require("subfolder
|
|
// import * as foo1 from "module-from-node
|
|
// We want this import to be a statement rather than import call expression
|
|
sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */;
|
|
expression = parseTokenNode();
|
|
}
|
|
else if (lookAhead(nextTokenIsDot)) {
|
|
// This is an 'import.*' metaproperty (i.e. 'import.meta')
|
|
var fullStart = scanner.getStartPos();
|
|
nextToken(); // advance past the 'import'
|
|
nextToken(); // advance past the dot
|
|
var node = createNode(210 /* MetaProperty */, fullStart);
|
|
node.keywordToken = 91 /* ImportKeyword */;
|
|
node.name = parseIdentifierName();
|
|
expression = finishNode(node);
|
|
sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */;
|
|
}
|
|
else {
|
|
expression = parseMemberExpressionOrHigher();
|
|
}
|
|
}
|
|
else {
|
|
expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher();
|
|
}
|
|
// Now, we *may* be complete. However, we might have consumed the start of a
|
|
// CallExpression. As such, we need to consume the rest of it here to be complete.
|
|
return parseCallExpressionRest(expression);
|
|
}
|
|
function parseMemberExpressionOrHigher() {
|
|
// Note: to make our lives simpler, we decompose the NewExpression productions and
|
|
// place ObjectCreationExpression and FunctionExpression into PrimaryExpression.
|
|
// like so:
|
|
//
|
|
// PrimaryExpression : See 11.1
|
|
// this
|
|
// Identifier
|
|
// Literal
|
|
// ArrayLiteral
|
|
// ObjectLiteral
|
|
// (Expression)
|
|
// FunctionExpression
|
|
// new MemberExpression Arguments?
|
|
//
|
|
// MemberExpression : See 11.2
|
|
// PrimaryExpression
|
|
// MemberExpression[Expression]
|
|
// MemberExpression.IdentifierName
|
|
//
|
|
// CallExpression : See 11.2
|
|
// MemberExpression
|
|
// CallExpression Arguments
|
|
// CallExpression[Expression]
|
|
// CallExpression.IdentifierName
|
|
//
|
|
// Technically this is ambiguous. i.e. CallExpression defines:
|
|
//
|
|
// CallExpression:
|
|
// CallExpression Arguments
|
|
//
|
|
// If you see: "new Foo()"
|
|
//
|
|
// Then that could be treated as a single ObjectCreationExpression, or it could be
|
|
// treated as the invocation of "new Foo". We disambiguate that in code (to match
|
|
// the original grammar) by making sure that if we see an ObjectCreationExpression
|
|
// we always consume arguments if they are there. So we treat "new Foo()" as an
|
|
// object creation only, and not at all as an invocation. Another way to think
|
|
// about this is that for every "new" that we see, we will consume an argument list if
|
|
// it is there as part of the *associated* object creation node. Any additional
|
|
// argument lists we see, will become invocation expressions.
|
|
//
|
|
// Because there are no other places in the grammar now that refer to FunctionExpression
|
|
// or ObjectCreationExpression, it is safe to push down into the PrimaryExpression
|
|
// production.
|
|
//
|
|
// Because CallExpression and MemberExpression are left recursive, we need to bottom out
|
|
// of the recursion immediately. So we parse out a primary expression to start with.
|
|
var expression = parsePrimaryExpression();
|
|
return parseMemberExpressionRest(expression);
|
|
}
|
|
function parseSuperExpression() {
|
|
var expression = parseTokenNode();
|
|
if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) {
|
|
return expression;
|
|
}
|
|
// If we have seen "super" it must be followed by '(' or '.'.
|
|
// If it wasn't then just try to parse out a '.' and report an error.
|
|
var node = createNode(185 /* PropertyAccessExpression */, expression.pos);
|
|
node.expression = expression;
|
|
parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
|
|
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) {
|
|
var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
|
|
var result;
|
|
if (opening.kind === 257 /* JsxOpeningElement */) {
|
|
var node = createNode(255 /* JsxElement */, opening.pos);
|
|
node.openingElement = opening;
|
|
node.children = parseJsxChildren(node.openingElement);
|
|
node.closingElement = parseJsxClosingElement(inExpressionContext);
|
|
if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
|
|
parseErrorAtRange(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
|
|
}
|
|
result = finishNode(node);
|
|
}
|
|
else if (opening.kind === 260 /* JsxOpeningFragment */) {
|
|
var node = createNode(259 /* JsxFragment */, opening.pos);
|
|
node.openingFragment = opening;
|
|
node.children = parseJsxChildren(node.openingFragment);
|
|
node.closingFragment = parseJsxClosingFragment(inExpressionContext);
|
|
result = finishNode(node);
|
|
}
|
|
else {
|
|
ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */);
|
|
// Nothing else to do for self-closing elements
|
|
result = opening;
|
|
}
|
|
// If the user writes the invalid code '<div></div><div></div>' in an expression context (i.e. not wrapped in
|
|
// an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag
|
|
// as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX
|
|
// element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter
|
|
// does less damage and we can report a better error.
|
|
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
|
|
// of one sort or another.
|
|
if (inExpressionContext && token() === 27 /* LessThanToken */) {
|
|
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); });
|
|
if (invalidElement) {
|
|
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
|
|
var badNode = createNode(200 /* BinaryExpression */, result.pos);
|
|
badNode.end = invalidElement.end;
|
|
badNode.left = result;
|
|
badNode.right = invalidElement;
|
|
badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217
|
|
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
|
|
return badNode;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function parseJsxText() {
|
|
var node = createNode(10 /* JsxText */);
|
|
node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */;
|
|
currentToken = scanner.scanJsxToken();
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxChild(openingTag, token) {
|
|
switch (token) {
|
|
case 1 /* EndOfFileToken */:
|
|
// If we hit EOF, issue the error at the tag that lacks the closing element
|
|
// rather than at the end of the file (which is useless)
|
|
if (ts.isJsxOpeningFragment(openingTag)) {
|
|
parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
|
|
}
|
|
else {
|
|
parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
|
|
}
|
|
return undefined;
|
|
case 28 /* LessThanSlashToken */:
|
|
case 7 /* ConflictMarkerTrivia */:
|
|
return undefined;
|
|
case 10 /* JsxText */:
|
|
case 11 /* JsxTextAllWhiteSpaces */:
|
|
return parseJsxText();
|
|
case 17 /* OpenBraceToken */:
|
|
return parseJsxExpression(/*inExpressionContext*/ false);
|
|
case 27 /* LessThanToken */:
|
|
return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false);
|
|
default:
|
|
return ts.Debug.assertNever(token);
|
|
}
|
|
}
|
|
function parseJsxChildren(openingTag) {
|
|
var list = [];
|
|
var listPos = getNodePos();
|
|
var saveParsingContext = parsingContext;
|
|
parsingContext |= 1 << 14 /* JsxChildren */;
|
|
while (true) {
|
|
var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
|
|
if (!child)
|
|
break;
|
|
list.push(child);
|
|
}
|
|
parsingContext = saveParsingContext;
|
|
return createNodeArray(list, listPos);
|
|
}
|
|
function parseJsxAttributes() {
|
|
var jsxAttributes = createNode(263 /* JsxAttributes */);
|
|
jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute);
|
|
return finishNode(jsxAttributes);
|
|
}
|
|
function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
|
|
var fullStart = scanner.getStartPos();
|
|
parseExpected(27 /* LessThanToken */);
|
|
if (token() === 29 /* GreaterThanToken */) {
|
|
// See below for explanation of scanJsxText
|
|
var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart);
|
|
scanJsxText();
|
|
return finishNode(node_1);
|
|
}
|
|
var tagName = parseJsxElementName();
|
|
var typeArguments = tryParseTypeArguments();
|
|
var attributes = parseJsxAttributes();
|
|
var node;
|
|
if (token() === 29 /* GreaterThanToken */) {
|
|
// Closing tag, so scan the immediately-following text with the JSX scanning instead
|
|
// of regular scanning to avoid treating illegal characters (e.g. '#') as immediate
|
|
// scanning errors
|
|
node = createNode(257 /* JsxOpeningElement */, fullStart);
|
|
scanJsxText();
|
|
}
|
|
else {
|
|
parseExpected(41 /* SlashToken */);
|
|
if (inExpressionContext) {
|
|
parseExpected(29 /* GreaterThanToken */);
|
|
}
|
|
else {
|
|
parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false);
|
|
scanJsxText();
|
|
}
|
|
node = createNode(256 /* JsxSelfClosingElement */, fullStart);
|
|
}
|
|
node.tagName = tagName;
|
|
node.typeArguments = typeArguments;
|
|
node.attributes = attributes;
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxElementName() {
|
|
scanJsxIdentifier();
|
|
// JsxElement can have name in the form of
|
|
// propertyAccessExpression
|
|
// primaryExpression in the form of an identifier and "this" keyword
|
|
// We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
|
|
// We only want to consider "this" as a primaryExpression
|
|
var expression = token() === 99 /* ThisKeyword */ ?
|
|
parseTokenNode() : parseIdentifierName();
|
|
while (parseOptional(23 /* DotToken */)) {
|
|
var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos);
|
|
propertyAccess.expression = expression;
|
|
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
|
expression = finishNode(propertyAccess);
|
|
}
|
|
return expression;
|
|
}
|
|
function parseJsxExpression(inExpressionContext) {
|
|
var node = createNode(265 /* JsxExpression */);
|
|
if (!parseExpected(17 /* OpenBraceToken */)) {
|
|
return undefined;
|
|
}
|
|
if (token() !== 18 /* CloseBraceToken */) {
|
|
node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */);
|
|
node.expression = parseAssignmentExpressionOrHigher();
|
|
}
|
|
if (inExpressionContext) {
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false);
|
|
scanJsxText();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxAttribute() {
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
return parseJsxSpreadAttribute();
|
|
}
|
|
scanJsxIdentifier();
|
|
var node = createNode(262 /* JsxAttribute */);
|
|
node.name = parseIdentifierName();
|
|
if (token() === 58 /* EqualsToken */) {
|
|
switch (scanJsxAttributeValue()) {
|
|
case 9 /* StringLiteral */:
|
|
node.initializer = parseLiteralNode();
|
|
break;
|
|
default:
|
|
node.initializer = parseJsxExpression(/*inExpressionContext*/ true);
|
|
break;
|
|
}
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxSpreadAttribute() {
|
|
var node = createNode(264 /* JsxSpreadAttribute */);
|
|
parseExpected(17 /* OpenBraceToken */);
|
|
parseExpected(24 /* DotDotDotToken */);
|
|
node.expression = parseExpression();
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxClosingElement(inExpressionContext) {
|
|
var node = createNode(258 /* JsxClosingElement */);
|
|
parseExpected(28 /* LessThanSlashToken */);
|
|
node.tagName = parseJsxElementName();
|
|
if (inExpressionContext) {
|
|
parseExpected(29 /* GreaterThanToken */);
|
|
}
|
|
else {
|
|
parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false);
|
|
scanJsxText();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseJsxClosingFragment(inExpressionContext) {
|
|
var node = createNode(261 /* JsxClosingFragment */);
|
|
parseExpected(28 /* LessThanSlashToken */);
|
|
if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
|
|
}
|
|
if (inExpressionContext) {
|
|
parseExpected(29 /* GreaterThanToken */);
|
|
}
|
|
else {
|
|
parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false);
|
|
scanJsxText();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeAssertion() {
|
|
var node = createNode(190 /* TypeAssertionExpression */);
|
|
parseExpected(27 /* LessThanToken */);
|
|
node.type = parseType();
|
|
parseExpected(29 /* GreaterThanToken */);
|
|
node.expression = parseSimpleUnaryExpression();
|
|
return finishNode(node);
|
|
}
|
|
function parseMemberExpressionRest(expression) {
|
|
while (true) {
|
|
var dotToken = parseOptionalToken(23 /* DotToken */);
|
|
if (dotToken) {
|
|
var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos);
|
|
propertyAccess.expression = expression;
|
|
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
|
expression = finishNode(propertyAccess);
|
|
continue;
|
|
}
|
|
if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
nextToken();
|
|
var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos);
|
|
nonNullExpression.expression = expression;
|
|
expression = finishNode(nonNullExpression);
|
|
continue;
|
|
}
|
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) {
|
|
var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos);
|
|
indexedAccess.expression = expression;
|
|
if (token() === 22 /* CloseBracketToken */) {
|
|
indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
|
|
}
|
|
else {
|
|
var argument = allowInAnd(parseExpression);
|
|
if (ts.isStringOrNumericLiteral(argument)) {
|
|
argument.text = internIdentifier(argument.text);
|
|
}
|
|
indexedAccess.argumentExpression = argument;
|
|
}
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
expression = finishNode(indexedAccess);
|
|
continue;
|
|
}
|
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined);
|
|
continue;
|
|
}
|
|
return expression;
|
|
}
|
|
}
|
|
function isTemplateStartOfTaggedTemplate() {
|
|
return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */;
|
|
}
|
|
function parseTaggedTemplateRest(tag, typeArguments) {
|
|
var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos);
|
|
tagExpression.tag = tag;
|
|
tagExpression.typeArguments = typeArguments;
|
|
tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */
|
|
? parseLiteralNode()
|
|
: parseTemplateExpression();
|
|
return finishNode(tagExpression);
|
|
}
|
|
function parseCallExpressionRest(expression) {
|
|
while (true) {
|
|
expression = parseMemberExpressionRest(expression);
|
|
if (token() === 27 /* LessThanToken */) {
|
|
// See if this is the start of a generic invocation. If so, consume it and
|
|
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
|
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
// stack.
|
|
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
if (!typeArguments) {
|
|
return expression;
|
|
}
|
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
expression = parseTaggedTemplateRest(expression, typeArguments);
|
|
continue;
|
|
}
|
|
var callExpr = createNode(187 /* CallExpression */, expression.pos);
|
|
callExpr.expression = expression;
|
|
callExpr.typeArguments = typeArguments;
|
|
callExpr.arguments = parseArgumentList();
|
|
expression = finishNode(callExpr);
|
|
continue;
|
|
}
|
|
else if (token() === 19 /* OpenParenToken */) {
|
|
var callExpr = createNode(187 /* CallExpression */, expression.pos);
|
|
callExpr.expression = expression;
|
|
callExpr.arguments = parseArgumentList();
|
|
expression = finishNode(callExpr);
|
|
continue;
|
|
}
|
|
return expression;
|
|
}
|
|
}
|
|
function parseArgumentList() {
|
|
parseExpected(19 /* OpenParenToken */);
|
|
var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
return result;
|
|
}
|
|
function parseTypeArgumentsInExpression() {
|
|
if (!parseOptional(27 /* LessThanToken */)) {
|
|
return undefined;
|
|
}
|
|
var typeArguments = parseDelimitedList(19 /* TypeArguments */, parseType);
|
|
if (!parseExpected(29 /* GreaterThanToken */)) {
|
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
return undefined;
|
|
}
|
|
// If we have a '<', then only parse this as a argument list if the type arguments
|
|
// are complete and we have an open paren. if we don't, rewind and return nothing.
|
|
return typeArguments && canFollowTypeArgumentsInExpression()
|
|
? typeArguments
|
|
: undefined;
|
|
}
|
|
function canFollowTypeArgumentsInExpression() {
|
|
switch (token()) {
|
|
case 19 /* OpenParenToken */: // foo<x>(
|
|
case 13 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
case 14 /* TemplateHead */: // foo<T> `...${100}...`
|
|
// these are the only tokens can legally follow a type argument
|
|
// list. So we definitely want to treat them as type arg lists.
|
|
case 23 /* DotToken */: // foo<x>.
|
|
case 20 /* CloseParenToken */: // foo<x>)
|
|
case 22 /* CloseBracketToken */: // foo<x>]
|
|
case 56 /* ColonToken */: // foo<x>:
|
|
case 25 /* SemicolonToken */: // foo<x>;
|
|
case 55 /* QuestionToken */: // foo<x>?
|
|
case 32 /* EqualsEqualsToken */: // foo<x> ==
|
|
case 34 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
case 33 /* ExclamationEqualsToken */: // foo<x> !=
|
|
case 35 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
case 53 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
case 54 /* BarBarToken */: // foo<x> ||
|
|
case 50 /* CaretToken */: // foo<x> ^
|
|
case 48 /* AmpersandToken */: // foo<x> &
|
|
case 49 /* BarToken */: // foo<x> |
|
|
case 18 /* CloseBraceToken */: // foo<x> }
|
|
case 1 /* EndOfFileToken */: // foo<x>
|
|
// these cases can't legally follow a type arg list. However, they're not legal
|
|
// expressions either. The user is probably in the middle of a generic type. So
|
|
// treat it as such.
|
|
return true;
|
|
case 26 /* CommaToken */: // foo<x>,
|
|
case 17 /* OpenBraceToken */: // foo<x> {
|
|
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
|
// as an invocation expression. Instead, we want to parse out the expression
|
|
// in isolation from the type arguments.
|
|
default:
|
|
// Anything else treat as an expression.
|
|
return false;
|
|
}
|
|
}
|
|
function parsePrimaryExpression() {
|
|
switch (token()) {
|
|
case 8 /* NumericLiteral */:
|
|
case 9 /* StringLiteral */:
|
|
case 13 /* NoSubstitutionTemplateLiteral */:
|
|
return parseLiteralNode();
|
|
case 99 /* ThisKeyword */:
|
|
case 97 /* SuperKeyword */:
|
|
case 95 /* NullKeyword */:
|
|
case 101 /* TrueKeyword */:
|
|
case 86 /* FalseKeyword */:
|
|
return parseTokenNode();
|
|
case 19 /* OpenParenToken */:
|
|
return parseParenthesizedExpression();
|
|
case 21 /* OpenBracketToken */:
|
|
return parseArrayLiteralExpression();
|
|
case 17 /* OpenBraceToken */:
|
|
return parseObjectLiteralExpression();
|
|
case 120 /* AsyncKeyword */:
|
|
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
|
|
// If we encounter `async [no LineTerminator here] function` then this is an async
|
|
// function; otherwise, its an identifier.
|
|
if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
|
|
break;
|
|
}
|
|
return parseFunctionExpression();
|
|
case 75 /* ClassKeyword */:
|
|
return parseClassExpression();
|
|
case 89 /* FunctionKeyword */:
|
|
return parseFunctionExpression();
|
|
case 94 /* NewKeyword */:
|
|
return parseNewExpressionOrNewDotTarget();
|
|
case 41 /* SlashToken */:
|
|
case 63 /* SlashEqualsToken */:
|
|
if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) {
|
|
return parseLiteralNode();
|
|
}
|
|
break;
|
|
case 14 /* TemplateHead */:
|
|
return parseTemplateExpression();
|
|
}
|
|
return parseIdentifier(ts.Diagnostics.Expression_expected);
|
|
}
|
|
function parseParenthesizedExpression() {
|
|
var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseSpreadElement() {
|
|
var node = createNode(204 /* SpreadElement */);
|
|
parseExpected(24 /* DotDotDotToken */);
|
|
node.expression = parseAssignmentExpressionOrHigher();
|
|
return finishNode(node);
|
|
}
|
|
function parseArgumentOrArrayLiteralElement() {
|
|
return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) :
|
|
parseAssignmentExpressionOrHigher();
|
|
}
|
|
function parseArgumentExpression() {
|
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
}
|
|
function parseArrayLiteralExpression() {
|
|
var node = createNode(183 /* ArrayLiteralExpression */);
|
|
parseExpected(21 /* OpenBracketToken */);
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
node.multiLine = true;
|
|
}
|
|
node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseObjectLiteralElement() {
|
|
var node = createNodeWithJSDoc(0 /* Unknown */);
|
|
if (parseOptionalToken(24 /* DotDotDotToken */)) {
|
|
node.kind = 272 /* SpreadAssignment */;
|
|
node.expression = parseAssignmentExpressionOrHigher();
|
|
return finishNode(node);
|
|
}
|
|
node.decorators = parseDecorators();
|
|
node.modifiers = parseModifiers();
|
|
if (parseContextualModifier(125 /* GetKeyword */)) {
|
|
return parseAccessorDeclaration(node, 156 /* GetAccessor */);
|
|
}
|
|
if (parseContextualModifier(136 /* SetKeyword */)) {
|
|
return parseAccessorDeclaration(node, 157 /* SetAccessor */);
|
|
}
|
|
var asteriskToken = parseOptionalToken(39 /* AsteriskToken */);
|
|
var tokenIsIdentifier = isIdentifier();
|
|
node.name = parsePropertyName();
|
|
// Disallowing of optional property assignments happens in the grammar checker.
|
|
node.questionToken = parseOptionalToken(55 /* QuestionToken */);
|
|
if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) {
|
|
return parseMethodDeclaration(node, asteriskToken);
|
|
}
|
|
// check if it is short-hand property assignment or normal property assignment
|
|
// NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production
|
|
// CoverInitializedName[Yield] :
|
|
// IdentifierReference[?Yield] Initializer[In, ?Yield]
|
|
// this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern
|
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */);
|
|
if (isShorthandPropertyAssignment) {
|
|
node.kind = 271 /* ShorthandPropertyAssignment */;
|
|
var equalsToken = parseOptionalToken(58 /* EqualsToken */);
|
|
if (equalsToken) {
|
|
node.equalsToken = equalsToken;
|
|
node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
}
|
|
}
|
|
else {
|
|
node.kind = 270 /* PropertyAssignment */;
|
|
parseExpected(56 /* ColonToken */);
|
|
node.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseObjectLiteralExpression() {
|
|
var node = createNode(184 /* ObjectLiteralExpression */);
|
|
parseExpected(17 /* OpenBraceToken */);
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
node.multiLine = true;
|
|
}
|
|
node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseFunctionExpression() {
|
|
// GeneratorExpression:
|
|
// function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody }
|
|
//
|
|
// FunctionExpression:
|
|
// function BindingIdentifier[opt](FormalParameters){ FunctionBody }
|
|
var saveDecoratorContext = inDecoratorContext();
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ false);
|
|
}
|
|
var node = createNodeWithJSDoc(192 /* FunctionExpression */);
|
|
node.modifiers = parseModifiers();
|
|
parseExpected(89 /* FunctionKeyword */);
|
|
node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */);
|
|
var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
|
var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */;
|
|
node.name =
|
|
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
|
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
|
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
|
parseOptionalIdentifier();
|
|
fillSignature(56 /* ColonToken */, isGenerator | isAsync, node);
|
|
node.body = parseFunctionBlock(isGenerator | isAsync);
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ true);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseOptionalIdentifier() {
|
|
return isIdentifier() ? parseIdentifier() : undefined;
|
|
}
|
|
function parseNewExpressionOrNewDotTarget() {
|
|
var fullStart = scanner.getStartPos();
|
|
parseExpected(94 /* NewKeyword */);
|
|
if (parseOptional(23 /* DotToken */)) {
|
|
var node_2 = createNode(210 /* MetaProperty */, fullStart);
|
|
node_2.keywordToken = 94 /* NewKeyword */;
|
|
node_2.name = parseIdentifierName();
|
|
return finishNode(node_2);
|
|
}
|
|
var expression = parsePrimaryExpression();
|
|
var typeArguments;
|
|
while (true) {
|
|
expression = parseMemberExpressionRest(expression);
|
|
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
expression = parseTaggedTemplateRest(expression, typeArguments);
|
|
typeArguments = undefined;
|
|
}
|
|
break;
|
|
}
|
|
var node = createNode(188 /* NewExpression */, fullStart);
|
|
node.expression = expression;
|
|
node.typeArguments = typeArguments;
|
|
if (node.typeArguments || token() === 19 /* OpenParenToken */) {
|
|
node.arguments = parseArgumentList();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
// STATEMENTS
|
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
var node = createNode(213 /* Block */);
|
|
if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
node.multiLine = true;
|
|
}
|
|
node.statements = parseList(1 /* BlockStatements */, parseStatement);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
node.statements = createMissingList();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseFunctionBlock(flags, diagnosticMessage) {
|
|
var savedYieldContext = inYieldContext();
|
|
setYieldContext(!!(flags & 1 /* Yield */));
|
|
var savedAwaitContext = inAwaitContext();
|
|
setAwaitContext(!!(flags & 2 /* Await */));
|
|
// We may be in a [Decorator] context when parsing a function expression or
|
|
// arrow function. The body of the function is not in [Decorator] context.
|
|
var saveDecoratorContext = inDecoratorContext();
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ false);
|
|
}
|
|
var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage);
|
|
if (saveDecoratorContext) {
|
|
setDecoratorContext(/*val*/ true);
|
|
}
|
|
setYieldContext(savedYieldContext);
|
|
setAwaitContext(savedAwaitContext);
|
|
return block;
|
|
}
|
|
function parseEmptyStatement() {
|
|
var node = createNode(215 /* EmptyStatement */);
|
|
parseExpected(25 /* SemicolonToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseIfStatement() {
|
|
var node = createNode(217 /* IfStatement */);
|
|
parseExpected(90 /* IfKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
node.thenStatement = parseStatement();
|
|
node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined;
|
|
return finishNode(node);
|
|
}
|
|
function parseDoStatement() {
|
|
var node = createNode(218 /* DoStatement */);
|
|
parseExpected(81 /* DoKeyword */);
|
|
node.statement = parseStatement();
|
|
parseExpected(106 /* WhileKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
|
|
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
|
|
// spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
|
|
// do;while(0)x will have a semicolon inserted before x.
|
|
parseOptional(25 /* SemicolonToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseWhileStatement() {
|
|
var node = createNode(219 /* WhileStatement */);
|
|
parseExpected(106 /* WhileKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
node.statement = parseStatement();
|
|
return finishNode(node);
|
|
}
|
|
function parseForOrForInOrForOfStatement() {
|
|
var pos = getNodePos();
|
|
parseExpected(88 /* ForKeyword */);
|
|
var awaitToken = parseOptionalToken(121 /* AwaitKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
var initializer;
|
|
if (token() !== 25 /* SemicolonToken */) {
|
|
if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) {
|
|
initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true);
|
|
}
|
|
else {
|
|
initializer = disallowInAnd(parseExpression);
|
|
}
|
|
}
|
|
var forOrForInOrForOfStatement;
|
|
if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) {
|
|
var forOfStatement = createNode(222 /* ForOfStatement */, pos);
|
|
forOfStatement.awaitModifier = awaitToken;
|
|
forOfStatement.initializer = initializer;
|
|
forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
forOrForInOrForOfStatement = forOfStatement;
|
|
}
|
|
else if (parseOptional(92 /* InKeyword */)) {
|
|
var forInStatement = createNode(221 /* ForInStatement */, pos);
|
|
forInStatement.initializer = initializer;
|
|
forInStatement.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
forOrForInOrForOfStatement = forInStatement;
|
|
}
|
|
else {
|
|
var forStatement = createNode(220 /* ForStatement */, pos);
|
|
forStatement.initializer = initializer;
|
|
parseExpected(25 /* SemicolonToken */);
|
|
if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) {
|
|
forStatement.condition = allowInAnd(parseExpression);
|
|
}
|
|
parseExpected(25 /* SemicolonToken */);
|
|
if (token() !== 20 /* CloseParenToken */) {
|
|
forStatement.incrementor = allowInAnd(parseExpression);
|
|
}
|
|
parseExpected(20 /* CloseParenToken */);
|
|
forOrForInOrForOfStatement = forStatement;
|
|
}
|
|
forOrForInOrForOfStatement.statement = parseStatement();
|
|
return finishNode(forOrForInOrForOfStatement);
|
|
}
|
|
function parseBreakOrContinueStatement(kind) {
|
|
var node = createNode(kind);
|
|
parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */);
|
|
if (!canParseSemicolon()) {
|
|
node.label = parseIdentifier();
|
|
}
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseReturnStatement() {
|
|
var node = createNode(225 /* ReturnStatement */);
|
|
parseExpected(96 /* ReturnKeyword */);
|
|
if (!canParseSemicolon()) {
|
|
node.expression = allowInAnd(parseExpression);
|
|
}
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseWithStatement() {
|
|
var node = createNode(226 /* WithStatement */);
|
|
parseExpected(107 /* WithKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement);
|
|
return finishNode(node);
|
|
}
|
|
function parseCaseClause() {
|
|
var node = createNode(266 /* CaseClause */);
|
|
parseExpected(73 /* CaseKeyword */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(56 /* ColonToken */);
|
|
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
return finishNode(node);
|
|
}
|
|
function parseDefaultClause() {
|
|
var node = createNode(267 /* DefaultClause */);
|
|
parseExpected(79 /* DefaultKeyword */);
|
|
parseExpected(56 /* ColonToken */);
|
|
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
return finishNode(node);
|
|
}
|
|
function parseCaseOrDefaultClause() {
|
|
return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
|
|
}
|
|
function parseSwitchStatement() {
|
|
var node = createNode(227 /* SwitchStatement */);
|
|
parseExpected(98 /* SwitchKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = allowInAnd(parseExpression);
|
|
parseExpected(20 /* CloseParenToken */);
|
|
var caseBlock = createNode(241 /* CaseBlock */);
|
|
parseExpected(17 /* OpenBraceToken */);
|
|
caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
node.caseBlock = finishNode(caseBlock);
|
|
return finishNode(node);
|
|
}
|
|
function parseThrowStatement() {
|
|
// ThrowStatement[Yield] :
|
|
// throw [no LineTerminator here]Expression[In, ?Yield];
|
|
// Because of automatic semicolon insertion, we need to report error if this
|
|
// throw could be terminated with a semicolon. Note: we can't call 'parseExpression'
|
|
// directly as that might consume an expression on the following line.
|
|
// We just return 'undefined' in that case. The actual error will be reported in the
|
|
// grammar walker.
|
|
var node = createNode(229 /* ThrowStatement */);
|
|
parseExpected(100 /* ThrowKeyword */);
|
|
node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
// TODO: Review for error recovery
|
|
function parseTryStatement() {
|
|
var node = createNode(230 /* TryStatement */);
|
|
parseExpected(102 /* TryKeyword */);
|
|
node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined;
|
|
// If we don't have a catch clause, then we must have a finally clause. Try to parse
|
|
// one out no matter what.
|
|
if (!node.catchClause || token() === 87 /* FinallyKeyword */) {
|
|
parseExpected(87 /* FinallyKeyword */);
|
|
node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseCatchClause() {
|
|
var result = createNode(269 /* CatchClause */);
|
|
parseExpected(74 /* CatchKeyword */);
|
|
if (parseOptional(19 /* OpenParenToken */)) {
|
|
result.variableDeclaration = parseVariableDeclaration();
|
|
parseExpected(20 /* CloseParenToken */);
|
|
}
|
|
else {
|
|
// Keep shape of node to avoid degrading performance.
|
|
result.variableDeclaration = undefined;
|
|
}
|
|
result.block = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
return finishNode(result);
|
|
}
|
|
function parseDebuggerStatement() {
|
|
var node = createNode(231 /* DebuggerStatement */);
|
|
parseExpected(78 /* DebuggerKeyword */);
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseExpressionOrLabeledStatement() {
|
|
// Avoiding having to do the lookahead for a labeled statement by just trying to parse
|
|
// out an expression, seeing if it is identifier and then seeing if it is followed by
|
|
// a colon.
|
|
var node = createNodeWithJSDoc(0 /* Unknown */);
|
|
var expression = allowInAnd(parseExpression);
|
|
if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) {
|
|
node.kind = 228 /* LabeledStatement */;
|
|
node.label = expression;
|
|
node.statement = parseStatement();
|
|
}
|
|
else {
|
|
node.kind = 216 /* ExpressionStatement */;
|
|
node.expression = expression;
|
|
parseSemicolon();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function nextTokenIsIdentifierOrKeywordOnSameLine() {
|
|
nextToken();
|
|
return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
|
|
}
|
|
function nextTokenIsClassKeywordOnSameLine() {
|
|
nextToken();
|
|
return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak();
|
|
}
|
|
function nextTokenIsFunctionKeywordOnSameLine() {
|
|
nextToken();
|
|
return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak();
|
|
}
|
|
function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
|
|
nextToken();
|
|
return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak();
|
|
}
|
|
function isDeclaration() {
|
|
while (true) {
|
|
switch (token()) {
|
|
case 104 /* VarKeyword */:
|
|
case 110 /* LetKeyword */:
|
|
case 76 /* ConstKeyword */:
|
|
case 89 /* FunctionKeyword */:
|
|
case 75 /* ClassKeyword */:
|
|
case 83 /* EnumKeyword */:
|
|
return true;
|
|
// 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers;
|
|
// however, an identifier cannot be followed by another identifier on the same line. This is what we
|
|
// count on to parse out the respective declarations. For instance, we exploit this to say that
|
|
//
|
|
// namespace n
|
|
//
|
|
// can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees
|
|
//
|
|
// namespace
|
|
// n
|
|
//
|
|
// as the identifier 'namespace' on one line followed by the identifier 'n' on another.
|
|
// We need to look one token ahead to see if it permissible to try parsing a declaration.
|
|
//
|
|
// *Note*: 'interface' is actually a strict mode reserved word. So while
|
|
//
|
|
// "use strict"
|
|
// interface
|
|
// I {}
|
|
//
|
|
// could be legal, it would add complexity for very little gain.
|
|
case 109 /* InterfaceKeyword */:
|
|
case 139 /* TypeKeyword */:
|
|
return nextTokenIsIdentifierOnSameLine();
|
|
case 129 /* ModuleKeyword */:
|
|
case 130 /* NamespaceKeyword */:
|
|
return nextTokenIsIdentifierOrStringLiteralOnSameLine();
|
|
case 117 /* AbstractKeyword */:
|
|
case 120 /* AsyncKeyword */:
|
|
case 124 /* DeclareKeyword */:
|
|
case 112 /* PrivateKeyword */:
|
|
case 113 /* ProtectedKeyword */:
|
|
case 114 /* PublicKeyword */:
|
|
case 132 /* ReadonlyKeyword */:
|
|
nextToken();
|
|
// ASI takes effect for this modifier.
|
|
if (scanner.hasPrecedingLineBreak()) {
|
|
return false;
|
|
}
|
|
continue;
|
|
case 144 /* GlobalKeyword */:
|
|
nextToken();
|
|
return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */;
|
|
case 91 /* ImportKeyword */:
|
|
nextToken();
|
|
return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ ||
|
|
token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token());
|
|
case 84 /* ExportKeyword */:
|
|
nextToken();
|
|
if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ ||
|
|
token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ ||
|
|
token() === 118 /* AsKeyword */) {
|
|
return true;
|
|
}
|
|
continue;
|
|
case 115 /* StaticKeyword */:
|
|
nextToken();
|
|
continue;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
function isStartOfDeclaration() {
|
|
return lookAhead(isDeclaration);
|
|
}
|
|
function isStartOfStatement() {
|
|
switch (token()) {
|
|
case 57 /* AtToken */:
|
|
case 25 /* SemicolonToken */:
|
|
case 17 /* OpenBraceToken */:
|
|
case 104 /* VarKeyword */:
|
|
case 110 /* LetKeyword */:
|
|
case 89 /* FunctionKeyword */:
|
|
case 75 /* ClassKeyword */:
|
|
case 83 /* EnumKeyword */:
|
|
case 90 /* IfKeyword */:
|
|
case 81 /* DoKeyword */:
|
|
case 106 /* WhileKeyword */:
|
|
case 88 /* ForKeyword */:
|
|
case 77 /* ContinueKeyword */:
|
|
case 72 /* BreakKeyword */:
|
|
case 96 /* ReturnKeyword */:
|
|
case 107 /* WithKeyword */:
|
|
case 98 /* SwitchKeyword */:
|
|
case 100 /* ThrowKeyword */:
|
|
case 102 /* TryKeyword */:
|
|
case 78 /* DebuggerKeyword */:
|
|
// 'catch' and 'finally' do not actually indicate that the code is part of a statement,
|
|
// however, we say they are here so that we may gracefully parse them and error later.
|
|
case 74 /* CatchKeyword */:
|
|
case 87 /* FinallyKeyword */:
|
|
return true;
|
|
case 91 /* ImportKeyword */:
|
|
return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
|
|
case 76 /* ConstKeyword */:
|
|
case 84 /* ExportKeyword */:
|
|
return isStartOfDeclaration();
|
|
case 120 /* AsyncKeyword */:
|
|
case 124 /* DeclareKeyword */:
|
|
case 109 /* InterfaceKeyword */:
|
|
case 129 /* ModuleKeyword */:
|
|
case 130 /* NamespaceKeyword */:
|
|
case 139 /* TypeKeyword */:
|
|
case 144 /* GlobalKeyword */:
|
|
// When these don't start a declaration, they're an identifier in an expression statement
|
|
return true;
|
|
case 114 /* PublicKeyword */:
|
|
case 112 /* PrivateKeyword */:
|
|
case 113 /* ProtectedKeyword */:
|
|
case 115 /* StaticKeyword */:
|
|
case 132 /* ReadonlyKeyword */:
|
|
// When these don't start a declaration, they may be the start of a class member if an identifier
|
|
// immediately follows. Otherwise they're an identifier in an expression statement.
|
|
return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
|
|
default:
|
|
return isStartOfExpression();
|
|
}
|
|
}
|
|
function nextTokenIsIdentifierOrStartOfDestructuring() {
|
|
nextToken();
|
|
return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */;
|
|
}
|
|
function isLetDeclaration() {
|
|
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
|
// or [.
|
|
return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
|
|
}
|
|
function parseStatement() {
|
|
switch (token()) {
|
|
case 25 /* SemicolonToken */:
|
|
return parseEmptyStatement();
|
|
case 17 /* OpenBraceToken */:
|
|
return parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
case 104 /* VarKeyword */:
|
|
return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */));
|
|
case 110 /* LetKeyword */:
|
|
if (isLetDeclaration()) {
|
|
return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */));
|
|
}
|
|
break;
|
|
case 89 /* FunctionKeyword */:
|
|
return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */));
|
|
case 75 /* ClassKeyword */:
|
|
return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */));
|
|
case 90 /* IfKeyword */:
|
|
return parseIfStatement();
|
|
case 81 /* DoKeyword */:
|
|
return parseDoStatement();
|
|
case 106 /* WhileKeyword */:
|
|
return parseWhileStatement();
|
|
case 88 /* ForKeyword */:
|
|
return parseForOrForInOrForOfStatement();
|
|
case 77 /* ContinueKeyword */:
|
|
return parseBreakOrContinueStatement(223 /* ContinueStatement */);
|
|
case 72 /* BreakKeyword */:
|
|
return parseBreakOrContinueStatement(224 /* BreakStatement */);
|
|
case 96 /* ReturnKeyword */:
|
|
return parseReturnStatement();
|
|
case 107 /* WithKeyword */:
|
|
return parseWithStatement();
|
|
case 98 /* SwitchKeyword */:
|
|
return parseSwitchStatement();
|
|
case 100 /* ThrowKeyword */:
|
|
return parseThrowStatement();
|
|
case 102 /* TryKeyword */:
|
|
// Include 'catch' and 'finally' for error recovery.
|
|
case 74 /* CatchKeyword */:
|
|
case 87 /* FinallyKeyword */:
|
|
return parseTryStatement();
|
|
case 78 /* DebuggerKeyword */:
|
|
return parseDebuggerStatement();
|
|
case 57 /* AtToken */:
|
|
return parseDeclaration();
|
|
case 120 /* AsyncKeyword */:
|
|
case 109 /* InterfaceKeyword */:
|
|
case 139 /* TypeKeyword */:
|
|
case 129 /* ModuleKeyword */:
|
|
case 130 /* NamespaceKeyword */:
|
|
case 124 /* DeclareKeyword */:
|
|
case 76 /* ConstKeyword */:
|
|
case 83 /* EnumKeyword */:
|
|
case 84 /* ExportKeyword */:
|
|
case 91 /* ImportKeyword */:
|
|
case 112 /* PrivateKeyword */:
|
|
case 113 /* ProtectedKeyword */:
|
|
case 114 /* PublicKeyword */:
|
|
case 117 /* AbstractKeyword */:
|
|
case 115 /* StaticKeyword */:
|
|
case 132 /* ReadonlyKeyword */:
|
|
case 144 /* GlobalKeyword */:
|
|
if (isStartOfDeclaration()) {
|
|
return parseDeclaration();
|
|
}
|
|
break;
|
|
}
|
|
return parseExpressionOrLabeledStatement();
|
|
}
|
|
function isDeclareModifier(modifier) {
|
|
return modifier.kind === 124 /* DeclareKeyword */;
|
|
}
|
|
function parseDeclaration() {
|
|
var node = createNodeWithJSDoc(0 /* Unknown */);
|
|
node.decorators = parseDecorators();
|
|
node.modifiers = parseModifiers();
|
|
if (ts.some(node.modifiers, isDeclareModifier)) {
|
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
var m = _a[_i];
|
|
m.flags |= 4194304 /* Ambient */;
|
|
}
|
|
return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); });
|
|
}
|
|
else {
|
|
return parseDeclarationWorker(node);
|
|
}
|
|
}
|
|
function parseDeclarationWorker(node) {
|
|
switch (token()) {
|
|
case 104 /* VarKeyword */:
|
|
case 110 /* LetKeyword */:
|
|
case 76 /* ConstKeyword */:
|
|
return parseVariableStatement(node);
|
|
case 89 /* FunctionKeyword */:
|
|
return parseFunctionDeclaration(node);
|
|
case 75 /* ClassKeyword */:
|
|
return parseClassDeclaration(node);
|
|
case 109 /* InterfaceKeyword */:
|
|
return parseInterfaceDeclaration(node);
|
|
case 139 /* TypeKeyword */:
|
|
return parseTypeAliasDeclaration(node);
|
|
case 83 /* EnumKeyword */:
|
|
return parseEnumDeclaration(node);
|
|
case 144 /* GlobalKeyword */:
|
|
case 129 /* ModuleKeyword */:
|
|
case 130 /* NamespaceKeyword */:
|
|
return parseModuleDeclaration(node);
|
|
case 91 /* ImportKeyword */:
|
|
return parseImportDeclarationOrImportEqualsDeclaration(node);
|
|
case 84 /* ExportKeyword */:
|
|
nextToken();
|
|
switch (token()) {
|
|
case 79 /* DefaultKeyword */:
|
|
case 58 /* EqualsToken */:
|
|
return parseExportAssignment(node);
|
|
case 118 /* AsKeyword */:
|
|
return parseNamespaceExportDeclaration(node);
|
|
default:
|
|
return parseExportDeclaration(node);
|
|
}
|
|
default:
|
|
if (node.decorators || node.modifiers) {
|
|
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
|
|
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
|
var missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
|
|
missing.pos = node.pos;
|
|
missing.decorators = node.decorators;
|
|
missing.modifiers = node.modifiers;
|
|
return finishNode(missing);
|
|
}
|
|
return undefined; // TODO: GH#18217
|
|
}
|
|
}
|
|
function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
|
|
nextToken();
|
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */);
|
|
}
|
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) {
|
|
parseSemicolon();
|
|
return;
|
|
}
|
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
}
|
|
// DECLARATIONS
|
|
function parseArrayBindingElement() {
|
|
if (token() === 26 /* CommaToken */) {
|
|
return createNode(206 /* OmittedExpression */);
|
|
}
|
|
var node = createNode(182 /* BindingElement */);
|
|
node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */);
|
|
node.name = parseIdentifierOrPattern();
|
|
node.initializer = parseInitializer();
|
|
return finishNode(node);
|
|
}
|
|
function parseObjectBindingElement() {
|
|
var node = createNode(182 /* BindingElement */);
|
|
node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */);
|
|
var tokenIsIdentifier = isIdentifier();
|
|
var propertyName = parsePropertyName();
|
|
if (tokenIsIdentifier && token() !== 56 /* ColonToken */) {
|
|
node.name = propertyName;
|
|
}
|
|
else {
|
|
parseExpected(56 /* ColonToken */);
|
|
node.propertyName = propertyName;
|
|
node.name = parseIdentifierOrPattern();
|
|
}
|
|
node.initializer = parseInitializer();
|
|
return finishNode(node);
|
|
}
|
|
function parseObjectBindingPattern() {
|
|
var node = createNode(180 /* ObjectBindingPattern */);
|
|
parseExpected(17 /* OpenBraceToken */);
|
|
node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseArrayBindingPattern() {
|
|
var node = createNode(181 /* ArrayBindingPattern */);
|
|
parseExpected(21 /* OpenBracketToken */);
|
|
node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
return finishNode(node);
|
|
}
|
|
function isIdentifierOrPattern() {
|
|
return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier();
|
|
}
|
|
function parseIdentifierOrPattern() {
|
|
if (token() === 21 /* OpenBracketToken */) {
|
|
return parseArrayBindingPattern();
|
|
}
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
return parseObjectBindingPattern();
|
|
}
|
|
return parseIdentifier();
|
|
}
|
|
function parseVariableDeclarationAllowExclamation() {
|
|
return parseVariableDeclaration(/*allowExclamation*/ true);
|
|
}
|
|
function parseVariableDeclaration(allowExclamation) {
|
|
var node = createNode(232 /* VariableDeclaration */);
|
|
node.name = parseIdentifierOrPattern();
|
|
if (allowExclamation && node.name.kind === 71 /* Identifier */ &&
|
|
token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
node.exclamationToken = parseTokenNode();
|
|
}
|
|
node.type = parseTypeAnnotation();
|
|
if (!isInOrOfKeyword(token())) {
|
|
node.initializer = parseInitializer();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseVariableDeclarationList(inForStatementInitializer) {
|
|
var node = createNode(233 /* VariableDeclarationList */);
|
|
switch (token()) {
|
|
case 104 /* VarKeyword */:
|
|
break;
|
|
case 110 /* LetKeyword */:
|
|
node.flags |= 1 /* Let */;
|
|
break;
|
|
case 76 /* ConstKeyword */:
|
|
node.flags |= 2 /* Const */;
|
|
break;
|
|
default:
|
|
ts.Debug.fail();
|
|
}
|
|
nextToken();
|
|
// The user may have written the following:
|
|
//
|
|
// for (let of X) { }
|
|
//
|
|
// In this case, we want to parse an empty declaration list, and then parse 'of'
|
|
// as a keyword. The reason this is not automatic is that 'of' is a valid identifier.
|
|
// So we need to look ahead to determine if 'of' should be treated as a keyword in
|
|
// this context.
|
|
// The checker will then give an error that there is an empty declaration list.
|
|
if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
|
|
node.declarations = createMissingList();
|
|
}
|
|
else {
|
|
var savedDisallowIn = inDisallowInContext();
|
|
setDisallowInContext(inForStatementInitializer);
|
|
node.declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
|
|
setDisallowInContext(savedDisallowIn);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function canFollowContextualOfKeyword() {
|
|
return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */;
|
|
}
|
|
function parseVariableStatement(node) {
|
|
node.kind = 214 /* VariableStatement */;
|
|
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false);
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseFunctionDeclaration(node) {
|
|
node.kind = 234 /* FunctionDeclaration */;
|
|
parseExpected(89 /* FunctionKeyword */);
|
|
node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */);
|
|
node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier();
|
|
var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
|
var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */;
|
|
fillSignature(56 /* ColonToken */, isGenerator | isAsync, node);
|
|
node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
|
|
return finishNode(node);
|
|
}
|
|
function parseConstructorDeclaration(node) {
|
|
node.kind = 155 /* Constructor */;
|
|
parseExpected(123 /* ConstructorKeyword */);
|
|
fillSignature(56 /* ColonToken */, 0 /* None */, node);
|
|
node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected);
|
|
return finishNode(node);
|
|
}
|
|
function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) {
|
|
node.kind = 154 /* MethodDeclaration */;
|
|
node.asteriskToken = asteriskToken;
|
|
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
|
var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */;
|
|
fillSignature(56 /* ColonToken */, isGenerator | isAsync, node);
|
|
node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
|
|
return finishNode(node);
|
|
}
|
|
function parsePropertyDeclaration(node) {
|
|
node.kind = 152 /* PropertyDeclaration */;
|
|
if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
node.exclamationToken = parseTokenNode();
|
|
}
|
|
node.type = parseTypeAnnotation();
|
|
// For instance properties specifically, since they are evaluated inside the constructor,
|
|
// we do *not * want to parse yield expressions, so we specifically turn the yield context
|
|
// off. The grammar would look something like this:
|
|
//
|
|
// MemberVariableDeclaration[Yield]:
|
|
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In];
|
|
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield];
|
|
//
|
|
// The checker may still error in the static case to explicitly disallow the yield expression.
|
|
node.initializer = ts.hasModifier(node, 32 /* Static */)
|
|
? allowInAnd(parseInitializer)
|
|
: doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer);
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parsePropertyOrMethodDeclaration(node) {
|
|
var asteriskToken = parseOptionalToken(39 /* AsteriskToken */);
|
|
node.name = parsePropertyName();
|
|
// Note: this is not legal as per the grammar. But we allow it in the parser and
|
|
// report an error in the grammar checker.
|
|
node.questionToken = parseOptionalToken(55 /* QuestionToken */);
|
|
if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) {
|
|
return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected);
|
|
}
|
|
return parsePropertyDeclaration(node);
|
|
}
|
|
function parseAccessorDeclaration(node, kind) {
|
|
node.kind = kind;
|
|
node.name = parsePropertyName();
|
|
fillSignature(56 /* ColonToken */, 0 /* None */, node);
|
|
node.body = parseFunctionBlockOrSemicolon(0 /* None */);
|
|
return finishNode(node);
|
|
}
|
|
function isClassMemberStart() {
|
|
var idToken;
|
|
if (token() === 57 /* AtToken */) {
|
|
return true;
|
|
}
|
|
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
|
|
while (ts.isModifierKind(token())) {
|
|
idToken = token();
|
|
// If the idToken is a class modifier (protected, private, public, and static), it is
|
|
// certain that we are starting to parse class member. This allows better error recovery
|
|
// Example:
|
|
// public foo() ... // true
|
|
// public @dec blah ... // true; we will then report an error later
|
|
// export public ... // true; we will then report an error later
|
|
if (ts.isClassMemberModifier(idToken)) {
|
|
return true;
|
|
}
|
|
nextToken();
|
|
}
|
|
if (token() === 39 /* AsteriskToken */) {
|
|
return true;
|
|
}
|
|
// Try to get the first property-like token following all modifiers.
|
|
// This can either be an identifier or the 'get' or 'set' keywords.
|
|
if (isLiteralPropertyName()) {
|
|
idToken = token();
|
|
nextToken();
|
|
}
|
|
// Index signatures and computed properties are class members; we can parse.
|
|
if (token() === 21 /* OpenBracketToken */) {
|
|
return true;
|
|
}
|
|
// If we were able to get any potential identifier...
|
|
if (idToken !== undefined) {
|
|
// If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse.
|
|
if (!ts.isKeyword(idToken) || idToken === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) {
|
|
return true;
|
|
}
|
|
// If it *is* a keyword, but not an accessor, check a little farther along
|
|
// to see if it should actually be parsed as a class member.
|
|
switch (token()) {
|
|
case 19 /* OpenParenToken */: // Method declaration
|
|
case 27 /* LessThanToken */: // Generic Method declaration
|
|
case 51 /* ExclamationToken */: // Non-null assertion on property name
|
|
case 56 /* ColonToken */: // Type Annotation for declaration
|
|
case 58 /* EqualsToken */: // Initializer for declaration
|
|
case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on.
|
|
return true;
|
|
default:
|
|
// Covers
|
|
// - Semicolons (declaration termination)
|
|
// - Closing braces (end-of-class, must be declaration)
|
|
// - End-of-files (not valid, but permitted so that it gets caught later on)
|
|
// - Line-breaks (enabling *automatic semicolon insertion*)
|
|
return canParseSemicolon();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function parseDecorators() {
|
|
var list;
|
|
var listPos = getNodePos();
|
|
while (true) {
|
|
var decoratorStart = getNodePos();
|
|
if (!parseOptional(57 /* AtToken */)) {
|
|
break;
|
|
}
|
|
var decorator = createNode(150 /* Decorator */, decoratorStart);
|
|
decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
|
finishNode(decorator);
|
|
(list || (list = [])).push(decorator);
|
|
}
|
|
return list && createNodeArray(list, listPos);
|
|
}
|
|
/*
|
|
* There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member.
|
|
* In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect
|
|
* and turns it into a standalone declaration), then it is better to parse it and report an error later.
|
|
*
|
|
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
|
|
*/
|
|
function parseModifiers(permitInvalidConstAsModifier) {
|
|
var list;
|
|
var listPos = getNodePos();
|
|
while (true) {
|
|
var modifierStart = scanner.getStartPos();
|
|
var modifierKind = token();
|
|
if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
// We need to ensure that any subsequent modifiers appear on the same line
|
|
// so that when 'const' is a standalone declaration, we don't issue an error.
|
|
if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
|
|
break;
|
|
}
|
|
}
|
|
else {
|
|
if (!parseAnyContextualModifier()) {
|
|
break;
|
|
}
|
|
}
|
|
var modifier = finishNode(createNode(modifierKind, modifierStart));
|
|
(list || (list = [])).push(modifier);
|
|
}
|
|
return list && createNodeArray(list, listPos);
|
|
}
|
|
function parseModifiersForArrowFunction() {
|
|
var modifiers;
|
|
if (token() === 120 /* AsyncKeyword */) {
|
|
var modifierStart = scanner.getStartPos();
|
|
var modifierKind = token();
|
|
nextToken();
|
|
var modifier = finishNode(createNode(modifierKind, modifierStart));
|
|
modifiers = createNodeArray([modifier], modifierStart);
|
|
}
|
|
return modifiers;
|
|
}
|
|
function parseClassElement() {
|
|
if (token() === 25 /* SemicolonToken */) {
|
|
var result = createNode(212 /* SemicolonClassElement */);
|
|
nextToken();
|
|
return finishNode(result);
|
|
}
|
|
var node = createNodeWithJSDoc(0 /* Unknown */);
|
|
node.decorators = parseDecorators();
|
|
node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true);
|
|
if (parseContextualModifier(125 /* GetKeyword */)) {
|
|
return parseAccessorDeclaration(node, 156 /* GetAccessor */);
|
|
}
|
|
if (parseContextualModifier(136 /* SetKeyword */)) {
|
|
return parseAccessorDeclaration(node, 157 /* SetAccessor */);
|
|
}
|
|
if (token() === 123 /* ConstructorKeyword */) {
|
|
return parseConstructorDeclaration(node);
|
|
}
|
|
if (isIndexSignature()) {
|
|
return parseIndexSignatureDeclaration(node);
|
|
}
|
|
// It is very important that we check this *after* checking indexers because
|
|
// the [ token can start an index signature or a computed property name
|
|
if (ts.tokenIsIdentifierOrKeyword(token()) ||
|
|
token() === 9 /* StringLiteral */ ||
|
|
token() === 8 /* NumericLiteral */ ||
|
|
token() === 39 /* AsteriskToken */ ||
|
|
token() === 21 /* OpenBracketToken */) {
|
|
return parsePropertyOrMethodDeclaration(node);
|
|
}
|
|
if (node.decorators || node.modifiers) {
|
|
// treat this as a property declaration with a missing name.
|
|
node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
|
|
return parsePropertyDeclaration(node);
|
|
}
|
|
// 'isClassMemberStart' should have hinted not to attempt parsing.
|
|
return ts.Debug.fail("Should not have attempted to parse class member declaration.");
|
|
}
|
|
function parseClassExpression() {
|
|
return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */);
|
|
}
|
|
function parseClassDeclaration(node) {
|
|
return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */);
|
|
}
|
|
function parseClassDeclarationOrExpression(node, kind) {
|
|
node.kind = kind;
|
|
parseExpected(75 /* ClassKeyword */);
|
|
node.name = parseNameOfClassDeclarationOrExpression();
|
|
node.typeParameters = parseTypeParameters();
|
|
node.heritageClauses = parseHeritageClauses();
|
|
if (parseExpected(17 /* OpenBraceToken */)) {
|
|
// ClassTail[Yield,Await] : (Modified) See 14.5
|
|
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
|
node.members = parseClassMembers();
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
node.members = createMissingList();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseNameOfClassDeclarationOrExpression() {
|
|
// implements is a future reserved word so
|
|
// 'class implements' might mean either
|
|
// - class expression with omitted name, 'implements' starts heritage clause
|
|
// - class with name 'implements'
|
|
// 'isImplementsClause' helps to disambiguate between these two cases
|
|
return isIdentifier() && !isImplementsClause()
|
|
? parseIdentifier()
|
|
: undefined;
|
|
}
|
|
function isImplementsClause() {
|
|
return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword);
|
|
}
|
|
function parseHeritageClauses() {
|
|
// ClassTail[Yield,Await] : (Modified) See 14.5
|
|
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
|
if (isHeritageClause()) {
|
|
return parseList(21 /* HeritageClauses */, parseHeritageClause);
|
|
}
|
|
return undefined;
|
|
}
|
|
function parseHeritageClause() {
|
|
var tok = token();
|
|
ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this.
|
|
var node = createNode(268 /* HeritageClause */);
|
|
node.token = tok;
|
|
nextToken();
|
|
node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments);
|
|
return finishNode(node);
|
|
}
|
|
function parseExpressionWithTypeArguments() {
|
|
var node = createNode(207 /* ExpressionWithTypeArguments */);
|
|
node.expression = parseLeftHandSideExpressionOrHigher();
|
|
node.typeArguments = tryParseTypeArguments();
|
|
return finishNode(node);
|
|
}
|
|
function tryParseTypeArguments() {
|
|
return token() === 27 /* LessThanToken */
|
|
? parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */)
|
|
: undefined;
|
|
}
|
|
function isHeritageClause() {
|
|
return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */;
|
|
}
|
|
function parseClassMembers() {
|
|
return parseList(5 /* ClassMembers */, parseClassElement);
|
|
}
|
|
function parseInterfaceDeclaration(node) {
|
|
node.kind = 236 /* InterfaceDeclaration */;
|
|
parseExpected(109 /* InterfaceKeyword */);
|
|
node.name = parseIdentifier();
|
|
node.typeParameters = parseTypeParameters();
|
|
node.heritageClauses = parseHeritageClauses();
|
|
node.members = parseObjectTypeMembers();
|
|
return finishNode(node);
|
|
}
|
|
function parseTypeAliasDeclaration(node) {
|
|
node.kind = 237 /* TypeAliasDeclaration */;
|
|
parseExpected(139 /* TypeKeyword */);
|
|
node.name = parseIdentifier();
|
|
node.typeParameters = parseTypeParameters();
|
|
parseExpected(58 /* EqualsToken */);
|
|
node.type = parseType();
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
// In an ambient declaration, the grammar only allows integer literals as initializers.
|
|
// In a non-ambient declaration, the grammar allows uninitialized members only in a
|
|
// ConstantEnumMemberSection, which starts at the beginning of an enum declaration
|
|
// or any time an integer literal initializer is encountered.
|
|
function parseEnumMember() {
|
|
var node = createNodeWithJSDoc(273 /* EnumMember */);
|
|
node.name = parsePropertyName();
|
|
node.initializer = allowInAnd(parseInitializer);
|
|
return finishNode(node);
|
|
}
|
|
function parseEnumDeclaration(node) {
|
|
node.kind = 238 /* EnumDeclaration */;
|
|
parseExpected(83 /* EnumKeyword */);
|
|
node.name = parseIdentifier();
|
|
if (parseExpected(17 /* OpenBraceToken */)) {
|
|
node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
node.members = createMissingList();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseModuleBlock() {
|
|
var node = createNode(240 /* ModuleBlock */);
|
|
if (parseExpected(17 /* OpenBraceToken */)) {
|
|
node.statements = parseList(1 /* BlockStatements */, parseStatement);
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
else {
|
|
node.statements = createMissingList();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseModuleOrNamespaceDeclaration(node, flags) {
|
|
node.kind = 239 /* ModuleDeclaration */;
|
|
// If we are parsing a dotted namespace name, we want to
|
|
// propagate the 'Namespace' flag across the names if set.
|
|
var namespaceFlag = flags & 16 /* Namespace */;
|
|
node.flags |= flags;
|
|
node.name = parseIdentifier();
|
|
node.body = parseOptional(23 /* DotToken */)
|
|
? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag)
|
|
: parseModuleBlock();
|
|
return finishNode(node);
|
|
}
|
|
function parseAmbientExternalModuleDeclaration(node) {
|
|
node.kind = 239 /* ModuleDeclaration */;
|
|
if (token() === 144 /* GlobalKeyword */) {
|
|
// parse 'global' as name of global scope augmentation
|
|
node.name = parseIdentifier();
|
|
node.flags |= 512 /* GlobalAugmentation */;
|
|
}
|
|
else {
|
|
node.name = parseLiteralNode();
|
|
node.name.text = internIdentifier(node.name.text);
|
|
}
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
node.body = parseModuleBlock();
|
|
}
|
|
else {
|
|
parseSemicolon();
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseModuleDeclaration(node) {
|
|
var flags = 0;
|
|
if (token() === 144 /* GlobalKeyword */) {
|
|
// global augmentation
|
|
return parseAmbientExternalModuleDeclaration(node);
|
|
}
|
|
else if (parseOptional(130 /* NamespaceKeyword */)) {
|
|
flags |= 16 /* Namespace */;
|
|
}
|
|
else {
|
|
parseExpected(129 /* ModuleKeyword */);
|
|
if (token() === 9 /* StringLiteral */) {
|
|
return parseAmbientExternalModuleDeclaration(node);
|
|
}
|
|
}
|
|
return parseModuleOrNamespaceDeclaration(node, flags);
|
|
}
|
|
function isExternalModuleReference() {
|
|
return token() === 133 /* RequireKeyword */ &&
|
|
lookAhead(nextTokenIsOpenParen);
|
|
}
|
|
function nextTokenIsOpenParen() {
|
|
return nextToken() === 19 /* OpenParenToken */;
|
|
}
|
|
function nextTokenIsSlash() {
|
|
return nextToken() === 41 /* SlashToken */;
|
|
}
|
|
function parseNamespaceExportDeclaration(node) {
|
|
node.kind = 242 /* NamespaceExportDeclaration */;
|
|
parseExpected(118 /* AsKeyword */);
|
|
parseExpected(130 /* NamespaceKeyword */);
|
|
node.name = parseIdentifier();
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseImportDeclarationOrImportEqualsDeclaration(node) {
|
|
parseExpected(91 /* ImportKeyword */);
|
|
var afterImportPos = scanner.getStartPos();
|
|
var identifier;
|
|
if (isIdentifier()) {
|
|
identifier = parseIdentifier();
|
|
if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) {
|
|
return parseImportEqualsDeclaration(node, identifier);
|
|
}
|
|
}
|
|
// Import statement
|
|
node.kind = 244 /* ImportDeclaration */;
|
|
// ImportDeclaration:
|
|
// import ImportClause from ModuleSpecifier ;
|
|
// import ModuleSpecifier;
|
|
if (identifier || // import id
|
|
token() === 39 /* AsteriskToken */ || // import *
|
|
token() === 17 /* OpenBraceToken */) { // import {
|
|
node.importClause = parseImportClause(identifier, afterImportPos);
|
|
parseExpected(143 /* FromKeyword */);
|
|
}
|
|
node.moduleSpecifier = parseModuleSpecifier();
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseImportEqualsDeclaration(node, identifier) {
|
|
node.kind = 243 /* ImportEqualsDeclaration */;
|
|
node.name = identifier;
|
|
parseExpected(58 /* EqualsToken */);
|
|
node.moduleReference = parseModuleReference();
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseImportClause(identifier, fullStart) {
|
|
// ImportClause:
|
|
// ImportedDefaultBinding
|
|
// NameSpaceImport
|
|
// NamedImports
|
|
// ImportedDefaultBinding, NameSpaceImport
|
|
// ImportedDefaultBinding, NamedImports
|
|
var importClause = createNode(245 /* ImportClause */, fullStart);
|
|
if (identifier) {
|
|
// ImportedDefaultBinding:
|
|
// ImportedBinding
|
|
importClause.name = identifier;
|
|
}
|
|
// If there was no default import or if there is comma token after default import
|
|
// parse namespace or named imports
|
|
if (!importClause.name ||
|
|
parseOptional(26 /* CommaToken */)) {
|
|
importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */);
|
|
}
|
|
return finishNode(importClause);
|
|
}
|
|
function parseModuleReference() {
|
|
return isExternalModuleReference()
|
|
? parseExternalModuleReference()
|
|
: parseEntityName(/*allowReservedWords*/ false);
|
|
}
|
|
function parseExternalModuleReference() {
|
|
var node = createNode(254 /* ExternalModuleReference */);
|
|
parseExpected(133 /* RequireKeyword */);
|
|
parseExpected(19 /* OpenParenToken */);
|
|
node.expression = parseModuleSpecifier();
|
|
parseExpected(20 /* CloseParenToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseModuleSpecifier() {
|
|
if (token() === 9 /* StringLiteral */) {
|
|
var result = parseLiteralNode();
|
|
result.text = internIdentifier(result.text);
|
|
return result;
|
|
}
|
|
else {
|
|
// We allow arbitrary expressions here, even though the grammar only allows string
|
|
// literals. We check to ensure that it is only a string literal later in the grammar
|
|
// check pass.
|
|
return parseExpression();
|
|
}
|
|
}
|
|
function parseNamespaceImport() {
|
|
// NameSpaceImport:
|
|
// * as ImportedBinding
|
|
var namespaceImport = createNode(246 /* NamespaceImport */);
|
|
parseExpected(39 /* AsteriskToken */);
|
|
parseExpected(118 /* AsKeyword */);
|
|
namespaceImport.name = parseIdentifier();
|
|
return finishNode(namespaceImport);
|
|
}
|
|
function parseNamedImportsOrExports(kind) {
|
|
var node = createNode(kind);
|
|
// NamedImports:
|
|
// { }
|
|
// { ImportsList }
|
|
// { ImportsList, }
|
|
// ImportsList:
|
|
// ImportSpecifier
|
|
// ImportsList, ImportSpecifier
|
|
node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */);
|
|
return finishNode(node);
|
|
}
|
|
function parseExportSpecifier() {
|
|
return parseImportOrExportSpecifier(252 /* ExportSpecifier */);
|
|
}
|
|
function parseImportSpecifier() {
|
|
return parseImportOrExportSpecifier(248 /* ImportSpecifier */);
|
|
}
|
|
function parseImportOrExportSpecifier(kind) {
|
|
var node = createNode(kind);
|
|
// ImportSpecifier:
|
|
// BindingIdentifier
|
|
// IdentifierName as BindingIdentifier
|
|
// ExportSpecifier:
|
|
// IdentifierName
|
|
// IdentifierName as IdentifierName
|
|
var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
var checkIdentifierStart = scanner.getTokenPos();
|
|
var checkIdentifierEnd = scanner.getTextPos();
|
|
var identifierName = parseIdentifierName();
|
|
if (token() === 118 /* AsKeyword */) {
|
|
node.propertyName = identifierName;
|
|
parseExpected(118 /* AsKeyword */);
|
|
checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
checkIdentifierStart = scanner.getTokenPos();
|
|
checkIdentifierEnd = scanner.getTextPos();
|
|
node.name = parseIdentifierName();
|
|
}
|
|
else {
|
|
node.name = identifierName;
|
|
}
|
|
if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
|
|
parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
|
|
}
|
|
return finishNode(node);
|
|
}
|
|
function parseExportDeclaration(node) {
|
|
node.kind = 250 /* ExportDeclaration */;
|
|
if (parseOptional(39 /* AsteriskToken */)) {
|
|
parseExpected(143 /* FromKeyword */);
|
|
node.moduleSpecifier = parseModuleSpecifier();
|
|
}
|
|
else {
|
|
node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */);
|
|
// It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios,
|
|
// the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`)
|
|
// If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect.
|
|
if (token() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) {
|
|
parseExpected(143 /* FromKeyword */);
|
|
node.moduleSpecifier = parseModuleSpecifier();
|
|
}
|
|
}
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function parseExportAssignment(node) {
|
|
node.kind = 249 /* ExportAssignment */;
|
|
if (parseOptional(58 /* EqualsToken */)) {
|
|
node.isExportEquals = true;
|
|
}
|
|
else {
|
|
parseExpected(79 /* DefaultKeyword */);
|
|
}
|
|
node.expression = parseAssignmentExpressionOrHigher();
|
|
parseSemicolon();
|
|
return finishNode(node);
|
|
}
|
|
function setExternalModuleIndicator(sourceFile) {
|
|
// Try to use the first top-level import/export when available, then
|
|
// fall back to looking for an 'import.meta' somewhere in the tree if necessary.
|
|
sourceFile.externalModuleIndicator =
|
|
ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
|
|
getImportMetaIfNecessary(sourceFile);
|
|
}
|
|
function isAnExternalModuleIndicatorNode(node) {
|
|
return ts.hasModifier(node, 1 /* Export */)
|
|
|| node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */
|
|
|| node.kind === 244 /* ImportDeclaration */
|
|
|| node.kind === 249 /* ExportAssignment */
|
|
|| node.kind === 250 /* ExportDeclaration */
|
|
? node
|
|
: undefined;
|
|
}
|
|
function getImportMetaIfNecessary(sourceFile) {
|
|
return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ?
|
|
walkTreeForExternalModuleIndicators(sourceFile) :
|
|
undefined;
|
|
}
|
|
function walkTreeForExternalModuleIndicators(node) {
|
|
return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
|
|
}
|
|
function isImportMeta(node) {
|
|
return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta";
|
|
}
|
|
var ParsingContext;
|
|
(function (ParsingContext) {
|
|
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
|
|
ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements";
|
|
ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses";
|
|
ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements";
|
|
ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers";
|
|
ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers";
|
|
ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers";
|
|
ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement";
|
|
ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations";
|
|
ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements";
|
|
ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements";
|
|
ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions";
|
|
ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers";
|
|
ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes";
|
|
ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren";
|
|
ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers";
|
|
ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters";
|
|
ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties";
|
|
ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters";
|
|
ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments";
|
|
ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes";
|
|
ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses";
|
|
ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers";
|
|
ParsingContext[ParsingContext["Count"] = 23] = "Count"; // Number of parsing contexts
|
|
})(ParsingContext || (ParsingContext = {}));
|
|
var Tristate;
|
|
(function (Tristate) {
|
|
Tristate[Tristate["False"] = 0] = "False";
|
|
Tristate[Tristate["True"] = 1] = "True";
|
|
Tristate[Tristate["Unknown"] = 2] = "Unknown";
|
|
})(Tristate || (Tristate = {}));
|
|
var JSDocParser;
|
|
(function (JSDocParser) {
|
|
function parseJSDocTypeExpressionForTests(content, start, length) {
|
|
initializeState(content, 6 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
sourceFile = createSourceFile("file.js", 6 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false);
|
|
scanner.setText(content, start, length);
|
|
currentToken = scanner.scan();
|
|
var jsDocTypeExpression = parseJSDocTypeExpression();
|
|
var diagnostics = parseDiagnostics;
|
|
clearState();
|
|
return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
|
|
}
|
|
JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
|
|
// Parses out a JSDoc type expression.
|
|
function parseJSDocTypeExpression(mayOmitBraces) {
|
|
var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos());
|
|
var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */);
|
|
result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType);
|
|
if (!mayOmitBraces || hasBrace) {
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
fixupParentReferences(result);
|
|
return finishNode(result);
|
|
}
|
|
JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
|
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
initializeState(content, 6 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion
|
|
var jsDoc = parseJSDocCommentWorker(start, length);
|
|
var diagnostics = parseDiagnostics;
|
|
clearState();
|
|
return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
|
|
}
|
|
JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
|
|
function parseJSDocComment(parent, start, length) {
|
|
var _a;
|
|
var saveToken = currentToken;
|
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
var comment = parseJSDocCommentWorker(start, length);
|
|
if (comment) {
|
|
comment.parent = parent;
|
|
}
|
|
if (contextFlags & 65536 /* JavaScriptFile */) {
|
|
if (!sourceFile.jsDocDiagnostics) {
|
|
sourceFile.jsDocDiagnostics = [];
|
|
}
|
|
(_a = sourceFile.jsDocDiagnostics).push.apply(_a, parseDiagnostics);
|
|
}
|
|
currentToken = saveToken;
|
|
parseDiagnostics.length = saveParseDiagnosticsLength;
|
|
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
|
|
return comment;
|
|
}
|
|
JSDocParser.parseJSDocComment = parseJSDocComment;
|
|
var JSDocState;
|
|
(function (JSDocState) {
|
|
JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine";
|
|
JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk";
|
|
JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments";
|
|
})(JSDocState || (JSDocState = {}));
|
|
var PropertyLikeParse;
|
|
(function (PropertyLikeParse) {
|
|
PropertyLikeParse[PropertyLikeParse["Property"] = 1] = "Property";
|
|
PropertyLikeParse[PropertyLikeParse["Parameter"] = 2] = "Parameter";
|
|
PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter";
|
|
})(PropertyLikeParse || (PropertyLikeParse = {}));
|
|
function parseJSDocCommentWorker(start, length) {
|
|
if (start === void 0) { start = 0; }
|
|
var content = sourceText;
|
|
var end = length === undefined ? content.length : start + length;
|
|
length = end - start;
|
|
ts.Debug.assert(start >= 0);
|
|
ts.Debug.assert(start <= end);
|
|
ts.Debug.assert(end <= content.length);
|
|
var tags;
|
|
var tagsPos;
|
|
var tagsEnd;
|
|
var comments = [];
|
|
var result;
|
|
// Check for /** (JSDoc opening part)
|
|
if (!isJSDocLikeText(content, start)) {
|
|
return result;
|
|
}
|
|
// + 3 for leading /**, - 5 in total for /** */
|
|
scanner.scanRange(start + 3, length - 5, function () {
|
|
// Initially we can parse out a tag. We also have seen a starting asterisk.
|
|
// This is so that /** * @type */ doesn't parse.
|
|
var state = 1 /* SawAsterisk */;
|
|
var margin;
|
|
// + 4 for leading '/** '
|
|
var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
|
|
function pushComment(text) {
|
|
if (!margin) {
|
|
margin = indent;
|
|
}
|
|
comments.push(text);
|
|
indent += text.length;
|
|
}
|
|
nextJSDocToken();
|
|
while (parseOptionalJsdoc(5 /* WhitespaceTrivia */))
|
|
;
|
|
if (parseOptionalJsdoc(4 /* NewLineTrivia */)) {
|
|
state = 0 /* BeginningOfLine */;
|
|
indent = 0;
|
|
}
|
|
loop: while (true) {
|
|
switch (token()) {
|
|
case 57 /* AtToken */:
|
|
if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) {
|
|
removeTrailingNewlines(comments);
|
|
addTag(parseTag(indent));
|
|
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
|
|
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
|
|
// for malformed examples like `/** @param {string} x @returns {number} the length */`
|
|
state = 0 /* BeginningOfLine */;
|
|
margin = undefined;
|
|
indent++;
|
|
}
|
|
else {
|
|
pushComment(scanner.getTokenText());
|
|
}
|
|
break;
|
|
case 4 /* NewLineTrivia */:
|
|
comments.push(scanner.getTokenText());
|
|
state = 0 /* BeginningOfLine */;
|
|
indent = 0;
|
|
break;
|
|
case 39 /* AsteriskToken */:
|
|
var asterisk = scanner.getTokenText();
|
|
if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) {
|
|
// If we've already seen an asterisk, then we can no longer parse a tag on this line
|
|
state = 2 /* SavingComments */;
|
|
pushComment(asterisk);
|
|
}
|
|
else {
|
|
// Ignore the first asterisk on a line
|
|
state = 1 /* SawAsterisk */;
|
|
indent += asterisk.length;
|
|
}
|
|
break;
|
|
case 71 /* Identifier */:
|
|
// Anything else is doc comment text. We just save it. Because it
|
|
// wasn't a tag, we can no longer parse a tag on this line until we hit the next
|
|
// line break.
|
|
pushComment(scanner.getTokenText());
|
|
state = 2 /* SavingComments */;
|
|
break;
|
|
case 5 /* WhitespaceTrivia */:
|
|
// only collect whitespace if we're already saving comments or have just crossed the comment indent margin
|
|
var whitespace = scanner.getTokenText();
|
|
if (state === 2 /* SavingComments */) {
|
|
comments.push(whitespace);
|
|
}
|
|
else if (margin !== undefined && indent + whitespace.length > margin) {
|
|
comments.push(whitespace.slice(margin - indent - 1));
|
|
}
|
|
indent += whitespace.length;
|
|
break;
|
|
case 1 /* EndOfFileToken */:
|
|
break loop;
|
|
default:
|
|
// anything other than whitespace or asterisk at the beginning of the line starts the comment text
|
|
state = 2 /* SavingComments */;
|
|
pushComment(scanner.getTokenText());
|
|
break;
|
|
}
|
|
nextJSDocToken();
|
|
}
|
|
removeLeadingNewlines(comments);
|
|
removeTrailingNewlines(comments);
|
|
result = createJSDocComment();
|
|
});
|
|
return result;
|
|
function removeLeadingNewlines(comments) {
|
|
while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
|
|
comments.shift();
|
|
}
|
|
}
|
|
function removeTrailingNewlines(comments) {
|
|
while (comments.length && (comments[comments.length - 1] === "\n" || comments[comments.length - 1] === "\r")) {
|
|
comments.pop();
|
|
}
|
|
}
|
|
function createJSDocComment() {
|
|
var result = createNode(286 /* JSDocComment */, start);
|
|
result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
|
|
result.comment = comments.length ? comments.join("") : undefined;
|
|
return finishNode(result, end);
|
|
}
|
|
function isNextNonwhitespaceTokenEndOfFile() {
|
|
// We must use infinite lookahead, as there could be any number of newlines :(
|
|
while (true) {
|
|
nextJSDocToken();
|
|
if (token() === 1 /* EndOfFileToken */) {
|
|
return true;
|
|
}
|
|
if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
function skipWhitespace() {
|
|
if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
|
|
if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
|
|
return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
|
|
}
|
|
}
|
|
while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
|
|
nextJSDocToken();
|
|
}
|
|
}
|
|
function parseTag(indent) {
|
|
ts.Debug.assert(token() === 57 /* AtToken */);
|
|
var atToken = createNode(57 /* AtToken */, scanner.getTokenPos());
|
|
atToken.end = scanner.getTextPos();
|
|
nextJSDocToken();
|
|
var tagName = parseJSDocIdentifierName();
|
|
skipWhitespace();
|
|
var tag;
|
|
switch (tagName.escapedText) {
|
|
case "augments":
|
|
case "extends":
|
|
tag = parseAugmentsTag(atToken, tagName);
|
|
break;
|
|
case "class":
|
|
case "constructor":
|
|
tag = parseClassTag(atToken, tagName);
|
|
break;
|
|
case "arg":
|
|
case "argument":
|
|
case "param":
|
|
return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent);
|
|
case "return":
|
|
case "returns":
|
|
tag = parseReturnTag(atToken, tagName);
|
|
break;
|
|
case "template":
|
|
tag = parseTemplateTag(atToken, tagName);
|
|
break;
|
|
case "type":
|
|
tag = parseTypeTag(atToken, tagName);
|
|
break;
|
|
case "typedef":
|
|
tag = parseTypedefTag(atToken, tagName, indent);
|
|
break;
|
|
case "callback":
|
|
tag = parseCallbackTag(atToken, tagName, indent);
|
|
break;
|
|
default:
|
|
tag = parseUnknownTag(atToken, tagName);
|
|
break;
|
|
}
|
|
if (!tag.comment) {
|
|
// some tags, like typedef and callback, have already parsed their comments earlier
|
|
tag.comment = parseTagComments(indent + tag.end - tag.pos);
|
|
}
|
|
return tag;
|
|
}
|
|
function parseTagComments(indent) {
|
|
var comments = [];
|
|
var state = 0 /* BeginningOfLine */;
|
|
var margin;
|
|
function pushComment(text) {
|
|
if (!margin) {
|
|
margin = indent;
|
|
}
|
|
comments.push(text);
|
|
indent += text.length;
|
|
}
|
|
var tok = token();
|
|
loop: while (true) {
|
|
switch (tok) {
|
|
case 4 /* NewLineTrivia */:
|
|
if (state >= 1 /* SawAsterisk */) {
|
|
state = 0 /* BeginningOfLine */;
|
|
comments.push(scanner.getTokenText());
|
|
}
|
|
indent = 0;
|
|
break;
|
|
case 57 /* AtToken */:
|
|
scanner.setTextPos(scanner.getTextPos() - 1);
|
|
// falls through
|
|
case 1 /* EndOfFileToken */:
|
|
// Done
|
|
break loop;
|
|
case 5 /* WhitespaceTrivia */:
|
|
if (state === 2 /* SavingComments */) {
|
|
pushComment(scanner.getTokenText());
|
|
}
|
|
else {
|
|
var whitespace = scanner.getTokenText();
|
|
// if the whitespace crosses the margin, take only the whitespace that passes the margin
|
|
if (margin !== undefined && indent + whitespace.length > margin) {
|
|
comments.push(whitespace.slice(margin - indent - 1));
|
|
}
|
|
indent += whitespace.length;
|
|
}
|
|
break;
|
|
case 39 /* AsteriskToken */:
|
|
if (state === 0 /* BeginningOfLine */) {
|
|
// leading asterisks start recording on the *next* (non-whitespace) token
|
|
state = 1 /* SawAsterisk */;
|
|
indent += 1;
|
|
break;
|
|
}
|
|
// record the * as a comment
|
|
// falls through
|
|
default:
|
|
state = 2 /* SavingComments */; // leading identifiers start recording as well
|
|
pushComment(scanner.getTokenText());
|
|
break;
|
|
}
|
|
tok = nextJSDocToken();
|
|
}
|
|
removeLeadingNewlines(comments);
|
|
removeTrailingNewlines(comments);
|
|
return comments.length === 0 ? undefined : comments.join("");
|
|
}
|
|
function parseUnknownTag(atToken, tagName) {
|
|
var result = createNode(289 /* JSDocTag */, atToken.pos);
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
return finishNode(result);
|
|
}
|
|
function addTag(tag) {
|
|
if (!tag) {
|
|
return;
|
|
}
|
|
if (!tags) {
|
|
tags = [tag];
|
|
tagsPos = tag.pos;
|
|
}
|
|
else {
|
|
tags.push(tag);
|
|
}
|
|
tagsEnd = tag.end;
|
|
}
|
|
function tryParseTypeExpression() {
|
|
skipWhitespace();
|
|
return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined;
|
|
}
|
|
function parseBracketNameInPropertyAndParamTag() {
|
|
if (token() === 13 /* NoSubstitutionTemplateLiteral */) {
|
|
// a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild
|
|
return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false };
|
|
}
|
|
// Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar'
|
|
var isBracketed = parseOptional(21 /* OpenBracketToken */);
|
|
var name = parseJSDocEntityName();
|
|
if (isBracketed) {
|
|
skipWhitespace();
|
|
// May have an optional default, e.g. '[foo = 42]'
|
|
if (parseOptionalToken(58 /* EqualsToken */)) {
|
|
parseExpression();
|
|
}
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
}
|
|
return { name: name, isBracketed: isBracketed };
|
|
}
|
|
function isObjectOrObjectArrayTypeReference(node) {
|
|
switch (node.kind) {
|
|
case 135 /* ObjectKeyword */:
|
|
return true;
|
|
case 167 /* ArrayType */:
|
|
return isObjectOrObjectArrayTypeReference(node.elementType);
|
|
default:
|
|
return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object";
|
|
}
|
|
}
|
|
function parseParameterOrPropertyTag(atToken, tagName, target, indent) {
|
|
var typeExpression = tryParseTypeExpression();
|
|
var isNameFirst = !typeExpression;
|
|
skipWhitespace();
|
|
var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
|
|
skipWhitespace();
|
|
if (isNameFirst) {
|
|
typeExpression = tryParseTypeExpression();
|
|
}
|
|
var result = target === 1 /* Property */ ?
|
|
createNode(298 /* JSDocPropertyTag */, atToken.pos) :
|
|
createNode(293 /* JSDocParameterTag */, atToken.pos);
|
|
var comment;
|
|
if (indent !== undefined)
|
|
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
|
|
var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target);
|
|
if (nestedTypeLiteral) {
|
|
typeExpression = nestedTypeLiteral;
|
|
isNameFirst = true;
|
|
}
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
result.typeExpression = typeExpression;
|
|
result.name = name;
|
|
result.isNameFirst = isNameFirst;
|
|
result.isBracketed = isBracketed;
|
|
result.comment = comment;
|
|
return finishNode(result);
|
|
}
|
|
function parseNestedTypeLiteral(typeExpression, name, target) {
|
|
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
|
var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos());
|
|
var child = void 0;
|
|
var jsdocTypeLiteral = void 0;
|
|
var start_2 = scanner.getStartPos();
|
|
var children = void 0;
|
|
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
|
|
if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 298 /* JSDocPropertyTag */) {
|
|
children = ts.append(children, child);
|
|
}
|
|
}
|
|
if (children) {
|
|
jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2);
|
|
jsdocTypeLiteral.jsDocPropertyTags = children;
|
|
if (typeExpression.type.kind === 167 /* ArrayType */) {
|
|
jsdocTypeLiteral.isArrayType = true;
|
|
}
|
|
typeLiteralExpression.type = finishNode(jsdocTypeLiteral);
|
|
return finishNode(typeLiteralExpression);
|
|
}
|
|
}
|
|
}
|
|
function parseReturnTag(atToken, tagName) {
|
|
if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) {
|
|
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
|
|
}
|
|
var result = createNode(294 /* JSDocReturnTag */, atToken.pos);
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
result.typeExpression = tryParseTypeExpression();
|
|
return finishNode(result);
|
|
}
|
|
function parseTypeTag(atToken, tagName) {
|
|
if (ts.forEach(tags, function (t) { return t.kind === 295 /* JSDocTypeTag */; })) {
|
|
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
|
|
}
|
|
var result = createNode(295 /* JSDocTypeTag */, atToken.pos);
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
|
|
return finishNode(result);
|
|
}
|
|
function parseAugmentsTag(atToken, tagName) {
|
|
var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos);
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
result.class = parseExpressionWithTypeArgumentsForAugments();
|
|
return finishNode(result);
|
|
}
|
|
function parseExpressionWithTypeArgumentsForAugments() {
|
|
var usedBrace = parseOptional(17 /* OpenBraceToken */);
|
|
var node = createNode(207 /* ExpressionWithTypeArguments */);
|
|
node.expression = parsePropertyAccessEntityNameExpression();
|
|
node.typeArguments = tryParseTypeArguments();
|
|
var res = finishNode(node);
|
|
if (usedBrace) {
|
|
parseExpected(18 /* CloseBraceToken */);
|
|
}
|
|
return res;
|
|
}
|
|
function parsePropertyAccessEntityNameExpression() {
|
|
var node = parseJSDocIdentifierName();
|
|
while (parseOptional(23 /* DotToken */)) {
|
|
var prop = createNode(185 /* PropertyAccessExpression */, node.pos);
|
|
prop.expression = node;
|
|
prop.name = parseJSDocIdentifierName();
|
|
node = finishNode(prop);
|
|
}
|
|
return node;
|
|
}
|
|
function parseClassTag(atToken, tagName) {
|
|
var tag = createNode(291 /* JSDocClassTag */, atToken.pos);
|
|
tag.atToken = atToken;
|
|
tag.tagName = tagName;
|
|
return finishNode(tag);
|
|
}
|
|
function parseTypedefTag(atToken, tagName, indent) {
|
|
var typeExpression = tryParseTypeExpression();
|
|
skipWhitespace();
|
|
var typedefTag = createNode(297 /* JSDocTypedefTag */, atToken.pos);
|
|
typedefTag.atToken = atToken;
|
|
typedefTag.tagName = tagName;
|
|
typedefTag.fullName = parseJSDocTypeNameWithNamespace();
|
|
typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
|
|
skipWhitespace();
|
|
typedefTag.comment = parseTagComments(indent);
|
|
typedefTag.typeExpression = typeExpression;
|
|
var end;
|
|
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
|
var child = void 0;
|
|
var jsdocTypeLiteral = void 0;
|
|
var childTypeTag = void 0;
|
|
var start_3 = scanner.getStartPos();
|
|
while (child = tryParse(function () { return parseChildPropertyTag(); })) {
|
|
if (!jsdocTypeLiteral) {
|
|
jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3);
|
|
}
|
|
if (child.kind === 295 /* JSDocTypeTag */) {
|
|
if (childTypeTag) {
|
|
break;
|
|
}
|
|
else {
|
|
childTypeTag = child;
|
|
}
|
|
}
|
|
else {
|
|
jsdocTypeLiteral.jsDocPropertyTags = ts.append(jsdocTypeLiteral.jsDocPropertyTags, child);
|
|
}
|
|
}
|
|
if (jsdocTypeLiteral) {
|
|
if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) {
|
|
jsdocTypeLiteral.isArrayType = true;
|
|
}
|
|
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
|
|
childTypeTag.typeExpression :
|
|
finishNode(jsdocTypeLiteral);
|
|
end = typedefTag.typeExpression.end;
|
|
}
|
|
}
|
|
// Only include the characters between the name end and the next token if a comment was actually parsed out - otherwise it's just whitespace
|
|
return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
|
|
}
|
|
function parseJSDocTypeNameWithNamespace(nested) {
|
|
var pos = scanner.getTokenPos();
|
|
if (!ts.tokenIsIdentifierOrKeyword(token())) {
|
|
return undefined;
|
|
}
|
|
var typeNameOrNamespaceName = parseJSDocIdentifierName();
|
|
if (parseOptional(23 /* DotToken */)) {
|
|
var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos);
|
|
if (nested) {
|
|
jsDocNamespaceNode.flags |= 4 /* NestedNamespace */;
|
|
}
|
|
jsDocNamespaceNode.name = typeNameOrNamespaceName;
|
|
jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
|
|
return finishNode(jsDocNamespaceNode);
|
|
}
|
|
if (nested) {
|
|
typeNameOrNamespaceName.isInJSDocNamespace = true;
|
|
}
|
|
return typeNameOrNamespaceName;
|
|
}
|
|
function parseCallbackTag(atToken, tagName, indent) {
|
|
var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos);
|
|
callbackTag.atToken = atToken;
|
|
callbackTag.tagName = tagName;
|
|
callbackTag.fullName = parseJSDocTypeNameWithNamespace();
|
|
callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
|
|
skipWhitespace();
|
|
callbackTag.comment = parseTagComments(indent);
|
|
var child;
|
|
var start = scanner.getStartPos();
|
|
var jsdocSignature = createNode(288 /* JSDocSignature */, start);
|
|
jsdocSignature.parameters = [];
|
|
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) {
|
|
jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
|
|
}
|
|
var returnTag = tryParse(function () {
|
|
if (parseOptionalJsdoc(57 /* AtToken */)) {
|
|
var tag = parseTag(indent);
|
|
if (tag && tag.kind === 294 /* JSDocReturnTag */) {
|
|
return tag;
|
|
}
|
|
}
|
|
});
|
|
if (returnTag) {
|
|
jsdocSignature.type = returnTag;
|
|
}
|
|
callbackTag.typeExpression = finishNode(jsdocSignature);
|
|
return finishNode(callbackTag);
|
|
}
|
|
function getJSDocTypeAliasName(fullName) {
|
|
if (fullName) {
|
|
var rightNode = fullName;
|
|
while (true) {
|
|
if (ts.isIdentifier(rightNode) || !rightNode.body) {
|
|
return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
|
|
}
|
|
rightNode = rightNode.body;
|
|
}
|
|
}
|
|
}
|
|
function escapedTextsEqual(a, b) {
|
|
while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
|
|
if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
|
|
a = a.left;
|
|
b = b.left;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
return a.escapedText === b.escapedText;
|
|
}
|
|
function parseChildPropertyTag() {
|
|
return parseChildParameterOrPropertyTag(1 /* Property */);
|
|
}
|
|
function parseChildParameterOrPropertyTag(target, name) {
|
|
var canParseTag = true;
|
|
var seenAsterisk = false;
|
|
while (true) {
|
|
switch (nextJSDocToken()) {
|
|
case 57 /* AtToken */:
|
|
if (canParseTag) {
|
|
var child = tryParseChildTag(target);
|
|
if (child && child.kind === 293 /* JSDocParameterTag */ &&
|
|
target !== 4 /* CallbackParameter */ &&
|
|
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217
|
|
return false;
|
|
}
|
|
return child;
|
|
}
|
|
seenAsterisk = false;
|
|
break;
|
|
case 4 /* NewLineTrivia */:
|
|
canParseTag = true;
|
|
seenAsterisk = false;
|
|
break;
|
|
case 39 /* AsteriskToken */:
|
|
if (seenAsterisk) {
|
|
canParseTag = false;
|
|
}
|
|
seenAsterisk = true;
|
|
break;
|
|
case 71 /* Identifier */:
|
|
canParseTag = false;
|
|
break;
|
|
case 1 /* EndOfFileToken */:
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
function tryParseChildTag(target) {
|
|
ts.Debug.assert(token() === 57 /* AtToken */);
|
|
var atToken = createNode(57 /* AtToken */);
|
|
atToken.end = scanner.getTextPos();
|
|
nextJSDocToken();
|
|
var tagName = parseJSDocIdentifierName();
|
|
skipWhitespace();
|
|
var t;
|
|
switch (tagName.escapedText) {
|
|
case "type":
|
|
return target === 1 /* Property */ && parseTypeTag(atToken, tagName);
|
|
case "prop":
|
|
case "property":
|
|
t = 1 /* Property */;
|
|
break;
|
|
case "arg":
|
|
case "argument":
|
|
case "param":
|
|
t = 2 /* Parameter */ | 4 /* CallbackParameter */;
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
if (!(target & t)) {
|
|
return false;
|
|
}
|
|
var tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined);
|
|
tag.comment = parseTagComments(tag.end - tag.pos);
|
|
return tag;
|
|
}
|
|
function parseTemplateTag(atToken, tagName) {
|
|
// the template tag looks like '@template {Constraint} T,U,V'
|
|
var constraint;
|
|
if (token() === 17 /* OpenBraceToken */) {
|
|
constraint = parseJSDocTypeExpression();
|
|
}
|
|
var typeParameters = [];
|
|
var typeParametersPos = getNodePos();
|
|
do {
|
|
skipWhitespace();
|
|
var typeParameter = createNode(148 /* TypeParameter */);
|
|
typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
|
|
skipWhitespace();
|
|
finishNode(typeParameter);
|
|
typeParameters.push(typeParameter);
|
|
} while (parseOptionalJsdoc(26 /* CommaToken */));
|
|
if (constraint) {
|
|
ts.first(typeParameters).constraint = constraint.type;
|
|
}
|
|
var result = createNode(296 /* JSDocTemplateTag */, atToken.pos);
|
|
result.atToken = atToken;
|
|
result.tagName = tagName;
|
|
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
|
|
finishNode(result);
|
|
return result;
|
|
}
|
|
function nextJSDocToken() {
|
|
return currentToken = scanner.scanJSDocToken();
|
|
}
|
|
function parseOptionalJsdoc(t) {
|
|
if (token() === t) {
|
|
nextJSDocToken();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function parseJSDocEntityName() {
|
|
var entity = parseJSDocIdentifierName();
|
|
if (parseOptional(21 /* OpenBracketToken */)) {
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
// Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking.
|
|
// Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}>
|
|
// but it's not worth it to enforce that restriction.
|
|
}
|
|
while (parseOptional(23 /* DotToken */)) {
|
|
var name = parseJSDocIdentifierName();
|
|
if (parseOptional(21 /* OpenBracketToken */)) {
|
|
parseExpected(22 /* CloseBracketToken */);
|
|
}
|
|
entity = createQualifiedName(entity, name);
|
|
}
|
|
return entity;
|
|
}
|
|
function parseJSDocIdentifierName(message) {
|
|
if (!ts.tokenIsIdentifierOrKeyword(token())) {
|
|
return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected);
|
|
}
|
|
var pos = scanner.getTokenPos();
|
|
var end = scanner.getTextPos();
|
|
var result = createNode(71 /* Identifier */, pos);
|
|
result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
|
|
finishNode(result, end);
|
|
nextJSDocToken();
|
|
return result;
|
|
}
|
|
}
|
|
JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker;
|
|
})(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
|
|
})(Parser || (Parser = {}));
|
|
var IncrementalParser;
|
|
(function (IncrementalParser) {
|
|
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
|
|
aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */);
|
|
checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
|
|
// if the text didn't change, then we can just return our current source file as-is.
|
|
return sourceFile;
|
|
}
|
|
if (sourceFile.statements.length === 0) {
|
|
// If we don't have any statements in the current source file, then there's no real
|
|
// way to incrementally parse. So just do a full parse instead.
|
|
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
|
|
}
|
|
// Make sure we're not trying to incrementally update a source file more than once. Once
|
|
// we do an update the original source file is considered unusable from that point onwards.
|
|
//
|
|
// This is because we do incremental parsing in-place. i.e. we take nodes from the old
|
|
// tree and give them new positions and parents. From that point on, trusting the old
|
|
// tree at all is not possible as far too much of it may violate invariants.
|
|
var incrementalSourceFile = sourceFile;
|
|
ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
|
|
incrementalSourceFile.hasBeenIncrementallyParsed = true;
|
|
var oldText = sourceFile.text;
|
|
var syntaxCursor = createSyntaxCursor(sourceFile);
|
|
// Make the actual change larger so that we know to reparse anything whose lookahead
|
|
// might have intersected the change.
|
|
var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
|
|
checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
|
|
// Ensure that extending the affected range only moved the start of the change range
|
|
// earlier in the file.
|
|
ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
|
|
ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
|
|
ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
|
|
// The is the amount the nodes after the edit range need to be adjusted. It can be
|
|
// positive (if the edit added characters), negative (if the edit deleted characters)
|
|
// or zero (if this was a pure overwrite with nothing added/removed).
|
|
var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
|
|
// If we added or removed characters during the edit, then we need to go and adjust all
|
|
// the nodes after the edit. Those nodes may move forward (if we inserted chars) or they
|
|
// may move backward (if we deleted chars).
|
|
//
|
|
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
|
|
// to reuse are already at the appropriate position in the new text. That way when we
|
|
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
|
|
// it very easy to determine if we can reuse a node. If the node's position is at where
|
|
// we are in the text, then we can reuse it. Otherwise we can't. If the node's position
|
|
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
|
|
// us, then we'll need to skip it or crumble it as appropriate
|
|
//
|
|
// We will also adjust the positions of nodes that intersect the change range as well.
|
|
// By doing this, we ensure that all the positions in the old tree are consistent, not
|
|
// just the positions of nodes entirely before/after the change range. By being
|
|
// consistent, we can then easily map from positions to nodes in the old tree easily.
|
|
//
|
|
// Also, mark any syntax elements that intersect the changed span. We know, up front,
|
|
// that we cannot reuse these elements.
|
|
updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
|
|
// Now that we've set up our internal incremental state just proceed and parse the
|
|
// source file in the normal fashion. When possible the parser will retrieve and
|
|
// reuse nodes from the old tree.
|
|
//
|
|
// Note: passing in 'true' for setNodeParents is very important. When incrementally
|
|
// parsing, we will be reusing nodes from the old tree, and placing it into new
|
|
// parents. If we don't set the parents now, we'll end up with an observably
|
|
// inconsistent tree. Setting the parents on the new tree should be very fast. We
|
|
// will immediately bail out of walking any subtrees when we can see that their parents
|
|
// are already correct.
|
|
var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
|
|
return result;
|
|
}
|
|
IncrementalParser.updateSourceFile = updateSourceFile;
|
|
function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
|
|
if (isArray) {
|
|
visitArray(element);
|
|
}
|
|
else {
|
|
visitNode(element);
|
|
}
|
|
return;
|
|
function visitNode(node) {
|
|
var text = "";
|
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
text = oldText.substring(node.pos, node.end);
|
|
}
|
|
// Ditch any existing LS children we may have created. This way we can avoid
|
|
// moving them forward.
|
|
if (node._children) {
|
|
node._children = undefined;
|
|
}
|
|
node.pos += delta;
|
|
node.end += delta;
|
|
if (aggressiveChecks && shouldCheckNode(node)) {
|
|
ts.Debug.assert(text === newText.substring(node.pos, node.end));
|
|
}
|
|
forEachChild(node, visitNode, visitArray);
|
|
if (ts.hasJSDocNodes(node)) {
|
|
for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
|
|
var jsDocComment = _a[_i];
|
|
visitNode(jsDocComment);
|
|
}
|
|
}
|
|
checkNodePositions(node, aggressiveChecks);
|
|
}
|
|
function visitArray(array) {
|
|
array._children = undefined;
|
|
array.pos += delta;
|
|
array.end += delta;
|
|
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
var node = array_1[_i];
|
|
visitNode(node);
|
|
}
|
|
}
|
|
}
|
|
function shouldCheckNode(node) {
|
|
switch (node.kind) {
|
|
case 9 /* StringLiteral */:
|
|
case 8 /* NumericLiteral */:
|
|
case 71 /* Identifier */:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
|
|
ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
|
|
ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
|
|
ts.Debug.assert(element.pos <= element.end);
|
|
// We have an element that intersects the change range in some way. It may have its
|
|
// start, or its end (or both) in the changed range. We want to adjust any part
|
|
// that intersects such that the final tree is in a consistent state. i.e. all
|
|
// children have spans within the span of their parent, and all siblings are ordered
|
|
// properly.
|
|
// We may need to update both the 'pos' and the 'end' of the element.
|
|
// If the 'pos' is before the start of the change, then we don't need to touch it.
|
|
// If it isn't, then the 'pos' must be inside the change. How we update it will
|
|
// depend if delta is positive or negative. If delta is positive then we have
|
|
// something like:
|
|
//
|
|
// -------------------AAA-----------------
|
|
// -------------------BBBCCCCCCC-----------------
|
|
//
|
|
// In this case, we consider any node that started in the change range to still be
|
|
// starting at the same position.
|
|
//
|
|
// however, if the delta is negative, then we instead have something like this:
|
|
//
|
|
// -------------------XXXYYYYYYY-----------------
|
|
// -------------------ZZZ-----------------
|
|
//
|
|
// In this case, any element that started in the 'X' range will keep its position.
|
|
// However any element that started after that will have their pos adjusted to be
|
|
// at the end of the new range. i.e. any node that started in the 'Y' range will
|
|
// be adjusted to have their start at the end of the 'Z' range.
|
|
//
|
|
// The element will keep its position if possible. Or Move backward to the new-end
|
|
// if it's in the 'Y' range.
|
|
element.pos = Math.min(element.pos, changeRangeNewEnd);
|
|
// If the 'end' is after the change range, then we always adjust it by the delta
|
|
// amount. However, if the end is in the change range, then how we adjust it
|
|
// will depend on if delta is positive or negative. If delta is positive then we
|
|
// have something like:
|
|
//
|
|
// -------------------AAA-----------------
|
|
// -------------------BBBCCCCCCC-----------------
|
|
//
|
|
// In this case, we consider any node that ended inside the change range to keep its
|
|
// end position.
|
|
//
|
|
// however, if the delta is negative, then we instead have something like this:
|
|
//
|
|
// -------------------XXXYYYYYYY-----------------
|
|
// -------------------ZZZ-----------------
|
|
//
|
|
// In this case, any element that ended in the 'X' range will keep its position.
|
|
// However any element that ended after that will have their pos adjusted to be
|
|
// at the end of the new range. i.e. any node that ended in the 'Y' range will
|
|
// be adjusted to have their end at the end of the 'Z' range.
|
|
if (element.end >= changeRangeOldEnd) {
|
|
// Element ends after the change range. Always adjust the end pos.
|
|
element.end += delta;
|
|
}
|
|
else {
|
|
// Element ends in the change range. The element will keep its position if
|
|
// possible. Or Move backward to the new-end if it's in the 'Y' range.
|
|
element.end = Math.min(element.end, changeRangeNewEnd);
|
|
}
|
|
ts.Debug.assert(element.pos <= element.end);
|
|
if (element.parent) {
|
|
ts.Debug.assert(element.pos >= element.parent.pos);
|
|
ts.Debug.assert(element.end <= element.parent.end);
|
|
}
|
|
}
|
|
function checkNodePositions(node, aggressiveChecks) {
|
|
if (aggressiveChecks) {
|
|
var pos_2 = node.pos;
|
|
var visitNode_1 = function (child) {
|
|
ts.Debug.assert(child.pos >= pos_2);
|
|
pos_2 = child.end;
|
|
};
|
|
if (ts.hasJSDocNodes(node)) {
|
|
for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
|
|
var jsDocComment = _a[_i];
|
|
visitNode_1(jsDocComment);
|
|
}
|
|
}
|
|
forEachChild(node, visitNode_1);
|
|
ts.Debug.assert(pos_2 <= node.end);
|
|
}
|
|
}
|
|
function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
|
|
visitNode(sourceFile);
|
|
return;
|
|
function visitNode(child) {
|
|
ts.Debug.assert(child.pos <= child.end);
|
|
if (child.pos > changeRangeOldEnd) {
|
|
// Node is entirely past the change range. We need to move both its pos and
|
|
// end, forward or backward appropriately.
|
|
moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks);
|
|
return;
|
|
}
|
|
// Check if the element intersects the change range. If it does, then it is not
|
|
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
|
// be able to use.
|
|
var fullEnd = child.end;
|
|
if (fullEnd >= changeStart) {
|
|
child.intersectsChange = true;
|
|
child._children = undefined;
|
|
// Adjust the pos or end (or both) of the intersecting element accordingly.
|
|
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
forEachChild(child, visitNode, visitArray);
|
|
if (ts.hasJSDocNodes(child)) {
|
|
for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
|
|
var jsDocComment = _a[_i];
|
|
visitNode(jsDocComment);
|
|
}
|
|
}
|
|
checkNodePositions(child, aggressiveChecks);
|
|
return;
|
|
}
|
|
// Otherwise, the node is entirely before the change range. No need to do anything with it.
|
|
ts.Debug.assert(fullEnd < changeStart);
|
|
}
|
|
function visitArray(array) {
|
|
ts.Debug.assert(array.pos <= array.end);
|
|
if (array.pos > changeRangeOldEnd) {
|
|
// Array is entirely after the change range. We need to move it, and move any of
|
|
// its children.
|
|
moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks);
|
|
return;
|
|
}
|
|
// Check if the element intersects the change range. If it does, then it is not
|
|
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
|
// be able to use.
|
|
var fullEnd = array.end;
|
|
if (fullEnd >= changeStart) {
|
|
array.intersectsChange = true;
|
|
array._children = undefined;
|
|
// Adjust the pos or end (or both) of the intersecting array accordingly.
|
|
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
|
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
|
|
var node = array_2[_i];
|
|
visitNode(node);
|
|
}
|
|
return;
|
|
}
|
|
// Otherwise, the array is entirely before the change range. No need to do anything with it.
|
|
ts.Debug.assert(fullEnd < changeStart);
|
|
}
|
|
}
|
|
function extendToAffectedRange(sourceFile, changeRange) {
|
|
// Consider the following code:
|
|
// void foo() { /; }
|
|
//
|
|
// If the text changes with an insertion of / just before the semicolon then we end up with:
|
|
// void foo() { //; }
|
|
//
|
|
// If we were to just use the changeRange a is, then we would not rescan the { token
|
|
// (as it does not intersect the actual original change range). Because an edit may
|
|
// change the token touching it, we actually need to look back *at least* one token so
|
|
// that the prior token sees that change.
|
|
var maxLookahead = 1;
|
|
var start = changeRange.span.start;
|
|
// the first iteration aligns us with the change start. subsequent iteration move us to
|
|
// the left by maxLookahead tokens. We only need to do this as long as we're not at the
|
|
// start of the tree.
|
|
for (var i = 0; start > 0 && i <= maxLookahead; i++) {
|
|
var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
|
|
ts.Debug.assert(nearestNode.pos <= start);
|
|
var position = nearestNode.pos;
|
|
start = Math.max(0, position - 1);
|
|
}
|
|
var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
|
|
var finalLength = changeRange.newLength + (changeRange.span.start - start);
|
|
return ts.createTextChangeRange(finalSpan, finalLength);
|
|
}
|
|
function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
|
|
var bestResult = sourceFile;
|
|
var lastNodeEntirelyBeforePosition;
|
|
forEachChild(sourceFile, visit);
|
|
if (lastNodeEntirelyBeforePosition) {
|
|
var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
|
|
if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
|
|
bestResult = lastChildOfLastEntireNodeBeforePosition;
|
|
}
|
|
}
|
|
return bestResult;
|
|
function getLastDescendant(node) {
|
|
while (true) {
|
|
var lastChild = ts.getLastChild(node);
|
|
if (lastChild) {
|
|
node = lastChild;
|
|
}
|
|
else {
|
|
return node;
|
|
}
|
|
}
|
|
}
|
|
function visit(child) {
|
|
if (ts.nodeIsMissing(child)) {
|
|
// Missing nodes are effectively invisible to us. We never even consider them
|
|
// When trying to find the nearest node before us.
|
|
return;
|
|
}
|
|
// If the child intersects this position, then this node is currently the nearest
|
|
// node that starts before the position.
|
|
if (child.pos <= position) {
|
|
if (child.pos >= bestResult.pos) {
|
|
// This node starts before the position, and is closer to the position than
|
|
// the previous best node we found. It is now the new best node.
|
|
bestResult = child;
|
|
}
|
|
// Now, the node may overlap the position, or it may end entirely before the
|
|
// position. If it overlaps with the position, then either it, or one of its
|
|
// children must be the nearest node before the position. So we can just
|
|
// recurse into this child to see if we can find something better.
|
|
if (position < child.end) {
|
|
// The nearest node is either this child, or one of the children inside
|
|
// of it. We've already marked this child as the best so far. Recurse
|
|
// in case one of the children is better.
|
|
forEachChild(child, visit);
|
|
// Once we look at the children of this node, then there's no need to
|
|
// continue any further.
|
|
return true;
|
|
}
|
|
else {
|
|
ts.Debug.assert(child.end <= position);
|
|
// The child ends entirely before this position. Say you have the following
|
|
// (where $ is the position)
|
|
//
|
|
// <complex expr 1> ? <complex expr 2> $ : <...> <...>
|
|
//
|
|
// We would want to find the nearest preceding node in "complex expr 2".
|
|
// To support that, we keep track of this node, and once we're done searching
|
|
// for a best node, we recurse down this node to see if we can find a good
|
|
// result in it.
|
|
//
|
|
// This approach allows us to quickly skip over nodes that are entirely
|
|
// before the position, while still allowing us to find any nodes in the
|
|
// last one that might be what we want.
|
|
lastNodeEntirelyBeforePosition = child;
|
|
}
|
|
}
|
|
else {
|
|
ts.Debug.assert(child.pos > position);
|
|
// We're now at a node that is entirely past the position we're searching for.
|
|
// This node (and all following nodes) could never contribute to the result,
|
|
// so just skip them by returning 'true' here.
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
|
|
var oldText = sourceFile.text;
|
|
if (textChangeRange) {
|
|
ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
|
|
if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) {
|
|
var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
|
|
var newTextPrefix = newText.substr(0, textChangeRange.span.start);
|
|
ts.Debug.assert(oldTextPrefix === newTextPrefix);
|
|
var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
|
|
var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
|
|
ts.Debug.assert(oldTextSuffix === newTextSuffix);
|
|
}
|
|
}
|
|
}
|
|
function createSyntaxCursor(sourceFile) {
|
|
var currentArray = sourceFile.statements;
|
|
var currentArrayIndex = 0;
|
|
ts.Debug.assert(currentArrayIndex < currentArray.length);
|
|
var current = currentArray[currentArrayIndex];
|
|
var lastQueriedPosition = -1 /* Value */;
|
|
return {
|
|
currentNode: function (position) {
|
|
// Only compute the current node if the position is different than the last time
|
|
// we were asked. The parser commonly asks for the node at the same position
|
|
// twice. Once to know if can read an appropriate list element at a certain point,
|
|
// and then to actually read and consume the node.
|
|
if (position !== lastQueriedPosition) {
|
|
// Much of the time the parser will need the very next node in the array that
|
|
// we just returned a node from.So just simply check for that case and move
|
|
// forward in the array instead of searching for the node again.
|
|
if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
|
|
currentArrayIndex++;
|
|
current = currentArray[currentArrayIndex];
|
|
}
|
|
// If we don't have a node, or the node we have isn't in the right position,
|
|
// then try to find a viable node at the position requested.
|
|
if (!current || current.pos !== position) {
|
|
findHighestListElementThatStartsAtPosition(position);
|
|
}
|
|
}
|
|
// Cache this query so that we don't do any extra work if the parser calls back
|
|
// into us. Note: this is very common as the parser will make pairs of calls like
|
|
// 'isListElement -> parseListElement'. If we were unable to find a node when
|
|
// called with 'isListElement', we don't want to redo the work when parseListElement
|
|
// is called immediately after.
|
|
lastQueriedPosition = position;
|
|
// Either we don'd have a node, or we have a node at the position being asked for.
|
|
ts.Debug.assert(!current || current.pos === position);
|
|
return current;
|
|
}
|
|
};
|
|
// Finds the highest element in the tree we can find that starts at the provided position.
|
|
// The element must be a direct child of some node list in the tree. This way after we
|
|
// return it, we can easily return its next sibling in the list.
|
|
function findHighestListElementThatStartsAtPosition(position) {
|
|
// Clear out any cached state about the last node we found.
|
|
currentArray = undefined;
|
|
currentArrayIndex = -1 /* Value */;
|
|
current = undefined;
|
|
// Recurse into the source file to find the highest node at this position.
|
|
forEachChild(sourceFile, visitNode, visitArray);
|
|
return;
|
|
function visitNode(node) {
|
|
if (position >= node.pos && position < node.end) {
|
|
// Position was within this node. Keep searching deeper to find the node.
|
|
forEachChild(node, visitNode, visitArray);
|
|
// don't proceed any further in the search.
|
|
return true;
|
|
}
|
|
// position wasn't in this node, have to keep searching.
|
|
return false;
|
|
}
|
|
function visitArray(array) {
|
|
if (position >= array.pos && position < array.end) {
|
|
// position was in this array. Search through this array to see if we find a
|
|
// viable element.
|
|
for (var i = 0; i < array.length; i++) {
|
|
var child = array[i];
|
|
if (child) {
|
|
if (child.pos === position) {
|
|
// Found the right node. We're done.
|
|
currentArray = array;
|
|
currentArrayIndex = i;
|
|
current = child;
|
|
return true;
|
|
}
|
|
else {
|
|
if (child.pos < position && position < child.end) {
|
|
// Position in somewhere within this child. Search in it and
|
|
// stop searching in this array.
|
|
forEachChild(child, visitNode, visitArray);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// position wasn't in this array, have to keep searching.
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
var InvalidPosition;
|
|
(function (InvalidPosition) {
|
|
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
|
})(InvalidPosition || (InvalidPosition = {}));
|
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
function isDeclarationFileName(fileName) {
|
|
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
}
|
|
/*@internal*/
|
|
function processCommentPragmas(context, sourceText) {
|
|
var triviaScanner = ts.createScanner(context.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText);
|
|
var pragmas = [];
|
|
// Keep scanning all the leading trivia in the file until we get to something that
|
|
// isn't trivia. Any single line comment will be analyzed to see if it is a
|
|
// reference comment.
|
|
while (true) {
|
|
var kind = triviaScanner.scan();
|
|
if (!ts.isTrivia(kind)) {
|
|
break;
|
|
}
|
|
var range = {
|
|
kind: triviaScanner.getToken(),
|
|
pos: triviaScanner.getTokenPos(),
|
|
end: triviaScanner.getTextPos(),
|
|
};
|
|
var comment = sourceText.substring(range.pos, range.end);
|
|
extractPragmas(pragmas, range, comment);
|
|
}
|
|
context.pragmas = ts.createMap();
|
|
for (var _i = 0, pragmas_1 = pragmas; _i < pragmas_1.length; _i++) {
|
|
var pragma = pragmas_1[_i];
|
|
if (context.pragmas.has(pragma.name)) { // TODO: GH#18217
|
|
var currentValue = context.pragmas.get(pragma.name);
|
|
if (currentValue instanceof Array) {
|
|
currentValue.push(pragma.args);
|
|
}
|
|
else {
|
|
context.pragmas.set(pragma.name, [currentValue, pragma.args]);
|
|
}
|
|
continue;
|
|
}
|
|
context.pragmas.set(pragma.name, pragma.args);
|
|
}
|
|
}
|
|
ts.processCommentPragmas = processCommentPragmas;
|
|
/*@internal*/
|
|
function processPragmasIntoFields(context, reportDiagnostic) {
|
|
context.checkJsDirective = undefined;
|
|
context.referencedFiles = [];
|
|
context.typeReferenceDirectives = [];
|
|
context.libReferenceDirectives = [];
|
|
context.amdDependencies = [];
|
|
context.hasNoDefaultLib = false;
|
|
context.pragmas.forEach(function (entryOrList, key) {
|
|
// TODO: The below should be strongly type-guarded and not need casts/explicit annotations, since entryOrList is related to
|
|
// key and key is constrained to a union; but it's not (see GH#21483 for at least partial fix) :(
|
|
switch (key) {
|
|
case "reference": {
|
|
var referencedFiles_1 = context.referencedFiles;
|
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
// TODO: GH#18217
|
|
if (arg.arguments["no-default-lib"]) {
|
|
context.hasNoDefaultLib = true;
|
|
}
|
|
else if (arg.arguments.types) {
|
|
typeReferenceDirectives_1.push({ pos: arg.arguments.types.pos, end: arg.arguments.types.end, fileName: arg.arguments.types.value });
|
|
}
|
|
else if (arg.arguments.lib) {
|
|
libReferenceDirectives_1.push({ pos: arg.arguments.lib.pos, end: arg.arguments.lib.end, fileName: arg.arguments.lib.value });
|
|
}
|
|
else if (arg.arguments.path) {
|
|
referencedFiles_1.push({ pos: arg.arguments.path.pos, end: arg.arguments.path.end, fileName: arg.arguments.path.value });
|
|
}
|
|
else {
|
|
reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
case "amd-dependency": {
|
|
context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); // TODO: GH#18217
|
|
break;
|
|
}
|
|
case "amd-module": {
|
|
if (entryOrList instanceof Array) {
|
|
for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
|
|
var entry = entryOrList_1[_i];
|
|
if (context.moduleName) {
|
|
// TODO: It's probably fine to issue this diagnostic on all instances of the pragma
|
|
reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
|
|
}
|
|
context.moduleName = entry.arguments.name;
|
|
}
|
|
}
|
|
else {
|
|
context.moduleName = entryOrList.arguments.name;
|
|
}
|
|
break;
|
|
}
|
|
case "ts-nocheck":
|
|
case "ts-check": {
|
|
// _last_ of either nocheck or check in a file is the "winner"
|
|
ts.forEach(ts.toArray(entryOrList), function (entry) {
|
|
if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { // TODO: GH#18217
|
|
context.checkJsDirective = {
|
|
enabled: key === "ts-check",
|
|
end: entry.range.end,
|
|
pos: entry.range.pos
|
|
};
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
case "jsx": return; // Accessed directly
|
|
default: ts.Debug.fail("Unhandled pragma kind"); // Can this be made into an assertNever in the future?
|
|
}
|
|
});
|
|
}
|
|
ts.processPragmasIntoFields = processPragmasIntoFields;
|
|
var namedArgRegExCache = ts.createMap();
|
|
function getNamedArgRegEx(name) {
|
|
if (namedArgRegExCache.has(name)) {
|
|
return namedArgRegExCache.get(name);
|
|
}
|
|
var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
|
|
namedArgRegExCache.set(name, result);
|
|
return result;
|
|
}
|
|
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
|
var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
|
|
function extractPragmas(pragmas, range, text) {
|
|
var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
|
|
if (tripleSlash) {
|
|
var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks
|
|
var pragma = ts.commentPragmas[name];
|
|
if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) {
|
|
return;
|
|
}
|
|
if (pragma.args) {
|
|
var argument = {};
|
|
for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
|
|
var arg = _a[_i];
|
|
var matcher = getNamedArgRegEx(arg.name);
|
|
var matchResult = matcher.exec(text);
|
|
if (!matchResult && !arg.optional) {
|
|
return; // Missing required argument, don't parse
|
|
}
|
|
else if (matchResult) {
|
|
if (arg.captureSpan) {
|
|
var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
|
|
argument[arg.name] = {
|
|
value: matchResult[3],
|
|
pos: startPos,
|
|
end: startPos + matchResult[3].length
|
|
};
|
|
}
|
|
else {
|
|
argument[arg.name] = matchResult[3];
|
|
}
|
|
}
|
|
}
|
|
pragmas.push({ name: name, args: { arguments: argument, range: range } });
|
|
}
|
|
else {
|
|
pragmas.push({ name: name, args: { arguments: {}, range: range } });
|
|
}
|
|
return;
|
|
}
|
|
var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text);
|
|
if (singleLine) {
|
|
return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine);
|
|
}
|
|
if (range.kind === 3 /* MultiLineCommentTrivia */) {
|
|
var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating)
|
|
var multiLineMatch = void 0;
|
|
while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
|
|
addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch);
|
|
}
|
|
}
|
|
}
|
|
function addPragmaForMatch(pragmas, range, kind, match) {
|
|
if (!match)
|
|
return;
|
|
var name = match[1].toLowerCase(); // Technically unsafe cast, but we do it so they below check to make it safe typechecks
|
|
var pragma = ts.commentPragmas[name];
|
|
if (!pragma || !(pragma.kind & kind)) {
|
|
return;
|
|
}
|
|
var args = match[2]; // Split on spaces and match up positionally with definition
|
|
var argument = getNamedPragmaArguments(pragma, args);
|
|
if (argument === "fail")
|
|
return; // Missing required argument, fail to parse it
|
|
pragmas.push({ name: name, args: { arguments: argument, range: range } });
|
|
return;
|
|
}
|
|
function getNamedPragmaArguments(pragma, text) {
|
|
if (!text)
|
|
return {};
|
|
if (!pragma.args)
|
|
return {};
|
|
var args = text.split(/\s+/);
|
|
var argMap = {};
|
|
for (var i = 0; i < pragma.args.length; i++) {
|
|
var argument = pragma.args[i];
|
|
if (!args[i] && !argument.optional) {
|
|
return "fail";
|
|
}
|
|
if (argument.captureSpan) {
|
|
return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
|
|
}
|
|
argMap[argument.name] = args[i];
|
|
}
|
|
return argMap;
|
|
}
|
|
/** @internal */
|
|
function tagNamesAreEquivalent(lhs, rhs) {
|
|
if (lhs.kind !== rhs.kind) {
|
|
return false;
|
|
}
|
|
if (lhs.kind === 71 /* Identifier */) {
|
|
return lhs.escapedText === rhs.escapedText;
|
|
}
|
|
if (lhs.kind === 99 /* ThisKeyword */) {
|
|
return true;
|
|
}
|
|
// If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only
|
|
// take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression
|
|
// it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element
|
|
return lhs.name.escapedText === rhs.name.escapedText &&
|
|
tagNamesAreEquivalent(lhs.expression, rhs.expression);
|
|
}
|
|
ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
/* @internal */
|
|
ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
|
|
// NOTE: The order here is important to default lib ordering as entries will have the same
|
|
// order in the generated program (see `getDefaultLibPriority` in program.ts). This
|
|
// order also affects overload resolution when a type declared in one lib is
|
|
// augmented in another lib.
|
|
var libEntries = [
|
|
// JavaScript only
|
|
["es5", "lib.es5.d.ts"],
|
|
["es6", "lib.es2015.d.ts"],
|
|
["es2015", "lib.es2015.d.ts"],
|
|
["es7", "lib.es2016.d.ts"],
|
|
["es2016", "lib.es2016.d.ts"],
|
|
["es2017", "lib.es2017.d.ts"],
|
|
["es2018", "lib.es2018.d.ts"],
|
|
["esnext", "lib.esnext.d.ts"],
|
|
// Host only
|
|
["dom", "lib.dom.d.ts"],
|
|
["dom.iterable", "lib.dom.iterable.d.ts"],
|
|
["webworker", "lib.webworker.d.ts"],
|
|
["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
|
|
["scripthost", "lib.scripthost.d.ts"],
|
|
// ES2015 Or ESNext By-feature options
|
|
["es2015.core", "lib.es2015.core.d.ts"],
|
|
["es2015.collection", "lib.es2015.collection.d.ts"],
|
|
["es2015.generator", "lib.es2015.generator.d.ts"],
|
|
["es2015.iterable", "lib.es2015.iterable.d.ts"],
|
|
["es2015.promise", "lib.es2015.promise.d.ts"],
|
|
["es2015.proxy", "lib.es2015.proxy.d.ts"],
|
|
["es2015.reflect", "lib.es2015.reflect.d.ts"],
|
|
["es2015.symbol", "lib.es2015.symbol.d.ts"],
|
|
["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
|
|
["es2016.array.include", "lib.es2016.array.include.d.ts"],
|
|
["es2017.object", "lib.es2017.object.d.ts"],
|
|
["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
|
|
["es2017.string", "lib.es2017.string.d.ts"],
|
|
["es2017.intl", "lib.es2017.intl.d.ts"],
|
|
["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
|
|
["es2018.intl", "lib.es2018.intl.d.ts"],
|
|
["es2018.promise", "lib.es2018.promise.d.ts"],
|
|
["es2018.regexp", "lib.es2018.regexp.d.ts"],
|
|
["esnext.array", "lib.esnext.array.d.ts"],
|
|
["esnext.symbol", "lib.esnext.symbol.d.ts"],
|
|
["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"],
|
|
];
|
|
/**
|
|
* An array of supported "lib" reference file names used to determine the order for inclusion
|
|
* when referenced, as well as for spelling suggestions. This ensures the correct ordering for
|
|
* overload resolution when a type declared in one lib is extended by another.
|
|
*/
|
|
/* @internal */
|
|
ts.libs = libEntries.map(function (entry) { return entry[0]; });
|
|
/**
|
|
* A map of lib names to lib files. This map is used both for parsing the "lib" command line
|
|
* option as well as for resolving lib reference directives.
|
|
*/
|
|
/* @internal */
|
|
ts.libMap = ts.createMapFromEntries(libEntries);
|
|
/* @internal */
|
|
ts.optionDeclarations = [
|
|
// CommandLine only options
|
|
{
|
|
name: "help",
|
|
shortName: "h",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Print_this_message,
|
|
},
|
|
{
|
|
name: "help",
|
|
shortName: "?",
|
|
type: "boolean"
|
|
},
|
|
{
|
|
name: "all",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Show_all_compiler_options,
|
|
},
|
|
{
|
|
name: "version",
|
|
shortName: "v",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Print_the_compiler_s_version,
|
|
},
|
|
{
|
|
name: "init",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
|
|
},
|
|
{
|
|
name: "project",
|
|
shortName: "p",
|
|
type: "string",
|
|
isFilePath: true,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
|
|
description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
|
|
},
|
|
{
|
|
name: "build",
|
|
type: "boolean",
|
|
shortName: "b",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
|
|
},
|
|
{
|
|
name: "pretty",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
|
|
},
|
|
{
|
|
name: "preserveWatchOutput",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: false,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
|
|
},
|
|
{
|
|
name: "watch",
|
|
shortName: "w",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Command_line_Options,
|
|
description: ts.Diagnostics.Watch_input_files,
|
|
},
|
|
// Basic
|
|
{
|
|
name: "target",
|
|
shortName: "t",
|
|
type: ts.createMapFromTemplate({
|
|
es3: 0 /* ES3 */,
|
|
es5: 1 /* ES5 */,
|
|
es6: 2 /* ES2015 */,
|
|
es2015: 2 /* ES2015 */,
|
|
es2016: 3 /* ES2016 */,
|
|
es2017: 4 /* ES2017 */,
|
|
es2018: 5 /* ES2018 */,
|
|
esnext: 6 /* ESNext */,
|
|
}),
|
|
paramType: ts.Diagnostics.VERSION,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT,
|
|
},
|
|
{
|
|
name: "module",
|
|
shortName: "m",
|
|
type: ts.createMapFromTemplate({
|
|
none: ts.ModuleKind.None,
|
|
commonjs: ts.ModuleKind.CommonJS,
|
|
amd: ts.ModuleKind.AMD,
|
|
system: ts.ModuleKind.System,
|
|
umd: ts.ModuleKind.UMD,
|
|
es6: ts.ModuleKind.ES2015,
|
|
es2015: ts.ModuleKind.ES2015,
|
|
esnext: ts.ModuleKind.ESNext
|
|
}),
|
|
paramType: ts.Diagnostics.KIND,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext,
|
|
},
|
|
{
|
|
name: "lib",
|
|
type: "list",
|
|
element: {
|
|
name: "lib",
|
|
type: ts.libMap
|
|
},
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation
|
|
},
|
|
{
|
|
name: "allowJs",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
|
|
},
|
|
{
|
|
name: "checkJs",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Report_errors_in_js_files
|
|
},
|
|
{
|
|
name: "jsx",
|
|
type: ts.createMapFromTemplate({
|
|
"preserve": 1 /* Preserve */,
|
|
"react-native": 3 /* ReactNative */,
|
|
"react": 2 /* React */
|
|
}),
|
|
paramType: ts.Diagnostics.KIND,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
|
|
},
|
|
{
|
|
name: "declaration",
|
|
shortName: "d",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Generates_corresponding_d_ts_file,
|
|
},
|
|
{
|
|
name: "declarationMap",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
|
|
},
|
|
{
|
|
name: "emitDeclarationOnly",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
|
|
},
|
|
{
|
|
name: "sourceMap",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Generates_corresponding_map_file,
|
|
},
|
|
{
|
|
name: "outFile",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.FILE,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
|
|
},
|
|
{
|
|
name: "outDir",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.DIRECTORY,
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
|
|
},
|
|
{
|
|
name: "rootDir",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.LOCATION,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
|
|
},
|
|
{
|
|
name: "composite",
|
|
type: "boolean",
|
|
isTSConfigOnly: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Enable_project_compilation,
|
|
},
|
|
{
|
|
name: "removeComments",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Do_not_emit_comments_to_output,
|
|
},
|
|
{
|
|
name: "noEmit",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Do_not_emit_outputs,
|
|
},
|
|
{
|
|
name: "importHelpers",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Import_emit_helpers_from_tslib
|
|
},
|
|
{
|
|
name: "downlevelIteration",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
|
|
},
|
|
{
|
|
name: "isolatedModules",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Basic_Options,
|
|
description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule
|
|
},
|
|
// Strict Type Checks
|
|
{
|
|
name: "strict",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Enable_all_strict_type_checking_options
|
|
},
|
|
{
|
|
name: "noImplicitAny",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
|
|
},
|
|
{
|
|
name: "strictNullChecks",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Enable_strict_null_checks
|
|
},
|
|
{
|
|
name: "strictFunctionTypes",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Enable_strict_checking_of_function_types
|
|
},
|
|
{
|
|
name: "strictPropertyInitialization",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
|
|
},
|
|
{
|
|
name: "noImplicitThis",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
|
|
},
|
|
{
|
|
name: "alwaysStrict",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Strict_Type_Checking_Options,
|
|
description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
|
|
},
|
|
// Additional Checks
|
|
{
|
|
name: "noUnusedLocals",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Additional_Checks,
|
|
description: ts.Diagnostics.Report_errors_on_unused_locals,
|
|
},
|
|
{
|
|
name: "noUnusedParameters",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Additional_Checks,
|
|
description: ts.Diagnostics.Report_errors_on_unused_parameters,
|
|
},
|
|
{
|
|
name: "noImplicitReturns",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Additional_Checks,
|
|
description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
|
|
},
|
|
{
|
|
name: "noFallthroughCasesInSwitch",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Additional_Checks,
|
|
description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
|
|
},
|
|
// Module Resolution
|
|
{
|
|
name: "moduleResolution",
|
|
type: ts.createMapFromTemplate({
|
|
node: ts.ModuleResolutionKind.NodeJs,
|
|
classic: ts.ModuleResolutionKind.Classic,
|
|
}),
|
|
paramType: ts.Diagnostics.STRATEGY,
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
|
},
|
|
{
|
|
name: "baseUrl",
|
|
type: "string",
|
|
isFilePath: true,
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
|
|
},
|
|
{
|
|
// this option can only be specified in tsconfig.json
|
|
// use type = object to copy the value as-is
|
|
name: "paths",
|
|
type: "object",
|
|
isTSConfigOnly: true,
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl
|
|
},
|
|
{
|
|
// this option can only be specified in tsconfig.json
|
|
// use type = object to copy the value as-is
|
|
name: "rootDirs",
|
|
type: "list",
|
|
isTSConfigOnly: true,
|
|
element: {
|
|
name: "rootDirs",
|
|
type: "string",
|
|
isFilePath: true
|
|
},
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime
|
|
},
|
|
{
|
|
name: "typeRoots",
|
|
type: "list",
|
|
element: {
|
|
name: "typeRoots",
|
|
type: "string",
|
|
isFilePath: true
|
|
},
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
|
|
},
|
|
{
|
|
name: "types",
|
|
type: "list",
|
|
element: {
|
|
name: "types",
|
|
type: "string"
|
|
},
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation
|
|
},
|
|
{
|
|
name: "allowSyntheticDefaultImports",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
|
|
},
|
|
{
|
|
name: "esModuleInterop",
|
|
type: "boolean",
|
|
showInSimplifiedHelpView: true,
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
|
|
},
|
|
{
|
|
name: "preserveSymlinks",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Module_Resolution_Options,
|
|
description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
|
|
},
|
|
// Source Maps
|
|
{
|
|
name: "sourceRoot",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.LOCATION,
|
|
category: ts.Diagnostics.Source_Map_Options,
|
|
description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
|
},
|
|
{
|
|
name: "mapRoot",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.LOCATION,
|
|
category: ts.Diagnostics.Source_Map_Options,
|
|
description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
|
|
},
|
|
{
|
|
name: "inlineSourceMap",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Source_Map_Options,
|
|
description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
|
|
},
|
|
{
|
|
name: "inlineSources",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Source_Map_Options,
|
|
description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
|
|
},
|
|
// Experimental
|
|
{
|
|
name: "experimentalDecorators",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Experimental_Options,
|
|
description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
|
|
},
|
|
{
|
|
name: "emitDecoratorMetadata",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Experimental_Options,
|
|
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
|
|
},
|
|
// Advanced
|
|
{
|
|
name: "jsxFactory",
|
|
type: "string",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
|
|
},
|
|
{
|
|
name: "diagnostics",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Show_diagnostic_information
|
|
},
|
|
{
|
|
name: "extendedDiagnostics",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Show_verbose_diagnostic_information
|
|
},
|
|
{
|
|
name: "traceResolution",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
|
|
},
|
|
{
|
|
name: "resolveJsonModule",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Include_modules_imported_with_json_extension
|
|
},
|
|
{
|
|
name: "listFiles",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
|
|
},
|
|
{
|
|
name: "listEmittedFiles",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
|
|
},
|
|
{
|
|
name: "out",
|
|
type: "string",
|
|
isFilePath: false,
|
|
// for correct behaviour, please use outFile
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
paramType: ts.Diagnostics.FILE,
|
|
description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
|
|
},
|
|
{
|
|
name: "reactNamespace",
|
|
type: "string",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
|
|
},
|
|
{
|
|
name: "skipDefaultLibCheck",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
|
|
},
|
|
{
|
|
name: "charset",
|
|
type: "string",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.The_character_set_of_the_input_files
|
|
},
|
|
{
|
|
name: "emitBOM",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
|
|
},
|
|
{
|
|
name: "locale",
|
|
type: "string",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
|
|
},
|
|
{
|
|
name: "newLine",
|
|
type: ts.createMapFromTemplate({
|
|
crlf: 0 /* CarriageReturnLineFeed */,
|
|
lf: 1 /* LineFeed */
|
|
}),
|
|
paramType: ts.Diagnostics.NEWLINE,
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
|
|
},
|
|
{
|
|
name: "noErrorTruncation",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_truncate_error_messages
|
|
},
|
|
{
|
|
name: "noLib",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts
|
|
},
|
|
{
|
|
name: "noResolve",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files
|
|
},
|
|
{
|
|
name: "stripInternal",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
|
|
},
|
|
{
|
|
name: "disableSizeLimit",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
|
|
},
|
|
{
|
|
name: "noImplicitUseStrict",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
|
|
},
|
|
{
|
|
name: "noEmitHelpers",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
|
|
},
|
|
{
|
|
name: "noEmitOnError",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
|
|
},
|
|
{
|
|
name: "preserveConstEnums",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
|
},
|
|
{
|
|
name: "declarationDir",
|
|
type: "string",
|
|
isFilePath: true,
|
|
paramType: ts.Diagnostics.DIRECTORY,
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Output_directory_for_generated_declaration_files
|
|
},
|
|
{
|
|
name: "skipLibCheck",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
|
|
},
|
|
{
|
|
name: "allowUnusedLabels",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
|
|
},
|
|
{
|
|
name: "allowUnreachableCode",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
|
|
},
|
|
{
|
|
name: "suppressExcessPropertyErrors",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
|
|
},
|
|
{
|
|
name: "suppressImplicitAnyIndexErrors",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
|
|
},
|
|
{
|
|
name: "forceConsistentCasingInFileNames",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
|
|
},
|
|
{
|
|
name: "maxNodeModuleJsDepth",
|
|
type: "number",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
|
|
},
|
|
{
|
|
name: "noStrictGenericChecks",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
|
|
},
|
|
{
|
|
name: "keyofStringsOnly",
|
|
type: "boolean",
|
|
category: ts.Diagnostics.Advanced_Options,
|
|
description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
|
|
},
|
|
{
|
|
// A list of plugins to load in the language service
|
|
name: "plugins",
|
|
type: "list",
|
|
isTSConfigOnly: true,
|
|
element: {
|
|
name: "plugin",
|
|
type: "object"
|
|
},
|
|
description: ts.Diagnostics.List_of_language_service_plugins
|
|
}
|
|
];
|
|
/* @internal */
|
|
ts.typeAcquisitionDeclarations = [
|
|
{
|
|
/* @deprecated typingOptions.enableAutoDiscovery
|
|
* Use typeAcquisition.enable instead.
|
|
*/
|
|
name: "enableAutoDiscovery",
|
|
type: "boolean",
|
|
},
|
|
{
|
|
name: "enable",
|
|
type: "boolean",
|
|
},
|
|
{
|
|
name: "include",
|
|
type: "list",
|
|
element: {
|
|
name: "include",
|
|
type: "string"
|
|
}
|
|
},
|
|
{
|
|
name: "exclude",
|
|
type: "list",
|
|
element: {
|
|
name: "exclude",
|
|
type: "string"
|
|
}
|
|
}
|
|
];
|
|
/* @internal */
|
|
ts.defaultInitCompilerOptions = {
|
|
module: ts.ModuleKind.CommonJS,
|
|
target: 1 /* ES5 */,
|
|
strict: true,
|
|
esModuleInterop: true
|
|
};
|
|
var optionNameMapCache;
|
|
/* @internal */
|
|
function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
|
|
// Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable
|
|
if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
|
|
return {
|
|
enable: typeAcquisition.enableAutoDiscovery,
|
|
include: typeAcquisition.include || [],
|
|
exclude: typeAcquisition.exclude || []
|
|
};
|
|
}
|
|
return typeAcquisition;
|
|
}
|
|
ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
|
|
function getOptionNameMap() {
|
|
if (optionNameMapCache) {
|
|
return optionNameMapCache;
|
|
}
|
|
var optionNameMap = ts.createMap();
|
|
var shortOptionNames = ts.createMap();
|
|
ts.forEach(ts.optionDeclarations, function (option) {
|
|
optionNameMap.set(option.name.toLowerCase(), option);
|
|
if (option.shortName) {
|
|
shortOptionNames.set(option.shortName, option.name);
|
|
}
|
|
});
|
|
optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames };
|
|
return optionNameMapCache;
|
|
}
|
|
/* @internal */
|
|
function createCompilerDiagnosticForInvalidCustomType(opt) {
|
|
return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
|
|
}
|
|
ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
|
|
function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
|
|
var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
|
|
return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
|
|
}
|
|
/* @internal */
|
|
function parseCustomTypeOption(opt, value, errors) {
|
|
return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
|
|
}
|
|
ts.parseCustomTypeOption = parseCustomTypeOption;
|
|
/* @internal */
|
|
function parseListTypeOption(opt, value, errors) {
|
|
if (value === void 0) { value = ""; }
|
|
value = trimString(value);
|
|
if (ts.startsWith(value, "-")) {
|
|
return undefined;
|
|
}
|
|
if (value === "") {
|
|
return [];
|
|
}
|
|
var values = value.split(",");
|
|
switch (opt.element.type) {
|
|
case "number":
|
|
return ts.map(values, parseInt);
|
|
case "string":
|
|
return ts.map(values, function (v) { return v || ""; });
|
|
default:
|
|
return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
|
|
}
|
|
}
|
|
ts.parseListTypeOption = parseListTypeOption;
|
|
function parseCommandLine(commandLine, readFile) {
|
|
var options = {};
|
|
var fileNames = [];
|
|
var projectReferences = undefined;
|
|
var errors = [];
|
|
parseStrings(commandLine);
|
|
return {
|
|
options: options,
|
|
fileNames: fileNames,
|
|
projectReferences: projectReferences,
|
|
errors: errors
|
|
};
|
|
function parseStrings(args) {
|
|
var i = 0;
|
|
while (i < args.length) {
|
|
var s = args[i];
|
|
i++;
|
|
if (s.charCodeAt(0) === 64 /* at */) {
|
|
parseResponseFile(s.slice(1));
|
|
}
|
|
else if (s.charCodeAt(0) === 45 /* minus */) {
|
|
var opt = getOptionFromName(s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1), /*allowShort*/ true);
|
|
if (opt) {
|
|
if (opt.isTSConfigOnly) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name));
|
|
}
|
|
else {
|
|
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
|
if (!args[i] && opt.type !== "boolean") {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name));
|
|
}
|
|
switch (opt.type) {
|
|
case "number":
|
|
options[opt.name] = parseInt(args[i]);
|
|
i++;
|
|
break;
|
|
case "boolean":
|
|
// boolean flag has optional value true, false, others
|
|
var optValue = args[i];
|
|
options[opt.name] = optValue !== "false";
|
|
// consume next argument as boolean flag value
|
|
if (optValue === "false" || optValue === "true") {
|
|
i++;
|
|
}
|
|
break;
|
|
case "string":
|
|
options[opt.name] = args[i] || "";
|
|
i++;
|
|
break;
|
|
case "list":
|
|
var result = parseListTypeOption(opt, args[i], errors);
|
|
options[opt.name] = result || [];
|
|
if (result) {
|
|
i++;
|
|
}
|
|
break;
|
|
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
|
default:
|
|
options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
|
|
i++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s));
|
|
}
|
|
}
|
|
else {
|
|
fileNames.push(s);
|
|
}
|
|
}
|
|
}
|
|
function parseResponseFile(fileName) {
|
|
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
|
|
if (!text) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
|
|
return;
|
|
}
|
|
var args = [];
|
|
var pos = 0;
|
|
while (true) {
|
|
while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */)
|
|
pos++;
|
|
if (pos >= text.length)
|
|
break;
|
|
var start = pos;
|
|
if (text.charCodeAt(start) === 34 /* doubleQuote */) {
|
|
pos++;
|
|
while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */)
|
|
pos++;
|
|
if (pos < text.length) {
|
|
args.push(text.substring(start + 1, pos));
|
|
pos++;
|
|
}
|
|
else {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
|
|
}
|
|
}
|
|
else {
|
|
while (text.charCodeAt(pos) > 32 /* space */)
|
|
pos++;
|
|
args.push(text.substring(start, pos));
|
|
}
|
|
}
|
|
parseStrings(args);
|
|
}
|
|
}
|
|
ts.parseCommandLine = parseCommandLine;
|
|
/** @internal */
|
|
function getOptionFromName(optionName, allowShort) {
|
|
if (allowShort === void 0) { allowShort = false; }
|
|
optionName = optionName.toLowerCase();
|
|
var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames;
|
|
// Try to translate short option names to their full equivalents.
|
|
if (allowShort) {
|
|
var short = shortOptionNames.get(optionName);
|
|
if (short !== undefined) {
|
|
optionName = short;
|
|
}
|
|
}
|
|
return optionNameMap.get(optionName);
|
|
}
|
|
ts.getOptionFromName = getOptionFromName;
|
|
function getDiagnosticText(_message) {
|
|
var _args = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
_args[_i - 1] = arguments[_i];
|
|
}
|
|
var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
|
|
return diagnostic.messageText;
|
|
}
|
|
/* @internal */
|
|
function printVersion() {
|
|
ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine);
|
|
}
|
|
ts.printVersion = printVersion;
|
|
/* @internal */
|
|
function printHelp(optionsList, syntaxPrefix) {
|
|
if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
|
|
var output = [];
|
|
// We want to align our "syntax" and "examples" commands to a certain margin.
|
|
var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
|
|
var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
|
|
var marginLength = Math.max(syntaxLength, examplesLength);
|
|
// Build up the syntactic skeleton.
|
|
var syntax = makePadding(marginLength - syntaxLength);
|
|
syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]";
|
|
output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
|
|
output.push(ts.sys.newLine + ts.sys.newLine);
|
|
// Build up the list of examples.
|
|
var padding = makePadding(marginLength);
|
|
output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine);
|
|
output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine);
|
|
output.push(padding + "tsc @args.txt" + ts.sys.newLine);
|
|
output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine);
|
|
output.push(ts.sys.newLine);
|
|
output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine);
|
|
// We want our descriptions to align at the same column in our output,
|
|
// so we keep track of the longest option usage string.
|
|
marginLength = 0;
|
|
var usageColumn = []; // Things like "-d, --declaration" go in here.
|
|
var descriptionColumn = [];
|
|
var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind
|
|
for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
|
|
var option = optionsList_1[_i];
|
|
// If an option lacks a description,
|
|
// it is not officially supported.
|
|
if (!option.description) {
|
|
continue;
|
|
}
|
|
var usageText_1 = " ";
|
|
if (option.shortName) {
|
|
usageText_1 += "-" + option.shortName;
|
|
usageText_1 += getParamType(option);
|
|
usageText_1 += ", ";
|
|
}
|
|
usageText_1 += "--" + option.name;
|
|
usageText_1 += getParamType(option);
|
|
usageColumn.push(usageText_1);
|
|
var description = void 0;
|
|
if (option.name === "lib") {
|
|
description = getDiagnosticText(option.description);
|
|
var element = option.element;
|
|
var typeMap = element.type;
|
|
optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
|
|
}
|
|
else {
|
|
description = getDiagnosticText(option.description);
|
|
}
|
|
descriptionColumn.push(description);
|
|
// Set the new margin for the description column if necessary.
|
|
marginLength = Math.max(usageText_1.length, marginLength);
|
|
}
|
|
// Special case that can't fit in the loop.
|
|
var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">";
|
|
usageColumn.push(usageText);
|
|
descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
|
|
marginLength = Math.max(usageText.length, marginLength);
|
|
// Print out each row, aligning all the descriptions on the same column.
|
|
for (var i = 0; i < usageColumn.length; i++) {
|
|
var usage = usageColumn[i];
|
|
var description = descriptionColumn[i];
|
|
var kindsList = optionsDescriptionMap.get(description);
|
|
output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine);
|
|
if (kindsList) {
|
|
output.push(makePadding(marginLength + 4));
|
|
for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
|
|
var kind = kindsList_1[_a];
|
|
output.push(kind + " ");
|
|
}
|
|
output.push(ts.sys.newLine);
|
|
}
|
|
}
|
|
for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
|
|
var line = output_1[_b];
|
|
ts.sys.write(line);
|
|
}
|
|
return;
|
|
function getParamType(option) {
|
|
if (option.paramType !== undefined) {
|
|
return " " + getDiagnosticText(option.paramType);
|
|
}
|
|
return "";
|
|
}
|
|
function makePadding(paddingLength) {
|
|
return Array(paddingLength + 1).join(" ");
|
|
}
|
|
}
|
|
ts.printHelp = printHelp;
|
|
/**
|
|
* Reads the config file, reports errors if any and exits if the config file cannot be found
|
|
*/
|
|
function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host) {
|
|
var configFileText;
|
|
try {
|
|
configFileText = host.readFile(configFileName);
|
|
}
|
|
catch (e) {
|
|
var error = ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message);
|
|
host.onUnRecoverableConfigFileDiagnostic(error);
|
|
return undefined;
|
|
}
|
|
if (!configFileText) {
|
|
var error = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
|
|
host.onUnRecoverableConfigFileDiagnostic(error);
|
|
return undefined;
|
|
}
|
|
var result = ts.parseJsonText(configFileName, configFileText);
|
|
var cwd = host.getCurrentDirectory();
|
|
return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd));
|
|
}
|
|
ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
|
|
/**
|
|
* Read tsconfig.json file
|
|
* @param fileName The path to the config file
|
|
*/
|
|
function readConfigFile(fileName, readFile) {
|
|
var textOrDiagnostic = tryReadFile(fileName, readFile);
|
|
return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
|
|
}
|
|
ts.readConfigFile = readConfigFile;
|
|
/**
|
|
* Parse the text of the tsconfig.json file
|
|
* @param fileName The path to the config file
|
|
* @param jsonText The text of the config file
|
|
*/
|
|
function parseConfigFileTextToJson(fileName, jsonText) {
|
|
var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
|
|
return {
|
|
config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
|
|
error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
|
|
};
|
|
}
|
|
ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
|
|
/**
|
|
* Read tsconfig.json file
|
|
* @param fileName The path to the config file
|
|
*/
|
|
function readJsonConfigFile(fileName, readFile) {
|
|
var textOrDiagnostic = tryReadFile(fileName, readFile);
|
|
return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] };
|
|
}
|
|
ts.readJsonConfigFile = readJsonConfigFile;
|
|
function tryReadFile(fileName, readFile) {
|
|
var text;
|
|
try {
|
|
text = readFile(fileName);
|
|
}
|
|
catch (e) {
|
|
return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
|
|
}
|
|
return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, fileName) : text;
|
|
}
|
|
function commandLineOptionsToMap(options) {
|
|
return ts.arrayToMap(options, function (option) { return option.name; });
|
|
}
|
|
var _tsconfigRootOptions;
|
|
function getTsconfigRootOptionsMap() {
|
|
if (_tsconfigRootOptions === undefined) {
|
|
_tsconfigRootOptions = {
|
|
name: undefined,
|
|
type: "object",
|
|
elementOptions: commandLineOptionsToMap([
|
|
{
|
|
name: "compilerOptions",
|
|
type: "object",
|
|
elementOptions: commandLineOptionsToMap(ts.optionDeclarations),
|
|
extraKeyDiagnosticMessage: ts.Diagnostics.Unknown_compiler_option_0
|
|
},
|
|
{
|
|
name: "typingOptions",
|
|
type: "object",
|
|
elementOptions: commandLineOptionsToMap(ts.typeAcquisitionDeclarations),
|
|
extraKeyDiagnosticMessage: ts.Diagnostics.Unknown_type_acquisition_option_0
|
|
},
|
|
{
|
|
name: "typeAcquisition",
|
|
type: "object",
|
|
elementOptions: commandLineOptionsToMap(ts.typeAcquisitionDeclarations),
|
|
extraKeyDiagnosticMessage: ts.Diagnostics.Unknown_type_acquisition_option_0
|
|
},
|
|
{
|
|
name: "extends",
|
|
type: "string"
|
|
},
|
|
{
|
|
name: "references",
|
|
type: "list",
|
|
element: {
|
|
name: "references",
|
|
type: "object"
|
|
}
|
|
},
|
|
{
|
|
name: "files",
|
|
type: "list",
|
|
element: {
|
|
name: "files",
|
|
type: "string"
|
|
}
|
|
},
|
|
{
|
|
name: "include",
|
|
type: "list",
|
|
element: {
|
|
name: "include",
|
|
type: "string"
|
|
}
|
|
},
|
|
{
|
|
name: "exclude",
|
|
type: "list",
|
|
element: {
|
|
name: "exclude",
|
|
type: "string"
|
|
}
|
|
},
|
|
ts.compileOnSaveCommandLineOption
|
|
])
|
|
};
|
|
}
|
|
return _tsconfigRootOptions;
|
|
}
|
|
/**
|
|
* Convert the json syntax tree into the json value
|
|
*/
|
|
function convertToObject(sourceFile, errors) {
|
|
return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined);
|
|
}
|
|
ts.convertToObject = convertToObject;
|
|
/**
|
|
* Convert the json syntax tree into the json value and report errors
|
|
* This returns the json value (apart from checking errors) only if returnValue provided is true.
|
|
* Otherwise it just checks the errors and returns undefined
|
|
*/
|
|
/*@internal*/
|
|
function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
|
|
if (!sourceFile.statements.length) {
|
|
return returnValue ? {} : undefined;
|
|
}
|
|
return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
|
|
function isRootOptionMap(knownOptions) {
|
|
return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
|
|
}
|
|
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnosticMessage, parentOption) {
|
|
var result = returnValue ? {} : undefined;
|
|
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
|
var element = _a[_i];
|
|
if (element.kind !== 270 /* PropertyAssignment */) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
|
continue;
|
|
}
|
|
if (element.questionToken) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
|
|
}
|
|
if (!isDoubleQuotedString(element.name)) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
|
|
}
|
|
var keyText = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(element.name));
|
|
var option = knownOptions ? knownOptions.get(keyText) : undefined;
|
|
if (extraKeyDiagnosticMessage && !option) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText));
|
|
}
|
|
var value = convertPropertyValueToJson(element.initializer, option);
|
|
if (typeof keyText !== "undefined") {
|
|
if (returnValue) {
|
|
result[keyText] = value;
|
|
}
|
|
// Notify key value set, if user asked for it
|
|
if (jsonConversionNotifier &&
|
|
// Current callbacks are only on known parent option or if we are setting values in the root
|
|
(parentOption || isRootOptionMap(knownOptions))) {
|
|
var isValidOptionValue = isCompilerOptionsValue(option, value);
|
|
if (parentOption) {
|
|
if (isValidOptionValue) {
|
|
// Notify option set in the parent if its a valid option value
|
|
jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
|
|
}
|
|
}
|
|
else if (isRootOptionMap(knownOptions)) {
|
|
if (isValidOptionValue) {
|
|
// Notify about the valid root key value being set
|
|
jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
|
|
}
|
|
else if (!option) {
|
|
// Notify about the unknown root key value being set
|
|
jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function convertArrayLiteralExpressionToJson(elements, elementOption) {
|
|
return (returnValue ? elements.map : elements.forEach).call(elements, function (element) { return convertPropertyValueToJson(element, elementOption); });
|
|
}
|
|
function convertPropertyValueToJson(valueExpression, option) {
|
|
switch (valueExpression.kind) {
|
|
case 101 /* TrueKeyword */:
|
|
reportInvalidOptionValue(option && option.type !== "boolean");
|
|
return true;
|
|
case 86 /* FalseKeyword */:
|
|
reportInvalidOptionValue(option && option.type !== "boolean");
|
|
return false;
|
|
case 95 /* NullKeyword */:
|
|
reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for
|
|
return null; // tslint:disable-line:no-null-keyword
|
|
case 9 /* StringLiteral */:
|
|
if (!isDoubleQuotedString(valueExpression)) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
|
|
}
|
|
reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
|
|
var text = valueExpression.text;
|
|
if (option && !ts.isString(option.type)) {
|
|
var customOption = option;
|
|
// Validate custom option type
|
|
if (!customOption.type.has(text.toLowerCase())) {
|
|
errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
|
|
}
|
|
}
|
|
return text;
|
|
case 8 /* NumericLiteral */:
|
|
reportInvalidOptionValue(option && option.type !== "number");
|
|
return Number(valueExpression.text);
|
|
case 198 /* PrefixUnaryExpression */:
|
|
if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) {
|
|
break; // not valid JSON syntax
|
|
}
|
|
reportInvalidOptionValue(option && option.type !== "number");
|
|
return -Number(valueExpression.operand.text);
|
|
case 184 /* ObjectLiteralExpression */:
|
|
reportInvalidOptionValue(option && option.type !== "object");
|
|
var objectLiteralExpression = valueExpression;
|
|
// Currently having element option declaration in the tsconfig with type "object"
|
|
// determines if it needs onSetValidOptionKeyValueInParent callback or not
|
|
// At moment there are only "compilerOptions", "typeAcquisition" and "typingOptions"
|
|
// that satifies it and need it to modify options set in them (for normalizing file paths)
|
|
// vs what we set in the json
|
|
// If need arises, we can modify this interface and callbacks as needed
|
|
if (option) {
|
|
var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnosticMessage = _a.extraKeyDiagnosticMessage, optionName = _a.name;
|
|
return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnosticMessage, optionName);
|
|
}
|
|
else {
|
|
return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined,
|
|
/*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined);
|
|
}
|
|
case 183 /* ArrayLiteralExpression */:
|
|
reportInvalidOptionValue(option && option.type !== "list");
|
|
return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
|
|
}
|
|
// Not in expected format
|
|
if (option) {
|
|
reportInvalidOptionValue(/*isError*/ true);
|
|
}
|
|
else {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal));
|
|
}
|
|
return undefined;
|
|
function reportInvalidOptionValue(isError) {
|
|
if (isError) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
|
|
}
|
|
}
|
|
}
|
|
function isDoubleQuotedString(node) {
|
|
return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
|
|
}
|
|
}
|
|
ts.convertToObjectWorker = convertToObjectWorker;
|
|
function getCompilerOptionValueTypeString(option) {
|
|
return option.type === "list" ?
|
|
"Array" :
|
|
ts.isString(option.type) ? option.type : "string";
|
|
}
|
|
function isCompilerOptionsValue(option, value) {
|
|
if (option) {
|
|
if (isNullOrUndefined(value))
|
|
return true; // All options are undefinable/nullable
|
|
if (option.type === "list") {
|
|
return ts.isArray(value);
|
|
}
|
|
var expectedType = ts.isString(option.type) ? option.type : "string";
|
|
return typeof value === expectedType;
|
|
}
|
|
return false;
|
|
}
|
|
/**
|
|
* Generate tsconfig configuration when running command line "--init"
|
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
* @param fileNames array of filenames to be generated into tsconfig.json
|
|
*/
|
|
/* @internal */
|
|
function generateTSConfig(options, fileNames, newLine) {
|
|
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
return writeConfigurations();
|
|
function getCustomTypeMapOfCommandLineOption(optionDefinition) {
|
|
if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") {
|
|
// this is of a type CommandLineOptionOfPrimitiveType
|
|
return undefined;
|
|
}
|
|
else if (optionDefinition.type === "list") {
|
|
return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
|
|
}
|
|
else {
|
|
return optionDefinition.type;
|
|
}
|
|
}
|
|
function getNameOfCompilerOptionValue(value, customTypeMap) {
|
|
// There is a typeMap associated with this command-line option so use it to map value back to its name
|
|
return ts.forEachEntry(customTypeMap, function (mapValue, key) {
|
|
if (mapValue === value) {
|
|
return key;
|
|
}
|
|
});
|
|
}
|
|
function serializeCompilerOptions(options) {
|
|
var result = ts.createMap();
|
|
var optionsNameMap = getOptionNameMap().optionNameMap;
|
|
var _loop_3 = function (name) {
|
|
if (ts.hasProperty(options, name)) {
|
|
// tsconfig only options cannot be specified via command line,
|
|
// so we can assume that only types that can appear here string | number | boolean
|
|
if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
|
|
return "continue";
|
|
}
|
|
var value = options[name];
|
|
var optionDefinition = optionsNameMap.get(name.toLowerCase());
|
|
if (optionDefinition) {
|
|
var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
|
|
if (!customTypeMap_1) {
|
|
// There is no map associated with this compiler option then use the value as-is
|
|
// This is the case if the value is expect to be string, number, boolean or list of string
|
|
result.set(name, value);
|
|
}
|
|
else {
|
|
if (optionDefinition.type === "list") {
|
|
result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217
|
|
}
|
|
else {
|
|
// There is a typeMap associated with this command-line option so use it to map value back to its name
|
|
result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
for (var name in options) {
|
|
_loop_3(name);
|
|
}
|
|
return result;
|
|
}
|
|
function getDefaultValueForOption(option) {
|
|
switch (option.type) {
|
|
case "number":
|
|
return 1;
|
|
case "boolean":
|
|
return true;
|
|
case "string":
|
|
return option.isFilePath ? "./" : "";
|
|
case "list":
|
|
return [];
|
|
case "object":
|
|
return {};
|
|
default:
|
|
return option.type.keys().next().value;
|
|
}
|
|
}
|
|
function makePadding(paddingLength) {
|
|
return Array(paddingLength + 1).join(" ");
|
|
}
|
|
function isAllowedOption(_a) {
|
|
var category = _a.category, name = _a.name;
|
|
// Skip options which do not have a category or have category `Command_line_Options`
|
|
// Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line
|
|
return category !== undefined
|
|
&& category !== ts.Diagnostics.Command_line_Options
|
|
&& (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
|
|
}
|
|
function writeConfigurations() {
|
|
// Filter applicable options to place in the file
|
|
var categorizedOptions = ts.createMultiMap();
|
|
for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
|
|
var option = optionDeclarations_1[_i];
|
|
var category = option.category;
|
|
if (isAllowedOption(option)) {
|
|
categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
|
|
}
|
|
}
|
|
// Serialize all options and their descriptions
|
|
var marginLength = 0;
|
|
var seenKnownKeys = 0;
|
|
var nameColumn = [];
|
|
var descriptionColumn = [];
|
|
categorizedOptions.forEach(function (options, category) {
|
|
if (nameColumn.length !== 0) {
|
|
nameColumn.push("");
|
|
descriptionColumn.push("");
|
|
}
|
|
nameColumn.push("/* " + category + " */");
|
|
descriptionColumn.push("");
|
|
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
var option = options_1[_i];
|
|
var optionName = void 0;
|
|
if (compilerOptionsMap.has(option.name)) {
|
|
optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
|
|
}
|
|
else {
|
|
optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
|
|
}
|
|
nameColumn.push(optionName);
|
|
descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */");
|
|
marginLength = Math.max(optionName.length, marginLength);
|
|
}
|
|
});
|
|
// Write the output
|
|
var tab = makePadding(2);
|
|
var result = [];
|
|
result.push("{");
|
|
result.push(tab + "\"compilerOptions\": {");
|
|
// Print out each row, aligning all the descriptions on the same column.
|
|
for (var i = 0; i < nameColumn.length; i++) {
|
|
var optionName = nameColumn[i];
|
|
var description = descriptionColumn[i];
|
|
result.push(optionName && "" + tab + tab + optionName + (description && (makePadding(marginLength - optionName.length + 2) + description)));
|
|
}
|
|
if (fileNames.length) {
|
|
result.push(tab + "},");
|
|
result.push(tab + "\"files\": [");
|
|
for (var i = 0; i < fileNames.length; i++) {
|
|
result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
|
|
}
|
|
result.push(tab + "]");
|
|
}
|
|
else {
|
|
result.push(tab + "}");
|
|
}
|
|
result.push("}");
|
|
return result.join(newLine);
|
|
}
|
|
}
|
|
ts.generateTSConfig = generateTSConfig;
|
|
/**
|
|
* Parse the contents of a config file (tsconfig.json).
|
|
* @param json The contents of the config file to parse
|
|
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
|
* @param basePath A root directory to resolve relative path entries in the config
|
|
* file to. e.g. outDir
|
|
*/
|
|
function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) {
|
|
return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions);
|
|
}
|
|
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
|
|
/**
|
|
* Parse the contents of a config file (tsconfig.json).
|
|
* @param jsonNode The contents of the config file to parse
|
|
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
|
* @param basePath A root directory to resolve relative path entries in the config
|
|
* file to. e.g. outDir
|
|
*/
|
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) {
|
|
return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions);
|
|
}
|
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
/*@internal*/
|
|
function setConfigFileInOptions(options, configFile) {
|
|
if (configFile) {
|
|
Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
|
|
}
|
|
}
|
|
ts.setConfigFileInOptions = setConfigFileInOptions;
|
|
function isNullOrUndefined(x) {
|
|
// tslint:disable-next-line:no-null-keyword
|
|
return x === undefined || x === null;
|
|
}
|
|
function directoryOfCombinedPath(fileName, basePath) {
|
|
// Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical
|
|
// until consistient casing errors are reported
|
|
return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
|
|
}
|
|
/**
|
|
* Parse the contents of a config file from json or json source file (tsconfig.json).
|
|
* @param json The contents of the config file to parse
|
|
* @param sourceFile sourceFile corresponding to the Json
|
|
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
|
* @param basePath A root directory to resolve relative path entries in the config
|
|
* file to. e.g. outDir
|
|
* @param resolutionStack Only present for backwards-compatibility. Should be empty.
|
|
*/
|
|
function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) {
|
|
if (existingOptions === void 0) { existingOptions = {}; }
|
|
if (resolutionStack === void 0) { resolutionStack = []; }
|
|
if (extraFileExtensions === void 0) { extraFileExtensions = []; }
|
|
ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
|
|
var errors = [];
|
|
var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors);
|
|
var raw = parsedConfig.raw;
|
|
var options = ts.extend(existingOptions, parsedConfig.options || {});
|
|
options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
|
|
setConfigFileInOptions(options, sourceFile);
|
|
var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec, projectReferences = _a.projectReferences;
|
|
return {
|
|
options: options,
|
|
fileNames: fileNames,
|
|
projectReferences: projectReferences,
|
|
typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
|
|
raw: raw,
|
|
errors: errors,
|
|
wildcardDirectories: wildcardDirectories,
|
|
compileOnSave: !!raw.compileOnSave,
|
|
configFileSpecs: spec
|
|
};
|
|
function getFileNames() {
|
|
var filesSpecs;
|
|
if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
|
|
if (ts.isArray(raw.files)) {
|
|
filesSpecs = raw.files;
|
|
if (filesSpecs.length === 0) {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
|
|
}
|
|
}
|
|
else {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
|
|
}
|
|
}
|
|
var includeSpecs;
|
|
if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
|
|
if (ts.isArray(raw.include)) {
|
|
includeSpecs = raw.include;
|
|
}
|
|
else {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
|
|
}
|
|
}
|
|
var excludeSpecs;
|
|
if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
|
|
if (ts.isArray(raw.exclude)) {
|
|
excludeSpecs = raw.exclude;
|
|
}
|
|
else {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
|
|
}
|
|
}
|
|
else if (raw.compilerOptions) {
|
|
var outDir = raw.compilerOptions.outDir;
|
|
var declarationDir = raw.compilerOptions.declarationDir;
|
|
if (outDir || declarationDir) {
|
|
excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
|
|
}
|
|
}
|
|
if (filesSpecs === undefined && includeSpecs === undefined) {
|
|
includeSpecs = ["**/*"];
|
|
}
|
|
var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
|
|
if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0 && !ts.hasProperty(raw, "references")) {
|
|
errors.push(getErrorForNoInputFiles(result.spec, configFileName));
|
|
}
|
|
if (ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
|
|
if (ts.isArray(raw.references)) {
|
|
var references = [];
|
|
for (var _i = 0, _a = raw.references; _i < _a.length; _i++) {
|
|
var ref = _a[_i];
|
|
if (typeof ref.path !== "string") {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
|
|
}
|
|
else {
|
|
references.push({
|
|
path: ts.getNormalizedAbsolutePath(ref.path, basePath),
|
|
originalPath: ref.path,
|
|
prepend: ref.prepend,
|
|
circular: ref.circular
|
|
});
|
|
}
|
|
}
|
|
result.projectReferences = references;
|
|
}
|
|
else {
|
|
createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
|
|
if (!sourceFile) {
|
|
errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
|
|
}
|
|
}
|
|
}
|
|
/*@internal*/
|
|
function isErrorNoInputFiles(error) {
|
|
return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
|
|
}
|
|
ts.isErrorNoInputFiles = isErrorNoInputFiles;
|
|
/*@internal*/
|
|
function getErrorForNoInputFiles(_a, configFileName) {
|
|
var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
|
|
return ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []));
|
|
}
|
|
ts.getErrorForNoInputFiles = getErrorForNoInputFiles;
|
|
function isSuccessfulParsedTsconfig(value) {
|
|
return !!value.options;
|
|
}
|
|
/**
|
|
* This *just* extracts options/include/exclude/files out of a config file.
|
|
* It does *not* resolve the included files.
|
|
*/
|
|
function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors) {
|
|
basePath = ts.normalizeSlashes(basePath);
|
|
var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
|
|
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> ")));
|
|
return { raw: json || convertToObject(sourceFile, errors) };
|
|
}
|
|
var ownConfig = json ?
|
|
parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
|
|
parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
|
|
if (ownConfig.extendedConfigPath) {
|
|
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
|
|
resolutionStack = resolutionStack.concat([resolvedPath]);
|
|
var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors);
|
|
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
|
|
var baseRaw_1 = extendedConfig.raw;
|
|
var raw_1 = ownConfig.raw;
|
|
var setPropertyInRawIfNotUndefined = function (propertyName) {
|
|
var value = raw_1[propertyName] || baseRaw_1[propertyName];
|
|
if (value) {
|
|
raw_1[propertyName] = value;
|
|
}
|
|
};
|
|
setPropertyInRawIfNotUndefined("include");
|
|
setPropertyInRawIfNotUndefined("exclude");
|
|
setPropertyInRawIfNotUndefined("files");
|
|
if (raw_1.compileOnSave === undefined) {
|
|
raw_1.compileOnSave = baseRaw_1.compileOnSave;
|
|
}
|
|
ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
|
|
// TODO extend type typeAcquisition
|
|
}
|
|
}
|
|
return ownConfig;
|
|
}
|
|
function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
|
|
if (ts.hasProperty(json, "excludes")) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
|
}
|
|
var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
|
|
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
|
// It should be removed in future releases - use typeAcquisition instead.
|
|
var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
|
|
json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
|
var extendedConfigPath;
|
|
if (json.extends) {
|
|
if (!ts.isString(json.extends)) {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
|
|
}
|
|
else {
|
|
var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
|
|
extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
|
|
}
|
|
}
|
|
return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
|
|
}
|
|
function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
|
|
var options = getDefaultCompilerOptions(configFileName);
|
|
var typeAcquisition, typingOptionstypeAcquisition;
|
|
var extendedConfigPath;
|
|
var optionsIterator = {
|
|
onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
|
|
ts.Debug.assert(parentOption === "compilerOptions" || parentOption === "typeAcquisition" || parentOption === "typingOptions");
|
|
var currentOption = parentOption === "compilerOptions" ?
|
|
options :
|
|
parentOption === "typeAcquisition" ?
|
|
(typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName))) :
|
|
(typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
|
|
currentOption[option.name] = normalizeOptionValue(option, basePath, value);
|
|
},
|
|
onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
|
|
switch (key) {
|
|
case "extends":
|
|
var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
|
|
extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
|
|
return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
|
|
});
|
|
return;
|
|
case "files":
|
|
if (value.length === 0) {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
|
}
|
|
return;
|
|
}
|
|
},
|
|
onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
|
|
if (key === "excludes") {
|
|
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
|
}
|
|
}
|
|
};
|
|
var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator);
|
|
if (!typeAcquisition) {
|
|
if (typingOptionstypeAcquisition) {
|
|
typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
|
|
{
|
|
enable: typingOptionstypeAcquisition.enableAutoDiscovery,
|
|
include: typingOptionstypeAcquisition.include,
|
|
exclude: typingOptionstypeAcquisition.exclude
|
|
} :
|
|
typingOptionstypeAcquisition;
|
|
}
|
|
else {
|
|
typeAcquisition = getDefaultTypeAcquisition(configFileName);
|
|
}
|
|
}
|
|
return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
|
|
}
|
|
function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
|
|
extendedConfig = ts.normalizeSlashes(extendedConfig);
|
|
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
|
|
if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) {
|
|
errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
|
|
return undefined;
|
|
}
|
|
var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
|
|
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
|
|
extendedConfigPath = extendedConfigPath + ".json";
|
|
if (!host.fileExists(extendedConfigPath)) {
|
|
errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
|
|
return undefined;
|
|
}
|
|
}
|
|
return extendedConfigPath;
|
|
}
|
|
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) {
|
|
var _a;
|
|
var extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
|
|
if (sourceFile) {
|
|
(sourceFile.extendedSourceFiles || (sourceFile.extendedSourceFiles = [])).push(extendedResult.fileName);
|
|
}
|
|
if (extendedResult.parseDiagnostics.length) {
|
|
errors.push.apply(errors, extendedResult.parseDiagnostics);
|
|
return undefined;
|
|
}
|
|
var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
|
|
var extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors);
|
|
if (sourceFile) {
|
|
(_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
|
|
}
|
|
if (isSuccessfulParsedTsconfig(extendedConfig)) {
|
|
// Update the paths to reflect base path
|
|
var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
|
|
var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
|
|
var mapPropertiesInRawIfNotUndefined = function (propertyName) {
|
|
if (raw_2[propertyName]) {
|
|
raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
|
|
}
|
|
};
|
|
var raw_2 = extendedConfig.raw;
|
|
mapPropertiesInRawIfNotUndefined("include");
|
|
mapPropertiesInRawIfNotUndefined("exclude");
|
|
mapPropertiesInRawIfNotUndefined("files");
|
|
}
|
|
return extendedConfig;
|
|
}
|
|
function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
|
|
if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
|
|
return false;
|
|
}
|
|
var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
|
|
return typeof result === "boolean" && result;
|
|
}
|
|
function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
|
|
var errors = [];
|
|
var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
|
return { options: options, errors: errors };
|
|
}
|
|
ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
|
|
function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
|
|
var errors = [];
|
|
var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
|
return { options: options, errors: errors };
|
|
}
|
|
ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
|
|
function getDefaultCompilerOptions(configFileName) {
|
|
var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
|
|
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
|
|
: {};
|
|
return options;
|
|
}
|
|
function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
|
|
var options = getDefaultCompilerOptions(configFileName);
|
|
convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors);
|
|
if (configFileName) {
|
|
options.configFilePath = ts.normalizeSlashes(configFileName);
|
|
}
|
|
return options;
|
|
}
|
|
function getDefaultTypeAcquisition(configFileName) {
|
|
return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
|
|
}
|
|
function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
|
|
var options = getDefaultTypeAcquisition(configFileName);
|
|
var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
|
|
convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors);
|
|
return options;
|
|
}
|
|
function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) {
|
|
if (!jsonOptions) {
|
|
return;
|
|
}
|
|
var optionNameMap = commandLineOptionsToMap(optionDeclarations);
|
|
for (var id in jsonOptions) {
|
|
var opt = optionNameMap.get(id);
|
|
if (opt) {
|
|
defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
|
|
}
|
|
else {
|
|
errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id));
|
|
}
|
|
}
|
|
}
|
|
function convertJsonOption(opt, value, basePath, errors) {
|
|
if (isCompilerOptionsValue(opt, value)) {
|
|
var optType = opt.type;
|
|
if (optType === "list" && ts.isArray(value)) {
|
|
return convertJsonOptionOfListType(opt, value, basePath, errors);
|
|
}
|
|
else if (!ts.isString(optType)) {
|
|
return convertJsonOptionOfCustomType(opt, value, errors);
|
|
}
|
|
return normalizeNonListOptionValue(opt, basePath, value);
|
|
}
|
|
else {
|
|
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
|
|
}
|
|
}
|
|
function normalizeOptionValue(option, basePath, value) {
|
|
if (isNullOrUndefined(value))
|
|
return undefined;
|
|
if (option.type === "list") {
|
|
var listOption_1 = option;
|
|
if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
|
|
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
|
|
}
|
|
return value;
|
|
}
|
|
else if (!ts.isString(option.type)) {
|
|
return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
|
|
}
|
|
return normalizeNonListOptionValue(option, basePath, value);
|
|
}
|
|
function normalizeNonListOptionValue(option, basePath, value) {
|
|
if (option.isFilePath) {
|
|
value = ts.normalizePath(ts.combinePaths(basePath, value));
|
|
if (value === "") {
|
|
value = ".";
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
function convertJsonOptionOfCustomType(opt, value, errors) {
|
|
if (isNullOrUndefined(value))
|
|
return undefined;
|
|
var key = value.toLowerCase();
|
|
var val = opt.type.get(key);
|
|
if (val !== undefined) {
|
|
return val;
|
|
}
|
|
else {
|
|
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
|
}
|
|
}
|
|
function convertJsonOptionOfListType(option, values, basePath, errors) {
|
|
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
|
|
}
|
|
function trimString(s) {
|
|
return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
|
|
}
|
|
/**
|
|
* Tests for a path that ends in a recursive directory wildcard.
|
|
* Matches **, \**, **\, and \**\, but not a**b.
|
|
*
|
|
* NOTE: used \ in place of / above to avoid issues with multiline comments.
|
|
*
|
|
* Breakdown:
|
|
* (^|\/) # matches either the beginning of the string or a directory separator.
|
|
* \*\* # matches the recursive directory wildcard "**".
|
|
* \/?$ # matches an optional trailing directory separator at the end of the string.
|
|
*/
|
|
var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
|
|
/**
|
|
* Tests for a path where .. appears after a recursive directory wildcard.
|
|
* Matches **\..\*, **\a\..\*, and **\.., but not ..\**\*
|
|
*
|
|
* NOTE: used \ in place of / above to avoid issues with multiline comments.
|
|
*
|
|
* Breakdown:
|
|
* (^|\/) # matches either the beginning of the string or a directory separator.
|
|
* \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
|
|
* (.*\/)? # optionally matches any number of characters followed by a directory separator.
|
|
* \.\. # matches a parent directory path component ".."
|
|
* ($|\/) # matches either the end of the string or a directory separator.
|
|
*/
|
|
var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
|
|
/**
|
|
* Tests for a path containing a wildcard character in a directory component of the path.
|
|
* Matches \*\, \?\, and \a*b\, but not \a\ or \a\*.
|
|
*
|
|
* NOTE: used \ in place of / above to avoid issues with multiline comments.
|
|
*
|
|
* Breakdown:
|
|
* \/ # matches a directory separator.
|
|
* [^/]*? # matches any number of characters excluding directory separators (non-greedy).
|
|
* [*?] # matches either a wildcard character (* or ?)
|
|
* [^/]* # matches any number of characters excluding directory separators (greedy).
|
|
* \/ # matches a directory separator.
|
|
*/
|
|
var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
|
|
/**
|
|
* Matches the portion of a wildcard path that does not contain wildcards.
|
|
* Matches \a of \a\*, or \a\b\c of \a\b\c\?\d.
|
|
*
|
|
* NOTE: used \ in place of / above to avoid issues with multiline comments.
|
|
*
|
|
* Breakdown:
|
|
* ^ # matches the beginning of the string
|
|
* [^*?]* # matches any number of non-wildcard characters
|
|
* (?=\/[^/]*[*?]) # lookahead that matches a directory separator followed by
|
|
* # a path component that contains at least one wildcard character (* or ?).
|
|
*/
|
|
var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
|
|
/**
|
|
* Expands an array of file specifications.
|
|
*
|
|
* @param filesSpecs The literal file names to include.
|
|
* @param includeSpecs The wildcard file specifications to include.
|
|
* @param excludeSpecs The wildcard file specifications to exclude.
|
|
* @param basePath The base path for any relative file specifications.
|
|
* @param options Compiler options.
|
|
* @param host The host used to resolve files and directories.
|
|
* @param errors An array for diagnostic reporting.
|
|
*/
|
|
function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
|
|
basePath = ts.normalizePath(basePath);
|
|
var validatedIncludeSpecs, validatedExcludeSpecs;
|
|
// The exclude spec list is converted into a regular expression, which allows us to quickly
|
|
// test whether a file or directory should be excluded before recursively traversing the
|
|
// file system.
|
|
if (includeSpecs) {
|
|
validatedIncludeSpecs = validateSpecs(includeSpecs, errors, /*allowTrailingRecursion*/ false, jsonSourceFile, "include");
|
|
}
|
|
if (excludeSpecs) {
|
|
validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, /*allowTrailingRecursion*/ true, jsonSourceFile, "exclude");
|
|
}
|
|
// Wildcard directories (provided as part of a wildcard path) are stored in a
|
|
// file map that marks whether it was a regular wildcard match (with a `*` or `?` token),
|
|
// or a recursive directory. This information is used by filesystem watchers to monitor for
|
|
// new entries in these paths.
|
|
var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
|
|
var spec = { filesSpecs: filesSpecs, referencesSpecs: undefined, includeSpecs: includeSpecs, excludeSpecs: excludeSpecs, validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, wildcardDirectories: wildcardDirectories };
|
|
return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
|
|
}
|
|
/**
|
|
* Gets the file names from the provided config file specs that contain, files, include, exclude and
|
|
* other properties needed to resolve the file names
|
|
* @param spec The config file specs extracted with file names to include, wildcards to include/exclude and other details
|
|
* @param basePath The base path for any relative file specifications.
|
|
* @param options Compiler options.
|
|
* @param host The host used to resolve files and directories.
|
|
* @param extraFileExtensions optionaly file extra file extension information from host
|
|
*/
|
|
/* @internal */
|
|
function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
|
|
if (extraFileExtensions === void 0) { extraFileExtensions = []; }
|
|
basePath = ts.normalizePath(basePath);
|
|
var keyMapper = host.useCaseSensitiveFileNames ? ts.identity : ts.toLowerCase;
|
|
// Literal file names (provided via the "files" array in tsconfig.json) are stored in a
|
|
// file map with a possibly case insensitive key. We use this map later when when including
|
|
// wildcard paths.
|
|
var literalFileMap = ts.createMap();
|
|
// Wildcard paths (provided via the "includes" array in tsconfig.json) are stored in a
|
|
// file map with a possibly case insensitive key. We use this map to store paths matched
|
|
// via wildcard, and to handle extension priority.
|
|
var wildcardFileMap = ts.createMap();
|
|
var filesSpecs = spec.filesSpecs, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
|
|
// Rather than requery this for each file and filespec, we query the supported extensions
|
|
// once and store it on the expansion context.
|
|
var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
|
|
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
|
// remove a literal file.
|
|
if (filesSpecs) {
|
|
for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
|
|
var fileName = filesSpecs_1[_i];
|
|
var file = ts.getNormalizedAbsolutePath(fileName, basePath);
|
|
literalFileMap.set(keyMapper(file), file);
|
|
}
|
|
}
|
|
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
|
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
var file = _b[_a];
|
|
// If we have already included a literal or wildcard path with a
|
|
// higher priority extension, we should skip this file.
|
|
//
|
|
// This handles cases where we may encounter both <file>.ts and
|
|
// <file>.d.ts (or <file>.js if "allowJs" is enabled) in the same
|
|
// directory when they are compilation outputs.
|
|
if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
|
|
continue;
|
|
}
|
|
// We may have included a wildcard path with a lower priority
|
|
// extension due to the user-defined order of entries in the
|
|
// "include" array. If there is a lower priority extension in the
|
|
// same directory, we should remove it.
|
|
removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
|
|
var key = keyMapper(file);
|
|
if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
|
|
wildcardFileMap.set(key, file);
|
|
}
|
|
}
|
|
}
|
|
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
|
var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
|
|
var projectReferences = spec.referencesSpecs && spec.referencesSpecs.map(function (r) {
|
|
return __assign({}, r, { path: ts.getNormalizedAbsolutePath(r.path, basePath) });
|
|
});
|
|
return {
|
|
fileNames: literalFiles.concat(wildcardFiles),
|
|
projectReferences: projectReferences,
|
|
wildcardDirectories: wildcardDirectories,
|
|
spec: spec
|
|
};
|
|
}
|
|
ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
|
|
function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
|
|
return specs.filter(function (spec) {
|
|
var diag = specToDiagnostic(spec, allowTrailingRecursion);
|
|
if (diag !== undefined) {
|
|
errors.push(createDiagnostic(diag, spec));
|
|
}
|
|
return diag === undefined;
|
|
});
|
|
function createDiagnostic(message, spec) {
|
|
var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
|
|
return element ?
|
|
ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
|
|
ts.createCompilerDiagnostic(message, spec);
|
|
}
|
|
}
|
|
function specToDiagnostic(spec, allowTrailingRecursion) {
|
|
if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
|
|
return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
|
|
}
|
|
else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
|
|
return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
|
|
}
|
|
}
|
|
/**
|
|
* Gets directories in a set of include patterns that should be watched for changes.
|
|
*/
|
|
function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
|
|
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
|
|
// of the pattern:
|
|
//
|
|
// /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively
|
|
// /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added
|
|
// /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler
|
|
//
|
|
// We watch a directory without recursion if it contains a wildcard in the file segment of
|
|
// the pattern:
|
|
//
|
|
// /a/b/* - Watch /a/b directly to catch any new file
|
|
// /a/b/a?z - Watch /a/b directly to catch any new file matching a?z
|
|
var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
|
|
var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
|
|
var wildcardDirectories = {};
|
|
if (include !== undefined) {
|
|
var recursiveKeys = [];
|
|
for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
|
|
var file = include_1[_i];
|
|
var spec = ts.normalizePath(ts.combinePaths(path, file));
|
|
if (excludeRegex && excludeRegex.test(spec)) {
|
|
continue;
|
|
}
|
|
var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
|
|
if (match) {
|
|
var key = match.key, flags = match.flags;
|
|
var existingFlags = wildcardDirectories[key];
|
|
if (existingFlags === undefined || existingFlags < flags) {
|
|
wildcardDirectories[key] = flags;
|
|
if (flags === 1 /* Recursive */) {
|
|
recursiveKeys.push(key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Remove any subpaths under an existing recursively watched directory.
|
|
for (var key in wildcardDirectories) {
|
|
if (ts.hasProperty(wildcardDirectories, key)) {
|
|
for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
|
|
var recursiveKey = recursiveKeys_1[_a];
|
|
if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
|
|
delete wildcardDirectories[key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return wildcardDirectories;
|
|
}
|
|
function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
|
|
var match = wildcardDirectoryPattern.exec(spec);
|
|
if (match) {
|
|
return {
|
|
key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(),
|
|
flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */
|
|
};
|
|
}
|
|
if (ts.isImplicitGlob(spec)) {
|
|
return { key: spec, flags: 1 /* Recursive */ };
|
|
}
|
|
return undefined;
|
|
}
|
|
/**
|
|
* Determines whether a literal or wildcard file has already been included that has a higher
|
|
* extension priority.
|
|
*
|
|
* @param file The path to the file.
|
|
* @param extensionPriority The priority of the extension.
|
|
* @param context The expansion context.
|
|
*/
|
|
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
|
|
var extensionPriority = ts.getExtensionPriority(file, extensions);
|
|
var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
|
|
for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) {
|
|
var higherPriorityExtension = extensions[i];
|
|
var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
|
|
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
/**
|
|
* Removes files included via wildcard expansion with a lower extension priority that have
|
|
* already been included.
|
|
*
|
|
* @param file The path to the file.
|
|
* @param extensionPriority The priority of the extension.
|
|
* @param context The expansion context.
|
|
*/
|
|
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
|
|
var extensionPriority = ts.getExtensionPriority(file, extensions);
|
|
var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
|
|
for (var i = nextExtensionPriority; i < extensions.length; i++) {
|
|
var lowerPriorityExtension = extensions[i];
|
|
var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
|
|
wildcardFiles.delete(lowerPriorityPath);
|
|
}
|
|
}
|
|
/**
|
|
* Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed.
|
|
* Also converts enum values back to strings.
|
|
*/
|
|
/* @internal */
|
|
function convertCompilerOptionsForTelemetry(opts) {
|
|
var out = {};
|
|
for (var key in opts) {
|
|
if (opts.hasOwnProperty(key)) {
|
|
var type = getOptionFromName(key);
|
|
if (type !== undefined) { // Ignore unknown options
|
|
out[key] = getOptionValueWithEmptyStrings(opts[key], type);
|
|
}
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
|
|
function getOptionValueWithEmptyStrings(value, option) {
|
|
switch (option.type) {
|
|
case "object": // "paths". Can't get any useful information from the value since we blank out strings, so just return "".
|
|
return "";
|
|
case "string": // Could be any arbitrary string -- use empty string instead.
|
|
return "";
|
|
case "number": // Allow numbers, but be sure to check it's actually a number.
|
|
return typeof value === "number" ? value : "";
|
|
case "boolean":
|
|
return typeof value === "boolean" ? value : "";
|
|
case "list":
|
|
var elementType_1 = option.element;
|
|
return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
|
|
default:
|
|
return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
|
|
if (optionEnumValue === value) {
|
|
return optionStringValue;
|
|
}
|
|
}); // TODO: GH#18217
|
|
}
|
|
}
|
|
})(ts || (ts = {}));
|
|
var ts;
|
|
(function (ts) {
|
|
function trace(host) {
|
|
host.trace(ts.formatMessage.apply(undefined, arguments));
|
|
}
|
|
ts.trace = trace;
|
|
/* @internal */
|
|
function isTraceEnabled(compilerOptions, host) {
|
|
return !!compilerOptions.traceResolution && host.trace !== undefined;
|
|
}
|
|
ts.isTraceEnabled = isTraceEnabled;
|
|
function withPackageId(packageId, r) {
|
|
return r && { path: r.path, extension: r.ext, packageId: packageId };
|
|
}
|
|
function noPackageId(r) {
|
|
return withPackageId(/*packageId*/ undefined, r);
|
|
}
|
|
/**
|
|
* Kinds of file that we are currently looking for.
|
|
* Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript.
|
|
*/
|
|
var Extensions;
|
|
(function (Extensions) {
|
|
Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
|
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */
|
|
})(Extensions || (Extensions = {}));
|
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
function resolvedTypeScriptOnly(resolved) {
|
|
if (!resolved) {
|
|
return undefined;
|
|
}
|
|
ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension));
|
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
}
|
|
function createResolvedModuleWithFailedLookupLocations(resolved, originalPath, isExternalLibraryImport, failedLookupLocations) {
|
|
return {
|
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
failedLookupLocations: failedLookupLocations
|
|
};
|
|
}
|
|
/** Reads from "main" or "types"/"typings" depending on `extensions`. */
|
|
function tryReadPackageJsonFields(readTypes, jsonContent, baseDirectory, state) {
|
|
return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main");
|
|
function tryReadFromField(fieldName) {
|
|
if (!ts.hasProperty(jsonContent, fieldName)) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
|
|
}
|
|
return;
|
|
}
|
|
var fileName = jsonContent[fieldName];
|
|
if (!ts.isString(fileName)) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName);
|
|
}
|
|
return;
|
|
}
|
|
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
|
|
}
|
|
return path;
|
|
}
|
|
}
|
|
/* @internal */
|
|
function readJson(path, host) {
|
|
try {
|
|
var jsonText = host.readFile(path);
|
|
if (!jsonText)
|
|
return {};
|
|
var result = ts.parseConfigFileTextToJson(path, jsonText);
|
|
if (result.error) {
|
|
return {};
|
|
}
|
|
return result.config;
|
|
}
|
|
catch (e) {
|
|
// gracefully handle if readFile fails or returns not JSON
|
|
return {};
|
|
}
|
|
}
|
|
ts.readJson = readJson;
|
|
function getEffectiveTypeRoots(options, host) {
|
|
if (options.typeRoots) {
|
|
return options.typeRoots;
|
|
}
|
|
var currentDirectory;
|
|
if (options.configFilePath) {
|
|
currentDirectory = ts.getDirectoryPath(options.configFilePath);
|
|
}
|
|
else if (host.getCurrentDirectory) {
|
|
currentDirectory = host.getCurrentDirectory();
|
|
}
|
|
if (currentDirectory !== undefined) {
|
|
return getDefaultTypeRoots(currentDirectory, host);
|
|
}
|
|
}
|
|
ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
|
|
/**
|
|
* Returns the path to every node_modules/@types directory from some ancestor directory.
|
|
* Returns undefined if there are none.
|
|
*/
|
|
function getDefaultTypeRoots(currentDirectory, host) {
|
|
if (!host.directoryExists) {
|
|
return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
// And if it doesn't exist, tough.
|
|
}
|
|
var typeRoots;
|
|
ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
|
|
var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
|
|
if (host.directoryExists(atTypes)) {
|
|
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
}
|
|
return undefined;
|
|
});
|
|
return typeRoots;
|
|
}
|
|
var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
|
|
/**
|
|
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
|
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
* is assumed to be the same as root directory of the project.
|
|
*/
|
|
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) {
|
|
var traceEnabled = isTraceEnabled(options, host);
|
|
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled };
|
|
var typeRoots = getEffectiveTypeRoots(options, host);
|
|
if (traceEnabled) {
|
|
if (containingFile === undefined) {
|
|
if (typeRoots === undefined) {
|
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
|
|
}
|
|
else {
|
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
|
|
}
|
|
}
|
|
else {
|
|
if (typeRoots === undefined) {
|
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
|
|
}
|
|
else {
|
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
|
|
}
|
|
}
|
|
}
|
|
var failedLookupLocations = [];
|
|
var resolved = primaryLookup();
|
|
var primary = true;
|
|
if (!resolved) {
|
|
resolved = secondaryLookup();
|
|
primary = false;
|
|
}
|
|
var resolvedTypeReferenceDirective;
|
|
if (resolved) {
|
|
if (!options.preserveSymlinks) {
|
|
resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) });
|
|
}
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary);
|
|
}
|
|
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId };
|
|
}
|
|
return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
function primaryLookup() {
|
|
// Check primary library paths
|
|
if (typeRoots && typeRoots.length) {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
|
|
}
|
|
return ts.forEach(typeRoots, function (typeRoot) {
|
|
var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
var candidateDirectory = ts.getDirectoryPath(candidate);
|
|
var directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
if (!directoryExists && traceEnabled) {
|
|
trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
|
|
}
|
|
return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState));
|
|
});
|
|
}
|
|
else {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
|
|
}
|
|
}
|
|
}
|
|
function secondaryLookup() {
|
|
var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
|
|
if (initialLocationForSecondaryLookup !== undefined) {
|
|
// check secondary locations
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
}
|
|
var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined);
|
|
var resolvedFile = resolvedTypeScriptOnly(result && result.value);
|
|
if (!resolvedFile && traceEnabled) {
|
|
trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
|
|
}
|
|
return resolvedFile;
|
|
}
|
|
else {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
|
|
/**
|
|
* Given a set of options, returns the set of type directive names
|
|
* that should be included for this program automatically.
|
|
* This list could either come from the config file,
|
|
* or from enumerating the types root + initial secondary types lookup location.
|
|
* More type directives might appear in the program later as a result of loading actual source files;
|
|
* this list is only the set of defaults that are implicitly included.
|
|
*/
|
|
function getAutomaticTypeDirectiveNames(options, host) {
|
|
// Use explicit type list from tsconfig.json
|
|
if (options.types) {
|
|
return options.types;
|
|
}
|
|
// Walk the primary type lookup locations
|
|
var result = [];
|
|
if (host.directoryExists && host.getDirectories) {
|
|
var typeRoots = getEffectiveTypeRoots(options, host);
|
|
if (typeRoots) {
|
|
for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
|
|
var root = typeRoots_1[_i];
|
|
if (host.directoryExists(root)) {
|
|
for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
|
|
var typeDirectivePath = _b[_a];
|
|
var normalized = ts.normalizePath(typeDirectivePath);
|
|
var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized));
|
|
// `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types.
|
|
// See `createNotNeededPackageJSON` in the types-publisher` repo.
|
|
// tslint:disable-next-line:no-null-keyword
|
|
var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null;
|
|
if (!isNotNeededPackage) {
|
|
// Return just the type directive names
|
|
result.push(ts.getBaseFileName(normalized));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
|
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName) {
|
|
return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName);
|
|
}
|
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
/*@internal*/
|
|
function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
|
|
return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName };
|
|
function getOrCreateCacheForDirectory(directoryName) {
|
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
var perFolderCache = directoryToModuleNameMap.get(path);
|
|
if (!perFolderCache) {
|
|
perFolderCache = ts.createMap();
|
|
directoryToModuleNameMap.set(path, perFolderCache);
|
|
}
|
|
return perFolderCache;
|
|
}
|
|
function getOrCreateCacheForModuleName(nonRelativeModuleName) {
|
|
if (ts.isExternalModuleNameRelative(nonRelativeModuleName)) {
|
|
return undefined; // TODO: GH#18217
|
|
}
|
|
var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName);
|
|
if (!perModuleNameCache) {
|
|
perModuleNameCache = createPerModuleNameCache();
|
|
moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache);
|
|
}
|
|
return perModuleNameCache;
|
|
}
|
|
function createPerModuleNameCache() {
|
|
var directoryPathMap = ts.createMap();
|
|
return { get: get, set: set };
|
|
function get(directory) {
|
|
return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
|
|
}
|
|
/**
|
|
* At first this function add entry directory -> module resolution result to the table.
|
|
* Then it computes the set of parent folders for 'directory' that should have the same module resolution result
|
|
* and for every parent folder in set it adds entry: parent -> module resolution. .
|
|
* Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts.
|
|
* Set of parent folders that should have the same result will be:
|
|
* [
|
|
* /a/b/c/d, /a/b/c, /a/b
|
|
* ]
|
|
* this means that request for module resolution from file in any of these folder will be immediately found in cache.
|
|
*/
|
|
function set(directory, result) {
|
|
var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
|
|
// if entry is already in cache do nothing
|
|
if (directoryPathMap.has(path)) {
|
|
return;
|
|
}
|
|
directoryPathMap.set(path, result);
|
|
var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName;
|
|
// find common prefix between directory and resolved file name
|
|
// this common prefix should be the shorted path that has the same resolution
|
|
// directory: /a/b/c/d/e
|
|
// resolvedFileName: /a/b/foo.d.ts
|
|
var commonPrefix = getCommonPrefix(path, resolvedFileName);
|
|
var current = path;
|
|
while (true) {
|
|
var parent = ts.getDirectoryPath(current);
|
|
if (parent === current || directoryPathMap.has(parent)) {
|
|
break;
|
|
}
|
|
directoryPathMap.set(parent, result);
|
|
current = parent;
|
|
if (current === commonPrefix) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function getCommonPrefix(directory, resolution) {
|
|
if (resolution === undefined) {
|
|
return undefined;
|
|
}
|
|
var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
|
|
// find first position where directory and resolution differs
|
|
var i = 0;
|
|
while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
|
|
i++;
|
|
}
|
|
// find last directory separator before position i
|
|
var sep = directory.lastIndexOf(ts.directorySeparator, i);
|
|
if (sep < 0) {
|
|
return undefined;
|
|
}
|
|
return directory.substr(0, sep);
|
|
}
|
|
}
|
|
}
|
|
ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
|
|
function resolveModuleNameFromCache(moduleName, containingFile, cache) {
|
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
return perFolderCache && perFolderCache.get(moduleName);
|
|
}
|
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) {
|
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
|
|
}
|
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
var result = perFolderCache && perFolderCache.get(moduleName);
|
|
if (result) {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
}
|
|
}
|
|
else {
|
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
if (moduleResolution === undefined) {
|
|
moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
}
|
|
}
|
|
else {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
}
|
|
}
|
|
switch (moduleResolution) {
|
|
case ts.ModuleResolutionKind.NodeJs:
|
|
result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache);
|
|
break;
|
|
case ts.ModuleResolutionKind.Classic:
|
|
result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache);
|
|
break;
|
|
default:
|
|
return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
|
|
}
|
|
if (perFolderCache) {
|
|
perFolderCache.set(moduleName, result);
|
|
// put result in per-module name cache
|
|
var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName);
|
|
if (perModuleNameCache) {
|
|
perModuleNameCache.set(containingDirectory, result);
|
|
}
|
|
}
|
|
}
|
|
if (traceEnabled) {
|
|
if (result.resolvedModule) {
|
|
trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
|
|
}
|
|
else {
|
|
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
ts.resolveModuleName = resolveModuleName;
|
|
/**
|
|
* Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to
|
|
* mitigate differences between design time structure of the project and its runtime counterpart so the same import name
|
|
* can be resolved successfully by TypeScript compiler and runtime module loader.
|
|
* If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will
|
|
* fallback to standard resolution routine.
|
|
*
|
|
* - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative
|
|
* names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will
|
|
* be '/a/b/c/d'
|
|
* - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names
|
|
* will be resolved based on the content of the module name.
|
|
* Structure of 'paths' compiler options
|
|
* 'paths': {
|
|
* pattern-1: [...substitutions],
|
|
* pattern-2: [...substitutions],
|
|
* ...
|
|
* pattern-n: [...substitutions]
|
|
* }
|
|
* Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against
|
|
* all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case.
|
|
* If pattern contains '*' then to match pattern "<prefix>*<suffix>" module name must start with the <prefix> and end with <suffix>.
|
|
* <MatchedStar> denotes part of the module name between <prefix> and <suffix>.
|
|
* If module name can be matches with multiple patterns then pattern with the longest prefix will be picked.
|
|
* After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module
|
|
* from the candidate location.
|
|
* Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every
|
|
* substitution in the list and replace '*' with <MatchedStar> string. If candidate location is not rooted it
|
|
* will be converted to absolute using baseUrl.
|
|
* For example:
|
|
* baseUrl: /a/b/c
|
|
* "paths": {
|
|
* // match all module names
|
|
* "*": [
|
|
* "*", // use matched name as is,
|
|
* // <matched name> will be looked as /a/b/c/<matched name>
|
|
*
|
|
* "folder1/*" // substitution will convert matched name to 'folder1/<matched name>',
|
|
* // since it is not rooted then final candidate location will be /a/b/c/folder1/<matched name>
|
|
* ],
|
|
* // match module names that start with 'components/'
|
|
* "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/<matched name> to '/root/components/folder1/<matched name>',
|
|
* // it is rooted so it will be final candidate location
|
|
* }
|
|
*
|
|
* 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if
|
|
* they were in the same location. For example lets say there are two files
|
|
* '/local/src/content/file1.ts'
|
|
* '/shared/components/contracts/src/content/protocols/file2.ts'
|
|
* After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so
|
|
* if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime.
|
|
* 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all
|
|
* root dirs were merged together.
|
|
* I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ].
|
|
* Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file:
|
|
* '/local/src/content/protocols/file2' and try to load it - failure.
|
|
* Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will
|
|
* be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining
|
|
* entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location.
|
|
*/
|
|
function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) {
|
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state);
|
|
}
|
|
else {
|
|
return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state);
|
|
}
|
|
}
|
|
function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) {
|
|
if (!state.compilerOptions.rootDirs) {
|
|
return undefined;
|
|
}
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
|
|
}
|
|
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
|
|
var matchedRootDir;
|
|
var matchedNormalizedPrefix;
|
|
for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
|
|
var rootDir = _a[_i];
|
|
// rootDirs are expected to be absolute
|
|
// in case of tsconfig.json this will happen automatically - compiler will expand relative names
|
|
// using location of tsconfig.json as base location
|
|
var normalizedRoot = ts.normalizePath(rootDir);
|
|
if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
|
|
normalizedRoot += ts.directorySeparator;
|
|
}
|
|
var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
|
|
(matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
|
|
}
|
|
if (isLongestMatchingPrefix) {
|
|
matchedNormalizedPrefix = normalizedRoot;
|
|
matchedRootDir = rootDir;
|
|
}
|
|
}
|
|
if (matchedNormalizedPrefix) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
|
|
}
|
|
var suffix = candidate.substr(matchedNormalizedPrefix.length);
|
|
// first - try to load from a initial location
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
|
|
}
|
|
var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state);
|
|
if (resolvedFileName) {
|
|
return resolvedFileName;
|
|
}
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
|
|
}
|
|
// then try to resolve using remaining entries in rootDirs
|
|
for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
|
|
var rootDir = _c[_b];
|
|
if (rootDir === matchedRootDir) {
|
|
// skip the initially matched entry
|
|
continue;
|
|
}
|
|
var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
|
|
}
|
|
var baseDirectory = ts.getDirectoryPath(candidate_1);
|
|
var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state);
|
|
if (resolvedFileName_1) {
|
|
return resolvedFileName_1;
|
|
}
|
|
}
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) {
|
|
if (!state.compilerOptions.baseUrl) {
|
|
return undefined;
|
|
}
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName);
|
|
}
|
|
// string is for exact match
|
|
var matchedPattern;
|
|
if (state.compilerOptions.paths) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
|
|
}
|
|
matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName);
|
|
}
|
|
if (matchedPattern) {
|
|
var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
|
|
var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
|
|
}
|
|
return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) {
|
|
var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
|
|
var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path));
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
|
|
}
|
|
// A path mapping may have an extension, in contrast to an import, which should omit it.
|
|
var extension = ts.tryGetExtensionFromPath(candidate);
|
|
if (extension !== undefined) {
|
|
var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
|
if (path_1 !== undefined) {
|
|
return noPackageId({ path: path_1, ext: extension });
|
|
}
|
|
}
|
|
return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
|
|
});
|
|
}
|
|
else {
|
|
var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName));
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate);
|
|
}
|
|
return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
|
|
}
|
|
}
|
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) {
|
|
return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false);
|
|
}
|
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
/**
|
|
* Expose resolution logic to allow us to use Node module resolution logic from arbitrary locations.
|
|
* No way to do this with `require()`: https://github.com/nodejs/node/issues/5963
|
|
* Throws an error if the module can't be resolved.
|
|
*/
|
|
/* @internal */
|
|
function resolveJavaScriptModule(moduleName, initialDir, host) {
|
|
var _a = nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
|
|
if (!resolvedModule) {
|
|
throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
|
|
}
|
|
return resolvedModule.resolvedFileName;
|
|
}
|
|
ts.resolveJavaScriptModule = resolveJavaScriptModule;
|
|
function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) {
|
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
var failedLookupLocations = [];
|
|
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled };
|
|
var result = jsOnly ?
|
|
tryResolve(Extensions.JavaScript) :
|
|
(tryResolve(Extensions.TypeScript) ||
|
|
tryResolve(Extensions.JavaScript) ||
|
|
(compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined));
|
|
if (result && result.value) {
|
|
var _a = result.value, resolved = _a.resolved, originalPath = _a.originalPath, isExternalLibraryImport = _a.isExternalLibraryImport;
|
|
return createResolvedModuleWithFailedLookupLocations(resolved, originalPath, isExternalLibraryImport, failedLookupLocations);
|
|
}
|
|
return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
|
|
function tryResolve(extensions) {
|
|
var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state);
|
|
if (resolved) {
|
|
return toSearchResult({ resolved: resolved, isExternalLibraryImport: false });
|
|
}
|
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
|
|
}
|
|
var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache);
|
|
if (!resolved_1)
|
|
return undefined;
|
|
var resolvedValue = resolved_1.value;
|
|
var originalPath = void 0;
|
|
if (!compilerOptions.preserveSymlinks && resolvedValue) {
|
|
originalPath = resolvedValue.path;
|
|
var path = realPath(resolvedValue.path, host, traceEnabled);
|
|
if (path === originalPath) {
|
|
originalPath = undefined;
|
|
}
|
|
resolvedValue = __assign({}, resolvedValue, { path: path });
|
|
}
|
|
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
|
|
return { value: resolvedValue && { resolved: resolvedValue, originalPath: originalPath, isExternalLibraryImport: true } };
|
|
}
|
|
else {
|
|
var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
|
|
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
|
|
// Treat explicit "node_modules" import as an external library import.
|
|
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
|
|
}
|
|
}
|
|
}
|
|
function realPath(path, host, traceEnabled) {
|
|
if (!host.realpath) {
|
|
return path;
|
|
}
|
|
var real = ts.normalizePath(host.realpath(path));
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
|
|
}
|
|
ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line
|
|
return real;
|
|
}
|
|
function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
|
|
}
|
|
if (!ts.hasTrailingDirectorySeparator(candidate)) {
|
|
if (!onlyRecordFailures) {
|
|
var parentOfCandidate = ts.getDirectoryPath(candidate);
|
|
if (!directoryProbablyExists(parentOfCandidate, state.host)) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
|
|
}
|
|
onlyRecordFailures = true;
|
|
}
|
|
}
|
|
var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state);
|
|
if (resolvedFromFile) {
|
|
var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
|
|
var packageId = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, failedLookupLocations, /*onlyRecordFailures*/ false, state).packageId;
|
|
return withPackageId(packageId, resolvedFromFile);
|
|
}
|
|
}
|
|
if (!onlyRecordFailures) {
|
|
var candidateExists = directoryProbablyExists(candidate, state.host);
|
|
if (!candidateExists) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
|
|
}
|
|
onlyRecordFailures = true;
|
|
}
|
|
}
|
|
return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson);
|
|
}
|
|
var nodeModulesPathPart = "/node_modules/";
|
|
/**
|
|
* This will be called on the successfully resolved path from `loadModuleFromFile`.
|
|
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
|
|
*
|
|
* packageDirectory is the directory of the package itself.
|
|
* subModuleName is the path within the package.
|
|
* For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
|
|
* For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
|
|
* For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
|
|
* For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
|
|
*/
|
|
function parseNodeModuleFromPath(resolved) {
|
|
var path = ts.normalizePath(resolved.path);
|
|
var idx = path.lastIndexOf(nodeModulesPathPart);
|
|
if (idx === -1) {
|
|
return undefined;
|
|
}
|
|
var indexAfterNodeModules = idx + nodeModulesPathPart.length;
|
|
var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
|
|
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
|
|
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
|
|
}
|
|
var packageDirectory = path.slice(0, indexAfterPackageName);
|
|
var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
|
|
return { packageDirectory: packageDirectory, subModuleName: subModuleName };
|
|
}
|
|
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
|
|
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
|
|
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
|
|
}
|
|
function addExtensionAndIndex(path) {
|
|
if (path === "") {
|
|
return "index.d.ts";
|
|
}
|
|
if (ts.endsWith(path, ".d.ts")) {
|
|
return path;
|
|
}
|
|
if (ts.endsWith(path, "/index")) {
|
|
return path + ".d.ts";
|
|
}
|
|
return path + "/index.d.ts";
|
|
}
|
|
/* @internal */
|
|
function directoryProbablyExists(directoryName, host) {
|
|
// if host does not support 'directoryExists' assume that directory will exist
|
|
return !host.directoryExists || host.directoryExists(directoryName);
|
|
}
|
|
ts.directoryProbablyExists = directoryProbablyExists;
|
|
function loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) {
|
|
return noPackageId(loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state));
|
|
}
|
|
/**
|
|
* @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary
|
|
* in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations.
|
|
*/
|
|
function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) {
|
|
if (extensions === Extensions.Json) {
|
|
var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
|
|
return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state);
|
|
}
|
|
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
|
|
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state);
|
|
if (resolvedByAddingExtension) {
|
|
return resolvedByAddingExtension;
|
|
}
|
|
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
|
|
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
|
|
if (ts.hasJavaScriptFileExtension(candidate)) {
|
|
var extensionless = ts.removeFileExtension(candidate);
|
|
if (state.traceEnabled) {
|
|
var extension = candidate.substring(extensionless.length);
|
|
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
}
|
|
return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state);
|
|
}
|
|
}
|
|
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
|
|
function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) {
|
|
if (!onlyRecordFailures) {
|
|
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
|
var directory = ts.getDirectoryPath(candidate);
|
|
if (directory) {
|
|
onlyRecordFailures = !directoryProbablyExists(directory, state.host);
|
|
}
|
|
}
|
|
switch (extensions) {
|
|
case Extensions.DtsOnly:
|
|
return tryExtension(".d.ts" /* Dts */);
|
|
case Extensions.TypeScript:
|
|
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
case Extensions.JavaScript:
|
|
return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
|
|
case Extensions.Json:
|
|
return tryExtension(".json" /* Json */);
|
|
}
|
|
function tryExtension(ext) {
|
|
var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state);
|
|
return path === undefined ? undefined : { path: path, ext: ext };
|
|
}
|
|
}
|
|
/** Return the file if it exists. */
|
|
function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) {
|
|
if (!onlyRecordFailures) {
|
|
if (state.host.fileExists(fileName)) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
|
|
}
|
|
return fileName;
|
|
}
|
|
else {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
|
|
}
|
|
}
|
|
}
|
|
failedLookupLocations.push(fileName);
|
|
return undefined;
|
|
}
|
|
function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) {
|
|
if (considerPackageJson === void 0) { considerPackageJson = true; }
|
|
var _a = considerPackageJson
|
|
? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state)
|
|
: { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId;
|
|
return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent));
|
|
}
|
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) {
|
|
var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state);
|
|
if (fromPackageJson) {
|
|
return fromPackageJson;
|
|
}
|
|
var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
|
|
return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state);
|
|
}
|
|
function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, state) {
|
|
var host = state.host, traceEnabled = state.traceEnabled;
|
|
var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host);
|
|
var packageJsonPath = pathToPackageJson(nodeModuleDirectory);
|
|
if (directoryExists && host.fileExists(packageJsonPath)) {
|
|
var packageJsonContent = readJson(packageJsonPath, host);
|
|
if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
|
|
var path = tryReadPackageJsonFields(/*readTypes*/ true, packageJsonContent, nodeModuleDirectory, state);
|
|
if (typeof path === "string") {
|
|
subModuleName = addExtensionAndIndex(path.substring(nodeModuleDirectory.length + 1));
|
|
}
|
|
else {
|
|
var jsPath = tryReadPackageJsonFields(/*readTypes*/ false, packageJsonContent, nodeModuleDirectory, state);
|
|
if (typeof jsPath === "string" && jsPath.length > nodeModuleDirectory.length) {
|
|
var potentialSubModule_1 = jsPath.substring(nodeModuleDirectory.length + 1);
|
|
subModuleName = (ts.forEach(ts.supportedJavascriptExtensions, function (extension) {
|
|
return ts.tryRemoveExtension(potentialSubModule_1, extension);
|
|
}) || potentialSubModule_1) + ".d.ts" /* Dts */;
|
|
}
|
|
else {
|
|
subModuleName = "index.d.ts";
|
|
}
|
|
}
|
|
}
|
|
if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
|
|
subModuleName = addExtensionAndIndex(subModuleName);
|
|
}
|
|
var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
|
|
? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
|
|
: undefined;
|
|
if (traceEnabled) {
|
|
if (packageId) {
|
|
trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
|
|
}
|
|
else {
|
|
trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
}
|
|
}
|
|
return { found: true, packageJsonContent: packageJsonContent, packageId: packageId };
|
|
}
|
|
else {
|
|
if (directoryExists && traceEnabled) {
|
|
trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
}
|
|
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
|
|
failedLookupLocations.push(packageJsonPath);
|
|
return { found: false, packageJsonContent: undefined, packageId: undefined };
|
|
}
|
|
}
|
|
function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) {
|
|
var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript && extensions !== Extensions.Json, jsonContent, candidate, state);
|
|
if (!file) {
|
|
if (extensions === Extensions.TypeScript) {
|
|
// When resolving typescript modules, try resolving using main field as well
|
|
file = tryReadPackageJsonFields(/*readTypes*/ false, jsonContent, candidate, state);
|
|
if (!file) {
|
|
return undefined;
|
|
}
|
|
}
|
|
else {
|
|
return undefined;
|
|
}
|
|
}
|
|
var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host);
|
|
var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state);
|
|
if (fromFile) {
|
|
var resolved = resolvedIfExtensionMatches(extensions, fromFile);
|
|
if (resolved) {
|
|
return resolved;
|
|
}
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
|
|
}
|
|
}
|
|
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
|
|
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
|
|
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
|
|
var result = nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false);
|
|
if (result) {
|
|
// It won't have a `packageId` set, because we disabled `considerPackageJson`.
|
|
ts.Debug.assert(result.packageId === undefined);
|
|
return { path: result.path, ext: result.extension };
|
|
}
|
|
}
|
|
/** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
|
|
function resolvedIfExtensionMatches(extensions, path) {
|
|
var ext = ts.tryGetExtensionFromPath(path);
|
|
return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
|
|
}
|
|
/** True if `extension` is one of the supported `extensions`. */
|
|
function extensionIsOk(extensions, extension) {
|
|
switch (extensions) {
|
|
case Extensions.JavaScript:
|
|
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
case Extensions.Json:
|
|
return extension === ".json" /* Json */;
|
|
case Extensions.TypeScript:
|
|
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
case Extensions.DtsOnly:
|
|
return extension === ".d.ts" /* Dts */;
|
|
}
|
|
}
|
|
function pathToPackageJson(directory) {
|
|
return ts.combinePaths(directory, "package.json");
|
|
}
|
|
function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) {
|
|
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
|
|
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
|
|
var packageJsonContent;
|
|
var packageId;
|
|
var packageInfo = getPackageJsonInfo(candidate, "", failedLookupLocations, /*onlyRecordFailures*/ !nodeModulesFolderExists, state);
|
|
if (packageInfo.found) {
|
|
(packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId);
|
|
}
|
|
else {
|
|
var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName);
|
|
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId.
|
|
packageId = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state).packageId;
|
|
}
|
|
}
|
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) ||
|
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent);
|
|
return withPackageId(packageId, pathAndExtension);
|
|
}
|
|
/* @internal */
|
|
function getPackageName(moduleName) {
|
|
var idx = moduleName.indexOf(ts.directorySeparator);
|
|
if (moduleName[0] === "@") {
|
|
idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
|
|
}
|
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
}
|
|
ts.getPackageName = getPackageName;
|
|
function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) {
|
|
return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache);
|
|
}
|
|
function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) {
|
|
// Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly.
|
|
return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined);
|
|
}
|
|
function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) {
|
|
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName);
|
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host, failedLookupLocations);
|
|
if (resolutionFromCache) {
|
|
return resolutionFromCache;
|
|
}
|
|
return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly));
|
|
}
|
|
});
|
|
}
|
|
/** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */
|
|
function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) {
|
|
if (typesOnly === void 0) { typesOnly = false; }
|
|
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
|
|
var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
|
|
if (!nodeModulesFolderExists && state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
|
|
}
|
|
var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state);
|
|
if (packageResult) {
|
|
return packageResult;
|
|
}
|
|
if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) {
|
|
var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
|
|
var nodeModulesAtTypesExists = nodeModulesFolderExists;
|
|
if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
|
|
if (state.traceEnabled) {
|
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
|
|
}
|
|
nodeModulesAtTypesExists = false;
|
|
}
|
|
return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state);
|
|
}
|
|
}
|
|
/** Double underscores are used in DefinitelyTyped to delimit scoped packages. */
|
|
var mangledScopedPackageSeparator = "__";
|
|
/** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */
|
|
function mangleScopedPackage(packageName, state) {
|
|
var mangled = getMangledNameForScopedPackage(packageName);
|
|
if (state.traceEnabled && mangled !== packageName) {
|
|
trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
|
|
}
|
|
return mangled;
|
|
}
|
|
/* @internal */
|
|
function getTypesPackageName(packageName) {
|
|
return "@types/" + getMangledNameForScopedPackage(packageName);
|
|
}
|
|
ts.getTypesPackageName = getTypesPackageName;
|
|
/* @internal */
|
|
function getMangledNameForScopedPackage(packageName) {
|
|
if (ts.startsWith(packageName, "@")) {
|
|
var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
|
|
if (replaceSlash !== packageName) {
|
|
return replaceSlash.slice(1); // Take off the "@"
|
|
}
|
|
}
|
|
return packageName;
|
|
}
|
|
ts.getMangledNameForScopedPackage = getMangledNameForScopedPackage;
|
|
/* @internal */
|
|
function getPackageNameFromAtTypesDirectory(mangledName) {
|
|
var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
|
|
if (withoutAtTypePrefix !== mangledName) {
|
|
return getUnmangledNameForScopedPackage(withoutAtTypePrefix);
|
|
}
|
|
return mangledName;
|
|
}
|
|
ts.getPackageNameFromAtTypesDirectory = getPackageNameFromAtTypesDirectory;
|
|
/* @internal */
|
|
function getUnmangledNameForScopedPackage(typesPackageName) {
|
|
return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
|
|
"@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
|
|
typesPackageName;
|
|
}
|
|
ts.getUnmangledNameForScopedPackage = getUnmangledNameForScopedPackage;
|
|
function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host, failedLookupLocations) {
|
|
var result = cache && cache.get(containingDirectory);
|
|
if (result) {
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
}
|
|
failedLookupLocations.push.apply(failedLookupLocations, result.failedLookupLocations);
|
|
return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
|
|
}
|
|
}
|
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) {
|
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled };
|
|
var failedLookupLocations = [];
|
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*originalPath*/ undefined, /*isExternalLibraryImport*/ false, failedLookupLocations);
|
|
function tryResolve(extensions) {
|
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, failedLookupLocations, state);
|
|
if (resolvedUsingSettings) {
|
|
return { value: resolvedUsingSettings };
|
|
}
|
|
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName);
|
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
// Climb up parent directories looking for a module.
|
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host, failedLookupLocations);
|
|
if (resolutionFromCache) {
|
|
return resolutionFromCache;
|
|
}
|
|
var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
|
|
return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state));
|
|
});
|
|
if (resolved_3) {
|
|
return resolved_3;
|
|
}
|
|
if (extensions === Extensions.TypeScript) {
|
|
// If we didn't find the file normally, look it up in @types.
|
|
return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state);
|
|
}
|
|
}
|
|
else {
|
|
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
|
|
return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state));
|
|
}
|
|
}
|
|
}
|
|
ts.classicNameResolver = classicNameResolver;
|
|
/**
|
|
* LSHost may load a module from a global cache of typings.
|
|
* This is the minumum code needed to expose that functionality; the rest is in LSHost.
|
|
*/
|
|
/* @internal */
|
|
function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
|
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
if (traceEnabled) {
|
|
trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
|
|
}
|
|
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled };
|
|
var failedLookupLocations = [];
|
|
var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state);
|
|
return createResolvedModuleWithFailedLookupLocations(resolved, /*originalPath*/ undefined, /*isExternalLibraryImport*/ true, failedLookupLocations);
|
|
}
|
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
/**
|
|
* Wraps value to SearchResult.
|
|
* @returns undefined if value is undefined or { value } otherwise
|
|
*/
|
|
function toSearchResult(value) {
|
|
return value !== undefined ? { value: value } : undefined;
|
|
}
|
|
})(ts || (ts = {}));
|
|
//# sourceMappingURL=parser.js.map
|
|
"use strict";
|
|
var ts;
|
|
(function (ts) {
|
|
var server;
|
|
(function (server) {
|
|
// tslint:disable variable-name
|
|
server.ActionSet = "action::set";
|
|
server.ActionInvalidate = "action::invalidate";
|
|
server.ActionPackageInstalled = "action::packageInstalled";
|
|
server.EventTypesRegistry = "event::typesRegistry";
|
|
server.EventBeginInstallTypes = "event::beginInstallTypes";
|
|
server.EventEndInstallTypes = "event::endInstallTypes";
|
|
server.EventInitializationFailed = "event::initializationFailed";
|
|
var Arguments;
|
|
(function (Arguments) {
|
|
Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation";
|
|
Arguments.LogFile = "--logFile";
|
|
Arguments.EnableTelemetry = "--enableTelemetry";
|
|
Arguments.TypingSafeListLocation = "--typingSafeListLocation";
|
|
Arguments.TypesMapLocation = "--typesMapLocation";
|
|
/**
|
|
* This argument specifies the location of the NPM executable.
|
|
* typingsInstaller will run the command with `${npmLocation} install ...`.
|
|
*/
|
|
Arguments.NpmLocation = "--npmLocation";
|
|
})(Arguments = server.Arguments || (server.Arguments = {}));
|
|
function hasArgument(argumentName) {
|
|
return ts.sys.args.indexOf(argumentName) >= 0;
|
|
}
|
|
server.hasArgument = hasArgument;
|
|
function findArgument(argumentName) {
|
|
var index = ts.sys.args.indexOf(argumentName);
|
|
return index >= 0 && index < ts.sys.args.length - 1
|
|
? ts.sys.args[index + 1]
|
|
: undefined;
|
|
}
|
|
server.findArgument = findArgument;
|
|
/*@internal*/
|
|
function nowString() {
|
|
// E.g. "12:34:56.789"
|
|
var d = new Date();
|
|
return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
|
|
}
|
|
server.nowString = nowString;
|
|
})(server = ts.server || (ts.server = {}));
|
|
})(ts || (ts = {}));
|
|
/* @internal */
|
|
var ts;
|
|
(function (ts) {
|
|
var JsTyping;
|
|
(function (JsTyping) {
|
|
/* @internal */
|
|
function isTypingUpToDate(cachedTyping, availableTypingVersions) {
|
|
var availableVersion = ts.Semver.parse(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest"));
|
|
return !availableVersion.greaterThan(cachedTyping.version);
|
|
}
|
|
JsTyping.isTypingUpToDate = isTypingUpToDate;
|
|
/* @internal */
|
|
JsTyping.nodeCoreModuleList = [
|
|
"assert",
|
|
"async_hooks",
|
|
"buffer",
|
|
"child_process",
|
|
"cluster",
|
|
"console",
|
|
"constants",
|
|
"crypto",
|
|
"dgram",
|
|
"dns",
|
|
"domain",
|
|
"events",
|
|
"fs",
|
|
"http",
|
|
"https",
|
|
"http2",
|
|
"inspector",
|
|
"net",
|
|
"os",
|
|
"path",
|
|
"perf_hooks",
|
|
"process",
|
|
"punycode",
|
|
"querystring",
|
|
"readline",
|
|
"repl",
|
|
"stream",
|
|
"string_decoder",
|
|
"timers",
|
|
"tls",
|
|
"tty",
|
|
"url",
|
|
"util",
|
|
"v8",
|
|
"vm",
|
|
"zlib"
|
|
];
|
|
/* @internal */
|
|
JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList);
|
|
function loadSafeList(host, safeListPath) {
|
|
var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); });
|
|
return ts.createMapFromTemplate(result.config);
|
|
}
|
|
JsTyping.loadSafeList = loadSafeList;
|
|
function loadTypesMap(host, typesMapPath) {
|
|
var result = ts.readConfigFile(typesMapPath, function (path) { return host.readFile(path); });
|
|
if (result.config) {
|
|
return ts.createMapFromTemplate(result.config.simpleMap);
|
|
}
|
|
return undefined;
|
|
}
|
|
JsTyping.loadTypesMap = loadTypesMap;
|
|
/**
|
|
* @param host is the object providing I/O related operations.
|
|
* @param fileNames are the file names that belong to the same project
|
|
* @param projectRootPath is the path to the project root directory
|
|
* @param safeListPath is the path used to retrieve the safe list
|
|
* @param packageNameToTypingLocation is the map of package names to their cached typing locations and installed versions
|
|
* @param typeAcquisition is used to customize the typing acquisition process
|
|
* @param compilerOptions are used as a source for typing inference
|
|
*/
|
|
function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
|
|
if (!typeAcquisition || !typeAcquisition.enable) {
|
|
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
|
}
|
|
// A typing name to typing file path mapping
|
|
var inferredTypings = ts.createMap();
|
|
// Only infer typings for .js and .jsx files
|
|
fileNames = ts.mapDefined(fileNames, function (fileName) {
|
|
var path = ts.normalizePath(fileName);
|
|
if (ts.hasJavaScriptFileExtension(path)) {
|
|
return path;
|
|
}
|
|
});
|
|
var filesToWatch = [];
|
|
if (typeAcquisition.include)
|
|
addInferredTypings(typeAcquisition.include, "Explicitly included types");
|
|
var exclude = typeAcquisition.exclude || [];
|
|
// Directories to search for package.json, bower.json and other typing information
|
|
var possibleSearchDirs = ts.arrayToSet(fileNames, ts.getDirectoryPath);
|
|
possibleSearchDirs.set(projectRootPath, true);
|
|
possibleSearchDirs.forEach(function (_true, searchDir) {
|
|
var packageJsonPath = ts.combinePaths(searchDir, "package.json");
|
|
getTypingNamesFromJson(packageJsonPath, filesToWatch);
|
|
var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
|
|
getTypingNamesFromJson(bowerJsonPath, filesToWatch);
|
|
var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
|
|
getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
|
|
var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
|
|
getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
|
|
});
|
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
// add typings for unresolved imports
|
|
if (unresolvedImports) {
|
|
var module_1 = ts.deduplicate(unresolvedImports.map(function (moduleId) { return JsTyping.nodeCoreModules.has(moduleId) ? "node" : moduleId; }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
|
|
addInferredTypings(module_1, "Inferred typings from unresolved imports");
|
|
}
|
|
// Add the cached typing locations for inferred typings that are already installed
|
|
packageNameToTypingLocation.forEach(function (typing, name) {
|
|
var registryEntry = typesRegistry.get(name);
|
|
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) {
|
|
inferredTypings.set(name, typing.typingLocation);
|
|
}
|
|
});
|
|
// Remove typings that the user has added to the exclude list
|
|
for (var _i = 0, exclude_1 = exclude; _i < exclude_1.length; _i++) {
|
|
var excludeTypingName = exclude_1[_i];
|
|
var didDelete = inferredTypings.delete(excludeTypingName);
|
|
if (didDelete && log)
|
|
log("Typing for " + excludeTypingName + " is in exclude list, will be ignored.");
|
|
}
|
|
var newTypingNames = [];
|
|
var cachedTypingPaths = [];
|
|
inferredTypings.forEach(function (inferred, typing) {
|
|
if (inferred !== undefined) {
|
|
cachedTypingPaths.push(inferred);
|
|
}
|
|
else {
|
|
newTypingNames.push(typing);
|
|
}
|
|
});
|
|
var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch };
|
|
if (log)
|
|
log("Result: " + JSON.stringify(result));
|
|
return result;
|
|
function addInferredTyping(typingName) {
|
|
if (!inferredTypings.has(typingName)) {
|
|
inferredTypings.set(typingName, undefined); // TODO: GH#18217
|
|
}
|
|
}
|
|
function addInferredTypings(typingNames, message) {
|
|
if (log)
|
|
log(message + ": " + JSON.stringify(typingNames));
|
|
ts.forEach(typingNames, addInferredTyping);
|
|
}
|
|
/**
|
|
* Get the typing info from common package manager json files like package.json or bower.json
|
|
*/
|
|
function getTypingNamesFromJson(jsonPath, filesToWatch) {
|
|
if (!host.fileExists(jsonPath)) {
|
|
return;
|
|
}
|
|
filesToWatch.push(jsonPath);
|
|
var jsonConfig = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }).config;
|
|
var jsonTypingNames = ts.flatMap([jsonConfig.dependencies, jsonConfig.devDependencies, jsonConfig.optionalDependencies, jsonConfig.peerDependencies], ts.getOwnKeys);
|
|
addInferredTypings(jsonTypingNames, "Typing names in '" + jsonPath + "' dependencies");
|
|
}
|
|
/**
|
|
* Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
|
|
* should be inferred to the 'jquery' typing name; and "angular-route.1.2.3.js" should be inferred
|
|
* to the 'angular-route' typing name.
|
|
* @param fileNames are the names for source files in the project
|
|
*/
|
|
function getTypingNamesFromSourceFileNames(fileNames) {
|
|
var fromFileNames = ts.mapDefined(fileNames, function (j) {
|
|
if (!ts.hasJavaScriptFileExtension(j))
|
|
return undefined;
|
|
var inferredTypingName = ts.removeFileExtension(ts.getBaseFileName(j.toLowerCase()));
|
|
var cleanedTypingName = ts.removeMinAndVersionNumbers(inferredTypingName);
|
|
return safeList.get(cleanedTypingName);
|
|
});
|
|
if (fromFileNames.length) {
|
|
addInferredTypings(fromFileNames, "Inferred typings from file names");
|
|
}
|
|
var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); });
|
|
if (hasJsxFile) {
|
|
if (log)
|
|
log("Inferred 'react' typings due to presence of '.jsx' extension");
|
|
addInferredTyping("react");
|
|
}
|
|
}
|
|
/**
|
|
* Infer typing names from packages folder (ex: node_module, bower_components)
|
|
* @param packagesFolderPath is the path to the packages folder
|
|
*/
|
|
function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
|
|
filesToWatch.push(packagesFolderPath);
|
|
// Todo: add support for ModuleResolutionHost too
|
|
if (!host.directoryExists(packagesFolderPath)) {
|
|
return;
|
|
}
|
|
// depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
|
|
var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
|
|
if (log)
|
|
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
|
|
var packageNames = [];
|
|
for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
|
|
var fileName = fileNames_1[_i];
|
|
var normalizedFileName = ts.normalizePath(fileName);
|
|
var baseFileName = ts.getBaseFileName(normalizedFileName);
|
|
if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
|
|
continue;
|
|
}
|
|
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
var packageJson = result_1.config;
|
|
// npm 3's package.json contains a "_requiredBy" field
|
|
// we should include all the top level module names for npm 2, and only module names whose
|
|
// "_requiredBy" field starts with "#" or equals "/" for npm 3.
|
|
if (baseFileName === "package.json" && packageJson._requiredBy &&
|
|
ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
|
|
continue;
|
|
}
|
|
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
// to download d.ts files from DefinitelyTyped
|
|
if (!packageJson.name) {
|
|
continue;
|
|
}
|
|
var ownTypes = packageJson.types || packageJson.typings;
|
|
if (ownTypes) {
|
|
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
if (log)
|
|
log(" Package '" + packageJson.name + "' provides its own types.");
|
|
inferredTypings.set(packageJson.name, absolutePath);
|
|
}
|
|
else {
|
|
packageNames.push(packageJson.name);
|
|
}
|
|
}
|
|
addInferredTypings(packageNames, " Found package names");
|
|
}
|
|
}
|
|
JsTyping.discoverTypings = discoverTypings;
|
|
var PackageNameValidationResult;
|
|
(function (PackageNameValidationResult) {
|
|
PackageNameValidationResult[PackageNameValidationResult["Ok"] = 0] = "Ok";
|
|
PackageNameValidationResult[PackageNameValidationResult["ScopedPackagesNotSupported"] = 1] = "ScopedPackagesNotSupported";
|
|
PackageNameValidationResult[PackageNameValidationResult["EmptyName"] = 2] = "EmptyName";
|
|
PackageNameValidationResult[PackageNameValidationResult["NameTooLong"] = 3] = "NameTooLong";
|
|
PackageNameValidationResult[PackageNameValidationResult["NameStartsWithDot"] = 4] = "NameStartsWithDot";
|
|
PackageNameValidationResult[PackageNameValidationResult["NameStartsWithUnderscore"] = 5] = "NameStartsWithUnderscore";
|
|
PackageNameValidationResult[PackageNameValidationResult["NameContainsNonURISafeCharacters"] = 6] = "NameContainsNonURISafeCharacters";
|
|
})(PackageNameValidationResult = JsTyping.PackageNameValidationResult || (JsTyping.PackageNameValidationResult = {}));
|
|
var maxPackageNameLength = 214;
|
|
/**
|
|
* Validates package name using rules defined at https://docs.npmjs.com/files/package.json
|
|
*/
|
|
function validatePackageName(packageName) {
|
|
if (!packageName) {
|
|
return 2 /* EmptyName */;
|
|
}
|
|
if (packageName.length > maxPackageNameLength) {
|
|
return 3 /* NameTooLong */;
|
|
}
|
|
if (packageName.charCodeAt(0) === 46 /* dot */) {
|
|
return 4 /* NameStartsWithDot */;
|
|
}
|
|
if (packageName.charCodeAt(0) === 95 /* _ */) {
|
|
return 5 /* NameStartsWithUnderscore */;
|
|
}
|
|
// check if name is scope package like: starts with @ and has one '/' in the middle
|
|
// scoped packages are not currently supported
|
|
// TODO: when support will be added we'll need to split and check both scope and package name
|
|
if (/^@[^/]+\/[^/]+$/.test(packageName)) {
|
|
return 1 /* ScopedPackagesNotSupported */;
|
|
}
|
|
if (encodeURIComponent(packageName) !== packageName) {
|
|
return 6 /* NameContainsNonURISafeCharacters */;
|
|
}
|
|
return 0 /* Ok */;
|
|
}
|
|
JsTyping.validatePackageName = validatePackageName;
|
|
function renderPackageNameValidationFailure(result, typing) {
|
|
switch (result) {
|
|
case 2 /* EmptyName */:
|
|
return "Package name '" + typing + "' cannot be empty";
|
|
case 3 /* NameTooLong */:
|
|
return "Package name '" + typing + "' should be less than " + maxPackageNameLength + " characters";
|
|
case 4 /* NameStartsWithDot */:
|
|
return "Package name '" + typing + "' cannot start with '.'";
|
|
case 5 /* NameStartsWithUnderscore */:
|
|
return "Package name '" + typing + "' cannot start with '_'";
|
|
case 1 /* ScopedPackagesNotSupported */:
|
|
return "Package '" + typing + "' is scoped and currently is not supported";
|
|
case 6 /* NameContainsNonURISafeCharacters */:
|
|
return "Package name '" + typing + "' contains non URI safe characters";
|
|
case 0 /* Ok */:
|
|
return ts.Debug.fail(); // Shouldn't have called this.
|
|
default:
|
|
throw ts.Debug.assertNever(result);
|
|
}
|
|
}
|
|
JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure;
|
|
})(JsTyping = ts.JsTyping || (ts.JsTyping = {}));
|
|
})(ts || (ts = {}));
|
|
/* @internal */
|
|
var ts;
|
|
(function (ts) {
|
|
function stringToInt(str) {
|
|
var n = parseInt(str, 10);
|
|
if (isNaN(n)) {
|
|
throw new Error("Error in parseInt(" + JSON.stringify(str) + ")");
|
|
}
|
|
return n;
|
|
}
|
|
var isPrereleaseRegex = /^(.*)-next.\d+/;
|
|
var prereleaseSemverRegex = /^(\d+)\.(\d+)\.0-next.(\d+)$/;
|
|
var semverRegex = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
var Semver = /** @class */ (function () {
|
|
function Semver(major, minor, patch,
|
|
/**
|
|
* If true, this is `major.minor.0-next.patch`.
|
|
* If false, this is `major.minor.patch`.
|
|
*/
|
|
isPrerelease) {
|
|
this.major = major;
|
|
this.minor = minor;
|
|
this.patch = patch;
|
|
this.isPrerelease = isPrerelease;
|
|
}
|
|
Semver.parse = function (semver) {
|
|
var isPrerelease = isPrereleaseRegex.test(semver);
|
|
var result = Semver.tryParse(semver, isPrerelease);
|
|
if (!result) {
|
|
throw new Error("Unexpected semver: " + semver + " (isPrerelease: " + isPrerelease + ")");
|
|
}
|
|
return result;
|
|
};
|
|
Semver.fromRaw = function (_a) {
|
|
var major = _a.major, minor = _a.minor, patch = _a.patch, isPrerelease = _a.isPrerelease;
|
|
return new Semver(major, minor, patch, isPrerelease);
|
|
};
|
|
// This must parse the output of `versionString`.
|
|
Semver.tryParse = function (semver, isPrerelease) {
|
|
// Per the semver spec <http://semver.org/#spec-item-2>:
|
|
// "A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes."
|
|
var rgx = isPrerelease ? prereleaseSemverRegex : semverRegex;
|
|
var match = rgx.exec(semver);
|
|
return match ? new Semver(stringToInt(match[1]), stringToInt(match[2]), stringToInt(match[3]), isPrerelease) : undefined;
|
|
};
|
|
Object.defineProperty(Semver.prototype, "versionString", {
|
|
get: function () {
|
|
return this.isPrerelease ? this.major + "." + this.minor + ".0-next." + this.patch : this.major + "." + this.minor + "." + this.patch;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Semver.prototype.equals = function (sem) {
|
|
return this.major === sem.major && this.minor === sem.minor && this.patch === sem.patch && this.isPrerelease === sem.isPrerelease;
|
|
};
|
|
Semver.prototype.greaterThan = function (sem) {
|
|
return this.major > sem.major || this.major === sem.major
|
|
&& (this.minor > sem.minor || this.minor === sem.minor
|
|
&& (!this.isPrerelease && sem.isPrerelease || this.isPrerelease === sem.isPrerelease
|
|
&& this.patch > sem.patch));
|
|
};
|
|
return Semver;
|
|
}());
|
|
ts.Semver = Semver;
|
|
})(ts || (ts = {}));
|
|
//# sourceMappingURL=jsTyping.js.map
|
|
"use strict";
|
|
var ts;
|
|
(function (ts) {
|
|
var server;
|
|
(function (server) {
|
|
var typingsInstaller;
|
|
(function (typingsInstaller) {
|
|
var nullLog = {
|
|
isEnabled: function () { return false; },
|
|
writeLine: ts.noop
|
|
};
|
|
function typingToFileName(cachePath, packageName, installTypingHost, log) {
|
|
try {
|
|
var result = ts.resolveModuleName(packageName, ts.combinePaths(cachePath, "index.d.ts"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, installTypingHost);
|
|
return result.resolvedModule && result.resolvedModule.resolvedFileName;
|
|
}
|
|
catch (e) {
|
|
if (log.isEnabled()) {
|
|
log.writeLine("Failed to resolve " + packageName + " in folder '" + cachePath + "': " + e.message);
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|
|
/*@internal*/
|
|
function installNpmPackages(npmPath, tsVersion, packageNames, install) {
|
|
var hasError = false;
|
|
for (var remaining = packageNames.length; remaining > 0;) {
|
|
var result = getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining);
|
|
remaining = result.remaining;
|
|
hasError = install(result.command) || hasError;
|
|
}
|
|
return hasError;
|
|
}
|
|
typingsInstaller.installNpmPackages = installNpmPackages;
|
|
/*@internal*/
|
|
function getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining) {
|
|
var sliceStart = packageNames.length - remaining;
|
|
var command, toSlice = remaining;
|
|
while (true) {
|
|
command = npmPath + " install --ignore-scripts " + (toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ") + " --save-dev --user-agent=\"typesInstaller/" + tsVersion + "\"";
|
|
if (command.length < 8000) {
|
|
break;
|
|
}
|
|
toSlice = toSlice - Math.floor(toSlice / 2);
|
|
}
|
|
return { command: command, remaining: remaining - toSlice };
|
|
}
|
|
typingsInstaller.getNpmCommandForInstallation = getNpmCommandForInstallation;
|
|
function isPackageOrBowerJson(fileName) {
|
|
var base = ts.getBaseFileName(fileName);
|
|
return base === "package.json" || base === "bower.json";
|
|
}
|
|
function getDirectoryExcludingNodeModulesOrBowerComponents(f) {
|
|
var indexOfNodeModules = f.indexOf("/node_modules/");
|
|
var indexOfBowerComponents = f.indexOf("/bower_components/");
|
|
var subStrLength = indexOfNodeModules === -1 || indexOfBowerComponents === -1 ?
|
|
Math.max(indexOfNodeModules, indexOfBowerComponents) :
|
|
Math.min(indexOfNodeModules, indexOfBowerComponents);
|
|
return subStrLength === -1 ? f : f.substr(0, subStrLength);
|
|
}
|
|
var TypingsInstaller = /** @class */ (function () {
|
|
function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit, log) {
|
|
if (log === void 0) { log = nullLog; }
|
|
this.installTypingHost = installTypingHost;
|
|
this.globalCachePath = globalCachePath;
|
|
this.safeListPath = safeListPath;
|
|
this.typesMapLocation = typesMapLocation;
|
|
this.throttleLimit = throttleLimit;
|
|
this.log = log;
|
|
this.packageNameToTypingLocation = ts.createMap();
|
|
this.missingTypingsSet = ts.createMap();
|
|
this.knownCachesSet = ts.createMap();
|
|
this.projectWatchers = ts.createMap();
|
|
this.pendingRunRequests = [];
|
|
this.installRunCount = 1;
|
|
this.inFlightRequestCount = 0;
|
|
this.latestDistTag = "latest";
|
|
this.toCanonicalFileName = ts.createGetCanonicalFileName(installTypingHost.useCaseSensitiveFileNames);
|
|
this.globalCacheCanonicalPackageJsonPath = ts.combinePaths(this.toCanonicalFileName(globalCachePath), "package.json");
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "', types map path " + typesMapLocation);
|
|
}
|
|
this.processCacheLocation(this.globalCachePath);
|
|
}
|
|
TypingsInstaller.prototype.closeProject = function (req) {
|
|
this.closeWatchers(req.projectName);
|
|
};
|
|
TypingsInstaller.prototype.closeWatchers = function (projectName) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Closing file watchers for project '" + projectName + "'");
|
|
}
|
|
var watchers = this.projectWatchers.get(projectName);
|
|
if (!watchers) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("No watchers are registered for project '" + projectName + "'");
|
|
}
|
|
return;
|
|
}
|
|
ts.clearMap(watchers, ts.closeFileWatcher);
|
|
this.projectWatchers.delete(projectName);
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Closing file watchers for project '" + projectName + "' - done.");
|
|
}
|
|
};
|
|
TypingsInstaller.prototype.install = function (req) {
|
|
var _this = this;
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Got install request " + JSON.stringify(req));
|
|
}
|
|
// load existing typing information from the cache
|
|
if (req.cachePath) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Request specifies cache path '" + req.cachePath + "', loading cached information...");
|
|
}
|
|
this.processCacheLocation(req.cachePath);
|
|
}
|
|
if (this.safeList === undefined) {
|
|
this.initializeSafeList();
|
|
}
|
|
var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry);
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult));
|
|
}
|
|
// start watching files
|
|
this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch, req.projectRootPath);
|
|
// install typings
|
|
if (discoverTypingsResult.newTypingNames.length) {
|
|
this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames);
|
|
}
|
|
else {
|
|
this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths));
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("No new typings were requested as a result of typings discovery");
|
|
}
|
|
}
|
|
};
|
|
TypingsInstaller.prototype.initializeSafeList = function () {
|
|
// Prefer the safe list from the types map if it exists
|
|
if (this.typesMapLocation) {
|
|
var safeListFromMap = ts.JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation);
|
|
if (safeListFromMap) {
|
|
this.log.writeLine("Loaded safelist from types map file '" + this.typesMapLocation + "'");
|
|
this.safeList = safeListFromMap;
|
|
return;
|
|
}
|
|
this.log.writeLine("Failed to load safelist from types map file '" + this.typesMapLocation + "'");
|
|
}
|
|
this.safeList = ts.JsTyping.loadSafeList(this.installTypingHost, this.safeListPath);
|
|
};
|
|
TypingsInstaller.prototype.processCacheLocation = function (cacheLocation) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Processing cache location '" + cacheLocation + "'");
|
|
}
|
|
if (this.knownCachesSet.has(cacheLocation)) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Cache location was already processed...");
|
|
}
|
|
return;
|
|
}
|
|
var packageJson = ts.combinePaths(cacheLocation, "package.json");
|
|
var packageLockJson = ts.combinePaths(cacheLocation, "package-lock.json");
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Trying to find '" + packageJson + "'...");
|
|
}
|
|
if (this.installTypingHost.fileExists(packageJson) && this.installTypingHost.fileExists(packageLockJson)) {
|
|
var npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); // TODO: GH#18217
|
|
var npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); // TODO: GH#18217
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Loaded content of '" + packageJson + "': " + JSON.stringify(npmConfig));
|
|
this.log.writeLine("Loaded content of '" + packageLockJson + "'");
|
|
}
|
|
if (npmConfig.devDependencies && npmLock.dependencies) {
|
|
for (var key in npmConfig.devDependencies) {
|
|
if (!ts.hasProperty(npmLock.dependencies, key)) {
|
|
// if package in package.json but not package-lock.json, skip adding to cache so it is reinstalled on next use
|
|
continue;
|
|
}
|
|
// key is @types/<package name>
|
|
var packageName = ts.getBaseFileName(key);
|
|
if (!packageName) {
|
|
continue;
|
|
}
|
|
var typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log);
|
|
if (!typingFile) {
|
|
this.missingTypingsSet.set(packageName, true);
|
|
continue;
|
|
}
|
|
var existingTypingFile = this.packageNameToTypingLocation.get(packageName);
|
|
if (existingTypingFile) {
|
|
if (existingTypingFile.typingLocation === typingFile) {
|
|
continue;
|
|
}
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("New typing for package " + packageName + " from '" + typingFile + "' conflicts with existing typing file '" + existingTypingFile + "'");
|
|
}
|
|
}
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Adding entry into typings cache: '" + packageName + "' => '" + typingFile + "'");
|
|
}
|
|
var info = ts.getProperty(npmLock.dependencies, key);
|
|
var version_1 = info && info.version;
|
|
var semver = ts.Semver.parse(version_1); // TODO: GH#18217
|
|
var newTyping = { typingLocation: typingFile, version: semver };
|
|
this.packageNameToTypingLocation.set(packageName, newTyping);
|
|
}
|
|
}
|
|
}
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Finished processing cache location '" + cacheLocation + "'");
|
|
}
|
|
this.knownCachesSet.set(cacheLocation, true);
|
|
};
|
|
TypingsInstaller.prototype.filterTypings = function (typingsToInstall) {
|
|
var _this = this;
|
|
return typingsToInstall.filter(function (typing) {
|
|
if (_this.missingTypingsSet.get(typing)) {
|
|
if (_this.log.isEnabled())
|
|
_this.log.writeLine("'" + typing + "' is in missingTypingsSet - skipping...");
|
|
return false;
|
|
}
|
|
var validationResult = ts.JsTyping.validatePackageName(typing);
|
|
if (validationResult !== 0 /* Ok */) {
|
|
// add typing name to missing set so we won't process it again
|
|
_this.missingTypingsSet.set(typing, true);
|
|
if (_this.log.isEnabled())
|
|
_this.log.writeLine(ts.JsTyping.renderPackageNameValidationFailure(validationResult, typing));
|
|
return false;
|
|
}
|
|
if (!_this.typesRegistry.has(typing)) {
|
|
if (_this.log.isEnabled())
|
|
_this.log.writeLine("Entry for package '" + typing + "' does not exist in local types registry - skipping...");
|
|
return false;
|
|
}
|
|
if (_this.packageNameToTypingLocation.get(typing) && ts.JsTyping.isTypingUpToDate(_this.packageNameToTypingLocation.get(typing), _this.typesRegistry.get(typing))) {
|
|
if (_this.log.isEnabled())
|
|
_this.log.writeLine("'" + typing + "' already has an up-to-date typing - skipping...");
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
};
|
|
TypingsInstaller.prototype.ensurePackageDirectoryExists = function (directory) {
|
|
var npmConfigPath = ts.combinePaths(directory, "package.json");
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Npm config file: " + npmConfigPath);
|
|
}
|
|
if (!this.installTypingHost.fileExists(npmConfigPath)) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Npm config file: '" + npmConfigPath + "' is missing, creating new one...");
|
|
}
|
|
this.ensureDirectoryExists(directory, this.installTypingHost);
|
|
this.installTypingHost.writeFile(npmConfigPath, '{ "private": true }');
|
|
}
|
|
};
|
|
TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) {
|
|
var _this = this;
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall));
|
|
}
|
|
var filteredTypings = this.filterTypings(typingsToInstall);
|
|
if (filteredTypings.length === 0) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("All typings are known to be missing or invalid - no need to install more typings");
|
|
}
|
|
this.sendResponse(this.createSetTypings(req, currentlyCachedTypings));
|
|
return;
|
|
}
|
|
this.ensurePackageDirectoryExists(cachePath);
|
|
var requestId = this.installRunCount;
|
|
this.installRunCount++;
|
|
// send progress event
|
|
this.sendResponse({
|
|
kind: server.EventBeginInstallTypes,
|
|
eventId: requestId,
|
|
typingsInstallerVersion: ts.version,
|
|
projectName: req.projectName
|
|
});
|
|
var scopedTypings = filteredTypings.map(typingsName);
|
|
this.installTypingsAsync(requestId, scopedTypings, cachePath, function (ok) {
|
|
try {
|
|
if (!ok) {
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: " + JSON.stringify(filteredTypings));
|
|
}
|
|
for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) {
|
|
var typing = filteredTypings_1[_i];
|
|
_this.missingTypingsSet.set(typing, true);
|
|
}
|
|
return;
|
|
}
|
|
// TODO: watch project directory
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Installed typings " + JSON.stringify(scopedTypings));
|
|
}
|
|
var installedTypingFiles = [];
|
|
for (var _a = 0, filteredTypings_2 = filteredTypings; _a < filteredTypings_2.length; _a++) {
|
|
var packageName = filteredTypings_2[_a];
|
|
var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost, _this.log);
|
|
if (!typingFile) {
|
|
_this.missingTypingsSet.set(packageName, true);
|
|
continue;
|
|
}
|
|
// packageName is guaranteed to exist in typesRegistry by filterTypings
|
|
var distTags = _this.typesRegistry.get(packageName);
|
|
var newVersion = ts.Semver.parse(distTags["ts" + ts.versionMajorMinor] || distTags[_this.latestDistTag]);
|
|
var newTyping = { typingLocation: typingFile, version: newVersion };
|
|
_this.packageNameToTypingLocation.set(packageName, newTyping);
|
|
installedTypingFiles.push(typingFile);
|
|
}
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Installed typing files " + JSON.stringify(installedTypingFiles));
|
|
}
|
|
_this.sendResponse(_this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles)));
|
|
}
|
|
finally {
|
|
var response = {
|
|
kind: server.EventEndInstallTypes,
|
|
eventId: requestId,
|
|
projectName: req.projectName,
|
|
packagesToInstall: scopedTypings,
|
|
installSuccess: ok,
|
|
typingsInstallerVersion: ts.version // tslint:disable-line no-unnecessary-qualifier (qualified explicitly to prevent occasional shadowing)
|
|
};
|
|
_this.sendResponse(response);
|
|
}
|
|
});
|
|
};
|
|
TypingsInstaller.prototype.ensureDirectoryExists = function (directory, host) {
|
|
var directoryName = ts.getDirectoryPath(directory);
|
|
if (!host.directoryExists(directoryName)) {
|
|
this.ensureDirectoryExists(directoryName, host);
|
|
}
|
|
if (!host.directoryExists(directory)) {
|
|
host.createDirectory(directory);
|
|
}
|
|
};
|
|
TypingsInstaller.prototype.watchFiles = function (projectName, files, projectRootPath) {
|
|
var _this = this;
|
|
if (!files.length) {
|
|
// shut down existing watchers
|
|
this.closeWatchers(projectName);
|
|
return;
|
|
}
|
|
var watchers = this.projectWatchers.get(projectName);
|
|
var toRemove = ts.createMap();
|
|
if (!watchers) {
|
|
watchers = ts.createMap();
|
|
this.projectWatchers.set(projectName, watchers);
|
|
}
|
|
else {
|
|
ts.copyEntries(watchers, toRemove);
|
|
}
|
|
// handler should be invoked once for the entire set of files since it will trigger full rediscovery of typings
|
|
watchers.isInvoked = false;
|
|
var isLoggingEnabled = this.log.isEnabled();
|
|
var createProjectWatcher = function (path, createWatch) {
|
|
toRemove.delete(path);
|
|
if (watchers.has(path)) {
|
|
return;
|
|
}
|
|
watchers.set(path, createWatch(path));
|
|
};
|
|
var createProjectFileWatcher = function (file) {
|
|
if (isLoggingEnabled) {
|
|
_this.log.writeLine("FileWatcher:: Added:: WatchInfo: " + file);
|
|
}
|
|
var watcher = _this.installTypingHost.watchFile(file, function (f, eventKind) {
|
|
if (isLoggingEnabled) {
|
|
_this.log.writeLine("FileWatcher:: Triggered with " + f + " eventKind: " + ts.FileWatcherEventKind[eventKind] + ":: WatchInfo: " + file + ":: handler is already invoked '" + watchers.isInvoked + "'");
|
|
}
|
|
if (!watchers.isInvoked) {
|
|
watchers.isInvoked = true;
|
|
_this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate });
|
|
}
|
|
}, /*pollingInterval*/ 2000);
|
|
return isLoggingEnabled ? {
|
|
close: function () {
|
|
_this.log.writeLine("FileWatcher:: Closed:: WatchInfo: " + file);
|
|
watcher.close();
|
|
}
|
|
} : watcher;
|
|
};
|
|
var createProjectDirectoryWatcher = function (dir) {
|
|
if (isLoggingEnabled) {
|
|
_this.log.writeLine("DirectoryWatcher:: Added:: WatchInfo: " + dir + " recursive");
|
|
}
|
|
var watcher = _this.installTypingHost.watchDirectory(dir, function (f) {
|
|
if (isLoggingEnabled) {
|
|
_this.log.writeLine("DirectoryWatcher:: Triggered with " + f + " :: WatchInfo: " + dir + " recursive :: handler is already invoked '" + watchers.isInvoked + "'");
|
|
}
|
|
if (watchers.isInvoked) {
|
|
return;
|
|
}
|
|
f = _this.toCanonicalFileName(f);
|
|
if (f !== _this.globalCacheCanonicalPackageJsonPath && isPackageOrBowerJson(f)) {
|
|
watchers.isInvoked = true;
|
|
_this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate });
|
|
}
|
|
}, /*recursive*/ true);
|
|
return isLoggingEnabled ? {
|
|
close: function () {
|
|
_this.log.writeLine("DirectoryWatcher:: Closed:: WatchInfo: " + dir + " recursive");
|
|
watcher.close();
|
|
}
|
|
} : watcher;
|
|
};
|
|
// Create watches from list of files
|
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
var file = files_1[_i];
|
|
var filePath = this.toCanonicalFileName(file);
|
|
if (isPackageOrBowerJson(filePath)) {
|
|
// package.json or bower.json exists, watch the file to detect changes and update typings
|
|
createProjectWatcher(filePath, createProjectFileWatcher);
|
|
continue;
|
|
}
|
|
// path in projectRoot, watch project root
|
|
if (ts.containsPath(projectRootPath, filePath, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
|
|
createProjectWatcher(projectRootPath, createProjectDirectoryWatcher);
|
|
continue;
|
|
}
|
|
// path in global cache, watch global cache
|
|
if (ts.containsPath(this.globalCachePath, filePath, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
|
|
createProjectWatcher(this.globalCachePath, createProjectDirectoryWatcher);
|
|
continue;
|
|
}
|
|
// Get path without node_modules and bower_components
|
|
createProjectWatcher(getDirectoryExcludingNodeModulesOrBowerComponents(ts.getDirectoryPath(filePath)), createProjectDirectoryWatcher);
|
|
}
|
|
// Remove unused watches
|
|
toRemove.forEach(function (watch, path) {
|
|
watch.close();
|
|
watchers.delete(path);
|
|
});
|
|
};
|
|
TypingsInstaller.prototype.createSetTypings = function (request, typings) {
|
|
return {
|
|
projectName: request.projectName,
|
|
typeAcquisition: request.typeAcquisition,
|
|
compilerOptions: request.compilerOptions,
|
|
typings: typings,
|
|
unresolvedImports: request.unresolvedImports,
|
|
kind: server.ActionSet
|
|
};
|
|
};
|
|
TypingsInstaller.prototype.installTypingsAsync = function (requestId, packageNames, cwd, onRequestCompleted) {
|
|
this.pendingRunRequests.unshift({ requestId: requestId, packageNames: packageNames, cwd: cwd, onRequestCompleted: onRequestCompleted });
|
|
this.executeWithThrottling();
|
|
};
|
|
TypingsInstaller.prototype.executeWithThrottling = function () {
|
|
var _this = this;
|
|
var _loop_1 = function () {
|
|
this_1.inFlightRequestCount++;
|
|
var request = this_1.pendingRunRequests.pop();
|
|
this_1.installWorker(request.requestId, request.packageNames, request.cwd, function (ok) {
|
|
_this.inFlightRequestCount--;
|
|
request.onRequestCompleted(ok);
|
|
_this.executeWithThrottling();
|
|
});
|
|
};
|
|
var this_1 = this;
|
|
while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) {
|
|
_loop_1();
|
|
}
|
|
};
|
|
return TypingsInstaller;
|
|
}());
|
|
typingsInstaller.TypingsInstaller = TypingsInstaller;
|
|
/* @internal */
|
|
function typingsName(packageName) {
|
|
return "@types/" + packageName + "@ts" + ts.versionMajorMinor;
|
|
}
|
|
typingsInstaller.typingsName = typingsName;
|
|
})(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {}));
|
|
})(server = ts.server || (ts.server = {}));
|
|
})(ts || (ts = {}));
|
|
//# sourceMappingURL=typingsInstallerCore.js.map
|
|
var ts;
|
|
(function (ts) {
|
|
var server;
|
|
(function (server) {
|
|
var typingsInstaller;
|
|
(function (typingsInstaller) {
|
|
var fs = require("fs");
|
|
var path = require("path");
|
|
var FileLog = (function () {
|
|
function FileLog(logFile) {
|
|
var _this = this;
|
|
this.logFile = logFile;
|
|
this.logEnabled = true;
|
|
this.isEnabled = function () {
|
|
return _this.logEnabled && _this.logFile !== undefined;
|
|
};
|
|
this.writeLine = function (text) {
|
|
try {
|
|
fs.appendFileSync(_this.logFile, "[" + server.nowString() + "] " + text + ts.sys.newLine);
|
|
}
|
|
catch (e) {
|
|
_this.logEnabled = false;
|
|
}
|
|
};
|
|
}
|
|
return FileLog;
|
|
}());
|
|
function getDefaultNPMLocation(processName) {
|
|
if (path.basename(processName).indexOf("node") === 0) {
|
|
return "\"" + path.join(path.dirname(process.argv[0]), "npm") + "\"";
|
|
}
|
|
else {
|
|
return "npm";
|
|
}
|
|
}
|
|
function loadTypesRegistryFile(typesRegistryFilePath, host, log) {
|
|
if (!host.fileExists(typesRegistryFilePath)) {
|
|
if (log.isEnabled()) {
|
|
log.writeLine("Types registry file '" + typesRegistryFilePath + "' does not exist");
|
|
}
|
|
return ts.createMap();
|
|
}
|
|
try {
|
|
var content = JSON.parse(host.readFile(typesRegistryFilePath));
|
|
return ts.createMapFromTemplate(content.entries);
|
|
}
|
|
catch (e) {
|
|
if (log.isEnabled()) {
|
|
log.writeLine("Error when loading types registry file '" + typesRegistryFilePath + "': " + e.message + ", " + e.stack);
|
|
}
|
|
return ts.createMap();
|
|
}
|
|
}
|
|
var typesRegistryPackageName = "types-registry";
|
|
function getTypesRegistryFileLocation(globalTypingsCacheLocation) {
|
|
return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/" + typesRegistryPackageName + "/index.json");
|
|
}
|
|
var NodeTypingsInstaller = (function (_super) {
|
|
__extends(NodeTypingsInstaller, _super);
|
|
function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, throttleLimit, log) {
|
|
var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), typesMapLocation ? ts.toPath(typesMapLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typesMap.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this;
|
|
_this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]);
|
|
if (ts.stringContains(_this.npmPath, " ") && _this.npmPath[0] !== "\"") {
|
|
_this.npmPath = "\"" + _this.npmPath + "\"";
|
|
}
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Process id: " + process.pid);
|
|
_this.log.writeLine("NPM location: " + _this.npmPath + " (explicit '" + server.Arguments.NpmLocation + "' " + (npmLocation === undefined ? "not " : "") + " provided)");
|
|
}
|
|
(_this.nodeExecSync = require("child_process").execSync);
|
|
_this.ensurePackageDirectoryExists(globalTypingsCacheLocation);
|
|
try {
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Updating " + typesRegistryPackageName + " npm package...");
|
|
}
|
|
_this.execSyncAndLog(_this.npmPath + " install --ignore-scripts " + typesRegistryPackageName + "@" + _this.latestDistTag, { cwd: globalTypingsCacheLocation });
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Updated " + typesRegistryPackageName + " npm package");
|
|
}
|
|
}
|
|
catch (e) {
|
|
if (_this.log.isEnabled()) {
|
|
_this.log.writeLine("Error updating " + typesRegistryPackageName + " package: " + e.message);
|
|
}
|
|
_this.delayedInitializationError = {
|
|
kind: "event::initializationFailed",
|
|
message: e.message
|
|
};
|
|
}
|
|
_this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), _this.installTypingHost, _this.log);
|
|
return _this;
|
|
}
|
|
NodeTypingsInstaller.prototype.listen = function () {
|
|
var _this = this;
|
|
process.on("message", function (req) {
|
|
if (_this.delayedInitializationError) {
|
|
_this.sendResponse(_this.delayedInitializationError);
|
|
_this.delayedInitializationError = undefined;
|
|
}
|
|
switch (req.kind) {
|
|
case "discover":
|
|
_this.install(req);
|
|
break;
|
|
case "closeProject":
|
|
_this.closeProject(req);
|
|
break;
|
|
case "typesRegistry": {
|
|
var typesRegistry_1 = {};
|
|
_this.typesRegistry.forEach(function (value, key) {
|
|
typesRegistry_1[key] = value;
|
|
});
|
|
var response = { kind: server.EventTypesRegistry, typesRegistry: typesRegistry_1 };
|
|
_this.sendResponse(response);
|
|
break;
|
|
}
|
|
case "installPackage": {
|
|
var fileName = req.fileName, packageName_1 = req.packageName, projectName_1 = req.projectName, projectRootPath = req.projectRootPath;
|
|
var cwd = getDirectoryOfPackageJson(fileName, _this.installTypingHost) || projectRootPath;
|
|
if (cwd) {
|
|
_this.installWorker(-1, [packageName_1], cwd, function (success) {
|
|
var message = success ? "Package " + packageName_1 + " installed." : "There was an error installing " + packageName_1 + ".";
|
|
var response = { kind: server.ActionPackageInstalled, projectName: projectName_1, success: success, message: message };
|
|
_this.sendResponse(response);
|
|
});
|
|
}
|
|
else {
|
|
var response = { kind: server.ActionPackageInstalled, projectName: projectName_1, success: false, message: "Could not determine a project root path." };
|
|
_this.sendResponse(response);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
ts.Debug.assertNever(req);
|
|
}
|
|
});
|
|
};
|
|
NodeTypingsInstaller.prototype.sendResponse = function (response) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Sending response:\n " + JSON.stringify(response));
|
|
}
|
|
process.send(response);
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Response has been sent.");
|
|
}
|
|
};
|
|
NodeTypingsInstaller.prototype.installWorker = function (requestId, packageNames, cwd, onRequestCompleted) {
|
|
var _this = this;
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(packageNames) + "'.");
|
|
}
|
|
var start = Date.now();
|
|
var hasError = typingsInstaller.installNpmPackages(this.npmPath, ts.version, packageNames, function (command) { return _this.execSyncAndLog(command, { cwd: cwd }); });
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms");
|
|
}
|
|
onRequestCompleted(!hasError);
|
|
};
|
|
NodeTypingsInstaller.prototype.execSyncAndLog = function (command, options) {
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine("Exec: " + command);
|
|
}
|
|
try {
|
|
var stdout = this.nodeExecSync(command, __assign({}, options, { encoding: "utf-8" }));
|
|
if (this.log.isEnabled()) {
|
|
this.log.writeLine(" Succeeded. stdout:" + indent(ts.sys.newLine, stdout));
|
|
}
|
|
return false;
|
|
}
|
|
catch (error) {
|
|
var stdout = error.stdout, stderr = error.stderr;
|
|
this.log.writeLine(" Failed. stdout:" + indent(ts.sys.newLine, stdout) + ts.sys.newLine + " stderr:" + indent(ts.sys.newLine, stderr));
|
|
return true;
|
|
}
|
|
};
|
|
return NodeTypingsInstaller;
|
|
}(typingsInstaller.TypingsInstaller));
|
|
typingsInstaller.NodeTypingsInstaller = NodeTypingsInstaller;
|
|
function getDirectoryOfPackageJson(fileName, host) {
|
|
return ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (directory) {
|
|
if (host.fileExists(ts.combinePaths(directory, "package.json"))) {
|
|
return directory;
|
|
}
|
|
});
|
|
}
|
|
var logFilePath = server.findArgument(server.Arguments.LogFile);
|
|
var globalTypingsCacheLocation = server.findArgument(server.Arguments.GlobalCacheLocation);
|
|
var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation);
|
|
var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation);
|
|
var npmLocation = server.findArgument(server.Arguments.NpmLocation);
|
|
var log = new FileLog(logFilePath);
|
|
if (log.isEnabled()) {
|
|
process.on("uncaughtException", function (e) {
|
|
log.writeLine("Unhandled exception: " + e + " at " + e.stack);
|
|
});
|
|
}
|
|
process.on("disconnect", function () {
|
|
if (log.isEnabled()) {
|
|
log.writeLine("Parent process has exited, shutting down...");
|
|
}
|
|
process.exit(0);
|
|
});
|
|
var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, 5, log);
|
|
installer.listen();
|
|
function indent(newline, str) {
|
|
return newline + " " + str.replace(/\r?\n/, newline + " ");
|
|
}
|
|
})(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {}));
|
|
})(server = ts.server || (ts.server = {}));
|
|
})(ts || (ts = {}));
|
|
//# sourceMappingURL=typingsInstaller.js.map |