mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into master-dynamicImport
# Conflicts: # src/compiler/checker.ts # src/compiler/emitter.ts # src/compiler/parser.ts # src/compiler/transformers/module/module.ts # src/compiler/transformers/module/system.ts
This commit is contained in:
+9
-2
@@ -131,6 +131,7 @@ const es2017LibrarySource = [
|
||||
"es2017.object.d.ts",
|
||||
"es2017.sharedmemory.d.ts",
|
||||
"es2017.string.d.ts",
|
||||
"es2017.intl.d.ts",
|
||||
];
|
||||
|
||||
const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) {
|
||||
@@ -935,7 +936,7 @@ gulp.task(loggedIOJsPath, /*help*/ false, [], (done) => {
|
||||
const temp = path.join(builtLocalDirectory, "temp");
|
||||
mkdirP(temp, (err) => {
|
||||
if (err) { console.error(err); done(err); process.exit(1); }
|
||||
exec(host, [LKGCompiler, "--types --outdir", temp, loggedIOpath], () => {
|
||||
exec(host, [LKGCompiler, "--types", "--target es5", "--lib es5", "--outdir", temp, loggedIOpath], () => {
|
||||
fs.renameSync(path.join(temp, "/harness/loggedIO.js"), loggedIOJsPath);
|
||||
del(temp).then(() => done(), done);
|
||||
}, done);
|
||||
@@ -946,7 +947,13 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts");
|
||||
const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js");
|
||||
gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
|
||||
const settings: tsc.Settings = getCompilerSettings({
|
||||
outFile: instrumenterJsPath
|
||||
outFile: instrumenterJsPath,
|
||||
target: "es5",
|
||||
lib: [
|
||||
"es6",
|
||||
"dom",
|
||||
"scripthost"
|
||||
]
|
||||
}, /*useBuiltCompiler*/ true);
|
||||
return gulp.src(instrumenterPath)
|
||||
.pipe(newer(instrumenterJsPath))
|
||||
|
||||
+2
-1
@@ -172,7 +172,8 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
|
||||
var es2017LibrarySource = [
|
||||
"es2017.object.d.ts",
|
||||
"es2017.sharedmemory.d.ts",
|
||||
"es2017.string.d.ts"
|
||||
"es2017.string.d.ts",
|
||||
"es2017.intl.d.ts"
|
||||
];
|
||||
|
||||
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
|
||||
|
||||
@@ -69,3 +69,5 @@ function createCancellationToken(args) {
|
||||
}
|
||||
}
|
||||
module.exports = createCancellationToken;
|
||||
|
||||
//# sourceMappingURL=cancellationToken.js.map
|
||||
|
||||
Vendored
+28
-20
@@ -1406,6 +1406,14 @@ interface ArrayBuffer {
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed ArrayBuffer types for the buffer of an ArrayBufferView and related Typed Arrays.
|
||||
*/
|
||||
interface ArrayBufferTypes {
|
||||
ArrayBuffer: ArrayBuffer;
|
||||
}
|
||||
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
readonly prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
@@ -1417,7 +1425,7 @@ interface ArrayBufferView {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
buffer: ArrayBuffer;
|
||||
buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1559,7 +1567,7 @@ interface DataView {
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView;
|
||||
}
|
||||
declare const DataView: DataViewConstructor;
|
||||
|
||||
@@ -1576,7 +1584,7 @@ interface Int8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1819,7 +1827,7 @@ interface Int8ArrayConstructor {
|
||||
readonly prototype: Int8Array;
|
||||
new (length: number): Int8Array;
|
||||
new (array: ArrayLike<number>): Int8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -1860,7 +1868,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2104,7 +2112,7 @@ interface Uint8ArrayConstructor {
|
||||
readonly prototype: Uint8Array;
|
||||
new (length: number): Uint8Array;
|
||||
new (array: ArrayLike<number>): Uint8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2145,7 +2153,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2389,7 +2397,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
readonly prototype: Uint8ClampedArray;
|
||||
new (length: number): Uint8ClampedArray;
|
||||
new (array: ArrayLike<number>): Uint8ClampedArray;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2429,7 +2437,7 @@ interface Int16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2673,7 +2681,7 @@ interface Int16ArrayConstructor {
|
||||
readonly prototype: Int16Array;
|
||||
new (length: number): Int16Array;
|
||||
new (array: ArrayLike<number>): Int16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2714,7 +2722,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2958,7 +2966,7 @@ interface Uint16ArrayConstructor {
|
||||
readonly prototype: Uint16Array;
|
||||
new (length: number): Uint16Array;
|
||||
new (array: ArrayLike<number>): Uint16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2998,7 +3006,7 @@ interface Int32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3242,7 +3250,7 @@ interface Int32ArrayConstructor {
|
||||
readonly prototype: Int32Array;
|
||||
new (length: number): Int32Array;
|
||||
new (array: ArrayLike<number>): Int32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3282,7 +3290,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3526,7 +3534,7 @@ interface Uint32ArrayConstructor {
|
||||
readonly prototype: Uint32Array;
|
||||
new (length: number): Uint32Array;
|
||||
new (array: ArrayLike<number>): Uint32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3566,7 +3574,7 @@ interface Float32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3810,7 +3818,7 @@ interface Float32ArrayConstructor {
|
||||
readonly prototype: Float32Array;
|
||||
new (length: number): Float32Array;
|
||||
new (array: ArrayLike<number>): Float32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3851,7 +3859,7 @@ interface Float64Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -4095,7 +4103,7 @@ interface Float64ArrayConstructor {
|
||||
readonly prototype: Float64Array;
|
||||
new (length: number): Float64Array;
|
||||
new (array: ArrayLike<number>): Float64Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
|
||||
Vendored
+71
-7
@@ -52,17 +52,17 @@ interface Array<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -86,21 +86,21 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -111,9 +111,42 @@ interface IArguments {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
@@ -128,9 +161,40 @@ interface WeakMapConstructor {
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -23,7 +23,7 @@ interface ProxyHandler<T extends object> {
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
|
||||
Vendored
+1824
File diff suppressed because it is too large
Load Diff
Vendored
+2
-1
@@ -21,4 +21,5 @@ and limitations under the License.
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
/// <reference path="lib.es2017.intl.d.ts" />
|
||||
Vendored
+1825
File diff suppressed because it is too large
Load Diff
Vendored
+92
-1
@@ -43,5 +43,96 @@ interface SharedArrayBufferConstructor {
|
||||
readonly prototype: SharedArrayBuffer;
|
||||
new (byteLength: number): SharedArrayBuffer;
|
||||
}
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
interface ArrayBufferTypes {
|
||||
SharedArrayBuffer: SharedArrayBuffer;
|
||||
}
|
||||
|
||||
interface Atomics {
|
||||
/**
|
||||
* Adds a value to the value at the given position in the array, returning the original value.
|
||||
* Until this atomic operation completes, any other read or write operation against the array
|
||||
* will block.
|
||||
*/
|
||||
add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise AND of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or
|
||||
* write operation against the array will block.
|
||||
*/
|
||||
and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array if the original value equals the given
|
||||
* expected value, returning the original value. Until this atomic operation completes, any
|
||||
* other read or write operation against the array will block.
|
||||
*/
|
||||
compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array, returning the original value. Until
|
||||
* this atomic operation completes, any other read or write operation against the array will
|
||||
* block.
|
||||
*/
|
||||
exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether high-performance algorithms can use atomic operations
|
||||
* (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
|
||||
* array.
|
||||
*/
|
||||
isLockFree(size: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the value at the given position in the array. Until this atomic operation completes,
|
||||
* any other read or write operation against the array will block.
|
||||
*/
|
||||
load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise OR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores a value at the given position in the array, returning the new value. Until this
|
||||
* atomic operation completes, any other read or write operation against the array will block.
|
||||
*/
|
||||
store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Subtracts a value from the value at the given position in the array, returning the original
|
||||
* value. Until this atomic operation completes, any other read or write operation against the
|
||||
* array will block.
|
||||
*/
|
||||
sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* If the value at the given position in the array is equal to the provided value, the current
|
||||
* agent is put to sleep causing execution to suspend until the timeout expires (returning
|
||||
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
||||
* `"not-equal"`.
|
||||
*/
|
||||
wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
|
||||
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
*/
|
||||
wake(typedArray: Int32Array, index: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
readonly [Symbol.toStringTag]: "Atomics";
|
||||
}
|
||||
|
||||
declare var Atomics: Atomics;
|
||||
Vendored
+28
-20
@@ -1406,6 +1406,14 @@ interface ArrayBuffer {
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed ArrayBuffer types for the buffer of an ArrayBufferView and related Typed Arrays.
|
||||
*/
|
||||
interface ArrayBufferTypes {
|
||||
ArrayBuffer: ArrayBuffer;
|
||||
}
|
||||
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
readonly prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
@@ -1417,7 +1425,7 @@ interface ArrayBufferView {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
buffer: ArrayBuffer;
|
||||
buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1559,7 +1567,7 @@ interface DataView {
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView;
|
||||
}
|
||||
declare const DataView: DataViewConstructor;
|
||||
|
||||
@@ -1576,7 +1584,7 @@ interface Int8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1819,7 +1827,7 @@ interface Int8ArrayConstructor {
|
||||
readonly prototype: Int8Array;
|
||||
new (length: number): Int8Array;
|
||||
new (array: ArrayLike<number>): Int8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -1860,7 +1868,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2104,7 +2112,7 @@ interface Uint8ArrayConstructor {
|
||||
readonly prototype: Uint8Array;
|
||||
new (length: number): Uint8Array;
|
||||
new (array: ArrayLike<number>): Uint8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2145,7 +2153,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2389,7 +2397,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
readonly prototype: Uint8ClampedArray;
|
||||
new (length: number): Uint8ClampedArray;
|
||||
new (array: ArrayLike<number>): Uint8ClampedArray;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2429,7 +2437,7 @@ interface Int16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2673,7 +2681,7 @@ interface Int16ArrayConstructor {
|
||||
readonly prototype: Int16Array;
|
||||
new (length: number): Int16Array;
|
||||
new (array: ArrayLike<number>): Int16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2714,7 +2722,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2958,7 +2966,7 @@ interface Uint16ArrayConstructor {
|
||||
readonly prototype: Uint16Array;
|
||||
new (length: number): Uint16Array;
|
||||
new (array: ArrayLike<number>): Uint16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2998,7 +3006,7 @@ interface Int32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3242,7 +3250,7 @@ interface Int32ArrayConstructor {
|
||||
readonly prototype: Int32Array;
|
||||
new (length: number): Int32Array;
|
||||
new (array: ArrayLike<number>): Int32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3282,7 +3290,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3526,7 +3534,7 @@ interface Uint32ArrayConstructor {
|
||||
readonly prototype: Uint32Array;
|
||||
new (length: number): Uint32Array;
|
||||
new (array: ArrayLike<number>): Uint32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3566,7 +3574,7 @@ interface Float32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3810,7 +3818,7 @@ interface Float32ArrayConstructor {
|
||||
readonly prototype: Float32Array;
|
||||
new (length: number): Float32Array;
|
||||
new (array: ArrayLike<number>): Float32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3851,7 +3859,7 @@ interface Float64Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -4095,7 +4103,7 @@ interface Float64ArrayConstructor {
|
||||
readonly prototype: Float64Array;
|
||||
new (length: number): Float64Array;
|
||||
new (array: ArrayLike<number>): Float64Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
|
||||
Vendored
+100
-28
@@ -1406,6 +1406,14 @@ interface ArrayBuffer {
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed ArrayBuffer types for the buffer of an ArrayBufferView and related Typed Arrays.
|
||||
*/
|
||||
interface ArrayBufferTypes {
|
||||
ArrayBuffer: ArrayBuffer;
|
||||
}
|
||||
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
readonly prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
@@ -1417,7 +1425,7 @@ interface ArrayBufferView {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
buffer: ArrayBuffer;
|
||||
buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1559,7 +1567,7 @@ interface DataView {
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView;
|
||||
}
|
||||
declare const DataView: DataViewConstructor;
|
||||
|
||||
@@ -1576,7 +1584,7 @@ interface Int8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1819,7 +1827,7 @@ interface Int8ArrayConstructor {
|
||||
readonly prototype: Int8Array;
|
||||
new (length: number): Int8Array;
|
||||
new (array: ArrayLike<number>): Int8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -1860,7 +1868,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2104,7 +2112,7 @@ interface Uint8ArrayConstructor {
|
||||
readonly prototype: Uint8Array;
|
||||
new (length: number): Uint8Array;
|
||||
new (array: ArrayLike<number>): Uint8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2145,7 +2153,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2389,7 +2397,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
readonly prototype: Uint8ClampedArray;
|
||||
new (length: number): Uint8ClampedArray;
|
||||
new (array: ArrayLike<number>): Uint8ClampedArray;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2429,7 +2437,7 @@ interface Int16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2673,7 +2681,7 @@ interface Int16ArrayConstructor {
|
||||
readonly prototype: Int16Array;
|
||||
new (length: number): Int16Array;
|
||||
new (array: ArrayLike<number>): Int16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2714,7 +2722,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2958,7 +2966,7 @@ interface Uint16ArrayConstructor {
|
||||
readonly prototype: Uint16Array;
|
||||
new (length: number): Uint16Array;
|
||||
new (array: ArrayLike<number>): Uint16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2998,7 +3006,7 @@ interface Int32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3242,7 +3250,7 @@ interface Int32ArrayConstructor {
|
||||
readonly prototype: Int32Array;
|
||||
new (length: number): Int32Array;
|
||||
new (array: ArrayLike<number>): Int32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3282,7 +3290,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3526,7 +3534,7 @@ interface Uint32ArrayConstructor {
|
||||
readonly prototype: Uint32Array;
|
||||
new (length: number): Uint32Array;
|
||||
new (array: ArrayLike<number>): Uint32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3566,7 +3574,7 @@ interface Float32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3810,7 +3818,7 @@ interface Float32ArrayConstructor {
|
||||
readonly prototype: Float32Array;
|
||||
new (length: number): Float32Array;
|
||||
new (array: ArrayLike<number>): Float32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3851,7 +3859,7 @@ interface Float64Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -4095,7 +4103,7 @@ interface Float64ArrayConstructor {
|
||||
readonly prototype: Float64Array;
|
||||
new (length: number): Float64Array;
|
||||
new (array: ArrayLike<number>): Float64Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -4977,17 +4985,17 @@ interface Array<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -5011,21 +5019,21 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -5036,9 +5044,42 @@ interface IArguments {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
@@ -5053,9 +5094,40 @@ interface WeakMapConstructor {
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
@@ -5637,7 +5709,7 @@ interface ProxyHandler<T extends object> {
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
|
||||
Vendored
+1824
File diff suppressed because it is too large
Load Diff
+3816
-1680
File diff suppressed because it is too large
Load Diff
+3929
-2602
File diff suppressed because it is too large
Load Diff
Vendored
+201
-119
@@ -352,9 +352,10 @@ declare namespace ts {
|
||||
SyntaxList = 294,
|
||||
NotEmittedStatement = 295,
|
||||
PartiallyEmittedExpression = 296,
|
||||
MergeDeclarationMarker = 297,
|
||||
EndOfDeclarationMarker = 298,
|
||||
Count = 299,
|
||||
CommaListExpression = 297,
|
||||
MergeDeclarationMarker = 298,
|
||||
EndOfDeclarationMarker = 299,
|
||||
Count = 300,
|
||||
FirstAssignment = 58,
|
||||
LastAssignment = 70,
|
||||
FirstCompoundAssignment = 59,
|
||||
@@ -482,9 +483,11 @@ declare namespace ts {
|
||||
type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern;
|
||||
interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
interface NamedDeclaration extends Declaration {
|
||||
name?: DeclarationName;
|
||||
}
|
||||
interface DeclarationStatement extends Declaration, Statement {
|
||||
interface DeclarationStatement extends NamedDeclaration, Statement {
|
||||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
interface ComputedPropertyName extends Node {
|
||||
@@ -495,7 +498,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Decorator;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends Declaration {
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.TypeParameter;
|
||||
parent?: DeclarationWithTypeParameters;
|
||||
name: Identifier;
|
||||
@@ -503,7 +506,7 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends Declaration {
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
@@ -516,7 +519,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
interface VariableDeclaration extends Declaration {
|
||||
interface VariableDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.VariableDeclaration;
|
||||
parent?: VariableDeclarationList | CatchClause;
|
||||
name: BindingName;
|
||||
@@ -528,7 +531,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends Declaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -537,7 +540,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends Declaration {
|
||||
interface BindingElement extends NamedDeclaration {
|
||||
kind: SyntaxKind.BindingElement;
|
||||
parent?: BindingPattern;
|
||||
propertyName?: PropertyName;
|
||||
@@ -559,7 +562,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface ObjectLiteralElement extends Declaration {
|
||||
interface ObjectLiteralElement extends NamedDeclaration {
|
||||
_objectLiteralBrandBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
@@ -581,7 +584,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends Declaration {
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name: DeclarationName;
|
||||
@@ -589,7 +592,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyLikeDeclaration extends Declaration {
|
||||
interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
name: PropertyName;
|
||||
}
|
||||
interface ObjectBindingPattern extends Node {
|
||||
@@ -926,7 +929,7 @@ declare namespace ts {
|
||||
}
|
||||
type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression;
|
||||
type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
name: Identifier;
|
||||
@@ -991,7 +994,7 @@ declare namespace ts {
|
||||
}
|
||||
interface MetaProperty extends PrimaryExpression {
|
||||
kind: SyntaxKind.MetaProperty;
|
||||
keywordToken: SyntaxKind;
|
||||
keywordToken: SyntaxKind.NewKeyword;
|
||||
name: Identifier;
|
||||
}
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
@@ -1051,6 +1054,10 @@ declare namespace ts {
|
||||
interface NotEmittedStatement extends Statement {
|
||||
kind: SyntaxKind.NotEmittedStatement;
|
||||
}
|
||||
interface CommaListExpression extends Expression {
|
||||
kind: SyntaxKind.CommaListExpression;
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
interface EmptyStatement extends Statement {
|
||||
kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
@@ -1172,7 +1179,7 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration;
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@@ -1185,11 +1192,11 @@ declare namespace ts {
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
interface ClassElement extends Declaration {
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
interface TypeElement extends Declaration {
|
||||
interface TypeElement extends NamedDeclaration {
|
||||
_typeElementBrand: any;
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -1213,7 +1220,7 @@ declare namespace ts {
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends Declaration {
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
@@ -1266,13 +1273,13 @@ declare namespace ts {
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
type NamedImportBindings = NamespaceImport | NamedImports;
|
||||
interface ImportClause extends Declaration {
|
||||
interface ImportClause extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportClause;
|
||||
parent?: ImportDeclaration;
|
||||
name?: Identifier;
|
||||
namedBindings?: NamedImportBindings;
|
||||
}
|
||||
interface NamespaceImport extends Declaration {
|
||||
interface NamespaceImport extends NamedDeclaration {
|
||||
kind: SyntaxKind.NamespaceImport;
|
||||
parent?: ImportClause;
|
||||
name: Identifier;
|
||||
@@ -1298,13 +1305,13 @@ declare namespace ts {
|
||||
elements: NodeArray<ExportSpecifier>;
|
||||
}
|
||||
type NamedImportsOrExports = NamedImports | NamedExports;
|
||||
interface ImportSpecifier extends Declaration {
|
||||
interface ImportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportSpecifier;
|
||||
parent?: NamedImports;
|
||||
propertyName?: Identifier;
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportSpecifier extends Declaration {
|
||||
interface ExportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ExportSpecifier;
|
||||
parent?: NamedExports;
|
||||
propertyName?: Identifier;
|
||||
@@ -1435,7 +1442,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocTypeTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypedefTag extends JSDocTag, Declaration {
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
kind: SyntaxKind.JSDocTypedefTag;
|
||||
fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
name?: Identifier;
|
||||
@@ -1626,11 +1633,11 @@ declare namespace ts {
|
||||
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration;
|
||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolAtLocation(node: Node): Symbol | undefined;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
getTypeFromTypeNode(node: TypeNode): Type;
|
||||
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
||||
@@ -1640,37 +1647,47 @@ declare namespace ts {
|
||||
getFullyQualifiedName(symbol: Symbol): string;
|
||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||
getRootSymbols(symbol: Symbol): Symbol[];
|
||||
getContextualType(node: Expression): Type;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
getContextualType(node: Expression): Type | undefined;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type;
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
}
|
||||
enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
allowThisInObjectLiteral = 1,
|
||||
allowQualifedNameInPlaceOfIdentifier = 2,
|
||||
allowTypeParameterInQualifiedName = 4,
|
||||
allowAnonymousIdentifier = 8,
|
||||
allowEmptyUnionOrIntersection = 16,
|
||||
allowEmptyTuple = 32,
|
||||
NoTruncation = 1,
|
||||
WriteArrayAsGenericType = 2,
|
||||
WriteTypeArgumentsOfSignature = 32,
|
||||
UseFullyQualifiedType = 64,
|
||||
SuppressAnyReturnType = 256,
|
||||
WriteTypeParametersInQualifiedName = 512,
|
||||
AllowThisInObjectLiteral = 1024,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 2048,
|
||||
AllowAnonymousIdentifier = 8192,
|
||||
AllowEmptyUnionOrIntersection = 16384,
|
||||
AllowEmptyTuple = 32768,
|
||||
IgnoreErrors = 60416,
|
||||
InObjectTypeLiteral = 1048576,
|
||||
InTypeAlias = 8388608,
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1831,18 +1848,18 @@ declare namespace ts {
|
||||
Index = 262144,
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 480,
|
||||
Literal = 224,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
NumberLike = 340,
|
||||
NumberLike = 84,
|
||||
BooleanLike = 136,
|
||||
EnumLike = 272,
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeVariable = 1032192,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 17810431,
|
||||
Narrowable = 17810175,
|
||||
NotUnionOrUnit = 16810497,
|
||||
}
|
||||
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
@@ -1854,15 +1871,17 @@ declare namespace ts {
|
||||
aliasTypeArguments?: Type[];
|
||||
}
|
||||
interface LiteralType extends Type {
|
||||
text: string;
|
||||
value: string | number;
|
||||
freshType?: LiteralType;
|
||||
regularType?: LiteralType;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
memberTypes: EnumLiteralType[];
|
||||
interface StringLiteralType extends LiteralType {
|
||||
value: string;
|
||||
}
|
||||
interface EnumLiteralType extends LiteralType {
|
||||
baseType: EnumType & UnionType;
|
||||
interface NumberLiteralType extends LiteralType {
|
||||
value: number;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
}
|
||||
const enum ObjectFlags {
|
||||
Class = 1,
|
||||
@@ -1896,7 +1915,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypeReference extends ObjectType {
|
||||
target: GenericType;
|
||||
typeArguments: Type[];
|
||||
typeArguments?: Type[];
|
||||
}
|
||||
interface GenericType extends InterfaceType, TypeReference {
|
||||
}
|
||||
@@ -1932,7 +1951,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Signature {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
typeParameters?: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
}
|
||||
const enum IndexKind {
|
||||
@@ -1961,9 +1980,9 @@ declare namespace ts {
|
||||
next?: DiagnosticMessageChain;
|
||||
}
|
||||
interface Diagnostic {
|
||||
file: SourceFile;
|
||||
start: number;
|
||||
length: number;
|
||||
file: SourceFile | undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
@@ -2204,6 +2223,7 @@ declare namespace ts {
|
||||
NoHoisting = 2097152,
|
||||
HasEndOfDeclarationMarker = 4194304,
|
||||
Iterator = 8388608,
|
||||
NoAsciiEscaping = 16777216,
|
||||
}
|
||||
interface EmitHelper {
|
||||
readonly name: string;
|
||||
@@ -2362,13 +2382,13 @@ declare namespace ts {
|
||||
function isWhiteSpaceSingleLine(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function couldStartTrivia(text: string, pos: number): boolean;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
function getShebang(text: string): string;
|
||||
function getShebang(text: string): string | undefined;
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
|
||||
@@ -2384,7 +2404,7 @@ declare namespace ts {
|
||||
error?: Diagnostic;
|
||||
};
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
@@ -2395,9 +2415,6 @@ declare namespace ts {
|
||||
};
|
||||
}
|
||||
declare namespace ts {
|
||||
interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
function moduleHasNonRelativeName(moduleName: string): boolean;
|
||||
function getEffectiveTypeRoots(options: CompilerOptions, host: {
|
||||
directoryExists?: (directoryName: string) => boolean;
|
||||
@@ -2466,6 +2483,7 @@ declare namespace ts {
|
||||
function createLiteral(value: string | number | boolean): PrimaryExpression;
|
||||
function createNumericLiteral(value: string): NumericLiteral;
|
||||
function createIdentifier(text: string): Identifier;
|
||||
function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode> | undefined): Identifier;
|
||||
function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier;
|
||||
function createLoopVariable(): Identifier;
|
||||
function createUniqueName(text: string): Identifier;
|
||||
@@ -2480,58 +2498,19 @@ declare namespace ts {
|
||||
function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
||||
function createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
||||
function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
||||
function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode;
|
||||
function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray<TypeNode>): UnionOrIntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
function createDecorator(expression: Expression): Decorator;
|
||||
function updateDecorator(node: Decorator, expression: Expression): Decorator;
|
||||
function createPropertySignature(modifiers: Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, modifiers: Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
@@ -2539,6 +2518,45 @@ declare namespace ts {
|
||||
function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
|
||||
function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createIndexSignature(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createUnionTypeNode(types: TypeNode[]): UnionTypeNode;
|
||||
function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
|
||||
function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode;
|
||||
function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionTypeNode | IntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern;
|
||||
@@ -2580,7 +2598,7 @@ declare namespace ts {
|
||||
function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression;
|
||||
function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression;
|
||||
function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression;
|
||||
function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
@@ -2600,16 +2618,15 @@ declare namespace ts {
|
||||
function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression;
|
||||
function createNonNullExpression(expression: Expression): NonNullExpression;
|
||||
function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression;
|
||||
function createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
|
||||
function updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
|
||||
function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function createSemicolonClassElement(): SemicolonClassElement;
|
||||
function createBlock(statements: Statement[], multiLine?: boolean): Block;
|
||||
function updateBlock(node: Block, statements: Statement[]): Block;
|
||||
function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement;
|
||||
function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createEmptyStatement(): EmptyStatement;
|
||||
function createStatement(expression: Expression): ExpressionStatement;
|
||||
function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement;
|
||||
@@ -2641,10 +2658,19 @@ declare namespace ts {
|
||||
function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement;
|
||||
function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function createDebuggerStatement(): DebuggerStatement;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function createTypeAliasDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration;
|
||||
@@ -2653,6 +2679,8 @@ declare namespace ts {
|
||||
function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock;
|
||||
function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration;
|
||||
function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration;
|
||||
function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration;
|
||||
@@ -2683,20 +2711,20 @@ declare namespace ts {
|
||||
function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement;
|
||||
function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(node: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute;
|
||||
function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression;
|
||||
function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCaseClause(expression: Expression, statements: Statement[]): CaseClause;
|
||||
function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause;
|
||||
function createDefaultClause(statements: Statement[]): DefaultClause;
|
||||
function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
|
||||
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
|
||||
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
|
||||
@@ -2712,6 +2740,8 @@ declare namespace ts {
|
||||
function createNotEmittedStatement(original: Node): NotEmittedStatement;
|
||||
function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression;
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: Expression[]): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: Expression[]): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
@@ -2745,8 +2775,8 @@ declare namespace ts {
|
||||
function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined;
|
||||
function setSyntheticTrailingComments<T extends Node>(node: T, comments: SynthesizedComment[]): T;
|
||||
function addSyntheticTrailingComment<T extends Node>(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T;
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression;
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number;
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression;
|
||||
function addEmitHelper<T extends Node>(node: T, helper: EmitHelper): T;
|
||||
function addEmitHelpers<T extends Node>(node: T, helpers: EmitHelper[] | undefined): T;
|
||||
function removeEmitHelper(node: Node, helper: EmitHelper): boolean;
|
||||
@@ -2756,7 +2786,7 @@ declare namespace ts {
|
||||
}
|
||||
declare namespace ts {
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName;
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
@@ -2789,6 +2819,7 @@ declare namespace ts {
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
@@ -2931,6 +2962,8 @@ declare namespace ts {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
|
||||
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
|
||||
getRefactorCodeActions(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string): CodeAction[] | undefined;
|
||||
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -2981,6 +3014,10 @@ declare namespace ts {
|
||||
description: string;
|
||||
changes: FileTextChanges[];
|
||||
}
|
||||
interface ApplicableRefactorInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
caretOffset: number;
|
||||
@@ -3367,6 +3404,7 @@ declare namespace ts {
|
||||
reportDiagnostics?: boolean;
|
||||
moduleName?: string;
|
||||
renamedDependencies?: MapLike<string>;
|
||||
transformers?: CustomTransformers;
|
||||
}
|
||||
interface TranspileOutput {
|
||||
outputText: string;
|
||||
@@ -3610,6 +3648,9 @@ declare namespace ts.server.protocol {
|
||||
type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
|
||||
type GetCodeFixes = "getCodeFixes";
|
||||
type GetSupportedCodeFixes = "getSupportedCodeFixes";
|
||||
type GetApplicableRefactors = "getApplicableRefactors";
|
||||
type GetRefactorCodeActions = "getRefactorCodeActions";
|
||||
type GetRefactorCodeActionsFull = "getRefactorCodeActions-full";
|
||||
}
|
||||
interface Message {
|
||||
seq: number;
|
||||
@@ -3704,15 +3745,44 @@ declare namespace ts.server.protocol {
|
||||
line: number;
|
||||
offset: number;
|
||||
}
|
||||
type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs;
|
||||
interface GetApplicableRefactorsRequest extends Request {
|
||||
command: CommandTypes.GetApplicableRefactors;
|
||||
arguments: GetApplicableRefactorsRequestArgs;
|
||||
}
|
||||
type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs;
|
||||
interface ApplicableRefactorInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
interface GetApplicableRefactorsResponse extends Response {
|
||||
body?: ApplicableRefactorInfo[];
|
||||
}
|
||||
interface GetRefactorCodeActionsRequest extends Request {
|
||||
command: CommandTypes.GetRefactorCodeActions;
|
||||
arguments: GetRefactorCodeActionsRequestArgs;
|
||||
}
|
||||
type GetRefactorCodeActionsRequestArgs = FileLocationOrRangeRequestArgs & {
|
||||
refactorName: string;
|
||||
};
|
||||
type RefactorCodeActions = {
|
||||
actions: protocol.CodeAction[];
|
||||
renameLocation?: number;
|
||||
};
|
||||
interface GetRefactorCodeActionsResponse extends Response {
|
||||
body: RefactorCodeActions;
|
||||
}
|
||||
interface CodeFixRequest extends Request {
|
||||
command: CommandTypes.GetCodeFixes;
|
||||
arguments: CodeFixRequestArgs;
|
||||
}
|
||||
interface CodeFixRequestArgs extends FileRequestArgs {
|
||||
interface FileRangeRequestArgs extends FileRequestArgs {
|
||||
startLine: number;
|
||||
startOffset: number;
|
||||
endLine: number;
|
||||
endOffset: number;
|
||||
}
|
||||
interface CodeFixRequestArgs extends FileRangeRequestArgs {
|
||||
errorCodes?: number[];
|
||||
}
|
||||
interface GetCodeFixesResponse extends Response {
|
||||
@@ -4291,6 +4361,7 @@ declare namespace ts.server.protocol {
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
|
||||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
||||
insertSpaceAfterTypeAssertion?: boolean;
|
||||
insertSpaceBeforeFunctionParenthesis?: boolean;
|
||||
placeOpenBraceOnNewLineForFunctions?: boolean;
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
@@ -4408,7 +4479,7 @@ declare namespace ts.server {
|
||||
project: Project;
|
||||
}
|
||||
interface EventSender {
|
||||
event(payload: any, eventName: string): void;
|
||||
event<T>(payload: T, eventName: string): void;
|
||||
}
|
||||
namespace CommandNames {
|
||||
const Brace: protocol.CommandTypes.Brace;
|
||||
@@ -4455,6 +4526,9 @@ declare namespace ts.server {
|
||||
const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects;
|
||||
const GetCodeFixes: protocol.CommandTypes.GetCodeFixes;
|
||||
const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes;
|
||||
const GetApplicableRefactors: protocol.CommandTypes.GetApplicableRefactors;
|
||||
const GetRefactorCodeActions: protocol.CommandTypes.GetRefactorCodeActions;
|
||||
const GetRefactorCodeActionsFull: protocol.CommandTypes.GetRefactorCodeActionsFull;
|
||||
}
|
||||
function formatMessage<T extends protocol.Message>(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string;
|
||||
interface SessionOptions {
|
||||
@@ -4470,6 +4544,7 @@ declare namespace ts.server {
|
||||
throttleWaitMilliseconds?: number;
|
||||
globalPlugins?: string[];
|
||||
pluginProbeLocations?: string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
}
|
||||
class Session implements EventSender {
|
||||
private readonly gcTimer;
|
||||
@@ -4491,7 +4566,7 @@ declare namespace ts.server {
|
||||
logError(err: Error, cmd: string): void;
|
||||
send(msg: protocol.Message): void;
|
||||
configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void;
|
||||
event(info: any, eventName: string): void;
|
||||
event<T>(info: T, eventName: string): void;
|
||||
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
|
||||
private semanticCheck(file, project);
|
||||
private syntacticCheck(file, project);
|
||||
@@ -4554,7 +4629,12 @@ declare namespace ts.server {
|
||||
private getNavigationTree(args, simplifiedResult);
|
||||
private getNavigateToItems(args, simplifiedResult);
|
||||
private getSupportedCodeFixes();
|
||||
private isLocation(locationOrSpan);
|
||||
private extractPositionAndRange(args, scriptInfo);
|
||||
private getApplicableRefactors(args);
|
||||
private getRefactorCodeActions(args, simplifiedResult);
|
||||
private getCodeFixes(args, simplifiedResult);
|
||||
private getStartAndEndPosition(args, scriptInfo);
|
||||
private mapCodeAction(codeAction, scriptInfo);
|
||||
private convertTextChangeToCodeEdit(change, scriptInfo);
|
||||
private getBraceMatching(args, simplifiedResult);
|
||||
@@ -5047,6 +5127,7 @@ declare namespace ts.server {
|
||||
throttleWaitMilliseconds?: number;
|
||||
globalPlugins?: string[];
|
||||
pluginProbeLocations?: string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
}
|
||||
class ProjectService {
|
||||
readonly typingsCache: TypingsCache;
|
||||
@@ -5076,6 +5157,7 @@ declare namespace ts.server {
|
||||
private readonly eventHandler?;
|
||||
readonly globalPlugins: ReadonlyArray<string>;
|
||||
readonly pluginProbeLocations: ReadonlyArray<string>;
|
||||
readonly allowLocalPluginLoads: boolean;
|
||||
constructor(opts: ProjectServiceOptions);
|
||||
ensureInferredProjectsUpToDate_TestOnly(): void;
|
||||
getCompilerOptionsForInferredProjects(): CompilerOptions;
|
||||
|
||||
+3921
-2596
File diff suppressed because it is too large
Load Diff
Vendored
+162
-117
@@ -359,9 +359,10 @@ declare namespace ts {
|
||||
SyntaxList = 294,
|
||||
NotEmittedStatement = 295,
|
||||
PartiallyEmittedExpression = 296,
|
||||
MergeDeclarationMarker = 297,
|
||||
EndOfDeclarationMarker = 298,
|
||||
Count = 299,
|
||||
CommaListExpression = 297,
|
||||
MergeDeclarationMarker = 298,
|
||||
EndOfDeclarationMarker = 299,
|
||||
Count = 300,
|
||||
FirstAssignment = 58,
|
||||
LastAssignment = 70,
|
||||
FirstCompoundAssignment = 59,
|
||||
@@ -474,6 +475,10 @@ declare namespace ts {
|
||||
type ModifiersArray = NodeArray<Modifier>;
|
||||
interface Identifier extends PrimaryExpression {
|
||||
kind: SyntaxKind.Identifier;
|
||||
/**
|
||||
* Text of identifier (with escapes converted to characters).
|
||||
* If the identifier begins with two underscores, this will begin with three.
|
||||
*/
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
isInJSDocNamespace?: boolean;
|
||||
@@ -491,9 +496,11 @@ declare namespace ts {
|
||||
type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern;
|
||||
interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
interface NamedDeclaration extends Declaration {
|
||||
name?: DeclarationName;
|
||||
}
|
||||
interface DeclarationStatement extends Declaration, Statement {
|
||||
interface DeclarationStatement extends NamedDeclaration, Statement {
|
||||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
interface ComputedPropertyName extends Node {
|
||||
@@ -504,7 +511,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Decorator;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends Declaration {
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.TypeParameter;
|
||||
parent?: DeclarationWithTypeParameters;
|
||||
name: Identifier;
|
||||
@@ -512,7 +519,7 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends Declaration {
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
@@ -525,7 +532,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
interface VariableDeclaration extends Declaration {
|
||||
interface VariableDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.VariableDeclaration;
|
||||
parent?: VariableDeclarationList | CatchClause;
|
||||
name: BindingName;
|
||||
@@ -537,7 +544,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends Declaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -546,7 +553,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends Declaration {
|
||||
interface BindingElement extends NamedDeclaration {
|
||||
kind: SyntaxKind.BindingElement;
|
||||
parent?: BindingPattern;
|
||||
propertyName?: PropertyName;
|
||||
@@ -568,7 +575,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface ObjectLiteralElement extends Declaration {
|
||||
interface ObjectLiteralElement extends NamedDeclaration {
|
||||
_objectLiteralBrandBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
@@ -590,7 +597,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends Declaration {
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name: DeclarationName;
|
||||
@@ -598,7 +605,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyLikeDeclaration extends Declaration {
|
||||
interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
name: PropertyName;
|
||||
}
|
||||
interface ObjectBindingPattern extends Node {
|
||||
@@ -950,7 +957,7 @@ declare namespace ts {
|
||||
}
|
||||
type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression;
|
||||
type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
name: Identifier;
|
||||
@@ -1016,7 +1023,7 @@ declare namespace ts {
|
||||
}
|
||||
interface MetaProperty extends PrimaryExpression {
|
||||
kind: SyntaxKind.MetaProperty;
|
||||
keywordToken: SyntaxKind;
|
||||
keywordToken: SyntaxKind.NewKeyword;
|
||||
name: Identifier;
|
||||
}
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
@@ -1076,6 +1083,13 @@ declare namespace ts {
|
||||
interface NotEmittedStatement extends Statement {
|
||||
kind: SyntaxKind.NotEmittedStatement;
|
||||
}
|
||||
/**
|
||||
* A list of comma-seperated expressions. This node is only created by transformations.
|
||||
*/
|
||||
interface CommaListExpression extends Expression {
|
||||
kind: SyntaxKind.CommaListExpression;
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
interface EmptyStatement extends Statement {
|
||||
kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
@@ -1197,7 +1211,7 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration;
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@@ -1210,11 +1224,11 @@ declare namespace ts {
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
interface ClassElement extends Declaration {
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
interface TypeElement extends Declaration {
|
||||
interface TypeElement extends NamedDeclaration {
|
||||
_typeElementBrand: any;
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -1238,7 +1252,7 @@ declare namespace ts {
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends Declaration {
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
@@ -1297,13 +1311,13 @@ declare namespace ts {
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
type NamedImportBindings = NamespaceImport | NamedImports;
|
||||
interface ImportClause extends Declaration {
|
||||
interface ImportClause extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportClause;
|
||||
parent?: ImportDeclaration;
|
||||
name?: Identifier;
|
||||
namedBindings?: NamedImportBindings;
|
||||
}
|
||||
interface NamespaceImport extends Declaration {
|
||||
interface NamespaceImport extends NamedDeclaration {
|
||||
kind: SyntaxKind.NamespaceImport;
|
||||
parent?: ImportClause;
|
||||
name: Identifier;
|
||||
@@ -1330,13 +1344,13 @@ declare namespace ts {
|
||||
elements: NodeArray<ExportSpecifier>;
|
||||
}
|
||||
type NamedImportsOrExports = NamedImports | NamedExports;
|
||||
interface ImportSpecifier extends Declaration {
|
||||
interface ImportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportSpecifier;
|
||||
parent?: NamedImports;
|
||||
propertyName?: Identifier;
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportSpecifier extends Declaration {
|
||||
interface ExportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ExportSpecifier;
|
||||
parent?: NamedExports;
|
||||
propertyName?: Identifier;
|
||||
@@ -1467,7 +1481,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocTypeTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypedefTag extends JSDocTag, Declaration {
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
kind: SyntaxKind.JSDocTypedefTag;
|
||||
fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
name?: Identifier;
|
||||
@@ -1706,11 +1720,11 @@ declare namespace ts {
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolAtLocation(node: Node): Symbol | undefined;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
getTypeFromTypeNode(node: TypeNode): Type;
|
||||
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
||||
@@ -1720,38 +1734,48 @@ declare namespace ts {
|
||||
getFullyQualifiedName(symbol: Symbol): string;
|
||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||
getRootSymbols(symbol: Symbol): Symbol[];
|
||||
getContextualType(node: Expression): Type;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
getContextualType(node: Expression): Type | undefined;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type;
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
}
|
||||
enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
allowThisInObjectLiteral = 1,
|
||||
allowQualifedNameInPlaceOfIdentifier = 2,
|
||||
allowTypeParameterInQualifiedName = 4,
|
||||
allowAnonymousIdentifier = 8,
|
||||
allowEmptyUnionOrIntersection = 16,
|
||||
allowEmptyTuple = 32,
|
||||
NoTruncation = 1,
|
||||
WriteArrayAsGenericType = 2,
|
||||
WriteTypeArgumentsOfSignature = 32,
|
||||
UseFullyQualifiedType = 64,
|
||||
SuppressAnyReturnType = 256,
|
||||
WriteTypeParametersInQualifiedName = 512,
|
||||
AllowThisInObjectLiteral = 1024,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 2048,
|
||||
AllowAnonymousIdentifier = 8192,
|
||||
AllowEmptyUnionOrIntersection = 16384,
|
||||
AllowEmptyTuple = 32768,
|
||||
IgnoreErrors = 60416,
|
||||
InObjectTypeLiteral = 1048576,
|
||||
InTypeAlias = 8388608,
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1912,18 +1936,18 @@ declare namespace ts {
|
||||
Index = 262144,
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 480,
|
||||
Literal = 224,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
NumberLike = 340,
|
||||
NumberLike = 84,
|
||||
BooleanLike = 136,
|
||||
EnumLike = 272,
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeVariable = 1032192,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 17810431,
|
||||
Narrowable = 17810175,
|
||||
NotUnionOrUnit = 16810497,
|
||||
}
|
||||
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
@@ -1935,15 +1959,17 @@ declare namespace ts {
|
||||
aliasTypeArguments?: Type[];
|
||||
}
|
||||
interface LiteralType extends Type {
|
||||
text: string;
|
||||
value: string | number;
|
||||
freshType?: LiteralType;
|
||||
regularType?: LiteralType;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
memberTypes: EnumLiteralType[];
|
||||
interface StringLiteralType extends LiteralType {
|
||||
value: string;
|
||||
}
|
||||
interface EnumLiteralType extends LiteralType {
|
||||
baseType: EnumType & UnionType;
|
||||
interface NumberLiteralType extends LiteralType {
|
||||
value: number;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
}
|
||||
enum ObjectFlags {
|
||||
Class = 1,
|
||||
@@ -1988,7 +2014,7 @@ declare namespace ts {
|
||||
*/
|
||||
interface TypeReference extends ObjectType {
|
||||
target: GenericType;
|
||||
typeArguments: Type[];
|
||||
typeArguments?: Type[];
|
||||
}
|
||||
interface GenericType extends InterfaceType, TypeReference {
|
||||
}
|
||||
@@ -2024,7 +2050,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Signature {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
typeParameters?: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
}
|
||||
enum IndexKind {
|
||||
@@ -2059,9 +2085,9 @@ declare namespace ts {
|
||||
next?: DiagnosticMessageChain;
|
||||
}
|
||||
interface Diagnostic {
|
||||
file: SourceFile;
|
||||
start: number;
|
||||
length: number;
|
||||
file: SourceFile | undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
@@ -2329,6 +2355,7 @@ declare namespace ts {
|
||||
NoHoisting = 2097152,
|
||||
HasEndOfDeclarationMarker = 4194304,
|
||||
Iterator = 8388608,
|
||||
NoAsciiEscaping = 16777216,
|
||||
}
|
||||
interface EmitHelper {
|
||||
readonly name: string;
|
||||
@@ -2611,14 +2638,14 @@ declare namespace ts {
|
||||
function isWhiteSpaceSingleLine(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function couldStartTrivia(text: string, pos: number): boolean;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
/** Optionally, get the shebang */
|
||||
function getShebang(text: string): string;
|
||||
function getShebang(text: string): string | undefined;
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
|
||||
@@ -2709,6 +2736,7 @@ declare namespace ts {
|
||||
function createLiteral(value: string | number | boolean): PrimaryExpression;
|
||||
function createNumericLiteral(value: string): NumericLiteral;
|
||||
function createIdentifier(text: string): Identifier;
|
||||
function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode> | undefined): Identifier;
|
||||
/** Create a unique temporary variable. */
|
||||
function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier;
|
||||
/** Create a unique temporary variable for use in a loop. */
|
||||
@@ -2727,58 +2755,19 @@ declare namespace ts {
|
||||
function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
||||
function createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
||||
function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
||||
function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode;
|
||||
function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray<TypeNode>): UnionOrIntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
function createDecorator(expression: Expression): Decorator;
|
||||
function updateDecorator(node: Decorator, expression: Expression): Decorator;
|
||||
function createPropertySignature(modifiers: Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, modifiers: Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
@@ -2786,6 +2775,45 @@ declare namespace ts {
|
||||
function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
|
||||
function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createIndexSignature(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createUnionTypeNode(types: TypeNode[]): UnionTypeNode;
|
||||
function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
|
||||
function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode;
|
||||
function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionTypeNode | IntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern;
|
||||
@@ -2827,7 +2855,7 @@ declare namespace ts {
|
||||
function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression;
|
||||
function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression;
|
||||
function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression;
|
||||
function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
@@ -2847,16 +2875,15 @@ declare namespace ts {
|
||||
function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression;
|
||||
function createNonNullExpression(expression: Expression): NonNullExpression;
|
||||
function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression;
|
||||
function createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
|
||||
function updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
|
||||
function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function createSemicolonClassElement(): SemicolonClassElement;
|
||||
function createBlock(statements: Statement[], multiLine?: boolean): Block;
|
||||
function updateBlock(node: Block, statements: Statement[]): Block;
|
||||
function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement;
|
||||
function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createEmptyStatement(): EmptyStatement;
|
||||
function createStatement(expression: Expression): ExpressionStatement;
|
||||
function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement;
|
||||
@@ -2888,10 +2915,19 @@ declare namespace ts {
|
||||
function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement;
|
||||
function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function createDebuggerStatement(): DebuggerStatement;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function createTypeAliasDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration;
|
||||
@@ -2900,6 +2936,8 @@ declare namespace ts {
|
||||
function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock;
|
||||
function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration;
|
||||
function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration;
|
||||
function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration;
|
||||
@@ -2930,20 +2968,20 @@ declare namespace ts {
|
||||
function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement;
|
||||
function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(node: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute;
|
||||
function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression;
|
||||
function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCaseClause(expression: Expression, statements: Statement[]): CaseClause;
|
||||
function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause;
|
||||
function createDefaultClause(statements: Statement[]): DefaultClause;
|
||||
function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
|
||||
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
|
||||
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
|
||||
@@ -2976,6 +3014,8 @@ declare namespace ts {
|
||||
*/
|
||||
function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression;
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: Expression[]): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: Expression[]): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
@@ -3040,11 +3080,11 @@ declare namespace ts {
|
||||
/**
|
||||
* Gets the constant value to emit for an expression.
|
||||
*/
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number;
|
||||
/**
|
||||
* Sets the constant value to emit for an expression.
|
||||
*/
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression;
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression;
|
||||
/**
|
||||
* Adds an EmitHelper to a node.
|
||||
*/
|
||||
@@ -3069,17 +3109,13 @@ declare namespace ts {
|
||||
}
|
||||
declare namespace ts {
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName;
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
/** Array that is only intended to be pushed to, never read. */
|
||||
interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
function moduleHasNonRelativeName(moduleName: string): boolean;
|
||||
function getEffectiveTypeRoots(options: CompilerOptions, host: {
|
||||
directoryExists?: (directoryName: string) => boolean;
|
||||
@@ -3218,6 +3254,7 @@ declare namespace ts {
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
@@ -3246,9 +3283,10 @@ declare namespace ts {
|
||||
* @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 parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
@@ -3422,6 +3460,8 @@ declare namespace ts {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
|
||||
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
|
||||
getRefactorCodeActions(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string): CodeAction[] | undefined;
|
||||
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -3492,6 +3532,10 @@ declare namespace ts {
|
||||
/** Text changes to apply to each file as part of the code action */
|
||||
changes: FileTextChanges[];
|
||||
}
|
||||
interface ApplicableRefactorInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
/** The position in newText the caret should point to after the insertion. */
|
||||
@@ -4006,6 +4050,7 @@ declare namespace ts {
|
||||
reportDiagnostics?: boolean;
|
||||
moduleName?: string;
|
||||
renamedDependencies?: MapLike<string>;
|
||||
transformers?: CustomTransformers;
|
||||
}
|
||||
interface TranspileOutput {
|
||||
outputText: string;
|
||||
|
||||
+4208
-2942
File diff suppressed because it is too large
Load Diff
Vendored
+162
-117
@@ -359,9 +359,10 @@ declare namespace ts {
|
||||
SyntaxList = 294,
|
||||
NotEmittedStatement = 295,
|
||||
PartiallyEmittedExpression = 296,
|
||||
MergeDeclarationMarker = 297,
|
||||
EndOfDeclarationMarker = 298,
|
||||
Count = 299,
|
||||
CommaListExpression = 297,
|
||||
MergeDeclarationMarker = 298,
|
||||
EndOfDeclarationMarker = 299,
|
||||
Count = 300,
|
||||
FirstAssignment = 58,
|
||||
LastAssignment = 70,
|
||||
FirstCompoundAssignment = 59,
|
||||
@@ -474,6 +475,10 @@ declare namespace ts {
|
||||
type ModifiersArray = NodeArray<Modifier>;
|
||||
interface Identifier extends PrimaryExpression {
|
||||
kind: SyntaxKind.Identifier;
|
||||
/**
|
||||
* Text of identifier (with escapes converted to characters).
|
||||
* If the identifier begins with two underscores, this will begin with three.
|
||||
*/
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
isInJSDocNamespace?: boolean;
|
||||
@@ -491,9 +496,11 @@ declare namespace ts {
|
||||
type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern;
|
||||
interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
interface NamedDeclaration extends Declaration {
|
||||
name?: DeclarationName;
|
||||
}
|
||||
interface DeclarationStatement extends Declaration, Statement {
|
||||
interface DeclarationStatement extends NamedDeclaration, Statement {
|
||||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
interface ComputedPropertyName extends Node {
|
||||
@@ -504,7 +511,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Decorator;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends Declaration {
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.TypeParameter;
|
||||
parent?: DeclarationWithTypeParameters;
|
||||
name: Identifier;
|
||||
@@ -512,7 +519,7 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends Declaration {
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
@@ -525,7 +532,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
interface VariableDeclaration extends Declaration {
|
||||
interface VariableDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.VariableDeclaration;
|
||||
parent?: VariableDeclarationList | CatchClause;
|
||||
name: BindingName;
|
||||
@@ -537,7 +544,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends Declaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -546,7 +553,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends Declaration {
|
||||
interface BindingElement extends NamedDeclaration {
|
||||
kind: SyntaxKind.BindingElement;
|
||||
parent?: BindingPattern;
|
||||
propertyName?: PropertyName;
|
||||
@@ -568,7 +575,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface ObjectLiteralElement extends Declaration {
|
||||
interface ObjectLiteralElement extends NamedDeclaration {
|
||||
_objectLiteralBrandBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
@@ -590,7 +597,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends Declaration {
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name: DeclarationName;
|
||||
@@ -598,7 +605,7 @@ declare namespace ts {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyLikeDeclaration extends Declaration {
|
||||
interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
name: PropertyName;
|
||||
}
|
||||
interface ObjectBindingPattern extends Node {
|
||||
@@ -950,7 +957,7 @@ declare namespace ts {
|
||||
}
|
||||
type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression;
|
||||
type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
name: Identifier;
|
||||
@@ -1016,7 +1023,7 @@ declare namespace ts {
|
||||
}
|
||||
interface MetaProperty extends PrimaryExpression {
|
||||
kind: SyntaxKind.MetaProperty;
|
||||
keywordToken: SyntaxKind;
|
||||
keywordToken: SyntaxKind.NewKeyword;
|
||||
name: Identifier;
|
||||
}
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
@@ -1076,6 +1083,13 @@ declare namespace ts {
|
||||
interface NotEmittedStatement extends Statement {
|
||||
kind: SyntaxKind.NotEmittedStatement;
|
||||
}
|
||||
/**
|
||||
* A list of comma-seperated expressions. This node is only created by transformations.
|
||||
*/
|
||||
interface CommaListExpression extends Expression {
|
||||
kind: SyntaxKind.CommaListExpression;
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
interface EmptyStatement extends Statement {
|
||||
kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
@@ -1197,7 +1211,7 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration;
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@@ -1210,11 +1224,11 @@ declare namespace ts {
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
interface ClassElement extends Declaration {
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
interface TypeElement extends Declaration {
|
||||
interface TypeElement extends NamedDeclaration {
|
||||
_typeElementBrand: any;
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -1238,7 +1252,7 @@ declare namespace ts {
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends Declaration {
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
@@ -1297,13 +1311,13 @@ declare namespace ts {
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
type NamedImportBindings = NamespaceImport | NamedImports;
|
||||
interface ImportClause extends Declaration {
|
||||
interface ImportClause extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportClause;
|
||||
parent?: ImportDeclaration;
|
||||
name?: Identifier;
|
||||
namedBindings?: NamedImportBindings;
|
||||
}
|
||||
interface NamespaceImport extends Declaration {
|
||||
interface NamespaceImport extends NamedDeclaration {
|
||||
kind: SyntaxKind.NamespaceImport;
|
||||
parent?: ImportClause;
|
||||
name: Identifier;
|
||||
@@ -1330,13 +1344,13 @@ declare namespace ts {
|
||||
elements: NodeArray<ExportSpecifier>;
|
||||
}
|
||||
type NamedImportsOrExports = NamedImports | NamedExports;
|
||||
interface ImportSpecifier extends Declaration {
|
||||
interface ImportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportSpecifier;
|
||||
parent?: NamedImports;
|
||||
propertyName?: Identifier;
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportSpecifier extends Declaration {
|
||||
interface ExportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ExportSpecifier;
|
||||
parent?: NamedExports;
|
||||
propertyName?: Identifier;
|
||||
@@ -1467,7 +1481,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocTypeTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypedefTag extends JSDocTag, Declaration {
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
kind: SyntaxKind.JSDocTypedefTag;
|
||||
fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
name?: Identifier;
|
||||
@@ -1706,11 +1720,11 @@ declare namespace ts {
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolAtLocation(node: Node): Symbol | undefined;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
getTypeFromTypeNode(node: TypeNode): Type;
|
||||
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
||||
@@ -1720,38 +1734,48 @@ declare namespace ts {
|
||||
getFullyQualifiedName(symbol: Symbol): string;
|
||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||
getRootSymbols(symbol: Symbol): Symbol[];
|
||||
getContextualType(node: Expression): Type;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
getContextualType(node: Expression): Type | undefined;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type;
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
}
|
||||
enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
allowThisInObjectLiteral = 1,
|
||||
allowQualifedNameInPlaceOfIdentifier = 2,
|
||||
allowTypeParameterInQualifiedName = 4,
|
||||
allowAnonymousIdentifier = 8,
|
||||
allowEmptyUnionOrIntersection = 16,
|
||||
allowEmptyTuple = 32,
|
||||
NoTruncation = 1,
|
||||
WriteArrayAsGenericType = 2,
|
||||
WriteTypeArgumentsOfSignature = 32,
|
||||
UseFullyQualifiedType = 64,
|
||||
SuppressAnyReturnType = 256,
|
||||
WriteTypeParametersInQualifiedName = 512,
|
||||
AllowThisInObjectLiteral = 1024,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 2048,
|
||||
AllowAnonymousIdentifier = 8192,
|
||||
AllowEmptyUnionOrIntersection = 16384,
|
||||
AllowEmptyTuple = 32768,
|
||||
IgnoreErrors = 60416,
|
||||
InObjectTypeLiteral = 1048576,
|
||||
InTypeAlias = 8388608,
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1912,18 +1936,18 @@ declare namespace ts {
|
||||
Index = 262144,
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 480,
|
||||
Literal = 224,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
NumberLike = 340,
|
||||
NumberLike = 84,
|
||||
BooleanLike = 136,
|
||||
EnumLike = 272,
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeVariable = 1032192,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 17810431,
|
||||
Narrowable = 17810175,
|
||||
NotUnionOrUnit = 16810497,
|
||||
}
|
||||
type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
@@ -1935,15 +1959,17 @@ declare namespace ts {
|
||||
aliasTypeArguments?: Type[];
|
||||
}
|
||||
interface LiteralType extends Type {
|
||||
text: string;
|
||||
value: string | number;
|
||||
freshType?: LiteralType;
|
||||
regularType?: LiteralType;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
memberTypes: EnumLiteralType[];
|
||||
interface StringLiteralType extends LiteralType {
|
||||
value: string;
|
||||
}
|
||||
interface EnumLiteralType extends LiteralType {
|
||||
baseType: EnumType & UnionType;
|
||||
interface NumberLiteralType extends LiteralType {
|
||||
value: number;
|
||||
}
|
||||
interface EnumType extends Type {
|
||||
}
|
||||
enum ObjectFlags {
|
||||
Class = 1,
|
||||
@@ -1988,7 +2014,7 @@ declare namespace ts {
|
||||
*/
|
||||
interface TypeReference extends ObjectType {
|
||||
target: GenericType;
|
||||
typeArguments: Type[];
|
||||
typeArguments?: Type[];
|
||||
}
|
||||
interface GenericType extends InterfaceType, TypeReference {
|
||||
}
|
||||
@@ -2024,7 +2050,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Signature {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
typeParameters?: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
}
|
||||
enum IndexKind {
|
||||
@@ -2059,9 +2085,9 @@ declare namespace ts {
|
||||
next?: DiagnosticMessageChain;
|
||||
}
|
||||
interface Diagnostic {
|
||||
file: SourceFile;
|
||||
start: number;
|
||||
length: number;
|
||||
file: SourceFile | undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
@@ -2329,6 +2355,7 @@ declare namespace ts {
|
||||
NoHoisting = 2097152,
|
||||
HasEndOfDeclarationMarker = 4194304,
|
||||
Iterator = 8388608,
|
||||
NoAsciiEscaping = 16777216,
|
||||
}
|
||||
interface EmitHelper {
|
||||
readonly name: string;
|
||||
@@ -2611,14 +2638,14 @@ declare namespace ts {
|
||||
function isWhiteSpaceSingleLine(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function couldStartTrivia(text: string, pos: number): boolean;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U;
|
||||
function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined;
|
||||
function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U;
|
||||
function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
|
||||
/** Optionally, get the shebang */
|
||||
function getShebang(text: string): string;
|
||||
function getShebang(text: string): string | undefined;
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
|
||||
@@ -2709,6 +2736,7 @@ declare namespace ts {
|
||||
function createLiteral(value: string | number | boolean): PrimaryExpression;
|
||||
function createNumericLiteral(value: string): NumericLiteral;
|
||||
function createIdentifier(text: string): Identifier;
|
||||
function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode> | undefined): Identifier;
|
||||
/** Create a unique temporary variable. */
|
||||
function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier;
|
||||
/** Create a unique temporary variable for use in a loop. */
|
||||
@@ -2727,58 +2755,19 @@ declare namespace ts {
|
||||
function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
||||
function createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
||||
function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
||||
function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode;
|
||||
function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray<TypeNode>): UnionOrIntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
function createDecorator(expression: Expression): Decorator;
|
||||
function updateDecorator(node: Decorator, expression: Expression): Decorator;
|
||||
function createPropertySignature(modifiers: Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function updatePropertySignature(node: PropertySignature, modifiers: Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature;
|
||||
function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration;
|
||||
function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature;
|
||||
function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
||||
function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
||||
@@ -2786,6 +2775,45 @@ declare namespace ts {
|
||||
function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
|
||||
function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
||||
function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
function createIndexSignature(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): FunctionTypeNode;
|
||||
function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructorTypeNode;
|
||||
function createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode;
|
||||
function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
||||
function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode;
|
||||
function createUnionTypeNode(types: TypeNode[]): UnionTypeNode;
|
||||
function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
|
||||
function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode;
|
||||
function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode;
|
||||
function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionTypeNode | IntersectionTypeNode;
|
||||
function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode;
|
||||
function createLiteralTypeNode(literal: Expression): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern;
|
||||
@@ -2827,7 +2855,7 @@ declare namespace ts {
|
||||
function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression;
|
||||
function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression;
|
||||
function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression;
|
||||
function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression;
|
||||
function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
|
||||
@@ -2847,16 +2875,15 @@ declare namespace ts {
|
||||
function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression;
|
||||
function createNonNullExpression(expression: Expression): NonNullExpression;
|
||||
function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression;
|
||||
function createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
|
||||
function updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
|
||||
function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
||||
function createSemicolonClassElement(): SemicolonClassElement;
|
||||
function createBlock(statements: Statement[], multiLine?: boolean): Block;
|
||||
function updateBlock(node: Block, statements: Statement[]): Block;
|
||||
function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement;
|
||||
function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createEmptyStatement(): EmptyStatement;
|
||||
function createStatement(expression: Expression): ExpressionStatement;
|
||||
function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement;
|
||||
@@ -2888,10 +2915,19 @@ declare namespace ts {
|
||||
function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement;
|
||||
function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
||||
function createDebuggerStatement(): DebuggerStatement;
|
||||
function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
||||
function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
||||
function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
||||
function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList;
|
||||
function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
||||
function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration;
|
||||
function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]): InterfaceDeclaration;
|
||||
function createTypeAliasDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
||||
function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration;
|
||||
function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration;
|
||||
@@ -2900,6 +2936,8 @@ declare namespace ts {
|
||||
function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock;
|
||||
function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock;
|
||||
function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration;
|
||||
function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration;
|
||||
function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration;
|
||||
@@ -2930,20 +2968,20 @@ declare namespace ts {
|
||||
function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement;
|
||||
function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute;
|
||||
function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function updateJsxAttributes(node: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes;
|
||||
function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
||||
function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute;
|
||||
function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression;
|
||||
function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCaseClause(expression: Expression, statements: Statement[]): CaseClause;
|
||||
function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause;
|
||||
function createDefaultClause(statements: Statement[]): DefaultClause;
|
||||
function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause;
|
||||
function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause;
|
||||
function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause;
|
||||
function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause;
|
||||
function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
|
||||
@@ -2976,6 +3014,8 @@ declare namespace ts {
|
||||
*/
|
||||
function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression;
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: Expression[]): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: Expression[]): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
@@ -3040,11 +3080,11 @@ declare namespace ts {
|
||||
/**
|
||||
* Gets the constant value to emit for an expression.
|
||||
*/
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number;
|
||||
/**
|
||||
* Sets the constant value to emit for an expression.
|
||||
*/
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression;
|
||||
function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression;
|
||||
/**
|
||||
* Adds an EmitHelper to a node.
|
||||
*/
|
||||
@@ -3069,17 +3109,13 @@ declare namespace ts {
|
||||
}
|
||||
declare namespace ts {
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName;
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
/** Array that is only intended to be pushed to, never read. */
|
||||
interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
function moduleHasNonRelativeName(moduleName: string): boolean;
|
||||
function getEffectiveTypeRoots(options: CompilerOptions, host: {
|
||||
directoryExists?: (directoryName: string) => boolean;
|
||||
@@ -3218,6 +3254,7 @@ declare namespace ts {
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
@@ -3246,9 +3283,10 @@ declare namespace ts {
|
||||
* @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 parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined;
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
@@ -3422,6 +3460,8 @@ declare namespace ts {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
|
||||
getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[];
|
||||
getRefactorCodeActions(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string): CodeAction[] | undefined;
|
||||
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
@@ -3492,6 +3532,10 @@ declare namespace ts {
|
||||
/** Text changes to apply to each file as part of the code action */
|
||||
changes: FileTextChanges[];
|
||||
}
|
||||
interface ApplicableRefactorInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
/** The position in newText the caret should point to after the insertion. */
|
||||
@@ -4006,6 +4050,7 @@ declare namespace ts {
|
||||
reportDiagnostics?: boolean;
|
||||
moduleName?: string;
|
||||
renamedDependencies?: MapLike<string>;
|
||||
transformers?: CustomTransformers;
|
||||
}
|
||||
interface TranspileOutput {
|
||||
outputText: string;
|
||||
|
||||
+4208
-2942
File diff suppressed because it is too large
Load Diff
+1155
-91
File diff suppressed because it is too large
Load Diff
+72
-67
@@ -149,7 +149,7 @@ namespace ts {
|
||||
inStrictMode = bindInStrictMode(file, opts);
|
||||
classifiableNames = createMap<string>();
|
||||
symbolCount = 0;
|
||||
skipTransformFlagAggregation = isDeclarationFile(file);
|
||||
skipTransformFlagAggregation = file.isDeclarationFile;
|
||||
|
||||
Symbol = objectAllocator.getSymbolConstructor();
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace ts {
|
||||
return bindSourceFile;
|
||||
|
||||
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
|
||||
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) {
|
||||
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !file.isDeclarationFile) {
|
||||
// bind in strict mode source files with alwaysStrict option
|
||||
return true;
|
||||
}
|
||||
@@ -221,18 +221,19 @@ namespace ts {
|
||||
// other kinds of value declarations take precedence over modules
|
||||
symbol.valueDeclaration = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Should not be called on a declaration with a computed property name,
|
||||
// unless it is a well known Symbol.
|
||||
function getDeclarationName(node: Declaration): string {
|
||||
if (node.name) {
|
||||
const name = getNameOfDeclaration(node);
|
||||
if (name) {
|
||||
if (isAmbientModule(node)) {
|
||||
return isGlobalScopeAugmentation(<ModuleDeclaration>node) ? "__global" : `"${(<LiteralExpression>node.name).text}"`;
|
||||
return isGlobalScopeAugmentation(<ModuleDeclaration>node) ? "__global" : `"${(<LiteralExpression>name).text}"`;
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>name).expression;
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
if (isStringOrNumericLiteral(nameExpression)) {
|
||||
return nameExpression.text;
|
||||
@@ -241,7 +242,7 @@ namespace ts {
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
|
||||
}
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
return (<Identifier | LiteralExpression>name).text;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -259,18 +260,9 @@ namespace ts {
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (<ExportAssignment>node).isExportEquals ? "export=" : "default";
|
||||
case SyntaxKind.BinaryExpression:
|
||||
switch (getSpecialPropertyAssignmentKind(node as BinaryExpression)) {
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
// module.exports = ...
|
||||
return "export=";
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
// exports.x = ... or this.y = ...
|
||||
return ((node as BinaryExpression).left as PropertyAccessExpression).name.text;
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
// className.prototype.methodName = ...
|
||||
return (((node as BinaryExpression).left as PropertyAccessExpression).expression as PropertyAccessExpression).name.text;
|
||||
if (getSpecialPropertyAssignmentKind(node as BinaryExpression) === SpecialPropertyAssignmentKind.ModuleExports) {
|
||||
// module.exports = ...
|
||||
return "export=";
|
||||
}
|
||||
Debug.fail("Unknown binary declaration kind");
|
||||
break;
|
||||
@@ -303,7 +295,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDisplayName(node: Declaration): string {
|
||||
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
|
||||
return (node as NamedDeclaration).name ? declarationNameToString((node as NamedDeclaration).name) : getDeclarationName(node);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,8 +358,8 @@ namespace ts {
|
||||
symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name));
|
||||
}
|
||||
else {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
if ((node as NamedDeclaration).name) {
|
||||
(node as NamedDeclaration).name.parent = node;
|
||||
}
|
||||
|
||||
// Report errors every position with duplicate declaration
|
||||
@@ -389,16 +381,16 @@ namespace ts {
|
||||
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
|
||||
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
|
||||
if (symbol.declarations && symbol.declarations.length &&
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(declaration) || declaration, message, getDisplayName(declaration)));
|
||||
});
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(node) || node, message, getDisplayName(node)));
|
||||
|
||||
symbol = createSymbol(SymbolFlags.None, name);
|
||||
}
|
||||
@@ -438,10 +430,11 @@ namespace ts {
|
||||
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
|
||||
// and this case is specially handled. Module augmentations should only be merged with original module definition
|
||||
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
|
||||
if (node.kind === SyntaxKind.JSDocTypedefTag) Debug.assert(isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
|
||||
const isJSDocTypedefInJSDocNamespace = node.kind === SyntaxKind.JSDocTypedefTag &&
|
||||
node.name &&
|
||||
node.name.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>node.name).isInJSDocNamespace;
|
||||
(node as JSDocTypedefTag).name &&
|
||||
(node as JSDocTypedefTag).name.kind === SyntaxKind.Identifier &&
|
||||
((node as JSDocTypedefTag).name as Identifier).isInJSDocNamespace;
|
||||
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypedefInJSDocNamespace) {
|
||||
const exportKind =
|
||||
(symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
|
||||
@@ -602,9 +595,7 @@ namespace ts {
|
||||
// Binding of JsDocComment should be done before the current block scope container changes.
|
||||
// because the scope of JsDocComment should not be affected by whether the current node is a
|
||||
// container or not.
|
||||
if (isInJavaScriptFile(node) && node.jsDoc) {
|
||||
forEach(node.jsDoc, bind);
|
||||
}
|
||||
forEach(node.jsDoc, bind);
|
||||
if (checkUnreachable(node)) {
|
||||
bindEachChild(node);
|
||||
return;
|
||||
@@ -1414,7 +1405,7 @@ namespace ts {
|
||||
if (isObjectLiteralOrClassExpressionMethod(node)) {
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
@@ -1716,7 +1707,7 @@ namespace ts {
|
||||
declareModuleMember(node, symbolFlags, symbolExcludes);
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
default:
|
||||
if (!blockScopeContainer.locals) {
|
||||
blockScopeContainer.locals = createMap<Symbol>();
|
||||
@@ -1912,9 +1903,7 @@ namespace ts {
|
||||
// Here the current node is "foo", which is a container, but the scope of "MyType" should
|
||||
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
|
||||
// and skip binding this tag later when binding all the other jsdoc tags.
|
||||
if (isInJavaScriptFile(node)) {
|
||||
bindJSDocTypedefTagIfAny(node);
|
||||
}
|
||||
bindJSDocTypedefTagIfAny(node);
|
||||
|
||||
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
|
||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||
@@ -2002,7 +1991,7 @@ namespace ts {
|
||||
// for typedef type names with namespaces, bind the new jsdoc type symbol here
|
||||
// because it requires all containing namespaces to be in effect, namely the
|
||||
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
|
||||
if ((<Identifier>node).isInJSDocNamespace) {
|
||||
if (isInJavaScriptFile(node) && (<Identifier>node).isInJSDocNamespace) {
|
||||
let parentNode = node.parent;
|
||||
while (parentNode && parentNode.kind !== SyntaxKind.JSDocTypedefTag) {
|
||||
parentNode = parentNode.parent;
|
||||
@@ -2010,7 +1999,7 @@ namespace ts {
|
||||
bindBlockScopedDeclaration(<Declaration>parentNode, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
case SyntaxKind.ThisKeyword:
|
||||
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
|
||||
node.flowNode = currentFlow;
|
||||
@@ -2072,10 +2061,7 @@ namespace ts {
|
||||
return bindVariableDeclarationOrBindingElement(<VariableDeclaration | BindingElement>node);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.JSDocRecordMember:
|
||||
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
return bindJSDocProperty(<JSDocPropertyTag>node);
|
||||
return bindPropertyWorker(node as PropertyDeclaration | PropertySignature);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
@@ -2120,13 +2106,10 @@ namespace ts {
|
||||
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes);
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
case SyntaxKind.JSDocRecordType:
|
||||
return bindAnonymousDeclaration(<Declaration>node, SymbolFlags.TypeLiteral, "__type");
|
||||
return bindAnonymousTypeWorker(node as TypeLiteralNode | MappedTypeNode);
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return bindObjectLiteralExpression(<ObjectLiteralExpression>node);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
@@ -2147,11 +2130,6 @@ namespace ts {
|
||||
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
if (!(<JSDocTypedefTag>node).fullName || (<JSDocTypedefTag>node).fullName.kind === SyntaxKind.Identifier) {
|
||||
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
@@ -2186,12 +2164,44 @@ namespace ts {
|
||||
if (!isFunctionLike(node.parent)) {
|
||||
return;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return updateStrictModeStatementList((<Block | ModuleBlock>node).statements);
|
||||
|
||||
default:
|
||||
if (isInJavaScriptFile(node)) return bindJSDocWorker(node);
|
||||
}
|
||||
}
|
||||
|
||||
function bindJSDocWorker(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.JSDocRecordMember:
|
||||
return bindPropertyWorker(node as JSDocRecordMember);
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
return declareSymbolAndAddToSymbolTable(node as JSDocPropertyTag, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
case SyntaxKind.JSDocRecordType:
|
||||
return bindAnonymousTypeWorker(node as JSDocTypeLiteral | JSDocRecordType);
|
||||
case SyntaxKind.JSDocTypedefTag: {
|
||||
const { fullName } = node as JSDocTypedefTag;
|
||||
if (!fullName || fullName.kind === SyntaxKind.Identifier) {
|
||||
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindPropertyWorker(node: PropertyDeclaration | PropertySignature) {
|
||||
return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | (node.questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
function bindAnonymousTypeWorker(node: TypeLiteralNode | MappedTypeNode | JSDocTypeLiteral | JSDocRecordType) {
|
||||
return bindAnonymousDeclaration(<Declaration>node, SymbolFlags.TypeLiteral, "__type");
|
||||
}
|
||||
|
||||
function checkTypePredicate(node: TypePredicateNode) {
|
||||
const { parameterName, type } = node;
|
||||
if (parameterName && parameterName.kind === SyntaxKind.Identifier) {
|
||||
@@ -2211,7 +2221,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindSourceFileAsExternalModule() {
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`);
|
||||
}
|
||||
|
||||
function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
|
||||
@@ -2504,7 +2514,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindParameter(node: ParameterDeclaration) {
|
||||
if (inStrictMode) {
|
||||
if (inStrictMode && !isInAmbientContext(node)) {
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
||||
checkStrictModeEvalOrArguments(node, node.name);
|
||||
@@ -2526,7 +2536,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindFunctionDeclaration(node: FunctionDeclaration) {
|
||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
||||
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
|
||||
if (isAsyncFunction(node)) {
|
||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||
}
|
||||
@@ -2543,7 +2553,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindFunctionExpression(node: FunctionExpression) {
|
||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
||||
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
|
||||
if (isAsyncFunction(node)) {
|
||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||
}
|
||||
@@ -2557,10 +2567,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
||||
if (isAsyncFunction(node)) {
|
||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||
}
|
||||
if (!file.isDeclarationFile && !isInAmbientContext(node) && isAsyncFunction(node)) {
|
||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||
}
|
||||
|
||||
if (currentFlow && isObjectLiteralOrClassExpressionMethod(node)) {
|
||||
@@ -2572,10 +2580,6 @@ namespace ts {
|
||||
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
|
||||
function bindJSDocProperty(node: JSDocPropertyTag) {
|
||||
return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
// reachability checks
|
||||
|
||||
function shouldReportErrorOnModuleDeclaration(node: ModuleDeclaration): boolean {
|
||||
@@ -3398,6 +3402,7 @@ namespace ts {
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.LiteralType:
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
// Types and signatures are TypeScript syntax, and exclude all other facts.
|
||||
transformFlags = TransformFlags.AssertTypeScript;
|
||||
excludeFlags = TransformFlags.TypeExcludes;
|
||||
|
||||
+1262
-845
File diff suppressed because it is too large
Load Diff
@@ -140,6 +140,7 @@ namespace 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",
|
||||
"esnext.asynciterable": "lib.esnext.asynciterable.d.ts",
|
||||
}),
|
||||
},
|
||||
@@ -1089,58 +1090,38 @@ namespace ts {
|
||||
* @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.
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine {
|
||||
export function parseJsonConfigFileContent(
|
||||
json: any,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
existingOptions: CompilerOptions = {},
|
||||
configFileName?: string,
|
||||
resolutionStack: Path[] = [],
|
||||
extraFileExtensions: JsFileExtensionInfo[] = [],
|
||||
): ParsedCommandLine {
|
||||
const errors: Diagnostic[] = [];
|
||||
basePath = normalizeSlashes(basePath);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
||||
return {
|
||||
options: {},
|
||||
fileNames: [],
|
||||
typeAcquisition: {},
|
||||
raw: json,
|
||||
errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
}
|
||||
|
||||
let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
let options = (() => {
|
||||
const { include, exclude, files, options, compileOnSave } = parseConfig(json, host, basePath, configFileName, resolutionStack, errors);
|
||||
if (include) { json.include = include; }
|
||||
if (exclude) { json.exclude = exclude; }
|
||||
if (files) { json.files = files; }
|
||||
if (compileOnSave !== undefined) { json.compileOnSave = compileOnSave; }
|
||||
return options;
|
||||
})();
|
||||
|
||||
options = extend(existingOptions, options);
|
||||
options.configFilePath = configFileName;
|
||||
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
||||
// It should be removed in future releases - use typeAcquisition instead.
|
||||
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
|
||||
const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
|
||||
let baseCompileOnSave: boolean;
|
||||
if (json["extends"]) {
|
||||
let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}];
|
||||
if (typeof json["extends"] === "string") {
|
||||
[include, exclude, files, baseCompileOnSave, baseOptions] = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]);
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
|
||||
}
|
||||
if (include && !json["include"]) {
|
||||
json["include"] = include;
|
||||
}
|
||||
if (exclude && !json["exclude"]) {
|
||||
json["exclude"] = exclude;
|
||||
}
|
||||
if (files && !json["files"]) {
|
||||
json["files"] = files;
|
||||
}
|
||||
options = assign({}, baseOptions, options);
|
||||
}
|
||||
|
||||
options = extend(existingOptions, options);
|
||||
options.configFilePath = configFileName;
|
||||
|
||||
const { fileNames, wildcardDirectories } = getFileNames(errors);
|
||||
let compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
||||
if (baseCompileOnSave && json[compileOnSaveCommandLineOption.name] === undefined) {
|
||||
compileOnSave = baseCompileOnSave;
|
||||
}
|
||||
const { fileNames, wildcardDirectories } = getFileNames();
|
||||
const compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
||||
|
||||
return {
|
||||
options,
|
||||
@@ -1152,40 +1133,7 @@ namespace ts {
|
||||
compileOnSave
|
||||
};
|
||||
|
||||
function tryExtendsName(extendedConfig: string): [string[], string[], string[], boolean, CompilerOptions] {
|
||||
// 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 (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
|
||||
return;
|
||||
}
|
||||
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);
|
||||
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) {
|
||||
extendedConfigPath = `${extendedConfigPath}.json` as Path;
|
||||
if (!host.fileExists(extendedConfigPath)) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig));
|
||||
return;
|
||||
}
|
||||
}
|
||||
const extendedResult = readConfigFile(extendedConfigPath, path => host.readFile(path));
|
||||
if (extendedResult.error) {
|
||||
errors.push(extendedResult.error);
|
||||
return;
|
||||
}
|
||||
const extendedDirname = getDirectoryPath(extendedConfigPath);
|
||||
const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName);
|
||||
const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
|
||||
// Merge configs (copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios)
|
||||
const result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, /*existingOptions*/ undefined, getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath]));
|
||||
errors.push(...result.errors);
|
||||
const [include, exclude, files] = map(["include", "exclude", "files"], key => {
|
||||
if (!json[key] && extendedResult.config[key]) {
|
||||
return map(extendedResult.config[key], updatePath);
|
||||
}
|
||||
});
|
||||
return [include, exclude, files, result.compileOnSave, result.options];
|
||||
}
|
||||
|
||||
function getFileNames(errors: Diagnostic[]): ExpandResult {
|
||||
function getFileNames(): ExpandResult {
|
||||
let fileNames: string[];
|
||||
if (hasProperty(json, "files")) {
|
||||
if (isArray(json["files"])) {
|
||||
@@ -1218,9 +1166,6 @@ namespace ts {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array"));
|
||||
}
|
||||
}
|
||||
else if (hasProperty(json, "excludes")) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
else {
|
||||
// If no includes were specified, exclude common package folders and the outDir
|
||||
excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"];
|
||||
@@ -1250,7 +1195,106 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined {
|
||||
interface ParsedTsconfig {
|
||||
include: string[] | undefined;
|
||||
exclude: string[] | undefined;
|
||||
files: string[] | undefined;
|
||||
options: CompilerOptions;
|
||||
compileOnSave: boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* This *just* extracts options/include/exclude/files out of a config file.
|
||||
* It does *not* resolve the included files.
|
||||
*/
|
||||
function parseConfig(
|
||||
json: any,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
configFileName: string,
|
||||
resolutionStack: Path[],
|
||||
errors: Diagnostic[],
|
||||
): ParsedTsconfig {
|
||||
|
||||
basePath = normalizeSlashes(basePath);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
|
||||
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> ")));
|
||||
return { include: undefined, exclude: undefined, files: undefined, options: {}, compileOnSave: undefined };
|
||||
}
|
||||
|
||||
if (hasProperty(json, "excludes")) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
|
||||
let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
|
||||
let include: string[] | undefined = json.include, exclude: string[] | undefined = json.exclude, files: string[] | undefined = json.files;
|
||||
let compileOnSave: boolean | undefined = json.compileOnSave;
|
||||
|
||||
if (json.extends) {
|
||||
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
|
||||
resolutionStack = resolutionStack.concat([resolvedPath]);
|
||||
const base = getExtendedConfig(json.extends, host, basePath, getCanonicalFileName, resolutionStack, errors);
|
||||
if (base) {
|
||||
include = include || base.include;
|
||||
exclude = exclude || base.exclude;
|
||||
files = files || base.files;
|
||||
if (compileOnSave === undefined) {
|
||||
compileOnSave = base.compileOnSave;
|
||||
}
|
||||
options = assign({}, base.options, options);
|
||||
}
|
||||
}
|
||||
|
||||
return { include, exclude, files, options, compileOnSave };
|
||||
}
|
||||
|
||||
function getExtendedConfig(
|
||||
extended: any, // Usually a string.
|
||||
host: ts.ParseConfigHost,
|
||||
basePath: string,
|
||||
getCanonicalFileName: (fileName: string) => string,
|
||||
resolutionStack: Path[],
|
||||
errors: Diagnostic[],
|
||||
): ParsedTsconfig | undefined {
|
||||
if (typeof extended !== "string") {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
|
||||
return undefined;
|
||||
}
|
||||
|
||||
extended = normalizeSlashes(extended);
|
||||
|
||||
// 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 (!(isRootedDiskPath(extended) || startsWith(extended, "./") || startsWith(extended, "../"))) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extended));
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let extendedConfigPath = toPath(extended, basePath, getCanonicalFileName);
|
||||
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) {
|
||||
extendedConfigPath = extendedConfigPath + ".json" as Path;
|
||||
if (!host.fileExists(extendedConfigPath)) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, extended));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const extendedResult = readConfigFile(extendedConfigPath, path => host.readFile(path));
|
||||
if (extendedResult.error) {
|
||||
errors.push(extendedResult.error);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const extendedDirname = getDirectoryPath(extendedConfigPath);
|
||||
const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName);
|
||||
const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
|
||||
const { include, exclude, files, options, compileOnSave } = parseConfig(extendedResult.config, host, extendedDirname, getBaseFileName(extendedConfigPath), resolutionStack, errors);
|
||||
return { include: map(include, updatePath), exclude: map(exclude, updatePath), files: map(files, updatePath), compileOnSave, options };
|
||||
}
|
||||
|
||||
export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean {
|
||||
if (!hasProperty(jsonOption, compileOnSaveCommandLineOption.name)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1662,4 +1706,4 @@ namespace ts {
|
||||
function caseInsensitiveKeyMapper(key: string) {
|
||||
return key.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
const isEmittedNode = node.kind !== SyntaxKind.NotEmittedStatement;
|
||||
const skipLeadingComments = pos < 0 || (emitFlags & EmitFlags.NoLeadingComments) !== 0;
|
||||
const skipTrailingComments = end < 0 || (emitFlags & EmitFlags.NoTrailingComments) !== 0;
|
||||
// We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation.
|
||||
// It is expensive to walk entire tree just to set one kind of node to have no comments.
|
||||
const skipLeadingComments = pos < 0 || (emitFlags & EmitFlags.NoLeadingComments) !== 0 || node.kind === SyntaxKind.JsxText;
|
||||
const skipTrailingComments = end < 0 || (emitFlags & EmitFlags.NoTrailingComments) !== 0 || node.kind === SyntaxKind.JsxText;
|
||||
|
||||
// Emit leading comments if the position is not synthesized and the node
|
||||
// has not opted out from emitting leading comments.
|
||||
|
||||
+39
-2
@@ -230,6 +230,8 @@ namespace ts {
|
||||
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
|
||||
* At that point findAncestor returns undefined.
|
||||
*/
|
||||
export function findAncestor<T extends Node>(node: Node, callback: (element: Node) => element is T): T | undefined;
|
||||
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node | undefined;
|
||||
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node {
|
||||
while (node) {
|
||||
const result = callback(node);
|
||||
@@ -490,6 +492,35 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an array. If the mapped value is an array, it is spread into the result.
|
||||
* Avoids allocation if all elements map to themselves.
|
||||
*
|
||||
* @param array The array to map.
|
||||
* @param mapfn The callback used to map the result into one or more values.
|
||||
*/
|
||||
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | T[]): T[] {
|
||||
let result: T[];
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const item = array[i];
|
||||
const 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the first matching span of elements and returns a tuple of the first span
|
||||
* and the remaining elements.
|
||||
@@ -1733,6 +1764,11 @@ namespace ts {
|
||||
return str.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function removePrefix(str: string, prefix: string): string {
|
||||
return startsWith(str, prefix) ? str.substr(prefix.length) : str;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function endsWith(str: string, suffix: string): boolean {
|
||||
const expectedPos = str.length - suffix.length;
|
||||
@@ -1747,7 +1783,8 @@ namespace ts {
|
||||
return path.length > extension.length && endsWith(path, extension);
|
||||
}
|
||||
|
||||
export function fileExtensionIsAny(path: string, extensions: string[]): boolean {
|
||||
/* @internal */
|
||||
export function fileExtensionIsOneOf(path: string, extensions: string[]): boolean {
|
||||
for (const extension of extensions) {
|
||||
if (fileExtensionIs(path, extension)) {
|
||||
return true;
|
||||
@@ -1947,7 +1984,7 @@ namespace ts {
|
||||
for (const current of files) {
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if (extensions && !fileExtensionIsAny(name, extensions)) continue;
|
||||
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
|
||||
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
|
||||
if (!includeFileRegexes) {
|
||||
results[0].push(name);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace ts {
|
||||
let errorNameNode: DeclarationName;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
let noDeclare: boolean;
|
||||
let needsDeclare = true;
|
||||
|
||||
let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[];
|
||||
@@ -110,11 +110,11 @@ namespace ts {
|
||||
|
||||
resultHasExternalModuleIndicator = false;
|
||||
if (!isBundledEmit || !isExternalModule(sourceFile)) {
|
||||
noDeclare = false;
|
||||
needsDeclare = true;
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
else if (isExternalModule(sourceFile)) {
|
||||
noDeclare = true;
|
||||
needsDeclare = false;
|
||||
write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
@@ -190,7 +190,7 @@ namespace ts {
|
||||
const writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
|
||||
writer.trackSymbol = trackSymbol;
|
||||
writer.reportInaccessibleThisError = reportInaccessibleThisError;
|
||||
writer.reportIllegalExtends = reportIllegalExtends;
|
||||
writer.reportPrivateInBaseOfClassExpression = reportPrivateInBaseOfClassExpression;
|
||||
writer.writeKeyword = writer.write;
|
||||
writer.writeOperator = writer.write;
|
||||
writer.writePunctuation = writer.write;
|
||||
@@ -314,11 +314,11 @@ namespace ts {
|
||||
recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
|
||||
}
|
||||
|
||||
function reportIllegalExtends() {
|
||||
function reportPrivateInBaseOfClassExpression(propertyName: string) {
|
||||
if (errorNameNode) {
|
||||
reportedDeclarationError = true;
|
||||
emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced,
|
||||
declarationNameToString(errorNameNode)));
|
||||
emitterDiagnostics.add(
|
||||
createDiagnosticForNode(errorNameNode, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,9 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
errorNameNode = declaration.name;
|
||||
const format = TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue |
|
||||
const format = TypeFormatFlags.UseTypeOfFunction |
|
||||
TypeFormatFlags.WriteClassExpressionAsTypeLiteral |
|
||||
TypeFormatFlags.UseTypeAliasValue |
|
||||
(shouldUseResolverType ? TypeFormatFlags.AddUndefined : 0);
|
||||
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer);
|
||||
errorNameNode = undefined;
|
||||
@@ -360,7 +362,11 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
errorNameNode = signature.name;
|
||||
resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
resolver.writeReturnTypeOfSignatureDeclaration(
|
||||
signature,
|
||||
enclosingDeclaration,
|
||||
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
|
||||
writer);
|
||||
errorNameNode = undefined;
|
||||
}
|
||||
}
|
||||
@@ -594,12 +600,11 @@ namespace ts {
|
||||
emitLines(node.statements);
|
||||
}
|
||||
|
||||
// Return a temp variable name to be used in `export default` statements.
|
||||
// Return a temp variable name to be used in `export default`/`export class ... extends` statements.
|
||||
// The temp name will be of the form _default_counter.
|
||||
// Note that export default is only allowed at most once in a module, so we
|
||||
// do not need to keep track of created temp names.
|
||||
function getExportDefaultTempVariableName(): string {
|
||||
const baseName = "_default";
|
||||
function getExportTempVariableName(baseName: string): string {
|
||||
if (!currentIdentifiers.has(baseName)) {
|
||||
return baseName;
|
||||
}
|
||||
@@ -613,24 +618,35 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitTempVariableDeclaration(expr: Expression, baseName: string, diagnostic: SymbolAccessibilityDiagnostic, needsDeclare: boolean): string {
|
||||
const tempVarName = getExportTempVariableName(baseName);
|
||||
if (needsDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
write("const ");
|
||||
write(tempVarName);
|
||||
write(": ");
|
||||
writer.getSymbolAccessibilityDiagnostic = () => diagnostic;
|
||||
resolver.writeTypeOfExpression(
|
||||
expr,
|
||||
enclosingDeclaration,
|
||||
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
|
||||
writer);
|
||||
write(";");
|
||||
writeLine();
|
||||
return tempVarName;
|
||||
}
|
||||
|
||||
function emitExportAssignment(node: ExportAssignment) {
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
writeTextOfNode(currentText, node.expression);
|
||||
}
|
||||
else {
|
||||
// Expression
|
||||
const tempVarName = getExportDefaultTempVariableName();
|
||||
if (!noDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
write("var ");
|
||||
write(tempVarName);
|
||||
write(": ");
|
||||
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
|
||||
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
write(";");
|
||||
writeLine();
|
||||
const tempVarName = emitTempVariableDeclaration(node.expression, "_default", {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
}, needsDeclare);
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
write(tempVarName);
|
||||
}
|
||||
@@ -644,13 +660,6 @@ namespace ts {
|
||||
// write each of these declarations asynchronously
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
}
|
||||
|
||||
function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function isModuleElementVisible(node: Declaration) {
|
||||
@@ -729,7 +738,7 @@ namespace ts {
|
||||
if (modifiers & ModifierFlags.Default) {
|
||||
write("default ");
|
||||
}
|
||||
else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) {
|
||||
else if (node.kind !== SyntaxKind.InterfaceDeclaration && needsDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
}
|
||||
@@ -985,7 +994,7 @@ namespace ts {
|
||||
const enumMemberValue = resolver.getConstantValue(node);
|
||||
if (enumMemberValue !== undefined) {
|
||||
write(" = ");
|
||||
write(enumMemberValue.toString());
|
||||
write(getTextOfConstantValue(enumMemberValue));
|
||||
}
|
||||
write(",");
|
||||
writeLine();
|
||||
@@ -1097,7 +1106,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitHeritageClause(className: Identifier, typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) {
|
||||
function emitHeritageClause(typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) {
|
||||
if (typeReferences) {
|
||||
write(isImplementsList ? " implements " : " extends ");
|
||||
emitCommaList(typeReferences, emitTypeOfTypeReference);
|
||||
@@ -1110,12 +1119,6 @@ namespace ts {
|
||||
else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) {
|
||||
write("null");
|
||||
}
|
||||
else {
|
||||
writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError;
|
||||
errorNameNode = className;
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
errorNameNode = undefined;
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
@@ -1134,7 +1137,7 @@ namespace ts {
|
||||
return {
|
||||
diagnosticMessage,
|
||||
errorNode: node,
|
||||
typeName: (<Declaration>node.parent.parent).name
|
||||
typeName: getNameOfDeclaration(node.parent.parent)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1151,23 +1154,43 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
let tempVarName: string;
|
||||
if (baseTypeNode && !isEntityNameExpression(baseTypeNode.expression)) {
|
||||
tempVarName = baseTypeNode.expression.kind === SyntaxKind.NullKeyword ?
|
||||
"null" :
|
||||
emitTempVariableDeclaration(baseTypeNode.expression, `${node.name.text}_base`, {
|
||||
diagnosticMessage: Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
|
||||
errorNode: baseTypeNode,
|
||||
typeName: node.name
|
||||
}, !findAncestor(node, n => n.kind === SyntaxKind.ModuleDeclaration));
|
||||
}
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (hasModifier(node, ModifierFlags.Abstract)) {
|
||||
write("abstract ");
|
||||
}
|
||||
|
||||
write("class ");
|
||||
writeTextOfNode(currentText, node.name);
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
node.name;
|
||||
emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false);
|
||||
if (!isEntityNameExpression(baseTypeNode.expression)) {
|
||||
write(" extends ");
|
||||
write(tempVarName);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
write("<");
|
||||
emitCommaList(baseTypeNode.typeArguments, emitType);
|
||||
write(">");
|
||||
}
|
||||
}
|
||||
else {
|
||||
emitHeritageClause([baseTypeNode], /*isImplementsList*/ false);
|
||||
}
|
||||
}
|
||||
emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
|
||||
emitHeritageClause(getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
@@ -1189,7 +1212,7 @@ namespace ts {
|
||||
emitTypeParameters(node.typeParameters);
|
||||
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
|
||||
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
|
||||
emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
}
|
||||
write(" {");
|
||||
writeLine();
|
||||
@@ -1253,7 +1276,9 @@ namespace ts {
|
||||
Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
|
||||
}
|
||||
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
|
||||
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) {
|
||||
// The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all.
|
||||
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) {
|
||||
// TODO(jfreeman): Deal with computed properties in error reporting.
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
@@ -1262,7 +1287,7 @@ namespace ts {
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.Parameter) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -1488,6 +1513,11 @@ namespace ts {
|
||||
write("[");
|
||||
}
|
||||
else {
|
||||
if (node.kind === SyntaxKind.Constructor && hasModifier(node, ModifierFlags.Private)) {
|
||||
write("();");
|
||||
writeLine();
|
||||
return;
|
||||
}
|
||||
// Construct signature or constructor type write new Signature
|
||||
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
|
||||
write("new ");
|
||||
@@ -1820,7 +1850,7 @@ namespace ts {
|
||||
function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean, emitOnlyDtsFiles: boolean): boolean {
|
||||
let declFileName: string;
|
||||
let addedBundledEmitReference = false;
|
||||
if (isDeclarationFile(referencedFile)) {
|
||||
if (referencedFile.isDeclarationFile) {
|
||||
// Declaration file, use declaration file name
|
||||
declFileName = referencedFile.fileName;
|
||||
}
|
||||
|
||||
@@ -635,6 +635,10 @@
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot re-export a type when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1205
|
||||
},
|
||||
"Decorators are not valid here.": {
|
||||
"category": "Error",
|
||||
"code": 1206
|
||||
@@ -1080,7 +1084,7 @@
|
||||
"category": "Error",
|
||||
"code": 2345
|
||||
},
|
||||
"Supplied parameters do not match any signature of call target.": {
|
||||
"Call target does not contain any signatures.": {
|
||||
"category": "Error",
|
||||
"code": 2346
|
||||
},
|
||||
@@ -1860,6 +1864,38 @@
|
||||
"category": "Error",
|
||||
"code": 2550
|
||||
},
|
||||
"Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?": {
|
||||
"category": "Error",
|
||||
"code": 2551
|
||||
},
|
||||
"Cannot find name '{0}'. Did you mean '{1}'?": {
|
||||
"category": "Error",
|
||||
"code": 2552
|
||||
},
|
||||
"Computed values are not permitted in an enum with string valued members.": {
|
||||
"category": "Error",
|
||||
"code": 2553
|
||||
},
|
||||
"Expected {0} arguments, but got {1}.": {
|
||||
"category": "Error",
|
||||
"code": 2554
|
||||
},
|
||||
"Expected at least {0} arguments, but got {1}.": {
|
||||
"category": "Error",
|
||||
"code": 2555
|
||||
},
|
||||
"Expected {0} arguments, but got a minimum of {1}.": {
|
||||
"category": "Error",
|
||||
"code": 2556
|
||||
},
|
||||
"Expected at least {0} arguments, but got a minimum of {1}.": {
|
||||
"category": "Error",
|
||||
"code": 2557
|
||||
},
|
||||
"Expected {0} type arguments, but got {1}.": {
|
||||
"category": "Error",
|
||||
"code": 2558
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -2441,9 +2477,9 @@
|
||||
"category": "Error",
|
||||
"code": 4092
|
||||
},
|
||||
"'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced.": {
|
||||
"Property '{0}' of exported class expression may not be private or protected.": {
|
||||
"category": "Error",
|
||||
"code": 4093
|
||||
"code": 4094
|
||||
},
|
||||
|
||||
"The current host does not support the '{0}' option.": {
|
||||
@@ -3046,6 +3082,10 @@
|
||||
"category": "Message",
|
||||
"code": 6136
|
||||
},
|
||||
"Cannot import type declaration files. Consider importing '{0}' instead of '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 6137
|
||||
},
|
||||
"Property '{0}' is declared but never used.": {
|
||||
"category": "Error",
|
||||
"code": 6138
|
||||
@@ -3565,7 +3605,19 @@
|
||||
"category": "Message",
|
||||
"code": 90021
|
||||
},
|
||||
"Change spelling to '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 90022
|
||||
},
|
||||
|
||||
"Convert function to an ES2015 class": {
|
||||
"category": "Message",
|
||||
"code": 95001
|
||||
},
|
||||
"Convert function '{0}' to class": {
|
||||
"category": "Message",
|
||||
"code": 95002
|
||||
},
|
||||
|
||||
"Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
+94
-21
@@ -153,7 +153,7 @@ namespace ts {
|
||||
for (let i = 0; i < numNodes; i++) {
|
||||
const currentNode = bundle ? bundle.sourceFiles[i] : node;
|
||||
const sourceFile = isSourceFile(currentNode) ? currentNode : currentSourceFile;
|
||||
const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined);
|
||||
const shouldSkip = compilerOptions.noEmitHelpers || getExternalHelpersModuleName(sourceFile) !== undefined;
|
||||
const shouldBundle = isSourceFile(currentNode) && !isOwnFileEmit;
|
||||
const helpers = getEmitHelpers(currentNode);
|
||||
if (helpers) {
|
||||
@@ -200,7 +200,9 @@ namespace ts {
|
||||
onSetSourceFile,
|
||||
substituteNode,
|
||||
onBeforeEmitNodeArray,
|
||||
onAfterEmitNodeArray
|
||||
onAfterEmitNodeArray,
|
||||
onBeforeEmitToken,
|
||||
onAfterEmitToken
|
||||
} = handlers;
|
||||
|
||||
const newLine = getNewLineCharacter(printerOptions);
|
||||
@@ -212,7 +214,7 @@ namespace ts {
|
||||
emitLeadingCommentsOfPosition,
|
||||
} = comments;
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
let currentSourceFile: SourceFile | undefined;
|
||||
let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes.
|
||||
let autoGeneratedIdToGeneratedName: string[]; // Map of generated names for temp and loop variables.
|
||||
let generatedNames: Map<string>; // Set of names generated by the NameGenerator.
|
||||
@@ -264,7 +266,12 @@ namespace ts {
|
||||
return endPrint();
|
||||
}
|
||||
|
||||
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter) {
|
||||
/**
|
||||
* If `sourceFile` is `undefined`, `node` must be a synthesized `TypeNode`.
|
||||
*/
|
||||
function writeNode(hint: EmitHint, node: TypeNode, sourceFile: undefined, output: EmitTextWriter): void;
|
||||
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter): void;
|
||||
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, output: EmitTextWriter) {
|
||||
const previousWriter = writer;
|
||||
setWriter(output);
|
||||
print(hint, node, sourceFile);
|
||||
@@ -305,8 +312,10 @@ namespace ts {
|
||||
return text;
|
||||
}
|
||||
|
||||
function print(hint: EmitHint, node: Node, sourceFile: SourceFile) {
|
||||
setSourceFile(sourceFile);
|
||||
function print(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined) {
|
||||
if (sourceFile) {
|
||||
setSourceFile(sourceFile);
|
||||
}
|
||||
pipelineEmitWithNotification(hint, node);
|
||||
}
|
||||
|
||||
@@ -399,7 +408,7 @@ namespace ts {
|
||||
// Strict mode reserved words
|
||||
// Contextual keywords
|
||||
if (isKeyword(kind)) {
|
||||
writeTokenText(kind);
|
||||
writeTokenNode(node);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -562,6 +571,8 @@ namespace ts {
|
||||
return emitModuleBlock(<ModuleBlock>node);
|
||||
case SyntaxKind.CaseBlock:
|
||||
return emitCaseBlock(<CaseBlock>node);
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
return emitNamespaceExportDeclaration(<NamespaceExportDeclaration>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return emitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
@@ -638,7 +649,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isToken(node)) {
|
||||
writeTokenText(kind);
|
||||
writeTokenNode(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -666,7 +677,7 @@ namespace ts {
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
writeTokenText(kind);
|
||||
writeTokenNode(node);
|
||||
return;
|
||||
|
||||
// Expressions
|
||||
@@ -734,6 +745,9 @@ namespace ts {
|
||||
// Transformation nodes
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
return emitPartiallyEmittedExpression(<PartiallyEmittedExpression>node);
|
||||
|
||||
case SyntaxKind.CommaListExpression:
|
||||
return emitCommaList(<CommaListExpression>node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,6 +793,7 @@ namespace ts {
|
||||
|
||||
function emitIdentifier(node: Identifier) {
|
||||
write(getTextOfNode(node, /*includeTrivia*/ false));
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -813,6 +828,7 @@ namespace ts {
|
||||
function emitTypeParameter(node: TypeParameterDeclaration) {
|
||||
emit(node.name);
|
||||
emitWithPrefix(" extends ", node.constraint);
|
||||
emitWithPrefix(" = ", node.default);
|
||||
}
|
||||
|
||||
function emitParameter(node: ParameterDeclaration) {
|
||||
@@ -847,6 +863,7 @@ namespace ts {
|
||||
emitDecorators(node, node.decorators);
|
||||
emitModifiers(node, node.modifiers);
|
||||
emit(node.name);
|
||||
writeIfPresent(node.questionToken, "?");
|
||||
emitWithPrefix(": ", node.type);
|
||||
emitExpressionWithPrefix(" = ", node.initializer);
|
||||
write(";");
|
||||
@@ -868,6 +885,7 @@ namespace ts {
|
||||
emitModifiers(node, node.modifiers);
|
||||
writeIfPresent(node.asteriskToken, "*");
|
||||
emit(node.name);
|
||||
writeIfPresent(node.questionToken, "?");
|
||||
emitSignatureAndBody(node, emitSignatureHead);
|
||||
}
|
||||
|
||||
@@ -953,7 +971,10 @@ namespace ts {
|
||||
|
||||
function emitTypeLiteral(node: TypeLiteralNode) {
|
||||
write("{");
|
||||
emitList(node, node.members, ListFormat.TypeLiteralMembers);
|
||||
// If the literal is empty, do not add spaces between braces.
|
||||
if (node.members.length > 0) {
|
||||
emitList(node, node.members, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers);
|
||||
}
|
||||
write("}");
|
||||
}
|
||||
|
||||
@@ -1000,9 +1021,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitMappedType(node: MappedTypeNode) {
|
||||
const emitFlags = getEmitFlags(node);
|
||||
write("{");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
if (emitFlags & EmitFlags.SingleLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
}
|
||||
writeIfPresent(node.readonlyToken, "readonly ");
|
||||
write("[");
|
||||
emit(node.typeParameter.name);
|
||||
@@ -1013,8 +1040,13 @@ namespace ts {
|
||||
write(": ");
|
||||
emit(node.type);
|
||||
write(";");
|
||||
writeLine();
|
||||
decreaseIndent();
|
||||
if (emitFlags & EmitFlags.SingleLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
decreaseIndent();
|
||||
}
|
||||
write("}");
|
||||
}
|
||||
|
||||
@@ -1129,7 +1161,7 @@ namespace ts {
|
||||
// check if constant enum value is integer
|
||||
const constantValue = getConstantValue(expression);
|
||||
// isFinite handles cases when constantValue is undefined
|
||||
return isFinite(constantValue)
|
||||
return typeof constantValue === "number" && isFinite(constantValue)
|
||||
&& Math.floor(constantValue) === constantValue
|
||||
&& printerOptions.removeComments;
|
||||
}
|
||||
@@ -1235,7 +1267,7 @@ namespace ts {
|
||||
const operand = node.operand;
|
||||
return operand.kind === SyntaxKind.PrefixUnaryExpression
|
||||
&& ((node.operator === SyntaxKind.PlusToken && ((<PrefixUnaryExpression>operand).operator === SyntaxKind.PlusToken || (<PrefixUnaryExpression>operand).operator === SyntaxKind.PlusPlusToken))
|
||||
|| (node.operator === SyntaxKind.MinusToken && ((<PrefixUnaryExpression>operand).operator === SyntaxKind.MinusToken || (<PrefixUnaryExpression>operand).operator === SyntaxKind.MinusMinusToken)));
|
||||
|| (node.operator === SyntaxKind.MinusToken && ((<PrefixUnaryExpression>operand).operator === SyntaxKind.MinusToken || (<PrefixUnaryExpression>operand).operator === SyntaxKind.MinusMinusToken)));
|
||||
}
|
||||
|
||||
function emitPostfixUnaryExpression(node: PostfixUnaryExpression) {
|
||||
@@ -1250,7 +1282,7 @@ namespace ts {
|
||||
|
||||
emitExpression(node.left);
|
||||
increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined);
|
||||
writeTokenText(node.operatorToken.kind);
|
||||
writeTokenNode(node.operatorToken);
|
||||
increaseIndentIf(indentAfterOperator, " ");
|
||||
emitExpression(node.right);
|
||||
decreaseIndentIf(indentBeforeOperator, indentAfterOperator);
|
||||
@@ -1857,6 +1889,12 @@ namespace ts {
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitNamespaceExportDeclaration(node: NamespaceExportDeclaration) {
|
||||
write("export as namespace ");
|
||||
emit(node.name);
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitNamedExports(node: NamedExports) {
|
||||
emitNamedImportsOrExports(node);
|
||||
}
|
||||
@@ -1994,6 +2032,22 @@ namespace ts {
|
||||
rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)
|
||||
);
|
||||
|
||||
// e.g:
|
||||
// case 0: // Zero
|
||||
// case 1: // One
|
||||
// case 2: // two
|
||||
// return "hi";
|
||||
// If there is no statements, emitNodeWithComments of the parentNode which is caseClause will take care of trailing comment.
|
||||
// So in example above, comment "// Zero" and "// One" will be emit in emitTrailingComments in emitNodeWithComments.
|
||||
// However, for "case 2", because parentNode which is caseClause has an "end" property to be end of the statements (in this case return statement)
|
||||
// comment "// two" will not be emitted in emitNodeWithComments.
|
||||
// Therefore, we have to do the check here to emit such comment.
|
||||
if (statements.length > 0) {
|
||||
// We use emitTrailingCommentsOfPosition instead of emitLeadingCommentsOfPosition because leading comments is defined as comments before the node after newline character separating it from previous line
|
||||
// Note: we can't use parentNode.end as such position includes statements.
|
||||
emitTrailingCommentsOfPosition(statements.pos);
|
||||
}
|
||||
|
||||
if (emitAsSingleStatement) {
|
||||
write(" ");
|
||||
emit(statements[0]);
|
||||
@@ -2102,6 +2156,10 @@ namespace ts {
|
||||
emitExpression(node.expression);
|
||||
}
|
||||
|
||||
function emitCommaList(node: CommaListExpression) {
|
||||
emitExpressionList(node, node.elements, ListFormat.CommaListElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits any prologue directives at the start of a Statement list, returning the
|
||||
* number of prologue directives written to the output.
|
||||
@@ -2426,6 +2484,16 @@ namespace ts {
|
||||
: writeTokenText(token, pos);
|
||||
}
|
||||
|
||||
function writeTokenNode(node: Node) {
|
||||
if (onBeforeEmitToken) {
|
||||
onBeforeEmitToken(node);
|
||||
}
|
||||
writeTokenText(node.kind);
|
||||
if (onAfterEmitToken) {
|
||||
onAfterEmitToken(node);
|
||||
}
|
||||
}
|
||||
|
||||
function writeTokenText(token: SyntaxKind, pos?: number) {
|
||||
const tokenString = tokenToString(token);
|
||||
write(tokenString);
|
||||
@@ -2631,7 +2699,9 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
||||
const textSourceNode = (<StringLiteral>node).textSourceNode;
|
||||
if (isIdentifier(textSourceNode)) {
|
||||
return "\"" + escapeNonAsciiCharacters(escapeString(getTextOfNode(textSourceNode))) + "\"";
|
||||
return getEmitFlags(node) & EmitFlags.NoAsciiEscaping ?
|
||||
`"${escapeString(getTextOfNode(textSourceNode))}"` :
|
||||
`"${escapeNonAsciiString(getTextOfNode(textSourceNode))}"`;
|
||||
}
|
||||
else {
|
||||
return getLiteralTextOfNode(textSourceNode);
|
||||
@@ -2897,9 +2967,9 @@ namespace ts {
|
||||
|
||||
// Flags enum to track count of temp variables and a few dedicated names
|
||||
const enum TempFlags {
|
||||
Auto = 0x00000000, // No preferred name
|
||||
Auto = 0x00000000, // No preferred name
|
||||
CountMask = 0x0FFFFFFF, // Temp variable counter
|
||||
_i = 0x10000000, // Use/preference flag for '_i'
|
||||
_i = 0x10000000, // Use/preference flag for '_i'
|
||||
}
|
||||
|
||||
const enum ListFormat {
|
||||
@@ -2944,7 +3014,9 @@ namespace ts {
|
||||
// Precomputed Formats
|
||||
Modifiers = SingleLine | SpaceBetweenSiblings,
|
||||
HeritageClauses = SingleLine | SpaceBetweenSiblings,
|
||||
TypeLiteralMembers = MultiLine | Indented,
|
||||
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings | Indented,
|
||||
MultiLineTypeLiteralMembers = MultiLine | Indented,
|
||||
|
||||
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented,
|
||||
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
|
||||
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
|
||||
@@ -2952,6 +3024,7 @@ namespace ts {
|
||||
ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings,
|
||||
ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces,
|
||||
ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets,
|
||||
CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
|
||||
CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis,
|
||||
NewExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis | OptionalIfUndefined,
|
||||
TemplateExpressionSpans = SingleLine | NoInterveningComments,
|
||||
|
||||
+520
-400
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
/// <reference path="diagnosticInformationMap.generated.ts" />
|
||||
|
||||
namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
|
||||
export function trace(host: ModuleResolutionHost): void {
|
||||
@@ -15,6 +14,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Array that is only intended to be pushed to, never read. */
|
||||
/* @internal */
|
||||
export interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
@@ -47,13 +47,11 @@ namespace ts {
|
||||
return resolved.path;
|
||||
}
|
||||
|
||||
/** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */
|
||||
function resolvedModuleFromResolved({ path, extension }: Resolved, isExternalLibraryImport: boolean): ResolvedModuleFull {
|
||||
return { resolvedFileName: path, extension, isExternalLibraryImport };
|
||||
}
|
||||
|
||||
function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations {
|
||||
return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations };
|
||||
return {
|
||||
resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport },
|
||||
failedLookupLocations
|
||||
};
|
||||
}
|
||||
|
||||
export function moduleHasNonRelativeName(moduleName: string): boolean {
|
||||
@@ -442,6 +440,8 @@ namespace ts {
|
||||
case ModuleResolutionKind.Classic:
|
||||
result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache);
|
||||
break;
|
||||
default:
|
||||
Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
|
||||
}
|
||||
|
||||
if (perFolderCache) {
|
||||
@@ -653,11 +653,13 @@ namespace ts {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
|
||||
}
|
||||
// A path mapping may have a ".ts" extension; in contrast to an import, which should omit it.
|
||||
const tsExtension = tryGetExtensionFromPath(candidate);
|
||||
if (tsExtension !== undefined) {
|
||||
// A path mapping may have an extension, in contrast to an import, which should omit it.
|
||||
const extension = tryGetExtensionFromPath(candidate);
|
||||
if (extension !== undefined) {
|
||||
const path = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
return path && { path, extension: tsExtension };
|
||||
if (path !== undefined) {
|
||||
return { path, extension };
|
||||
}
|
||||
}
|
||||
|
||||
return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);
|
||||
@@ -675,12 +677,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations {
|
||||
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false);
|
||||
return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
export function nodeModuleNameResolverWorker(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, jsOnly = false): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
export function resolveJavaScriptModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string {
|
||||
const { resolvedModule, failedLookupLocations } =
|
||||
nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true);
|
||||
if (!resolvedModule) {
|
||||
throw new Error(`Could not resolve JS module ${moduleName} starting at ${initialDir}. Looked in: ${failedLookupLocations.join(", ")}`);
|
||||
}
|
||||
return resolvedModule.resolvedFileName;
|
||||
}
|
||||
|
||||
function nodeModuleNameResolverWorker(moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, jsOnly: boolean): ResolvedModuleWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
@@ -958,10 +973,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/** Double underscores are used in DefinitelyTyped to delimit scoped packages. */
|
||||
const mangledScopedPackageSeparator = "__";
|
||||
|
||||
/** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */
|
||||
function mangleScopedPackage(moduleName: string, state: ModuleResolutionState): string {
|
||||
if (startsWith(moduleName, "@")) {
|
||||
const replaceSlash = moduleName.replace(ts.directorySeparator, "__");
|
||||
const replaceSlash = moduleName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
|
||||
if (replaceSlash !== moduleName) {
|
||||
const mangled = replaceSlash.slice(1); // Take off the "@"
|
||||
if (state.traceEnabled) {
|
||||
@@ -973,6 +991,17 @@ namespace ts {
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getPackageNameFromAtTypesDirectory(mangledName: string): string {
|
||||
const withoutAtTypePrefix = removePrefix(mangledName, "@types/");
|
||||
if (withoutAtTypePrefix !== mangledName) {
|
||||
return withoutAtTypePrefix.indexOf("__") !== -1 ?
|
||||
"@" + withoutAtTypePrefix.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
|
||||
withoutAtTypePrefix;
|
||||
}
|
||||
return mangledName;
|
||||
}
|
||||
|
||||
function tryFindNonRelativeModuleNameInCache(cache: PerModuleNameCache | undefined, moduleName: string, containingDirectory: string, traceEnabled: boolean, host: ModuleResolutionHost): SearchResult<Resolved> {
|
||||
const result = cache && cache.get(containingDirectory);
|
||||
if (result) {
|
||||
|
||||
+13
-8
@@ -23,19 +23,19 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
|
||||
function visitNode<T>(cbNode: (node: Node) => T, node?: Node): T | undefined {
|
||||
if (node) {
|
||||
return cbNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
|
||||
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes?: Node[]): T | undefined {
|
||||
if (nodes) {
|
||||
return cbNodes(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
|
||||
function visitEachNode<T>(cbNode: (node: Node) => T, nodes?: Node[]): T | undefined {
|
||||
if (nodes) {
|
||||
for (const node of nodes) {
|
||||
const result = cbNode(node);
|
||||
@@ -56,14 +56,14 @@ namespace ts {
|
||||
* @param cbNode a callback to be invoked for all child nodes
|
||||
* @param cbNodeArray a callback to be invoked for embedded array
|
||||
*/
|
||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
|
||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray
|
||||
// callback parameters, but that causes a closure allocation for each invocation with noticeable effects
|
||||
// on performance.
|
||||
const visitNodes: (cb: ((node: Node) => T) | ((node: Node[]) => T), nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
|
||||
const visitNodes: (cb: ((node?: Node) => T | undefined) | ((node?: Node[]) => T | undefined), nodes?: Node[]) => T | undefined = cbNodeArray ? visitNodeArray : visitEachNode;
|
||||
const cbNodes = cbNodeArray || cbNode;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -368,6 +368,8 @@ namespace ts {
|
||||
return visitNode(cbNode, (<ExternalModuleReference>node).expression);
|
||||
case SyntaxKind.MissingDeclaration:
|
||||
return visitNodes(cbNodes, node.decorators);
|
||||
case SyntaxKind.CommaListExpression:
|
||||
return visitNodes(cbNodes, (<CommaListExpression>node).elements);
|
||||
|
||||
case SyntaxKind.JsxElement:
|
||||
return visitNode(cbNode, (<JsxElement>node).openingElement) ||
|
||||
@@ -1244,12 +1246,12 @@ namespace ts {
|
||||
if (token() === SyntaxKind.ExportKeyword) {
|
||||
nextToken();
|
||||
if (token() === SyntaxKind.DefaultKeyword) {
|
||||
return lookAhead(nextTokenIsClassOrFunctionOrAsync);
|
||||
return lookAhead(nextTokenCanFollowDefaultKeyword);
|
||||
}
|
||||
return token() !== SyntaxKind.AsteriskToken && token() !== SyntaxKind.AsKeyword && token() !== SyntaxKind.OpenBraceToken && canFollowModifier();
|
||||
}
|
||||
if (token() === SyntaxKind.DefaultKeyword) {
|
||||
return nextTokenIsClassOrFunctionOrAsync();
|
||||
return nextTokenCanFollowDefaultKeyword();
|
||||
}
|
||||
if (token() === SyntaxKind.StaticKeyword) {
|
||||
nextToken();
|
||||
@@ -1271,9 +1273,10 @@ namespace ts {
|
||||
|| isLiteralPropertyName();
|
||||
}
|
||||
|
||||
function nextTokenIsClassOrFunctionOrAsync(): boolean {
|
||||
function nextTokenCanFollowDefaultKeyword(): boolean {
|
||||
nextToken();
|
||||
return token() === SyntaxKind.ClassKeyword || token() === SyntaxKind.FunctionKeyword ||
|
||||
token() === SyntaxKind.InterfaceKeyword ||
|
||||
(token() === SyntaxKind.AbstractKeyword && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
|
||||
(token() === SyntaxKind.AsyncKeyword && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
|
||||
}
|
||||
@@ -6519,6 +6522,8 @@ namespace ts {
|
||||
case "augments":
|
||||
tag = parseAugmentsTag(atToken, tagName);
|
||||
break;
|
||||
case "arg":
|
||||
case "argument":
|
||||
case "param":
|
||||
tag = parseParamTag(atToken, tagName);
|
||||
break;
|
||||
|
||||
+161
-41
@@ -241,6 +241,101 @@ namespace ts {
|
||||
return output;
|
||||
}
|
||||
|
||||
const redForegroundEscapeSequence = "\u001b[91m";
|
||||
const yellowForegroundEscapeSequence = "\u001b[93m";
|
||||
const blueForegroundEscapeSequence = "\u001b[93m";
|
||||
const gutterStyleSequence = "\u001b[100;30m";
|
||||
const gutterSeparator = " ";
|
||||
const resetEscapeSequence = "\u001b[0m";
|
||||
const ellipsis = "...";
|
||||
function getCategoryFormat(category: DiagnosticCategory): string {
|
||||
switch (category) {
|
||||
case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence;
|
||||
case DiagnosticCategory.Error: return redForegroundEscapeSequence;
|
||||
case DiagnosticCategory.Message: return blueForegroundEscapeSequence;
|
||||
}
|
||||
}
|
||||
|
||||
function formatAndReset(text: string, formatStyle: string) {
|
||||
return formatStyle + text + resetEscapeSequence;
|
||||
}
|
||||
|
||||
function padLeft(s: string, length: number) {
|
||||
while (s.length < length) {
|
||||
s = " " + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string {
|
||||
let output = "";
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.file) {
|
||||
const { start, length, file } = diagnostic;
|
||||
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start);
|
||||
const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length);
|
||||
const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line;
|
||||
const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName;
|
||||
|
||||
const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
|
||||
let gutterWidth = (lastLine + 1 + "").length;
|
||||
if (hasMoreThanFiveLines) {
|
||||
gutterWidth = Math.max(ellipsis.length, gutterWidth);
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
for (let i = firstLine; i <= lastLine; i++) {
|
||||
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
|
||||
// so we'll skip ahead to the second-to-last line.
|
||||
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
|
||||
output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine;
|
||||
i = lastLine - 1;
|
||||
}
|
||||
|
||||
const lineStart = getPositionOfLineAndCharacter(file, i, 0);
|
||||
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
|
||||
let lineContent = file.text.slice(lineStart, lineEnd);
|
||||
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
|
||||
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
|
||||
|
||||
// Output the gutter and the actual contents of the line.
|
||||
output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += lineContent + sys.newLine;
|
||||
|
||||
// Output the gutter and the error span for the line using tildes.
|
||||
output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += redForegroundEscapeSequence;
|
||||
if (i === firstLine) {
|
||||
// If we're on the last line, then limit it to the last character of the last line.
|
||||
// Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
|
||||
const lastCharForLine = i === lastLine ? lastLineChar : undefined;
|
||||
|
||||
output += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
|
||||
output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
|
||||
}
|
||||
else if (i === lastLine) {
|
||||
output += lineContent.slice(0, lastLineChar).replace(/./g, "~");
|
||||
}
|
||||
else {
|
||||
// Squiggle the entire line.
|
||||
output += lineContent.replace(/./g, "~");
|
||||
}
|
||||
output += resetEscapeSequence;
|
||||
|
||||
output += sys.newLine;
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `;
|
||||
}
|
||||
|
||||
const categoryColor = getCategoryFormat(diagnostic.category);
|
||||
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
|
||||
if (typeof messageText === "string") {
|
||||
return messageText;
|
||||
@@ -291,6 +386,19 @@ namespace ts {
|
||||
allDiagnostics?: Diagnostic[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
|
||||
* that represent a compilation unit.
|
||||
*
|
||||
* Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and
|
||||
* triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in.
|
||||
*
|
||||
* @param rootNames - A set of root files.
|
||||
* @param options - The compiler options which should be used.
|
||||
* @param host - The host interacts with the underlying file system.
|
||||
* @param oldProgram - Reuses an old program structure.
|
||||
* @returns A 'Program' object.
|
||||
*/
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
@@ -434,7 +542,8 @@ namespace ts {
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
||||
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
|
||||
isSourceFileFromExternalLibrary,
|
||||
dropDiagnosticsProducingTypeChecker
|
||||
dropDiagnosticsProducingTypeChecker,
|
||||
getSourceFileFromReference,
|
||||
};
|
||||
|
||||
verifyCompilerOptions();
|
||||
@@ -1214,7 +1323,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||
return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
@@ -1253,7 +1362,6 @@ namespace ts {
|
||||
|
||||
const isJavaScriptFile = isSourceFileJavaScript(file);
|
||||
const isExternalModuleFile = isExternalModule(file);
|
||||
const isDtsFile = isDeclarationFile(file);
|
||||
|
||||
// file.imports may not be undefined if there exists dynamic import
|
||||
let imports: LiteralExpression[];
|
||||
@@ -1307,7 +1415,7 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || isDeclarationFile(file))) {
|
||||
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
|
||||
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
|
||||
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
||||
// This will happen in two cases:
|
||||
@@ -1318,7 +1426,7 @@ namespace ts {
|
||||
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
|
||||
}
|
||||
else if (!inAmbientModule) {
|
||||
if (isDtsFile) {
|
||||
if (file.isDeclarationFile) {
|
||||
// for global .d.ts files record name of ambient module
|
||||
(ambientModules || (ambientModules = [])).push(moduleName.text);
|
||||
}
|
||||
@@ -1353,48 +1461,60 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
let diagnosticArgument: string[];
|
||||
let diagnostic: DiagnosticMessage;
|
||||
/** This should have similar behavior to 'processSourceFile' without diagnostics or mutation. */
|
||||
function getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined {
|
||||
return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), fileName => filesByName.get(toPath(fileName, currentDirectory, getCanonicalFileName)));
|
||||
}
|
||||
|
||||
function getSourceFileFromReferenceWorker(
|
||||
fileName: string,
|
||||
getSourceFile: (fileName: string) => SourceFile | undefined,
|
||||
fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void,
|
||||
refFile?: SourceFile): SourceFile | undefined {
|
||||
|
||||
if (hasExtension(fileName)) {
|
||||
if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) {
|
||||
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
|
||||
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
|
||||
if (fail) fail(Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
||||
return undefined;
|
||||
}
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) {
|
||||
diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (diagnostic) {
|
||||
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
|
||||
const sourceFile = getSourceFile(fileName);
|
||||
if (fail) {
|
||||
if (!sourceFile) {
|
||||
fail(Diagnostics.File_0_not_found, fileName);
|
||||
}
|
||||
else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) {
|
||||
fail(Diagnostics.A_file_cannot_have_a_reference_to_itself, fileName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument));
|
||||
return sourceFile;
|
||||
} else {
|
||||
const sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
|
||||
if (sourceFileNoExtension) return sourceFileNoExtension;
|
||||
|
||||
if (fail && options.allowNonTsExtensions) {
|
||||
fail(Diagnostics.File_0_not_found, fileName);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension));
|
||||
if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.File_0_not_found, fileName + ".ts");
|
||||
return sourceFileWithAddedExtension;
|
||||
}
|
||||
}
|
||||
|
||||
/** This has side effects through `findSourceFile`. */
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): void {
|
||||
getSourceFileFromReferenceWorker(fileName,
|
||||
fileName => findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd),
|
||||
(diagnostic, ...args) => {
|
||||
fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined
|
||||
? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args)
|
||||
: createCompilerDiagnostic(diagnostic, ...args));
|
||||
},
|
||||
refFile);
|
||||
}
|
||||
|
||||
function reportFileNamesDifferOnlyInCasingError(fileName: string, existingFileName: string, refFile: SourceFile, refPos: number, refEnd: number): void {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
@@ -1640,7 +1760,7 @@ namespace ts {
|
||||
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||
|
||||
for (const sourceFile of sourceFiles) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if (!sourceFile.isDeclarationFile) {
|
||||
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||
@@ -1753,13 +1873,13 @@ namespace ts {
|
||||
const languageVersion = options.target || ScriptTarget.ES3;
|
||||
const outFile = options.outFile || options.out;
|
||||
|
||||
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
|
||||
if (options.isolatedModules) {
|
||||
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
||||
}
|
||||
|
||||
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
|
||||
@@ -712,11 +712,11 @@ namespace ts {
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) {
|
||||
export function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined {
|
||||
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state);
|
||||
}
|
||||
|
||||
export function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) {
|
||||
export function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined {
|
||||
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state);
|
||||
}
|
||||
|
||||
@@ -746,10 +746,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Optionally, get the shebang */
|
||||
export function getShebang(text: string): string {
|
||||
return shebangTriviaRegex.test(text)
|
||||
? shebangTriviaRegex.exec(text)[0]
|
||||
: undefined;
|
||||
export function getShebang(text: string): string | undefined {
|
||||
const match = shebangTriviaRegex.exec(text);
|
||||
if (match) {
|
||||
return match[0];
|
||||
}
|
||||
}
|
||||
|
||||
export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean {
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace ts {
|
||||
};
|
||||
|
||||
function transformRoot(node: T) {
|
||||
return node && (!isSourceFile(node) || !isDeclarationFile(node)) ? transformation(node) : node;
|
||||
return node && (!isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -2009,13 +2009,14 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
|
||||
setTextRange(assignment, decl);
|
||||
}
|
||||
|
||||
assignments = append(assignments, assignment);
|
||||
}
|
||||
}
|
||||
if (assignments) {
|
||||
updated = setTextRange(createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc))), node);
|
||||
updated = setTextRange(createStatement(inlineExpressions(assignments)), node);
|
||||
}
|
||||
else {
|
||||
// none of declarations has initializer - the entire variable statement can be deleted
|
||||
@@ -3748,7 +3749,7 @@ namespace ts {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return (<Declaration>parent).name === node
|
||||
return (<NamedDeclaration>parent).name === node
|
||||
&& resolver.isDeclarationWithCollidingName(<Declaration>parent);
|
||||
}
|
||||
|
||||
@@ -3781,7 +3782,7 @@ namespace ts {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings && !isInternalName(node)) {
|
||||
const declaration = resolver.getReferencedDeclarationWithCollidingName(node);
|
||||
if (declaration && !(isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
|
||||
return setTextRange(getGeneratedNameForNode(declaration.name), node);
|
||||
return setTextRange(getGeneratedNameForNode(getNameOfDeclaration(declaration)), node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -106,15 +106,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function visitAwaitExpression(node: AwaitExpression) {
|
||||
function visitAwaitExpression(node: AwaitExpression): Expression {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
return setOriginalNode(
|
||||
setTextRange(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
createArrayLiteral([createLiteral("await"), expression])
|
||||
),
|
||||
createYield(createAwaitHelper(context, visitNode(node.expression, visitor, isExpression))),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
@@ -124,18 +120,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitYieldExpression(node: YieldExpression) {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator && node.asteriskToken) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
return updateYield(
|
||||
node,
|
||||
node.asteriskToken,
|
||||
node.asteriskToken
|
||||
? createAsyncDelegatorHelper(context, expression, expression)
|
||||
: createArrayLiteral(
|
||||
expression
|
||||
? [createLiteral("yield"), expression]
|
||||
: [createLiteral("yield")]
|
||||
)
|
||||
return setOriginalNode(
|
||||
setTextRange(
|
||||
createYield(
|
||||
createAwaitHelper(context,
|
||||
updateYield(
|
||||
node,
|
||||
node.asteriskToken,
|
||||
createAsyncDelegatorHelper(
|
||||
context,
|
||||
createAsyncValuesHelper(context, expression, expression),
|
||||
expression
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
node
|
||||
),
|
||||
node
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
@@ -347,6 +351,10 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function awaitAsYield(expression: Expression) {
|
||||
return createYield(/*asteriskToken*/ undefined, enclosingFunctionFlags & FunctionFlags.Generator ? createAwaitHelper(context, expression) : expression);
|
||||
}
|
||||
|
||||
function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined);
|
||||
@@ -354,16 +362,11 @@ namespace ts {
|
||||
const errorRecord = createUniqueName("e");
|
||||
const catchVariable = getGeneratedNameForNode(errorRecord);
|
||||
const returnMethod = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression);
|
||||
const next = createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
enclosingFunctionFlags & FunctionFlags.Generator
|
||||
? createArrayLiteral([
|
||||
createLiteral("await"),
|
||||
createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
|
||||
])
|
||||
: createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
|
||||
);
|
||||
const callValues = createAsyncValuesHelper(context, expression, /*location*/ node.expression);
|
||||
const callNext = createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []);
|
||||
const getDone = createPropertyAccess(result, "done");
|
||||
const getValue = createPropertyAccess(result, "value");
|
||||
const callReturn = createFunctionCall(returnMethod, iterator, []);
|
||||
|
||||
hoistVariableDeclaration(errorRecord);
|
||||
hoistVariableDeclaration(returnMethod);
|
||||
@@ -374,16 +377,19 @@ namespace ts {
|
||||
/*initializer*/ setEmitFlags(
|
||||
setTextRange(
|
||||
createVariableDeclarationList([
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
|
||||
createVariableDeclaration(result, /*type*/ undefined, next)
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression),
|
||||
createVariableDeclaration(result)
|
||||
]),
|
||||
node.expression
|
||||
),
|
||||
EmitFlags.NoHoisting
|
||||
),
|
||||
/*condition*/ createLogicalNot(createPropertyAccess(result, "done")),
|
||||
/*incrementor*/ createAssignment(result, next),
|
||||
/*statement*/ convertForOfStatementHead(node, createPropertyAccess(result, "value"))
|
||||
/*condition*/ createComma(
|
||||
createAssignment(result, awaitAsYield(callNext)),
|
||||
createLogicalNot(getDone)
|
||||
),
|
||||
/*incrementor*/ undefined,
|
||||
/*statement*/ convertForOfStatementHead(node, awaitAsYield(getValue))
|
||||
),
|
||||
/*location*/ node
|
||||
),
|
||||
@@ -421,26 +427,14 @@ namespace ts {
|
||||
createLogicalAnd(
|
||||
createLogicalAnd(
|
||||
result,
|
||||
createLogicalNot(
|
||||
createPropertyAccess(result, "done")
|
||||
)
|
||||
createLogicalNot(getDone)
|
||||
),
|
||||
createAssignment(
|
||||
returnMethod,
|
||||
createPropertyAccess(iterator, "return")
|
||||
)
|
||||
),
|
||||
createStatement(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
enclosingFunctionFlags & FunctionFlags.Generator
|
||||
? createArrayLiteral([
|
||||
createLiteral("await"),
|
||||
createFunctionCall(returnMethod, iterator, [])
|
||||
])
|
||||
: createFunctionCall(returnMethod, iterator, [])
|
||||
)
|
||||
)
|
||||
createStatement(awaitAsYield(callReturn))
|
||||
),
|
||||
EmitFlags.SingleLine
|
||||
)
|
||||
@@ -880,27 +874,39 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
const awaitHelper: EmitHelper = {
|
||||
name: "typescript:await",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
`
|
||||
};
|
||||
|
||||
function createAwaitHelper(context: TransformationContext, expression: Expression) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
return createCall(getHelperName("__await"), /*typeArguments*/ undefined, [expression]);
|
||||
}
|
||||
|
||||
const asyncGeneratorHelper: EmitHelper = {
|
||||
name: "typescript:asyncGenerator",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
|
||||
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
|
||||
function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }
|
||||
function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === "yield" ? send : fulfill, reject); }
|
||||
function send(value) { settle(c[2], { value: value, done: false }); }
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { c = void 0, f(v), next(); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
context.requestEmitHelper(asyncGeneratorHelper);
|
||||
|
||||
// Mark this node as originally an async function
|
||||
@@ -922,16 +928,16 @@ namespace ts {
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||
var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }, p;
|
||||
return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { return function (v) { return v = p && n === "throw" ? f(v) : p && v.done ? v : { value: p ? ["yield", v.value] : ["await", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncDelegatorHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
context.requestEmitHelper(asyncDelegator);
|
||||
context.requestEmitHelper(asyncValues);
|
||||
return setTextRange(
|
||||
createCall(
|
||||
getHelperName("__asyncDelegator"),
|
||||
|
||||
@@ -293,8 +293,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)
|
||||
|| (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
|
||||
if (node.isDeclarationFile || (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts {
|
||||
* @param node A SourceFile node.
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace ts {
|
||||
* @param node The SourceFile node.
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
|
||||
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace ts {
|
||||
* @param node The SourceFile node.
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
|
||||
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace ts {
|
||||
* @param node A SourceFile node.
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -345,6 +345,9 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
// TypeScript property declarations are elided.
|
||||
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
// TypeScript namespace export declarations are elided.
|
||||
return undefined;
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -1762,23 +1765,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function serializeUnionOrIntersectionType(node: UnionOrIntersectionTypeNode): SerializedTypeNode {
|
||||
// Note when updating logic here also update getEntityNameForDecoratorMetadata
|
||||
// so that aliases can be marked as referenced
|
||||
let serializedUnion: SerializedTypeNode;
|
||||
for (const typeNode of node.types) {
|
||||
const serializedIndividual = serializeTypeNode(typeNode);
|
||||
|
||||
if (isVoidExpression(serializedIndividual)) {
|
||||
// If we dont have any other type already set, set the initial type
|
||||
if (!serializedUnion) {
|
||||
serializedUnion = serializedIndividual;
|
||||
}
|
||||
}
|
||||
else if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") {
|
||||
if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") {
|
||||
// One of the individual is global object, return immediately
|
||||
return serializedIndividual;
|
||||
}
|
||||
// If there exists union that is not void 0 expression, check if the the common type is identifier.
|
||||
// anything more complex and we will just default to Object
|
||||
else if (serializedUnion && !isVoidExpression(serializedUnion)) {
|
||||
else if (serializedUnion) {
|
||||
// Different types
|
||||
if (!isIdentifier(serializedUnion) ||
|
||||
!isIdentifier(serializedIndividual) ||
|
||||
@@ -2498,22 +2497,27 @@ namespace ts {
|
||||
// we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes
|
||||
// old emitter always generate 'expression' part of the name as-is.
|
||||
const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
|
||||
const valueExpression = transformEnumMemberDeclarationValue(member);
|
||||
const innerAssignment = createAssignment(
|
||||
createElementAccess(
|
||||
currentNamespaceContainerName,
|
||||
name
|
||||
),
|
||||
valueExpression
|
||||
);
|
||||
const outerAssignment = valueExpression.kind === SyntaxKind.StringLiteral ?
|
||||
innerAssignment :
|
||||
createAssignment(
|
||||
createElementAccess(
|
||||
currentNamespaceContainerName,
|
||||
innerAssignment
|
||||
),
|
||||
name
|
||||
);
|
||||
return setTextRange(
|
||||
createStatement(
|
||||
setTextRange(
|
||||
createAssignment(
|
||||
createElementAccess(
|
||||
currentNamespaceContainerName,
|
||||
createAssignment(
|
||||
createElementAccess(
|
||||
currentNamespaceContainerName,
|
||||
name
|
||||
),
|
||||
transformEnumMemberDeclarationValue(member)
|
||||
)
|
||||
),
|
||||
name
|
||||
),
|
||||
outerAssignment,
|
||||
member
|
||||
)
|
||||
),
|
||||
@@ -2922,7 +2926,7 @@ namespace ts {
|
||||
function visitExportDeclaration(node: ExportDeclaration): VisitResult<Statement> {
|
||||
if (!node.exportClause) {
|
||||
// Elide a star export if the module it references does not export a value.
|
||||
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
return compilerOptions.isolatedModules || resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
}
|
||||
|
||||
if (!resolver.isValueAliasDeclaration(node)) {
|
||||
@@ -3353,7 +3357,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function tryGetConstEnumValue(node: Node): number {
|
||||
function tryGetConstEnumValue(node: Node): string | number {
|
||||
if (compilerOptions.isolatedModules) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
+1
-86
@@ -60,93 +60,8 @@ namespace ts {
|
||||
sys.write(ts.formatDiagnostics([diagnostic], host));
|
||||
}
|
||||
|
||||
const redForegroundEscapeSequence = "\u001b[91m";
|
||||
const yellowForegroundEscapeSequence = "\u001b[93m";
|
||||
const blueForegroundEscapeSequence = "\u001b[93m";
|
||||
const gutterStyleSequence = "\u001b[100;30m";
|
||||
const gutterSeparator = " ";
|
||||
const resetEscapeSequence = "\u001b[0m";
|
||||
const ellipsis = "...";
|
||||
function getCategoryFormat(category: DiagnosticCategory): string {
|
||||
switch (category) {
|
||||
case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence;
|
||||
case DiagnosticCategory.Error: return redForegroundEscapeSequence;
|
||||
case DiagnosticCategory.Message: return blueForegroundEscapeSequence;
|
||||
}
|
||||
}
|
||||
|
||||
function formatAndReset(text: string, formatStyle: string) {
|
||||
return formatStyle + text + resetEscapeSequence;
|
||||
}
|
||||
|
||||
function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic, host: FormatDiagnosticsHost): void {
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
const { start, length, file } = diagnostic;
|
||||
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start);
|
||||
const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length);
|
||||
const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line;
|
||||
const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName;
|
||||
|
||||
const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
|
||||
let gutterWidth = (lastLine + 1 + "").length;
|
||||
if (hasMoreThanFiveLines) {
|
||||
gutterWidth = Math.max(ellipsis.length, gutterWidth);
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
for (let i = firstLine; i <= lastLine; i++) {
|
||||
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
|
||||
// so we'll skip ahead to the second-to-last line.
|
||||
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
|
||||
output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine;
|
||||
i = lastLine - 1;
|
||||
}
|
||||
|
||||
const lineStart = getPositionOfLineAndCharacter(file, i, 0);
|
||||
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
|
||||
let lineContent = file.text.slice(lineStart, lineEnd);
|
||||
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
|
||||
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
|
||||
|
||||
// Output the gutter and the actual contents of the line.
|
||||
output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += lineContent + sys.newLine;
|
||||
|
||||
// Output the gutter and the error span for the line using tildes.
|
||||
output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += redForegroundEscapeSequence;
|
||||
if (i === firstLine) {
|
||||
// If we're on the last line, then limit it to the last character of the last line.
|
||||
// Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
|
||||
const lastCharForLine = i === lastLine ? lastLineChar : undefined;
|
||||
|
||||
output += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
|
||||
output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
|
||||
}
|
||||
else if (i === lastLine) {
|
||||
output += lineContent.slice(0, lastLineChar).replace(/./g, "~");
|
||||
}
|
||||
else {
|
||||
// Squiggle the entire line.
|
||||
output += lineContent.replace(/./g, "~");
|
||||
}
|
||||
output += resetEscapeSequence;
|
||||
|
||||
output += sys.newLine;
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `;
|
||||
}
|
||||
|
||||
const categoryColor = getCategoryFormat(diagnostic.category);
|
||||
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`;
|
||||
output += sys.newLine + sys.newLine;
|
||||
|
||||
sys.write(output);
|
||||
sys.write(ts.formatDiagnosticsWithColorAndContext([diagnostic], host) + sys.newLine + sys.newLine);
|
||||
}
|
||||
|
||||
function reportWatchDiagnostic(diagnostic: Diagnostic) {
|
||||
|
||||
+153
-90
@@ -389,6 +389,7 @@ namespace ts {
|
||||
// Transformation nodes
|
||||
NotEmittedStatement,
|
||||
PartiallyEmittedExpression,
|
||||
CommaListExpression,
|
||||
MergeDeclarationMarker,
|
||||
EndOfDeclarationMarker,
|
||||
|
||||
@@ -580,11 +581,16 @@ namespace ts {
|
||||
|
||||
export interface Identifier extends PrimaryExpression {
|
||||
kind: SyntaxKind.Identifier;
|
||||
text: string; // Text of identifier (with escapes converted to characters)
|
||||
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
|
||||
/**
|
||||
* Text of identifier (with escapes converted to characters).
|
||||
* If the identifier begins with two underscores, this will begin with three.
|
||||
*/
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
|
||||
/*@internal*/ autoGenerateKind?: GeneratedIdentifierKind; // Specifies whether to auto-generate the text for an identifier.
|
||||
/*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name.
|
||||
isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace
|
||||
/*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name.
|
||||
isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace
|
||||
/*@internal*/ typeArguments?: NodeArray<TypeNode>; // Only defined on synthesized nodes. Though not syntactically valid, used in emitting diagnostics.
|
||||
}
|
||||
|
||||
// Transient identifier node (marked by id === -1)
|
||||
@@ -614,10 +620,13 @@ namespace ts {
|
||||
|
||||
export interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
}
|
||||
|
||||
export interface NamedDeclaration extends Declaration {
|
||||
name?: DeclarationName;
|
||||
}
|
||||
|
||||
export interface DeclarationStatement extends Declaration, Statement {
|
||||
export interface DeclarationStatement extends NamedDeclaration, Statement {
|
||||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
|
||||
@@ -631,7 +640,7 @@ namespace ts {
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
|
||||
export interface TypeParameterDeclaration extends Declaration {
|
||||
export interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.TypeParameter;
|
||||
parent?: DeclarationWithTypeParameters;
|
||||
name: Identifier;
|
||||
@@ -642,7 +651,7 @@ namespace ts {
|
||||
expression?: Expression;
|
||||
}
|
||||
|
||||
export interface SignatureDeclaration extends Declaration {
|
||||
export interface SignatureDeclaration extends NamedDeclaration {
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
@@ -659,7 +668,7 @@ namespace ts {
|
||||
|
||||
export type BindingName = Identifier | BindingPattern;
|
||||
|
||||
export interface VariableDeclaration extends Declaration {
|
||||
export interface VariableDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.VariableDeclaration;
|
||||
parent?: VariableDeclarationList | CatchClause;
|
||||
name: BindingName; // Declared variable name
|
||||
@@ -673,7 +682,7 @@ namespace ts {
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
|
||||
export interface ParameterDeclaration extends Declaration {
|
||||
export interface ParameterDeclaration extends NamedDeclaration {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken; // Present on rest parameter
|
||||
@@ -683,7 +692,7 @@ namespace ts {
|
||||
initializer?: Expression; // Optional initializer
|
||||
}
|
||||
|
||||
export interface BindingElement extends Declaration {
|
||||
export interface BindingElement extends NamedDeclaration {
|
||||
kind: SyntaxKind.BindingElement;
|
||||
parent?: BindingPattern;
|
||||
propertyName?: PropertyName; // Binding property name (in object binding pattern)
|
||||
@@ -708,7 +717,7 @@ namespace ts {
|
||||
initializer?: Expression; // Optional initializer
|
||||
}
|
||||
|
||||
export interface ObjectLiteralElement extends Declaration {
|
||||
export interface ObjectLiteralElement extends NamedDeclaration {
|
||||
_objectLiteralBrandBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
@@ -752,7 +761,7 @@ namespace ts {
|
||||
// SyntaxKind.ShorthandPropertyAssignment
|
||||
// SyntaxKind.EnumMember
|
||||
// SyntaxKind.JSDocPropertyTag
|
||||
export interface VariableLikeDeclaration extends Declaration {
|
||||
export interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name: DeclarationName;
|
||||
@@ -761,7 +770,7 @@ namespace ts {
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface PropertyLikeDeclaration extends Declaration {
|
||||
export interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
name: PropertyName;
|
||||
}
|
||||
|
||||
@@ -892,6 +901,8 @@ namespace ts {
|
||||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
|
||||
export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference;
|
||||
|
||||
export interface TypeReferenceNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeReference;
|
||||
typeName: EntityName;
|
||||
@@ -1230,8 +1241,7 @@ namespace ts {
|
||||
|
||||
export type BinaryOperatorToken = Token<BinaryOperator>;
|
||||
|
||||
// Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files
|
||||
export interface BinaryExpression extends Expression, Declaration {
|
||||
export interface BinaryExpression extends Expression, Declaration {
|
||||
kind: SyntaxKind.BinaryExpression;
|
||||
left: Expression;
|
||||
operatorToken: BinaryOperatorToken;
|
||||
@@ -1431,7 +1441,7 @@ namespace ts {
|
||||
export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression;
|
||||
export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
|
||||
export interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
kind: SyntaxKind.PropertyAccessExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
name: Identifier;
|
||||
@@ -1521,7 +1531,7 @@ namespace ts {
|
||||
// for the same reasons we treat NewExpression as a PrimaryExpression.
|
||||
export interface MetaProperty extends PrimaryExpression {
|
||||
kind: SyntaxKind.MetaProperty;
|
||||
keywordToken: SyntaxKind;
|
||||
keywordToken: SyntaxKind.NewKeyword;
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
@@ -1612,6 +1622,14 @@ namespace ts {
|
||||
kind: SyntaxKind.EndOfDeclarationMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of comma-seperated expressions. This node is only created by transformations.
|
||||
*/
|
||||
export interface CommaListExpression extends Expression {
|
||||
kind: SyntaxKind.CommaListExpression;
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the beginning of a merged transformed declaration.
|
||||
*/
|
||||
@@ -1777,7 +1795,7 @@ namespace ts {
|
||||
|
||||
export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration;
|
||||
|
||||
export interface ClassLikeDeclaration extends Declaration {
|
||||
export interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@@ -1793,12 +1811,12 @@ namespace ts {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
|
||||
export interface ClassElement extends Declaration {
|
||||
export interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
}
|
||||
|
||||
export interface TypeElement extends Declaration {
|
||||
export interface TypeElement extends NamedDeclaration {
|
||||
_typeElementBrand: any;
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -1826,7 +1844,7 @@ namespace ts {
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface EnumMember extends Declaration {
|
||||
export interface EnumMember extends NamedDeclaration {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
// This does include ComputedPropertyName, but the parser will give an error
|
||||
@@ -1915,14 +1933,14 @@ namespace ts {
|
||||
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
|
||||
// import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
||||
// import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
||||
export interface ImportClause extends Declaration {
|
||||
export interface ImportClause extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportClause;
|
||||
parent?: ImportDeclaration;
|
||||
name?: Identifier; // Default binding
|
||||
namedBindings?: NamedImportBindings;
|
||||
}
|
||||
|
||||
export interface NamespaceImport extends Declaration {
|
||||
export interface NamespaceImport extends NamedDeclaration {
|
||||
kind: SyntaxKind.NamespaceImport;
|
||||
parent?: ImportClause;
|
||||
name: Identifier;
|
||||
@@ -1955,14 +1973,14 @@ namespace ts {
|
||||
|
||||
export type NamedImportsOrExports = NamedImports | NamedExports;
|
||||
|
||||
export interface ImportSpecifier extends Declaration {
|
||||
export interface ImportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ImportSpecifier;
|
||||
parent?: NamedImports;
|
||||
propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent)
|
||||
name: Identifier; // Declared name
|
||||
}
|
||||
|
||||
export interface ExportSpecifier extends Declaration {
|
||||
export interface ExportSpecifier extends NamedDeclaration {
|
||||
kind: SyntaxKind.ExportSpecifier;
|
||||
parent?: NamedExports;
|
||||
propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent)
|
||||
@@ -2128,7 +2146,7 @@ namespace ts {
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocTypedefTag extends JSDocTag, Declaration {
|
||||
export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
kind: SyntaxKind.JSDocTypedefTag;
|
||||
fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
name?: Identifier;
|
||||
@@ -2424,6 +2442,8 @@ namespace ts {
|
||||
/* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
// For testing purposes only.
|
||||
/* @internal */ structureIsReused?: StructureIsReused;
|
||||
|
||||
/* @internal */ getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -2503,10 +2523,10 @@ namespace ts {
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo;
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
||||
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
||||
getBaseTypes(type: InterfaceType): BaseType[];
|
||||
getBaseTypeOfLiteralType(type: Type): Type;
|
||||
getWidenedType(type: Type): Type;
|
||||
@@ -2527,11 +2547,11 @@ namespace ts {
|
||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
||||
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolAtLocation(node: Node): Symbol | undefined;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
|
||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
|
||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
getTypeFromTypeNode(node: TypeNode): Type;
|
||||
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
||||
@@ -2541,16 +2561,16 @@ namespace ts {
|
||||
getFullyQualifiedName(symbol: Symbol): string;
|
||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||
getRootSymbols(symbol: Symbol): Symbol[];
|
||||
getContextualType(node: Expression): Type;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
getContextualType(node: Expression): Type | undefined;
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
/* @internal */ getMergedSymbol(symbol: Symbol): Symbol;
|
||||
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
@@ -2560,15 +2580,18 @@ namespace ts {
|
||||
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
|
||||
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type;
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
/* @internal */ getBaseConstraintOfType(type: Type): Type | undefined;
|
||||
|
||||
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
|
||||
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined;
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
@@ -2579,22 +2602,43 @@ namespace ts {
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
|
||||
/**
|
||||
* For a union, will include a property if it's defined in *any* of the member types.
|
||||
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
||||
* Does not include properties of primitive types.
|
||||
*/
|
||||
/* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[];
|
||||
}
|
||||
|
||||
export enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
allowThisInObjectLiteral = 1 << 0,
|
||||
allowQualifedNameInPlaceOfIdentifier = 1 << 1,
|
||||
allowTypeParameterInQualifiedName = 1 << 2,
|
||||
allowAnonymousIdentifier = 1 << 3,
|
||||
allowEmptyUnionOrIntersection = 1 << 4,
|
||||
allowEmptyTuple = 1 << 5
|
||||
// Options
|
||||
NoTruncation = 1 << 0, // Don't truncate result
|
||||
WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[]
|
||||
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
||||
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type.
|
||||
WriteTypeParametersInQualifiedName = 1 << 9,
|
||||
|
||||
// Error handling
|
||||
AllowThisInObjectLiteral = 1 << 10,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 1 << 11,
|
||||
AllowAnonymousIdentifier = 1 << 13,
|
||||
AllowEmptyUnionOrIntersection = 1 << 14,
|
||||
AllowEmptyTuple = 1 << 15,
|
||||
|
||||
IgnoreErrors = AllowThisInObjectLiteral | AllowQualifedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple,
|
||||
|
||||
// State
|
||||
InObjectTypeLiteral = 1 << 20,
|
||||
InTypeAlias = 1 << 23, // Writing type in type alias declaration
|
||||
}
|
||||
|
||||
export interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -2624,24 +2668,25 @@ namespace ts {
|
||||
// with import statements it previously saw (but chose not to emit).
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
reportIllegalExtends(): void;
|
||||
reportPrivateInBaseOfClassExpression(propertyName: string): void;
|
||||
}
|
||||
|
||||
export const enum TypeFormatFlags {
|
||||
None = 0x00000000,
|
||||
WriteArrayAsGenericType = 0x00000001, // Write Array<T> instead T[]
|
||||
UseTypeOfFunction = 0x00000002, // Write typeof instead of function type literal
|
||||
NoTruncation = 0x00000004, // Don't truncate typeToString result
|
||||
WriteArrowStyleSignature = 0x00000008, // Write arrow style signature
|
||||
WriteOwnNameForAnyLike = 0x00000010, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
|
||||
WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature
|
||||
InElementType = 0x00000040, // Writing an array or union element type
|
||||
UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type
|
||||
InTypeAlias = 0x00000200, // Writing type in type alias declaration
|
||||
UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
|
||||
SuppressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type.
|
||||
AddUndefined = 0x00001000, // Add undefined to types of initialized, non-optional parameters
|
||||
None = 0,
|
||||
WriteArrayAsGenericType = 1 << 0, // Write Array<T> instead T[]
|
||||
UseTypeOfFunction = 1 << 2, // Write typeof instead of function type literal
|
||||
NoTruncation = 1 << 3, // Don't truncate typeToString result
|
||||
WriteArrowStyleSignature = 1 << 4, // Write arrow style signature
|
||||
WriteOwnNameForAnyLike = 1 << 5, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
|
||||
WriteTypeArgumentsOfSignature = 1 << 6, // Write the type arguments instead of type parameters of the signature
|
||||
InElementType = 1 << 7, // Writing an array or union element type
|
||||
UseFullyQualifiedType = 1 << 8, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
InFirstTypeArgument = 1 << 9, // Writing first type argument of the instantiated type
|
||||
InTypeAlias = 1 << 10, // Writing type in type alias declaration
|
||||
UseTypeAliasValue = 1 << 11, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
|
||||
SuppressAnyReturnType = 1 << 12, // If the return type is any-like, don't offer a return type.
|
||||
AddUndefined = 1 << 13, // Add undefined to types of initialized, non-optional parameters
|
||||
WriteClassExpressionAsTypeLiteral = 1 << 14, // Write a type literal instead of (Anonymous class)
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
@@ -2744,16 +2789,15 @@ namespace ts {
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
collectLinkedAliases(node: Identifier): Node[];
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
||||
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number;
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind;
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
@@ -2891,6 +2935,13 @@ namespace ts {
|
||||
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
|
||||
bindingElement?: BindingElement; // Binding element associated with property symbol
|
||||
exportsSomeValue?: boolean; // True if module exports some value (not just types)
|
||||
enumKind?: EnumKind; // Enum declaration classification
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum EnumKind {
|
||||
Numeric, // Numeric enum (each member has a TypeFlags.Enum type)
|
||||
Literal // Literal enum (each member has a TypeFlags.EnumLiteral type)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -2963,7 +3014,7 @@ namespace ts {
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||
maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate
|
||||
enumMemberValue?: number; // Constant value of enum member
|
||||
enumMemberValue?: string | number; // Constant value of enum member
|
||||
isVisible?: boolean; // Is this node visible
|
||||
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
@@ -2983,7 +3034,7 @@ namespace ts {
|
||||
StringLiteral = 1 << 5,
|
||||
NumberLiteral = 1 << 6,
|
||||
BooleanLiteral = 1 << 7,
|
||||
EnumLiteral = 1 << 8,
|
||||
EnumLiteral = 1 << 8, // Always combined with StringLiteral, NumberLiteral, or Union
|
||||
ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6
|
||||
Void = 1 << 10,
|
||||
Undefined = 1 << 11,
|
||||
@@ -3009,7 +3060,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral,
|
||||
Literal = StringLiteral | NumberLiteral | BooleanLiteral,
|
||||
StringOrNumberLiteral = StringLiteral | NumberLiteral,
|
||||
/* @internal */
|
||||
DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null,
|
||||
@@ -3017,9 +3068,9 @@ namespace ts {
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
|
||||
/* @internal */
|
||||
Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal,
|
||||
Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal,
|
||||
StringLike = String | StringLiteral | Index,
|
||||
NumberLike = Number | NumberLiteral | Enum | EnumLiteral,
|
||||
NumberLike = Number | NumberLiteral | Enum,
|
||||
BooleanLike = Boolean | BooleanLiteral,
|
||||
EnumLike = Enum | EnumLiteral,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
@@ -3058,19 +3109,21 @@ namespace ts {
|
||||
// String literal types (TypeFlags.StringLiteral)
|
||||
// Numeric literal types (TypeFlags.NumberLiteral)
|
||||
export interface LiteralType extends Type {
|
||||
text: string; // Text of literal
|
||||
value: string | number; // Value of literal
|
||||
freshType?: LiteralType; // Fresh version of type
|
||||
regularType?: LiteralType; // Regular version of type
|
||||
}
|
||||
|
||||
// Enum types (TypeFlags.Enum)
|
||||
export interface EnumType extends Type {
|
||||
memberTypes: EnumLiteralType[];
|
||||
export interface StringLiteralType extends LiteralType {
|
||||
value: string;
|
||||
}
|
||||
|
||||
// Enum types (TypeFlags.EnumLiteral)
|
||||
export interface EnumLiteralType extends LiteralType {
|
||||
baseType: EnumType & UnionType; // Base enum type
|
||||
export interface NumberLiteralType extends LiteralType {
|
||||
value: number;
|
||||
}
|
||||
|
||||
// Enum types (TypeFlags.Enum)
|
||||
export interface EnumType extends Type {
|
||||
}
|
||||
|
||||
export const enum ObjectFlags {
|
||||
@@ -3127,7 +3180,7 @@ namespace ts {
|
||||
*/
|
||||
export interface TypeReference extends ObjectType {
|
||||
target: GenericType; // Type reference target
|
||||
typeArguments: Type[]; // Type reference type arguments (undefined if none)
|
||||
typeArguments?: Type[]; // Type reference type arguments (undefined if none)
|
||||
}
|
||||
|
||||
// Generic class and interface types
|
||||
@@ -3257,7 +3310,7 @@ namespace ts {
|
||||
|
||||
export interface Signature {
|
||||
declaration: SignatureDeclaration; // Originating declaration
|
||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
typeParameters?: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
parameters: Symbol[]; // Parameters
|
||||
/* @internal */
|
||||
thisParameter?: Symbol; // symbol of this-type parameter
|
||||
@@ -3368,9 +3421,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface Diagnostic {
|
||||
file: SourceFile;
|
||||
start: number;
|
||||
length: number;
|
||||
file: SourceFile | undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
@@ -3380,7 +3433,7 @@ namespace ts {
|
||||
export enum DiagnosticCategory {
|
||||
Warning,
|
||||
Error,
|
||||
Message,
|
||||
Message
|
||||
}
|
||||
|
||||
export enum ModuleResolutionKind {
|
||||
@@ -3520,7 +3573,7 @@ namespace ts {
|
||||
|
||||
export const enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
LineFeed = 1
|
||||
}
|
||||
|
||||
export interface LineAndCharacter {
|
||||
@@ -3944,7 +3997,7 @@ namespace ts {
|
||||
commentRange?: TextRange; // The text range to use when emitting leading or trailing comments
|
||||
sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings
|
||||
tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens
|
||||
constantValue?: number; // The constant value of an expression
|
||||
constantValue?: string | number; // The constant value of an expression
|
||||
externalHelpersModuleName?: Identifier; // The local name for an imported helpers module
|
||||
helpers?: EmitHelper[]; // Emit helpers for the node
|
||||
}
|
||||
@@ -3977,6 +4030,7 @@ namespace ts {
|
||||
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
||||
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||
NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions.
|
||||
}
|
||||
|
||||
export interface EmitHelper {
|
||||
@@ -4001,11 +4055,12 @@ namespace ts {
|
||||
Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation)
|
||||
Generator = 1 << 7, // __generator (used by ES2015 generator transformation)
|
||||
Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations)
|
||||
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Spread = 1 << 10, // __spread (used by ES2015 array spread and argument list spread transformations)
|
||||
AsyncGenerator = 1 << 11, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncDelegator = 1 << 12, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 13, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
Await = 1 << 11, // __await (used by ES2017 async generator transformation)
|
||||
AsyncGenerator = 1 << 12, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncDelegator = 1 << 13, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
|
||||
// Helpers included by ES2015 for..of
|
||||
ForOfIncludes = Values,
|
||||
@@ -4013,6 +4068,12 @@ namespace ts {
|
||||
// Helpers included by ES2017 for..await..of
|
||||
ForAwaitOfIncludes = AsyncValues,
|
||||
|
||||
// Helpers included by ES2017 async generators
|
||||
AsyncGeneratorIncludes = Await | AsyncGenerator,
|
||||
|
||||
// Helpers included by yield* in ES2017 async generators
|
||||
AsyncDelegatorIncludes = Await | AsyncDelegator | AsyncValues,
|
||||
|
||||
// Helpers included by ES2015 spread
|
||||
SpreadIncludes = Read | Spread,
|
||||
|
||||
@@ -4182,7 +4243,7 @@ namespace ts {
|
||||
* Prints a bundle of source files as-is, without any emit transformations.
|
||||
*/
|
||||
printBundle(bundle: Bundle): string;
|
||||
/*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, writer: EmitTextWriter): void;
|
||||
/*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
||||
/*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void;
|
||||
/*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter): void;
|
||||
}
|
||||
@@ -4236,6 +4297,8 @@ namespace ts {
|
||||
/*@internal*/ onSetSourceFile?: (node: SourceFile) => void;
|
||||
/*@internal*/ onBeforeEmitNodeArray?: (nodes: NodeArray<any>) => void;
|
||||
/*@internal*/ onAfterEmitNodeArray?: (nodes: NodeArray<any>) => void;
|
||||
/*@internal*/ onBeforeEmitToken?: (node: Node) => void;
|
||||
/*@internal*/ onAfterEmitToken?: (node: Node) => void;
|
||||
}
|
||||
|
||||
export interface PrinterOptions {
|
||||
|
||||
+192
-74
@@ -11,12 +11,12 @@ namespace ts {
|
||||
isTypeReferenceDirective?: boolean;
|
||||
}
|
||||
|
||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
||||
export function getDeclarationOfKind<T extends Declaration>(symbol: Symbol, kind: T["kind"]): T {
|
||||
const declarations = symbol.declarations;
|
||||
if (declarations) {
|
||||
for (const declaration of declarations) {
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
return declaration as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace ts {
|
||||
clear: () => str = "",
|
||||
trackSymbol: noop,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportIllegalExtends: noop
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -328,19 +328,21 @@ namespace ts {
|
||||
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
||||
}
|
||||
|
||||
const escapeText = getEmitFlags(node) & EmitFlags.NoAsciiEscaping ? escapeString : escapeNonAsciiString;
|
||||
|
||||
// If we can't reach the original source text, use the canonical form if it's a number,
|
||||
// or an escaped quoted form of the original text if it's string-like.
|
||||
// or a (possibly escaped) quoted form of the original text if it's string-like.
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getQuotedEscapedLiteralText('"', node.text, '"');
|
||||
return '"' + escapeText(node.text) + '"';
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return getQuotedEscapedLiteralText("`", node.text, "`");
|
||||
return "`" + escapeText(node.text) + "`";
|
||||
case SyntaxKind.TemplateHead:
|
||||
return getQuotedEscapedLiteralText("`", node.text, "${");
|
||||
return "`" + escapeText(node.text) + "${";
|
||||
case SyntaxKind.TemplateMiddle:
|
||||
return getQuotedEscapedLiteralText("}", node.text, "${");
|
||||
return "}" + escapeText(node.text) + "${";
|
||||
case SyntaxKind.TemplateTail:
|
||||
return getQuotedEscapedLiteralText("}", node.text, "`");
|
||||
return "}" + escapeText(node.text) + "`";
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return node.text;
|
||||
}
|
||||
@@ -348,8 +350,8 @@ namespace ts {
|
||||
Debug.fail(`Literal kind '${node.kind}' not accounted for.`);
|
||||
}
|
||||
|
||||
function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) {
|
||||
return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote;
|
||||
export function getTextOfConstantValue(value: string | number) {
|
||||
return typeof value === "string" ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
|
||||
}
|
||||
|
||||
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
||||
@@ -465,7 +467,7 @@ namespace ts {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function getNameFromIndexInfo(info: IndexInfo) {
|
||||
export function getNameFromIndexInfo(info: IndexInfo): string | undefined {
|
||||
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
|
||||
}
|
||||
|
||||
@@ -566,7 +568,7 @@ namespace ts {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
errorNode = (<Declaration>node).name;
|
||||
errorNode = (<NamedDeclaration>node).name;
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return getErrorSpanForArrowFunction(sourceFile, <ArrowFunction>node);
|
||||
@@ -589,10 +591,6 @@ namespace ts {
|
||||
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
||||
}
|
||||
|
||||
export function isDeclarationFile(file: SourceFile): boolean {
|
||||
return file.isDeclarationFile;
|
||||
}
|
||||
|
||||
export function isConstEnumDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
||||
}
|
||||
@@ -885,6 +883,16 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function introducesArgumentsExoticObject(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -1146,6 +1154,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression {
|
||||
return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression;
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
@@ -1591,7 +1603,7 @@ namespace ts {
|
||||
|
||||
// Pull parameter comments from declaring function as well
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
cache = concatenate(cache, getJSDocParameterTags(node));
|
||||
cache = concatenate(cache, getJSDocParameterTags(node as ParameterDeclaration));
|
||||
}
|
||||
|
||||
if (isVariableLike(node) && node.initializer) {
|
||||
@@ -1602,11 +1614,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getJSDocParameterTags(param: Node): JSDocParameterTag[] {
|
||||
if (!isParameter(param)) {
|
||||
return undefined;
|
||||
}
|
||||
const func = param.parent as FunctionLikeDeclaration;
|
||||
export function getJSDocParameterTags(param: ParameterDeclaration): JSDocParameterTag[] {
|
||||
const func = param.parent;
|
||||
const tags = getJSDocTags(func, SyntaxKind.JSDocParameterTag) as JSDocParameterTag[];
|
||||
if (!param.name) {
|
||||
// this is an anonymous jsdoc param from a `function(type1, type2): type3` specification
|
||||
@@ -1627,10 +1636,22 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */
|
||||
export function getParameterFromJSDoc(node: JSDocParameterTag): ParameterDeclaration | undefined {
|
||||
const name = node.parameterName.text;
|
||||
const grandParent = node.parent!.parent!;
|
||||
Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment);
|
||||
if (!isFunctionLike(grandParent)) {
|
||||
return undefined;
|
||||
}
|
||||
return find(grandParent.parameters, p =>
|
||||
p.name.kind === SyntaxKind.Identifier && p.name.text === name);
|
||||
}
|
||||
|
||||
export function getJSDocType(node: Node): JSDocType {
|
||||
let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag;
|
||||
if (!tag && node.kind === SyntaxKind.Parameter) {
|
||||
const paramTags = getJSDocParameterTags(node);
|
||||
const paramTags = getJSDocParameterTags(node as ParameterDeclaration);
|
||||
if (paramTags) {
|
||||
tag = find(paramTags, tag => !!tag.typeExpression);
|
||||
}
|
||||
@@ -1758,22 +1779,31 @@ namespace ts {
|
||||
|
||||
// True if the given identifier, string literal, or number literal is the name of a declaration node
|
||||
export function isDeclarationName(name: Node): boolean {
|
||||
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
|
||||
return false;
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return isDeclaration(name.parent) && name.parent.name === name;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const parent = name.parent;
|
||||
if (parent.kind === SyntaxKind.ImportSpecifier || parent.kind === SyntaxKind.ExportSpecifier) {
|
||||
if ((<ImportOrExportSpecifier>parent).propertyName) {
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
// See GH#16030
|
||||
export function isAnyDeclarationName(name: Node): boolean {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
if (isDeclaration(name.parent)) {
|
||||
return name.parent.name === name;
|
||||
}
|
||||
const binExp = name.parent.parent;
|
||||
return isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None && getNameOfDeclaration(binExp) === name;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isDeclaration(parent)) {
|
||||
return (<Declaration>parent).name === name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isLiteralComputedPropertyDeclarationName(node: Node) {
|
||||
@@ -1796,7 +1826,7 @@ namespace ts {
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
// Name in member declaration or property name in property access
|
||||
return (<Declaration | PropertyAccessExpression>parent).name === node;
|
||||
return (<NamedDeclaration | PropertyAccessExpression>parent).name === node;
|
||||
case SyntaxKind.QualifiedName:
|
||||
// Name on right hand side of dot in a type query
|
||||
if ((<QualifiedName>parent).right === node) {
|
||||
@@ -1888,21 +1918,19 @@ namespace ts {
|
||||
const isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.test(comment)) {
|
||||
if (isNoDefaultLibRegEx.test(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
};
|
||||
return { isNoDefaultLib: true };
|
||||
}
|
||||
else {
|
||||
const refMatchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
const refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment);
|
||||
if (refMatchResult || refLibResult) {
|
||||
const start = commentRange.pos;
|
||||
const end = commentRange.end;
|
||||
const match = refMatchResult || refLibResult;
|
||||
if (match) {
|
||||
const pos = commentRange.pos + match[1].length + match[2].length;
|
||||
return {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
fileName: (refMatchResult || refLibResult)[3]
|
||||
pos,
|
||||
end: pos + match[3].length,
|
||||
fileName: match[3]
|
||||
},
|
||||
isNoDefaultLib: false,
|
||||
isTypeReferenceDirective: !!refLibResult
|
||||
@@ -1928,16 +1956,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
export const enum FunctionFlags {
|
||||
Normal = 0,
|
||||
Generator = 1 << 0,
|
||||
Async = 1 << 1,
|
||||
AsyncOrAsyncGenerator = Async | Generator,
|
||||
Invalid = 1 << 2,
|
||||
InvalidAsyncOrAsyncGenerator = AsyncOrAsyncGenerator | Invalid,
|
||||
InvalidGenerator = Generator | Invalid,
|
||||
Normal = 0, // Function is a normal function
|
||||
Generator = 1 << 0, // Function is a generator function or async generator function
|
||||
Async = 1 << 1, // Function is an async function or an async generator function
|
||||
Invalid = 1 << 2, // Function is a signature or overload and does not have a body.
|
||||
AsyncGenerator = Async | Generator, // Function is an async generator function
|
||||
}
|
||||
|
||||
export function getFunctionFlags(node: FunctionLikeDeclaration) {
|
||||
export function getFunctionFlags(node: FunctionLikeDeclaration | undefined) {
|
||||
if (!node) {
|
||||
return FunctionFlags.Invalid;
|
||||
}
|
||||
|
||||
let flags = FunctionFlags.Normal;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -1992,7 +2022,8 @@ namespace ts {
|
||||
* Symbol.
|
||||
*/
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name && isDynamicName(declaration.name);
|
||||
const name = getNameOfDeclaration(declaration);
|
||||
return name && isDynamicName(name);
|
||||
}
|
||||
|
||||
export function isDynamicName(name: DeclarationName): boolean {
|
||||
@@ -2302,6 +2333,9 @@ namespace ts {
|
||||
case SyntaxKind.SpreadElement:
|
||||
return 1;
|
||||
|
||||
case SyntaxKind.CommaListExpression:
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -2434,7 +2468,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
const nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
||||
export function escapeNonAsciiCharacters(s: string): string {
|
||||
export function escapeNonAsciiString(s: string): string {
|
||||
s = escapeString(s);
|
||||
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
|
||||
// Otherwise just return the original string.
|
||||
return nonAsciiCharacters.test(s) ?
|
||||
@@ -2538,7 +2573,7 @@ namespace ts {
|
||||
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string {
|
||||
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
||||
if (!file || isDeclarationFile(file)) {
|
||||
if (!file || file.isDeclarationFile) {
|
||||
return undefined;
|
||||
}
|
||||
return getResolvedExternalModuleName(host, file);
|
||||
@@ -2611,7 +2646,7 @@ namespace ts {
|
||||
|
||||
/** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
|
||||
export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) {
|
||||
return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile);
|
||||
return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2757,7 +2792,7 @@ namespace ts {
|
||||
forEach(declarations, (member: Declaration) => {
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
|
||||
&& hasModifier(member, ModifierFlags.Static) === hasModifier(accessor, ModifierFlags.Static)) {
|
||||
const memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
const memberName = getPropertyNameForPropertyNameNode((member as NamedDeclaration).name);
|
||||
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
if (!firstAccessor) {
|
||||
@@ -3137,11 +3172,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getLocalSymbolForExportDefault(symbol: Symbol) {
|
||||
return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
|
||||
}
|
||||
|
||||
function isExportDefaultSymbol(symbol: Symbol): boolean {
|
||||
return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default);
|
||||
return symbol && length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], ModifierFlags.Default);
|
||||
}
|
||||
|
||||
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
||||
@@ -3227,13 +3262,13 @@ namespace ts {
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string {
|
||||
if (options.newLine === NewLineKind.CarriageReturnLineFeed) {
|
||||
return carriageReturnLineFeed;
|
||||
switch (options.newLine) {
|
||||
case NewLineKind.CarriageReturnLineFeed:
|
||||
return carriageReturnLineFeed;
|
||||
case NewLineKind.LineFeed:
|
||||
return lineFeed;
|
||||
}
|
||||
else if (options.newLine === NewLineKind.LineFeed) {
|
||||
return lineFeed;
|
||||
}
|
||||
else if (sys) {
|
||||
if (sys) {
|
||||
return sys.newLine;
|
||||
}
|
||||
return carriageReturnLineFeed;
|
||||
@@ -3572,10 +3607,6 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
export function isVoidExpression(node: Node): node is VoidExpression {
|
||||
return node.kind === SyntaxKind.VoidExpression;
|
||||
}
|
||||
|
||||
export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier {
|
||||
// Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`.
|
||||
return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None;
|
||||
@@ -3652,7 +3683,18 @@ namespace ts {
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor
|
||||
|| kind === SyntaxKind.IndexSignature
|
||||
|| kind === SyntaxKind.SemicolonClassElement;
|
||||
|| kind === SyntaxKind.SemicolonClassElement
|
||||
|| kind === SyntaxKind.MissingDeclaration;
|
||||
}
|
||||
|
||||
export function isTypeElement(node: Node): node is TypeElement {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ConstructSignature
|
||||
|| kind === SyntaxKind.CallSignature
|
||||
|| kind === SyntaxKind.PropertySignature
|
||||
|| kind === SyntaxKind.MethodSignature
|
||||
|| kind === SyntaxKind.IndexSignature
|
||||
|| kind === SyntaxKind.MissingDeclaration;
|
||||
}
|
||||
|
||||
export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike {
|
||||
@@ -3883,6 +3925,7 @@ namespace ts {
|
||||
|| kind === SyntaxKind.SpreadElement
|
||||
|| kind === SyntaxKind.AsExpression
|
||||
|| kind === SyntaxKind.OmittedExpression
|
||||
|| kind === SyntaxKind.CommaListExpression
|
||||
|| isUnaryExpressionKind(kind);
|
||||
}
|
||||
|
||||
@@ -3974,6 +4017,10 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration;
|
||||
}
|
||||
|
||||
export function isImportDeclaration(node: Node): node is ImportDeclaration {
|
||||
return node.kind === SyntaxKind.ImportDeclaration;
|
||||
}
|
||||
|
||||
export function isImportClause(node: Node): node is ImportClause {
|
||||
return node.kind === SyntaxKind.ImportClause;
|
||||
}
|
||||
@@ -3996,6 +4043,10 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ExportSpecifier;
|
||||
}
|
||||
|
||||
export function isExportAssignment(node: Node): node is ExportAssignment {
|
||||
return node.kind === SyntaxKind.ExportAssignment;
|
||||
}
|
||||
|
||||
export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration {
|
||||
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
|
||||
}
|
||||
@@ -4073,7 +4124,7 @@ namespace ts {
|
||||
|| kind === SyntaxKind.MergeDeclarationMarker;
|
||||
}
|
||||
|
||||
export function isDeclaration(node: Node): node is Declaration {
|
||||
export function isDeclaration(node: Node): node is NamedDeclaration {
|
||||
return isDeclarationKind(node.kind);
|
||||
}
|
||||
|
||||
@@ -4202,6 +4253,52 @@ namespace ts {
|
||||
// Firefox has Object.prototype.watch
|
||||
return options.watch && options.hasOwnProperty("watch");
|
||||
}
|
||||
|
||||
export function getCheckFlags(symbol: Symbol): CheckFlags {
|
||||
return symbol.flags & SymbolFlags.Transient ? (<TransientSymbol>symbol).checkFlags : 0;
|
||||
}
|
||||
|
||||
export function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags {
|
||||
if (s.valueDeclaration) {
|
||||
const flags = getCombinedModifierFlags(s.valueDeclaration);
|
||||
return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier;
|
||||
}
|
||||
if (getCheckFlags(s) & CheckFlags.Synthetic) {
|
||||
const checkFlags = (<TransientSymbol>s).checkFlags;
|
||||
const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private :
|
||||
checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public :
|
||||
ModifierFlags.Protected;
|
||||
const staticModifier = checkFlags & CheckFlags.ContainsStatic ? ModifierFlags.Static : 0;
|
||||
return accessModifier | staticModifier;
|
||||
}
|
||||
if (s.flags & SymbolFlags.Prototype) {
|
||||
return ModifierFlags.Public | ModifierFlags.Static;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function levenshtein(s1: string, s2: string): number {
|
||||
let previous: number[] = new Array(s2.length + 1);
|
||||
let current: number[] = new Array(s2.length + 1);
|
||||
for (let i = 0; i < s2.length + 1; i++) {
|
||||
previous[i] = i;
|
||||
current[i] = -1;
|
||||
}
|
||||
for (let i = 1; i < s1.length + 1; i++) {
|
||||
current[0] = i;
|
||||
for (let j = 1; j < s2.length + 1; j++) {
|
||||
current[j] = Math.min(
|
||||
previous[j] + 1,
|
||||
current[j - 1] + 1,
|
||||
previous[j - 1] + (s1[i - 1] === s2[j - 1] ? 0 : 2));
|
||||
}
|
||||
// shift current back to previous, and then reuse previous' array
|
||||
const tmp = previous;
|
||||
previous = current;
|
||||
current = tmp;
|
||||
}
|
||||
return previous[previous.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
namespace ts {
|
||||
@@ -4632,4 +4729,25 @@ namespace ts {
|
||||
export function unescapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
export function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined {
|
||||
if (!declaration) {
|
||||
return undefined;
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.BinaryExpression) {
|
||||
const expr = declaration as BinaryExpression;
|
||||
switch (getSpecialPropertyAssignmentKind(expr)) {
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
return (expr.left as PropertyAccessExpression).name;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (declaration as NamedDeclaration).name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+174
-118
@@ -218,17 +218,12 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.EndOfDeclarationMarker:
|
||||
case SyntaxKind.MissingDeclaration:
|
||||
// No need to visit nodes with no children.
|
||||
return node;
|
||||
|
||||
switch (kind) {
|
||||
// Names
|
||||
|
||||
case SyntaxKind.Identifier:
|
||||
return updateIdentifier(<Identifier>node, nodesVisitor((<Identifier>node).typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.QualifiedName:
|
||||
return updateQualifiedName(<QualifiedName>node,
|
||||
visitNode((<QualifiedName>node).left, visitor, isEntityName),
|
||||
@@ -238,45 +233,13 @@ namespace ts {
|
||||
return updateComputedPropertyName(<ComputedPropertyName>node,
|
||||
visitNode((<ComputedPropertyName>node).expression, visitor, isExpression));
|
||||
|
||||
// Signatures and Signature Elements
|
||||
case SyntaxKind.FunctionType:
|
||||
return updateFunctionTypeNode(<FunctionTypeNode>node,
|
||||
nodesVisitor((<FunctionTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<FunctionTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<FunctionTypeNode>node).type, visitor, isTypeNode));
|
||||
// Signature elements
|
||||
|
||||
case SyntaxKind.ConstructorType:
|
||||
return updateConstructorTypeNode(<ConstructorTypeNode>node,
|
||||
nodesVisitor((<ConstructorTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructorTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructorTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return updateCallSignatureDeclaration(<CallSignatureDeclaration>node,
|
||||
nodesVisitor((<CallSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<CallSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<CallSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return updateConstructSignatureDeclaration(<ConstructSignatureDeclaration>node,
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
return updateMethodSignature(<MethodSignature>node,
|
||||
nodesVisitor((<MethodSignature>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<MethodSignature>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<MethodSignature>node).type, visitor, isTypeNode),
|
||||
visitNode((<MethodSignature>node).name, visitor, isPropertyName),
|
||||
visitNode((<MethodSignature>node).questionToken, tokenVisitor, isToken));
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
return updateIndexSignatureDeclaration(<IndexSignatureDeclaration>node,
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).modifiers, visitor, isModifier),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<IndexSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
case SyntaxKind.TypeParameter:
|
||||
return updateTypeParameterDeclaration(<TypeParameterDeclaration>node,
|
||||
visitNode((<TypeParameterDeclaration>node).name, visitor, isIdentifier),
|
||||
visitNode((<TypeParameterDeclaration>node).constraint, visitor, isTypeNode),
|
||||
visitNode((<TypeParameterDeclaration>node).default, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
return updateParameter(<ParameterDeclaration>node,
|
||||
@@ -292,70 +255,11 @@ namespace ts {
|
||||
return updateDecorator(<Decorator>node,
|
||||
visitNode((<Decorator>node).expression, visitor, isExpression));
|
||||
|
||||
// Types
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
return updateTypeReferenceNode(<TypeReferenceNode>node,
|
||||
visitNode((<TypeReferenceNode>node).typeName, visitor, isEntityName),
|
||||
nodesVisitor((<TypeReferenceNode>node).typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
return updateTypePredicateNode(<TypePredicateNode>node,
|
||||
visitNode((<TypePredicateNode>node).parameterName, visitor),
|
||||
visitNode((<TypePredicateNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
return updateTypeQueryNode((<TypeQueryNode>node), visitNode((<TypeQueryNode>node).exprName, visitor, isEntityName));
|
||||
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return updateTypeLiteralNode((<TypeLiteralNode>node), nodesVisitor((<TypeLiteralNode>node).members, visitor));
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
return updateArrayTypeNode(<ArrayTypeNode>node, visitNode((<ArrayTypeNode>node).elementType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TupleType:
|
||||
return updateTypleTypeNode((<TupleTypeNode>node), nodesVisitor((<TupleTypeNode>node).elementTypes, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
return updateUnionOrIntersectionTypeNode(<UnionOrIntersectionTypeNode>node,
|
||||
nodesVisitor((<UnionOrIntersectionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return updateParenthesizedType(<ParenthesizedTypeNode>node,
|
||||
visitNode((<ParenthesizedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeOperator:
|
||||
return updateTypeOperatorNode(<TypeOperatorNode>node, visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return updateIndexedAccessTypeNode((<IndexedAccessTypeNode>node),
|
||||
visitNode((<IndexedAccessTypeNode>node).objectType, visitor, isTypeNode),
|
||||
visitNode((<IndexedAccessTypeNode>node).indexType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MappedType:
|
||||
return updateMappedTypeNode((<MappedTypeNode>node),
|
||||
visitNode((<MappedTypeNode>node).readonlyToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).typeParameter, visitor, isTypeParameter),
|
||||
visitNode((<MappedTypeNode>node).questionToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.LiteralType:
|
||||
return updateLiteralTypeNode(<LiteralTypeNode>node,
|
||||
visitNode((<LiteralTypeNode>node).literal, visitor, isExpression));
|
||||
|
||||
// Type Declarations
|
||||
|
||||
case SyntaxKind.TypeParameter:
|
||||
return updateTypeParameterDeclaration(<TypeParameterDeclaration>node,
|
||||
visitNode((<TypeParameterDeclaration>node).name, visitor, isIdentifier),
|
||||
visitNode((<TypeParameterDeclaration>node).constraint, visitor, isTypeNode),
|
||||
visitNode((<TypeParameterDeclaration>node).default, visitor, isTypeNode));
|
||||
|
||||
// Type members
|
||||
// Type elements
|
||||
|
||||
case SyntaxKind.PropertySignature:
|
||||
return updatePropertySignature((<PropertySignature>node),
|
||||
nodesVisitor((<PropertySignature>node).modifiers, visitor, isToken),
|
||||
visitNode((<PropertySignature>node).name, visitor, isPropertyName),
|
||||
visitNode((<PropertySignature>node).questionToken, tokenVisitor, isToken),
|
||||
visitNode((<PropertySignature>node).type, visitor, isTypeNode),
|
||||
@@ -369,6 +273,14 @@ namespace ts {
|
||||
visitNode((<PropertyDeclaration>node).type, visitor, isTypeNode),
|
||||
visitNode((<PropertyDeclaration>node).initializer, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
return updateMethodSignature(<MethodSignature>node,
|
||||
nodesVisitor((<MethodSignature>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<MethodSignature>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<MethodSignature>node).type, visitor, isTypeNode),
|
||||
visitNode((<MethodSignature>node).name, visitor, isPropertyName),
|
||||
visitNode((<MethodSignature>node).questionToken, tokenVisitor, isToken));
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return updateMethod(<MethodDeclaration>node,
|
||||
nodesVisitor((<MethodDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -405,7 +317,99 @@ namespace ts {
|
||||
visitParameterList((<SetAccessorDeclaration>node).parameters, visitor, context, nodesVisitor),
|
||||
visitFunctionBody((<SetAccessorDeclaration>node).body, visitor, context));
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return updateCallSignature(<CallSignatureDeclaration>node,
|
||||
nodesVisitor((<CallSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<CallSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<CallSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return updateConstructSignature(<ConstructSignatureDeclaration>node,
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
return updateIndexSignature(<IndexSignatureDeclaration>node,
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).modifiers, visitor, isModifier),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<IndexSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
// Types
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
return updateTypePredicateNode(<TypePredicateNode>node,
|
||||
visitNode((<TypePredicateNode>node).parameterName, visitor),
|
||||
visitNode((<TypePredicateNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
return updateTypeReferenceNode(<TypeReferenceNode>node,
|
||||
visitNode((<TypeReferenceNode>node).typeName, visitor, isEntityName),
|
||||
nodesVisitor((<TypeReferenceNode>node).typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
return updateFunctionTypeNode(<FunctionTypeNode>node,
|
||||
nodesVisitor((<FunctionTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<FunctionTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<FunctionTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructorType:
|
||||
return updateConstructorTypeNode(<ConstructorTypeNode>node,
|
||||
nodesVisitor((<ConstructorTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructorTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructorTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
return updateTypeQueryNode((<TypeQueryNode>node),
|
||||
visitNode((<TypeQueryNode>node).exprName, visitor, isEntityName));
|
||||
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return updateTypeLiteralNode((<TypeLiteralNode>node),
|
||||
nodesVisitor((<TypeLiteralNode>node).members, visitor, isTypeElement));
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
return updateArrayTypeNode(<ArrayTypeNode>node,
|
||||
visitNode((<ArrayTypeNode>node).elementType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TupleType:
|
||||
return updateTypleTypeNode((<TupleTypeNode>node),
|
||||
nodesVisitor((<TupleTypeNode>node).elementTypes, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.UnionType:
|
||||
return updateUnionTypeNode(<UnionTypeNode>node,
|
||||
nodesVisitor((<UnionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IntersectionType:
|
||||
return updateIntersectionTypeNode(<IntersectionTypeNode>node,
|
||||
nodesVisitor((<IntersectionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return updateParenthesizedType(<ParenthesizedTypeNode>node,
|
||||
visitNode((<ParenthesizedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeOperator:
|
||||
return updateTypeOperatorNode(<TypeOperatorNode>node,
|
||||
visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return updateIndexedAccessTypeNode((<IndexedAccessTypeNode>node),
|
||||
visitNode((<IndexedAccessTypeNode>node).objectType, visitor, isTypeNode),
|
||||
visitNode((<IndexedAccessTypeNode>node).indexType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MappedType:
|
||||
return updateMappedTypeNode((<MappedTypeNode>node),
|
||||
visitNode((<MappedTypeNode>node).readonlyToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).typeParameter, visitor, isTypeParameter),
|
||||
visitNode((<MappedTypeNode>node).questionToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.LiteralType:
|
||||
return updateLiteralTypeNode(<LiteralTypeNode>node,
|
||||
visitNode((<LiteralTypeNode>node).literal, visitor, isExpression));
|
||||
|
||||
// Binding patterns
|
||||
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return updateObjectBindingPattern(<ObjectBindingPattern>node,
|
||||
nodesVisitor((<ObjectBindingPattern>node).elements, visitor, isBindingElement));
|
||||
@@ -422,6 +426,7 @@ namespace ts {
|
||||
visitNode((<BindingElement>node).initializer, visitor, isExpression));
|
||||
|
||||
// Expression
|
||||
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return updateArrayLiteral(<ArrayLiteralExpression>node,
|
||||
nodesVisitor((<ArrayLiteralExpression>node).elements, visitor, isExpression));
|
||||
@@ -500,11 +505,6 @@ namespace ts {
|
||||
return updateAwait(<AwaitExpression>node,
|
||||
visitNode((<AwaitExpression>node).expression, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return updateBinary(<BinaryExpression>node,
|
||||
visitNode((<BinaryExpression>node).left, visitor, isExpression),
|
||||
visitNode((<BinaryExpression>node).right, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return updatePrefix(<PrefixUnaryExpression>node,
|
||||
visitNode((<PrefixUnaryExpression>node).operand, visitor, isExpression));
|
||||
@@ -513,6 +513,12 @@ namespace ts {
|
||||
return updatePostfix(<PostfixUnaryExpression>node,
|
||||
visitNode((<PostfixUnaryExpression>node).operand, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return updateBinary(<BinaryExpression>node,
|
||||
visitNode((<BinaryExpression>node).left, visitor, isExpression),
|
||||
visitNode((<BinaryExpression>node).right, visitor, isExpression),
|
||||
visitNode((<BinaryExpression>node).operatorToken, visitor, isToken));
|
||||
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return updateConditional(<ConditionalExpression>node,
|
||||
visitNode((<ConditionalExpression>node).condition, visitor, isExpression),
|
||||
@@ -555,13 +561,19 @@ namespace ts {
|
||||
return updateNonNullExpression(<NonNullExpression>node,
|
||||
visitNode((<NonNullExpression>node).expression, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.MetaProperty:
|
||||
return updateMetaProperty(<MetaProperty>node,
|
||||
visitNode((<MetaProperty>node).name, visitor, isIdentifier));
|
||||
|
||||
// Misc
|
||||
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return updateTemplateSpan(<TemplateSpan>node,
|
||||
visitNode((<TemplateSpan>node).expression, visitor, isExpression),
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateMiddleOrTemplateTail));
|
||||
|
||||
// Element
|
||||
|
||||
case SyntaxKind.Block:
|
||||
return updateBlock(<Block>node,
|
||||
nodesVisitor((<Block>node).statements, visitor, isStatement));
|
||||
@@ -678,6 +690,23 @@ namespace ts {
|
||||
nodesVisitor((<ClassDeclaration>node).heritageClauses, visitor, isHeritageClause),
|
||||
nodesVisitor((<ClassDeclaration>node).members, visitor, isClassElement));
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return updateInterfaceDeclaration(<InterfaceDeclaration>node,
|
||||
nodesVisitor((<InterfaceDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<InterfaceDeclaration>node).modifiers, visitor, isModifier),
|
||||
visitNode((<InterfaceDeclaration>node).name, visitor, isIdentifier),
|
||||
nodesVisitor((<InterfaceDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<InterfaceDeclaration>node).heritageClauses, visitor, isHeritageClause),
|
||||
nodesVisitor((<InterfaceDeclaration>node).members, visitor, isTypeElement));
|
||||
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return updateTypeAliasDeclaration(<TypeAliasDeclaration>node,
|
||||
nodesVisitor((<TypeAliasDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<TypeAliasDeclaration>node).modifiers, visitor, isModifier),
|
||||
visitNode((<TypeAliasDeclaration>node).name, visitor, isIdentifier),
|
||||
nodesVisitor((<TypeAliasDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
visitNode((<TypeAliasDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return updateEnumDeclaration(<EnumDeclaration>node,
|
||||
nodesVisitor((<EnumDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -700,6 +729,10 @@ namespace ts {
|
||||
return updateCaseBlock(<CaseBlock>node,
|
||||
nodesVisitor((<CaseBlock>node).clauses, visitor, isCaseOrDefaultClause));
|
||||
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
return updateNamespaceExportDeclaration(<NamespaceExportDeclaration>node,
|
||||
visitNode((<NamespaceExportDeclaration>node).name, visitor, isIdentifier));
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return updateImportEqualsDeclaration(<ImportEqualsDeclaration>node,
|
||||
nodesVisitor((<ImportEqualsDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -755,21 +788,19 @@ namespace ts {
|
||||
visitNode((<ExportSpecifier>node).name, visitor, isIdentifier));
|
||||
|
||||
// Module references
|
||||
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
return updateExternalModuleReference(<ExternalModuleReference>node,
|
||||
visitNode((<ExternalModuleReference>node).expression, visitor, isExpression));
|
||||
|
||||
// JSX
|
||||
|
||||
case SyntaxKind.JsxElement:
|
||||
return updateJsxElement(<JsxElement>node,
|
||||
visitNode((<JsxElement>node).openingElement, visitor, isJsxOpeningElement),
|
||||
nodesVisitor((<JsxElement>node).children, visitor, isJsxChild),
|
||||
visitNode((<JsxElement>node).closingElement, visitor, isJsxClosingElement));
|
||||
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return updateJsxAttributes(<JsxAttributes>node,
|
||||
nodesVisitor((<JsxAttributes>node).properties, visitor, isJsxAttributeLike));
|
||||
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
return updateJsxSelfClosingElement(<JsxSelfClosingElement>node,
|
||||
visitNode((<JsxSelfClosingElement>node).tagName, visitor, isJsxTagNameExpression),
|
||||
@@ -789,6 +820,10 @@ namespace ts {
|
||||
visitNode((<JsxAttribute>node).name, visitor, isIdentifier),
|
||||
visitNode((<JsxAttribute>node).initializer, visitor, isStringLiteralOrJsxExpression));
|
||||
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return updateJsxAttributes(<JsxAttributes>node,
|
||||
nodesVisitor((<JsxAttributes>node).properties, visitor, isJsxAttributeLike));
|
||||
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
return updateJsxSpreadAttribute(<JsxSpreadAttribute>node,
|
||||
visitNode((<JsxSpreadAttribute>node).expression, visitor, isExpression));
|
||||
@@ -798,6 +833,7 @@ namespace ts {
|
||||
visitNode((<JsxExpression>node).expression, visitor, isExpression));
|
||||
|
||||
// Clauses
|
||||
|
||||
case SyntaxKind.CaseClause:
|
||||
return updateCaseClause(<CaseClause>node,
|
||||
visitNode((<CaseClause>node).expression, visitor, isExpression),
|
||||
@@ -817,6 +853,7 @@ namespace ts {
|
||||
visitNode((<CatchClause>node).block, visitor, isBlock));
|
||||
|
||||
// Property assignments
|
||||
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return updatePropertyAssignment(<PropertyAssignment>node,
|
||||
visitNode((<PropertyAssignment>node).name, visitor, isPropertyName),
|
||||
@@ -847,9 +884,15 @@ namespace ts {
|
||||
return updatePartiallyEmittedExpression(<PartiallyEmittedExpression>node,
|
||||
visitNode((<PartiallyEmittedExpression>node).expression, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.CommaListExpression:
|
||||
return updateCommaList(<CommaListExpression>node,
|
||||
nodesVisitor((<CommaListExpression>node).elements, visitor, isExpression));
|
||||
|
||||
default:
|
||||
// No need to visit nodes with no children.
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -935,6 +978,15 @@ namespace ts {
|
||||
break;
|
||||
|
||||
// Type member
|
||||
|
||||
case SyntaxKind.PropertySignature:
|
||||
result = reduceNodes((<PropertySignature>node).modifiers, cbNodes, result);
|
||||
result = reduceNode((<PropertySignature>node).name, cbNode, result);
|
||||
result = reduceNode((<PropertySignature>node).questionToken, cbNode, result);
|
||||
result = reduceNode((<PropertySignature>node).type, cbNode, result);
|
||||
result = reduceNode((<PropertySignature>node).initializer, cbNode, result);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
result = reduceNodes((<PropertyDeclaration>node).decorators, cbNodes, result);
|
||||
result = reduceNodes((<PropertyDeclaration>node).modifiers, cbNodes, result);
|
||||
@@ -1358,6 +1410,10 @@ namespace ts {
|
||||
result = reduceNode((<PartiallyEmittedExpression>node).expression, cbNode, result);
|
||||
break;
|
||||
|
||||
case SyntaxKind.CommaListExpression:
|
||||
result = reduceNodes((<CommaListExpression>node).elements, cbNodes, result);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+158
-58
@@ -655,7 +655,7 @@ namespace FourSlash {
|
||||
ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => {
|
||||
const marker = this.getMarkerByName(endMarker);
|
||||
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
|
||||
this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
|
||||
this.raiseError(`goToDefinition failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -916,7 +916,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private getNode(): ts.Node {
|
||||
return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition);
|
||||
return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition, /*includeJsDocComment*/ false);
|
||||
}
|
||||
|
||||
private goToAndGetNode(range: Range): ts.Node {
|
||||
@@ -994,17 +994,15 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public verifyReferenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void {
|
||||
interface ReferenceJson { definition: string; ranges: ts.ReferenceEntry[]; }
|
||||
type ReferencesJson = ReferenceJson[];
|
||||
const fullExpected = parts.map<ReferenceJson>(({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) }));
|
||||
const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) }));
|
||||
|
||||
for (const startRange of toArray(startRanges)) {
|
||||
this.goToRangeStart(startRange);
|
||||
const fullActual = ts.map<ts.ReferencedSymbol, ReferenceJson>(this.findReferencesAtCaret(), ({ definition, references }) => ({
|
||||
const fullActual = ts.map(this.findReferencesAtCaret(), ({ definition, references }) => ({
|
||||
definition: definition.displayParts.map(d => d.text).join(""),
|
||||
ranges: references
|
||||
}));
|
||||
this.assertObjectsEqual<ReferencesJson>(fullActual, fullExpected);
|
||||
this.assertObjectsEqual(fullActual, fullExpected);
|
||||
}
|
||||
|
||||
function rangeToReferenceEntry(r: Range): ts.ReferenceEntry {
|
||||
@@ -1047,6 +1045,10 @@ namespace FourSlash {
|
||||
this.raiseError(`${msgPrefix}At ${path}: ${msg}`);
|
||||
};
|
||||
|
||||
if ((actual === undefined) !== (expected === undefined)) {
|
||||
fail(`Expected ${expected}, got ${actual}`);
|
||||
}
|
||||
|
||||
for (const key in actual) if (ts.hasProperty(actual as any, key)) {
|
||||
const ak = actual[key], ek = expected[key];
|
||||
if (typeof ak === "object" && typeof ek === "object") {
|
||||
@@ -1062,6 +1064,14 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (fullActual === undefined || fullExpected === undefined) {
|
||||
if (fullActual === fullExpected) {
|
||||
return;
|
||||
}
|
||||
console.log("Expected:", stringify(fullExpected));
|
||||
console.log("Actual: ", stringify(fullActual));
|
||||
this.raiseError(msgPrefix);
|
||||
}
|
||||
recur(fullActual, fullExpected, "");
|
||||
|
||||
}
|
||||
@@ -2167,7 +2177,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
ts.zipWith(expected, actual, (expectedClassification, actualClassification) => {
|
||||
const expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||
const expectedType = expectedClassification.classificationType;
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
this.raiseError("verifyClassifications failed - expected classifications type to be " +
|
||||
expectedType + ", but was " +
|
||||
@@ -2347,7 +2357,8 @@ namespace FourSlash {
|
||||
private applyCodeAction(fileName: string, actions: ts.CodeAction[], index?: number): void {
|
||||
if (index === undefined) {
|
||||
if (!(actions && actions.length === 1)) {
|
||||
this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`);
|
||||
const actionText = (actions && actions.length) ? JSON.stringify(actions) : "none";
|
||||
this.raiseError(`Should find exactly one codefix, but found ${actionText}`);
|
||||
}
|
||||
index = 0;
|
||||
}
|
||||
@@ -2701,6 +2712,60 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyApplicableRefactorAvailableAtMarker(negative: boolean, markerName: string) {
|
||||
const marker = this.getMarkerByName(markerName);
|
||||
const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, marker.position);
|
||||
const isAvailable = applicableRefactors && applicableRefactors.length > 0;
|
||||
if (negative && isAvailable) {
|
||||
this.raiseError(`verifyApplicableRefactorAvailableAtMarker failed - expected no refactor at marker ${markerName} but found some.`);
|
||||
}
|
||||
if (!negative && !isAvailable) {
|
||||
this.raiseError(`verifyApplicableRefactorAvailableAtMarker failed - expected a refactor at marker ${markerName} but found none.`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyApplicableRefactorAvailableForRange(negative: boolean) {
|
||||
const ranges = this.getRanges();
|
||||
if (!(ranges && ranges.length === 1)) {
|
||||
throw new Error("Exactly one refactor range is allowed per test.");
|
||||
}
|
||||
|
||||
const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, { pos: ranges[0].start, end: ranges[0].end });
|
||||
const isAvailable = applicableRefactors && applicableRefactors.length > 0;
|
||||
if (negative && isAvailable) {
|
||||
this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected no refactor but found some.`);
|
||||
}
|
||||
if (!negative && !isAvailable) {
|
||||
this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected a refactor but found none.`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyFileAfterApplyingRefactorAtMarker(
|
||||
markerName: string,
|
||||
expectedContent: string,
|
||||
refactorNameToApply: string,
|
||||
formattingOptions?: ts.FormatCodeSettings) {
|
||||
|
||||
formattingOptions = formattingOptions || this.formatCodeSettings;
|
||||
const markerPos = this.getMarkerByName(markerName).position;
|
||||
|
||||
const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, markerPos);
|
||||
const applicableRefactorToApply = ts.find(applicableRefactors, refactor => refactor.name === refactorNameToApply);
|
||||
|
||||
if (!applicableRefactorToApply) {
|
||||
this.raiseError(`The expected refactor: ${refactorNameToApply} is not available at the marker location.`);
|
||||
}
|
||||
|
||||
const codeActions = this.languageService.getRefactorCodeActions(this.activeFile.fileName, formattingOptions, markerPos, refactorNameToApply);
|
||||
|
||||
this.applyCodeAction(this.activeFile.fileName, codeActions);
|
||||
const actualContent = this.getFileContent(this.activeFile.fileName);
|
||||
|
||||
if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) {
|
||||
this.raiseError(`verifyFileAfterApplyingRefactors failed: expected:\n${expectedContent}\nactual:\n${actualContent}`);
|
||||
}
|
||||
}
|
||||
|
||||
public printAvailableCodeFixes() {
|
||||
const codeFixes = this.getCodeFixActions(this.activeFile.fileName);
|
||||
Harness.IO.log(stringify(codeFixes));
|
||||
@@ -3417,6 +3482,18 @@ namespace FourSlashInterface {
|
||||
|
||||
export class VerifyNegatable {
|
||||
public not: VerifyNegatable;
|
||||
public allowedClassElementKeywords = [
|
||||
"public",
|
||||
"private",
|
||||
"protected",
|
||||
"static",
|
||||
"abstract",
|
||||
"readonly",
|
||||
"get",
|
||||
"set",
|
||||
"constructor",
|
||||
"async"
|
||||
];
|
||||
|
||||
constructor(protected state: FourSlash.TestState, private negative = false) {
|
||||
if (!negative) {
|
||||
@@ -3453,6 +3530,12 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListIsEmpty(this.negative);
|
||||
}
|
||||
|
||||
public completionListContainsClassElementKeywords() {
|
||||
for (const keyword of this.allowedClassElementKeywords) {
|
||||
this.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword");
|
||||
}
|
||||
}
|
||||
|
||||
public completionListIsGlobal(expected: boolean) {
|
||||
this.state.verifyCompletionListIsGlobal(expected);
|
||||
}
|
||||
@@ -3496,6 +3579,14 @@ namespace FourSlashInterface {
|
||||
public codeFixAvailable() {
|
||||
this.state.verifyCodeFixAvailable(this.negative);
|
||||
}
|
||||
|
||||
public applicableRefactorAvailableAtMarker(markerName: string) {
|
||||
this.state.verifyApplicableRefactorAvailableAtMarker(this.negative, markerName);
|
||||
}
|
||||
|
||||
public applicableRefactorAvailableForRange() {
|
||||
this.state.verifyApplicableRefactorAvailableForRange(this.negative);
|
||||
}
|
||||
}
|
||||
|
||||
export class Verify extends VerifyNegatable {
|
||||
@@ -3710,6 +3801,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyRangeAfterCodeFix(expectedText, includeWhiteSpace, errorCode, index);
|
||||
}
|
||||
|
||||
public fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, formattingOptions?: ts.FormatCodeSettings): void {
|
||||
this.state.verifyFileAfterApplyingRefactorAtMarker(markerName, expectedContent, refactorNameToApply, formattingOptions);
|
||||
}
|
||||
|
||||
public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void {
|
||||
this.state.verifyImportFixAtPosition(expectedTextArray, errorCode);
|
||||
}
|
||||
@@ -3784,7 +3879,7 @@ namespace FourSlashInterface {
|
||||
/**
|
||||
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
|
||||
*/
|
||||
public semanticClassificationsAre(...classifications: { classificationType: string; text: string; textSpan?: FourSlash.TextSpan }[]) {
|
||||
public semanticClassificationsAre(...classifications: Classification[]) {
|
||||
this.state.verifySemanticClassifications(classifications);
|
||||
}
|
||||
|
||||
@@ -3979,102 +4074,107 @@ namespace FourSlashInterface {
|
||||
}
|
||||
}
|
||||
|
||||
interface Classification {
|
||||
classificationType: ts.ClassificationTypeNames;
|
||||
text: string;
|
||||
textSpan?: FourSlash.TextSpan;
|
||||
}
|
||||
export namespace Classification {
|
||||
export function comment(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("comment", text, position);
|
||||
export function comment(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.comment, text, position);
|
||||
}
|
||||
|
||||
export function identifier(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("identifier", text, position);
|
||||
export function identifier(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.identifier, text, position);
|
||||
}
|
||||
|
||||
export function keyword(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("keyword", text, position);
|
||||
export function keyword(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.keyword, text, position);
|
||||
}
|
||||
|
||||
export function numericLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("numericLiteral", text, position);
|
||||
export function numericLiteral(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.numericLiteral, text, position);
|
||||
}
|
||||
|
||||
export function operator(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("operator", text, position);
|
||||
export function operator(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.operator, text, position);
|
||||
}
|
||||
|
||||
export function stringLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("stringLiteral", text, position);
|
||||
export function stringLiteral(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.stringLiteral, text, position);
|
||||
}
|
||||
|
||||
export function whiteSpace(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("whiteSpace", text, position);
|
||||
export function whiteSpace(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.whiteSpace, text, position);
|
||||
}
|
||||
|
||||
export function text(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("text", text, position);
|
||||
export function text(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.text, text, position);
|
||||
}
|
||||
|
||||
export function punctuation(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("punctuation", text, position);
|
||||
export function punctuation(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.punctuation, text, position);
|
||||
}
|
||||
|
||||
export function docCommentTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("docCommentTagName", text, position);
|
||||
export function docCommentTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.docCommentTagName, text, position);
|
||||
}
|
||||
|
||||
export function className(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("className", text, position);
|
||||
export function className(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.className, text, position);
|
||||
}
|
||||
|
||||
export function enumName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("enumName", text, position);
|
||||
export function enumName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.enumName, text, position);
|
||||
}
|
||||
|
||||
export function interfaceName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("interfaceName", text, position);
|
||||
export function interfaceName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.interfaceName, text, position);
|
||||
}
|
||||
|
||||
export function moduleName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("moduleName", text, position);
|
||||
export function moduleName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.moduleName, text, position);
|
||||
}
|
||||
|
||||
export function typeParameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("typeParameterName", text, position);
|
||||
export function typeParameterName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.typeParameterName, text, position);
|
||||
}
|
||||
|
||||
export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("parameterName", text, position);
|
||||
export function parameterName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.parameterName, text, position);
|
||||
}
|
||||
|
||||
export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("typeAliasName", text, position);
|
||||
export function typeAliasName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.typeAliasName, text, position);
|
||||
}
|
||||
|
||||
export function jsxOpenTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxOpenTagName", text, position);
|
||||
export function jsxOpenTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxOpenTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxCloseTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxCloseTagName", text, position);
|
||||
export function jsxCloseTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxCloseTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxSelfClosingTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxSelfClosingTagName", text, position);
|
||||
export function jsxSelfClosingTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxSelfClosingTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxAttribute(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxAttribute", text, position);
|
||||
export function jsxAttribute(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxAttribute, text, position);
|
||||
}
|
||||
|
||||
export function jsxText(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxText", text, position);
|
||||
export function jsxText(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxText, text, position);
|
||||
}
|
||||
|
||||
export function jsxAttributeStringLiteralValue(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } {
|
||||
return getClassification("jsxAttributeStringLiteralValue", text, position);
|
||||
export function jsxAttributeStringLiteralValue(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxAttributeStringLiteralValue, text, position);
|
||||
}
|
||||
|
||||
function getClassification(type: string, text: string, position?: number) {
|
||||
function getClassification(classificationType: ts.ClassificationTypeNames, text: string, position?: number): Classification {
|
||||
return {
|
||||
classificationType: type,
|
||||
classificationType,
|
||||
text: text,
|
||||
textSpan: position === undefined ? undefined : { start: position, end: position + text.length }
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Utils {
|
||||
assert.isFalse(child.pos < currentPos, "child.pos < currentPos");
|
||||
currentPos = child.end;
|
||||
},
|
||||
(array: ts.NodeArray<ts.Node>) => {
|
||||
array => {
|
||||
assert.isFalse(array.pos < node.pos, "array.pos < node.pos");
|
||||
assert.isFalse(array.end > node.end, "array.end > node.end");
|
||||
assert.isFalse(array.pos < currentPos, "array.pos < currentPos");
|
||||
@@ -383,7 +383,7 @@ namespace Utils {
|
||||
|
||||
assertStructuralEquals(child1, child2);
|
||||
},
|
||||
(array1: ts.NodeArray<ts.Node>) => {
|
||||
array1 => {
|
||||
const childName = findChildName(node1, array1);
|
||||
const array2: ts.NodeArray<ts.Node> = (<any>node2)[childName];
|
||||
|
||||
@@ -1984,5 +1984,5 @@ namespace Harness {
|
||||
return { unitName: libFile, content: io.readFile(libFile) };
|
||||
}
|
||||
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
if (Error) (<any>Error).stackTraceLimit = 100;
|
||||
}
|
||||
|
||||
@@ -489,6 +489,15 @@ namespace Harness.LanguageService {
|
||||
getCodeFixesAtPosition(): ts.CodeAction[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getCodeFixDiagnostics(): ts.Diagnostic[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getRefactorCodeActions(): ts.CodeAction[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getApplicableRefactors(): ts.ApplicableRefactorInfo[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getEmitOutput(fileName: string): ts.EmitOutput {
|
||||
return unwrapJSONCallResult(this.shim.getEmitOutput(fileName));
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ class ProjectRunner extends RunnerBase {
|
||||
const compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
|
||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||
if (ts.isDeclarationFile(sourceFile)) {
|
||||
if (sourceFile.isDeclarationFile) {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||
}
|
||||
else if (!(compilerOptions.outFile || compilerOptions.out)) {
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -264,7 +264,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -295,7 +295,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -326,7 +326,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
|
||||
@@ -241,6 +241,18 @@ namespace ts {
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("argSynonymForParamTag",
|
||||
`/**
|
||||
* @arg {number} name1 Description
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("argumentSynonymForParamTag",
|
||||
`/**
|
||||
* @argument {number} name1 Description
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("templateTag",
|
||||
`/**
|
||||
* @template T
|
||||
|
||||
@@ -98,8 +98,43 @@ namespace ts {
|
||||
)
|
||||
])
|
||||
);
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/15971
|
||||
const classWithOptionalMethodAndProperty = createClassDeclaration(
|
||||
undefined,
|
||||
/* modifiers */ createNodeArray([createToken(SyntaxKind.DeclareKeyword)]),
|
||||
/* name */ createIdentifier("X"),
|
||||
undefined,
|
||||
undefined,
|
||||
createNodeArray([
|
||||
createMethod(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
/* name */ createIdentifier("method"),
|
||||
/* questionToken */ createToken(SyntaxKind.QuestionToken),
|
||||
undefined,
|
||||
undefined,
|
||||
/* type */ createKeywordTypeNode(SyntaxKind.VoidKeyword),
|
||||
undefined
|
||||
),
|
||||
createProperty(
|
||||
undefined,
|
||||
undefined,
|
||||
/* name */ createIdentifier("property"),
|
||||
/* questionToken */ createToken(SyntaxKind.QuestionToken),
|
||||
/* type */ createKeywordTypeNode(SyntaxKind.StringKeyword),
|
||||
undefined
|
||||
),
|
||||
])
|
||||
);
|
||||
|
||||
// tslint:enable boolean-trivia
|
||||
printsCorrectly("class", {}, printer => printer.printNode(EmitHint.Unspecified, syntheticNode, sourceFile));
|
||||
|
||||
printsCorrectly("namespaceExportDeclaration", {}, printer => printer.printNode(EmitHint.Unspecified, createNamespaceExportDeclaration("B"), sourceFile));
|
||||
|
||||
printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode(EmitHint.Unspecified, classWithOptionalMethodAndProperty, sourceFile));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ describe("PreProcessFile:", function () {
|
||||
/*readImportFile*/ true,
|
||||
/*detectJavaScriptImports*/ false,
|
||||
{
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 37 }, { fileName: "refFile2.ts", pos: 38, end: 73 },
|
||||
{ fileName: "refFile3.ts", pos: 74, end: 109 }, { fileName: "..\\refFile4d.ts", pos: 110, end: 150 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 22, end: 33 }, { fileName: "refFile2.ts", pos: 59, end: 70 },
|
||||
{ fileName: "refFile3.ts", pos: 94, end: 105 }, { fileName: "..\\refFile4d.ts", pos: 131, end: 146 }],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
ambientExternalModules: undefined,
|
||||
@@ -104,7 +104,7 @@ describe("PreProcessFile:", function () {
|
||||
/*readImportFile*/ true,
|
||||
/*detectJavaScriptImports*/ false,
|
||||
{
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }, { fileName: "refFile2.ts", pos: 36, end: 71 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 20, end: 31 }, { fileName: "refFile2.ts", pos: 57, end: 68 }],
|
||||
typeReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }],
|
||||
ambientExternalModules: undefined,
|
||||
@@ -117,7 +117,7 @@ describe("PreProcessFile:", function () {
|
||||
/*readImportFile*/ true,
|
||||
/*detectJavaScriptImports*/ false,
|
||||
{
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 20, end: 31 }],
|
||||
typeReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }],
|
||||
ambientExternalModules: undefined,
|
||||
@@ -442,12 +442,12 @@ describe("PreProcessFile:", function () {
|
||||
/*detectJavaScriptImports*/ false,
|
||||
{
|
||||
referencedFiles: [
|
||||
{ "pos": 13, "end": 38, "fileName": "a" },
|
||||
{ "pos": 91, "end": 117, "fileName": "a2" }
|
||||
{ "pos": 34, "end": 35, "fileName": "a" },
|
||||
{ "pos": 112, "end": 114, "fileName": "a2" }
|
||||
],
|
||||
typeReferenceDirectives: [
|
||||
{ "pos": 51, "end": 78, "fileName": "a1" },
|
||||
{ "pos": 130, "end": 157, "fileName": "a3" }
|
||||
{ "pos": 73, "end": 75, "fileName": "a1" },
|
||||
{ "pos": 152, "end": 154, "fileName": "a3" }
|
||||
],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: undefined,
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace ts.server {
|
||||
type: "request",
|
||||
arguments: {
|
||||
formatOptions: {
|
||||
indentStyle: "Block"
|
||||
indentStyle: protocol.IndentStyle.Block,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -149,11 +149,11 @@ namespace ts.server {
|
||||
type: "request",
|
||||
arguments: {
|
||||
options: {
|
||||
module: "System",
|
||||
target: "ES5",
|
||||
jsx: "React",
|
||||
newLine: "Lf",
|
||||
moduleResolution: "Node"
|
||||
module: protocol.ModuleKind.System,
|
||||
target: protocol.ScriptTarget.ES5,
|
||||
jsx: protocol.JsxEmit.React,
|
||||
newLine: protocol.NewLineKind.Lf,
|
||||
moduleResolution: protocol.ModuleResolutionKind.Node,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -172,12 +172,81 @@ namespace ts.server {
|
||||
});
|
||||
|
||||
describe("onMessage", () => {
|
||||
const allCommandNames: CommandNames[] = [
|
||||
CommandNames.Brace,
|
||||
CommandNames.BraceFull,
|
||||
CommandNames.BraceCompletion,
|
||||
CommandNames.Change,
|
||||
CommandNames.Close,
|
||||
CommandNames.Completions,
|
||||
CommandNames.CompletionsFull,
|
||||
CommandNames.CompletionDetails,
|
||||
CommandNames.CompileOnSaveAffectedFileList,
|
||||
CommandNames.Configure,
|
||||
CommandNames.Definition,
|
||||
CommandNames.DefinitionFull,
|
||||
CommandNames.Implementation,
|
||||
CommandNames.ImplementationFull,
|
||||
CommandNames.Exit,
|
||||
CommandNames.Format,
|
||||
CommandNames.Formatonkey,
|
||||
CommandNames.FormatFull,
|
||||
CommandNames.FormatonkeyFull,
|
||||
CommandNames.FormatRangeFull,
|
||||
CommandNames.Geterr,
|
||||
CommandNames.GeterrForProject,
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
CommandNames.SyntacticDiagnosticsSync,
|
||||
CommandNames.NavBar,
|
||||
CommandNames.NavBarFull,
|
||||
CommandNames.Navto,
|
||||
CommandNames.NavtoFull,
|
||||
CommandNames.NavTree,
|
||||
CommandNames.NavTreeFull,
|
||||
CommandNames.Occurrences,
|
||||
CommandNames.DocumentHighlights,
|
||||
CommandNames.DocumentHighlightsFull,
|
||||
CommandNames.Open,
|
||||
CommandNames.Quickinfo,
|
||||
CommandNames.QuickinfoFull,
|
||||
CommandNames.References,
|
||||
CommandNames.ReferencesFull,
|
||||
CommandNames.Reload,
|
||||
CommandNames.Rename,
|
||||
CommandNames.RenameInfoFull,
|
||||
CommandNames.RenameLocationsFull,
|
||||
CommandNames.Saveto,
|
||||
CommandNames.SignatureHelp,
|
||||
CommandNames.SignatureHelpFull,
|
||||
CommandNames.TypeDefinition,
|
||||
CommandNames.ProjectInfo,
|
||||
CommandNames.ReloadProjects,
|
||||
CommandNames.Unknown,
|
||||
CommandNames.OpenExternalProject,
|
||||
CommandNames.CloseExternalProject,
|
||||
CommandNames.SynchronizeProjectList,
|
||||
CommandNames.ApplyChangedToOpenFiles,
|
||||
CommandNames.EncodedSemanticClassificationsFull,
|
||||
CommandNames.Cleanup,
|
||||
CommandNames.OutliningSpans,
|
||||
CommandNames.TodoComments,
|
||||
CommandNames.Indentation,
|
||||
CommandNames.DocCommentTemplate,
|
||||
CommandNames.CompilerOptionsDiagnosticsFull,
|
||||
CommandNames.NameOrDottedNameSpan,
|
||||
CommandNames.BreakpointStatement,
|
||||
CommandNames.CompilerOptionsForInferredProjects,
|
||||
CommandNames.GetCodeFixes,
|
||||
CommandNames.GetCodeFixesFull,
|
||||
CommandNames.GetSupportedCodeFixes,
|
||||
CommandNames.GetApplicableRefactors,
|
||||
CommandNames.GetRefactorCodeActions,
|
||||
CommandNames.GetRefactorCodeActionsFull,
|
||||
];
|
||||
|
||||
it("should not throw when commands are executed with invalid arguments", () => {
|
||||
let i = 0;
|
||||
for (const name in CommandNames) {
|
||||
if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) {
|
||||
continue;
|
||||
}
|
||||
for (const name of allCommandNames) {
|
||||
const req: protocol.Request = {
|
||||
command: name,
|
||||
seq: i,
|
||||
|
||||
@@ -337,6 +337,7 @@ namespace ts.projectSystem {
|
||||
this.map[timeoutId] = cb.bind(/*this*/ undefined, ...args);
|
||||
return timeoutId;
|
||||
}
|
||||
|
||||
unregister(id: any) {
|
||||
if (typeof id === "number") {
|
||||
delete this.map[id];
|
||||
@@ -352,10 +353,13 @@ namespace ts.projectSystem {
|
||||
}
|
||||
|
||||
invoke() {
|
||||
// Note: invoking a callback may result in new callbacks been queued,
|
||||
// so do not clear the entire callback list regardless. Only remove the
|
||||
// ones we have invoked.
|
||||
for (const key in this.map) {
|
||||
this.map[key]();
|
||||
delete this.map[key];
|
||||
}
|
||||
this.map = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3743,7 +3747,7 @@ namespace ts.projectSystem {
|
||||
|
||||
// run first step
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 messages");
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 message");
|
||||
const e1 = <protocol.Event>getMessage(0);
|
||||
assert.equal(e1.event, "syntaxDiag");
|
||||
host.clearOutput();
|
||||
@@ -3765,11 +3769,12 @@ namespace ts.projectSystem {
|
||||
|
||||
// run first step
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 messages");
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 message");
|
||||
const e1 = <protocol.Event>getMessage(0);
|
||||
assert.equal(e1.event, "syntaxDiag");
|
||||
host.clearOutput();
|
||||
|
||||
// the semanticDiag message
|
||||
host.runQueuedImmediateCallbacks();
|
||||
assert.equal(host.getOutput().length, 2, "expect 2 messages");
|
||||
const e2 = <protocol.Event>getMessage(0);
|
||||
@@ -3787,7 +3792,7 @@ namespace ts.projectSystem {
|
||||
assert.equal(host.getOutput().length, 0, "expect 0 messages");
|
||||
// run first step
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 messages");
|
||||
assert.equal(host.getOutput().length, 1, "expect 1 message");
|
||||
const e1 = <protocol.Event>getMessage(0);
|
||||
assert.equal(e1.event, "syntaxDiag");
|
||||
host.clearOutput();
|
||||
|
||||
Vendored
+4198
-4451
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -3,7 +3,7 @@ interface ProxyHandler<T extends object> {
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
|
||||
Vendored
+2
-1
@@ -1,4 +1,5 @@
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
/// <reference path="lib.es2017.intl.d.ts" />
|
||||
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year";
|
||||
|
||||
interface DateTimeFormatPart {
|
||||
type: DateTimeFormatPartTypes;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
formatToParts(date?: Date | number): DateTimeFormatPart[];
|
||||
}
|
||||
Vendored
+92
-1
@@ -23,5 +23,96 @@ interface SharedArrayBufferConstructor {
|
||||
readonly prototype: SharedArrayBuffer;
|
||||
new (byteLength: number): SharedArrayBuffer;
|
||||
}
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
interface ArrayBufferTypes {
|
||||
SharedArrayBuffer: SharedArrayBuffer;
|
||||
}
|
||||
|
||||
interface Atomics {
|
||||
/**
|
||||
* Adds a value to the value at the given position in the array, returning the original value.
|
||||
* Until this atomic operation completes, any other read or write operation against the array
|
||||
* will block.
|
||||
*/
|
||||
add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise AND of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or
|
||||
* write operation against the array will block.
|
||||
*/
|
||||
and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array if the original value equals the given
|
||||
* expected value, returning the original value. Until this atomic operation completes, any
|
||||
* other read or write operation against the array will block.
|
||||
*/
|
||||
compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array, returning the original value. Until
|
||||
* this atomic operation completes, any other read or write operation against the array will
|
||||
* block.
|
||||
*/
|
||||
exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether high-performance algorithms can use atomic operations
|
||||
* (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
|
||||
* array.
|
||||
*/
|
||||
isLockFree(size: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the value at the given position in the array. Until this atomic operation completes,
|
||||
* any other read or write operation against the array will block.
|
||||
*/
|
||||
load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise OR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores a value at the given position in the array, returning the new value. Until this
|
||||
* atomic operation completes, any other read or write operation against the array will block.
|
||||
*/
|
||||
store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Subtracts a value from the value at the given position in the array, returning the original
|
||||
* value. Until this atomic operation completes, any other read or write operation against the
|
||||
* array will block.
|
||||
*/
|
||||
sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* If the value at the given position in the array is equal to the provided value, the current
|
||||
* agent is put to sleep causing execution to suspend until the timeout expires (returning
|
||||
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
||||
* `"not-equal"`.
|
||||
*/
|
||||
wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
|
||||
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
*/
|
||||
wake(typedArray: Int32Array, index: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
||||
|
||||
readonly [Symbol.toStringTag]: "Atomics";
|
||||
}
|
||||
|
||||
declare var Atomics: Atomics;
|
||||
Vendored
+28
-20
@@ -1386,6 +1386,14 @@ interface ArrayBuffer {
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed ArrayBuffer types for the buffer of an ArrayBufferView and related Typed Arrays.
|
||||
*/
|
||||
interface ArrayBufferTypes {
|
||||
ArrayBuffer: ArrayBuffer;
|
||||
}
|
||||
type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
readonly prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
@@ -1397,7 +1405,7 @@ interface ArrayBufferView {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
buffer: ArrayBuffer;
|
||||
buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1539,7 +1547,7 @@ interface DataView {
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView;
|
||||
}
|
||||
declare const DataView: DataViewConstructor;
|
||||
|
||||
@@ -1556,7 +1564,7 @@ interface Int8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -1799,7 +1807,7 @@ interface Int8ArrayConstructor {
|
||||
readonly prototype: Int8Array;
|
||||
new (length: number): Int8Array;
|
||||
new (array: ArrayLike<number>): Int8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -1840,7 +1848,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2084,7 +2092,7 @@ interface Uint8ArrayConstructor {
|
||||
readonly prototype: Uint8Array;
|
||||
new (length: number): Uint8Array;
|
||||
new (array: ArrayLike<number>): Uint8Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2125,7 +2133,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2369,7 +2377,7 @@ interface Uint8ClampedArrayConstructor {
|
||||
readonly prototype: Uint8ClampedArray;
|
||||
new (length: number): Uint8ClampedArray;
|
||||
new (array: ArrayLike<number>): Uint8ClampedArray;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2409,7 +2417,7 @@ interface Int16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2653,7 +2661,7 @@ interface Int16ArrayConstructor {
|
||||
readonly prototype: Int16Array;
|
||||
new (length: number): Int16Array;
|
||||
new (array: ArrayLike<number>): Int16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2694,7 +2702,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -2938,7 +2946,7 @@ interface Uint16ArrayConstructor {
|
||||
readonly prototype: Uint16Array;
|
||||
new (length: number): Uint16Array;
|
||||
new (array: ArrayLike<number>): Uint16Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2978,7 +2986,7 @@ interface Int32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3222,7 +3230,7 @@ interface Int32ArrayConstructor {
|
||||
readonly prototype: Int32Array;
|
||||
new (length: number): Int32Array;
|
||||
new (array: ArrayLike<number>): Int32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3262,7 +3270,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3506,7 +3514,7 @@ interface Uint32ArrayConstructor {
|
||||
readonly prototype: Uint32Array;
|
||||
new (length: number): Uint32Array;
|
||||
new (array: ArrayLike<number>): Uint32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3546,7 +3554,7 @@ interface Float32Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -3790,7 +3798,7 @@ interface Float32ArrayConstructor {
|
||||
readonly prototype: Float32Array;
|
||||
new (length: number): Float32Array;
|
||||
new (array: ArrayLike<number>): Float32Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3831,7 +3839,7 @@ interface Float64Array {
|
||||
/**
|
||||
* The ArrayBuffer instance referenced by the array.
|
||||
*/
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly buffer: ArrayBufferLike;
|
||||
|
||||
/**
|
||||
* The length in bytes of the array.
|
||||
@@ -4075,7 +4083,7 @@ interface Float64ArrayConstructor {
|
||||
readonly prototype: Float64Array;
|
||||
new (length: number): Float64Array;
|
||||
new (array: ArrayLike<number>): Float64Array;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array;
|
||||
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
|
||||
Vendored
+145
-134
@@ -1,6 +1,6 @@
|
||||
|
||||
/////////////////////////////
|
||||
/// IE Worker APIs
|
||||
/// Worker APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface Algorithm {
|
||||
@@ -8,16 +8,16 @@ interface Algorithm {
|
||||
}
|
||||
|
||||
interface CacheQueryOptions {
|
||||
ignoreSearch?: boolean;
|
||||
ignoreMethod?: boolean;
|
||||
ignoreVary?: boolean;
|
||||
cacheName?: string;
|
||||
ignoreMethod?: boolean;
|
||||
ignoreSearch?: boolean;
|
||||
ignoreVary?: boolean;
|
||||
}
|
||||
|
||||
interface CloseEventInit extends EventInit {
|
||||
wasClean?: boolean;
|
||||
code?: number;
|
||||
reason?: string;
|
||||
wasClean?: boolean;
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
@@ -49,16 +49,16 @@ interface MessageEventInit extends EventInit {
|
||||
channel?: string;
|
||||
data?: any;
|
||||
origin?: string;
|
||||
source?: any;
|
||||
ports?: MessagePort[];
|
||||
source?: any;
|
||||
}
|
||||
|
||||
interface NotificationOptions {
|
||||
dir?: NotificationDirection;
|
||||
lang?: string;
|
||||
body?: string;
|
||||
tag?: string;
|
||||
dir?: NotificationDirection;
|
||||
icon?: string;
|
||||
lang?: string;
|
||||
tag?: string;
|
||||
}
|
||||
|
||||
interface ObjectURLOptions {
|
||||
@@ -66,29 +66,29 @@ interface ObjectURLOptions {
|
||||
}
|
||||
|
||||
interface PushSubscriptionOptionsInit {
|
||||
userVisibleOnly?: boolean;
|
||||
applicationServerKey?: any;
|
||||
userVisibleOnly?: boolean;
|
||||
}
|
||||
|
||||
interface RequestInit {
|
||||
method?: string;
|
||||
headers?: any;
|
||||
body?: any;
|
||||
referrer?: string;
|
||||
referrerPolicy?: ReferrerPolicy;
|
||||
mode?: RequestMode;
|
||||
credentials?: RequestCredentials;
|
||||
cache?: RequestCache;
|
||||
redirect?: RequestRedirect;
|
||||
credentials?: RequestCredentials;
|
||||
headers?: any;
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
method?: string;
|
||||
mode?: RequestMode;
|
||||
redirect?: RequestRedirect;
|
||||
referrer?: string;
|
||||
referrerPolicy?: ReferrerPolicy;
|
||||
window?: any;
|
||||
}
|
||||
|
||||
interface ResponseInit {
|
||||
headers?: any;
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
interface ClientQueryOptions {
|
||||
@@ -156,7 +156,7 @@ interface AudioBuffer {
|
||||
declare var AudioBuffer: {
|
||||
prototype: AudioBuffer;
|
||||
new(): AudioBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
interface Blob {
|
||||
readonly size: number;
|
||||
@@ -169,7 +169,7 @@ interface Blob {
|
||||
declare var Blob: {
|
||||
prototype: Blob;
|
||||
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
|
||||
}
|
||||
};
|
||||
|
||||
interface Cache {
|
||||
add(request: RequestInfo): Promise<void>;
|
||||
@@ -184,7 +184,7 @@ interface Cache {
|
||||
declare var Cache: {
|
||||
prototype: Cache;
|
||||
new(): Cache;
|
||||
}
|
||||
};
|
||||
|
||||
interface CacheStorage {
|
||||
delete(cacheName: string): Promise<boolean>;
|
||||
@@ -197,7 +197,7 @@ interface CacheStorage {
|
||||
declare var CacheStorage: {
|
||||
prototype: CacheStorage;
|
||||
new(): CacheStorage;
|
||||
}
|
||||
};
|
||||
|
||||
interface CloseEvent extends Event {
|
||||
readonly code: number;
|
||||
@@ -209,7 +209,7 @@ interface CloseEvent extends Event {
|
||||
declare var CloseEvent: {
|
||||
prototype: CloseEvent;
|
||||
new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface Console {
|
||||
assert(test?: boolean, message?: string, ...optionalParams: any[]): void;
|
||||
@@ -220,8 +220,8 @@ interface Console {
|
||||
dirxml(value: any): void;
|
||||
error(message?: any, ...optionalParams: any[]): void;
|
||||
exception(message?: string, ...optionalParams: any[]): void;
|
||||
group(groupTitle?: string): void;
|
||||
groupCollapsed(groupTitle?: string): void;
|
||||
group(groupTitle?: string, ...optionalParams: any[]): void;
|
||||
groupCollapsed(groupTitle?: string, ...optionalParams: any[]): void;
|
||||
groupEnd(): void;
|
||||
info(message?: any, ...optionalParams: any[]): void;
|
||||
log(message?: any, ...optionalParams: any[]): void;
|
||||
@@ -239,7 +239,7 @@ interface Console {
|
||||
declare var Console: {
|
||||
prototype: Console;
|
||||
new(): Console;
|
||||
}
|
||||
};
|
||||
|
||||
interface Coordinates {
|
||||
readonly accuracy: number;
|
||||
@@ -254,7 +254,7 @@ interface Coordinates {
|
||||
declare var Coordinates: {
|
||||
prototype: Coordinates;
|
||||
new(): Coordinates;
|
||||
}
|
||||
};
|
||||
|
||||
interface CryptoKey {
|
||||
readonly algorithm: KeyAlgorithm;
|
||||
@@ -266,7 +266,7 @@ interface CryptoKey {
|
||||
declare var CryptoKey: {
|
||||
prototype: CryptoKey;
|
||||
new(): CryptoKey;
|
||||
}
|
||||
};
|
||||
|
||||
interface DOMError {
|
||||
readonly name: string;
|
||||
@@ -276,7 +276,7 @@ interface DOMError {
|
||||
declare var DOMError: {
|
||||
prototype: DOMError;
|
||||
new(): DOMError;
|
||||
}
|
||||
};
|
||||
|
||||
interface DOMException {
|
||||
readonly code: number;
|
||||
@@ -296,10 +296,10 @@ interface DOMException {
|
||||
readonly INVALID_STATE_ERR: number;
|
||||
readonly NAMESPACE_ERR: number;
|
||||
readonly NETWORK_ERR: number;
|
||||
readonly NOT_FOUND_ERR: number;
|
||||
readonly NOT_SUPPORTED_ERR: number;
|
||||
readonly NO_DATA_ALLOWED_ERR: number;
|
||||
readonly NO_MODIFICATION_ALLOWED_ERR: number;
|
||||
readonly NOT_FOUND_ERR: number;
|
||||
readonly NOT_SUPPORTED_ERR: number;
|
||||
readonly PARSE_ERR: number;
|
||||
readonly QUOTA_EXCEEDED_ERR: number;
|
||||
readonly SECURITY_ERR: number;
|
||||
@@ -328,10 +328,10 @@ declare var DOMException: {
|
||||
readonly INVALID_STATE_ERR: number;
|
||||
readonly NAMESPACE_ERR: number;
|
||||
readonly NETWORK_ERR: number;
|
||||
readonly NOT_FOUND_ERR: number;
|
||||
readonly NOT_SUPPORTED_ERR: number;
|
||||
readonly NO_DATA_ALLOWED_ERR: number;
|
||||
readonly NO_MODIFICATION_ALLOWED_ERR: number;
|
||||
readonly NOT_FOUND_ERR: number;
|
||||
readonly NOT_SUPPORTED_ERR: number;
|
||||
readonly PARSE_ERR: number;
|
||||
readonly QUOTA_EXCEEDED_ERR: number;
|
||||
readonly SECURITY_ERR: number;
|
||||
@@ -342,7 +342,7 @@ declare var DOMException: {
|
||||
readonly URL_MISMATCH_ERR: number;
|
||||
readonly VALIDATION_ERR: number;
|
||||
readonly WRONG_DOCUMENT_ERR: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface DOMStringList {
|
||||
readonly length: number;
|
||||
@@ -354,7 +354,7 @@ interface DOMStringList {
|
||||
declare var DOMStringList: {
|
||||
prototype: DOMStringList;
|
||||
new(): DOMStringList;
|
||||
}
|
||||
};
|
||||
|
||||
interface ErrorEvent extends Event {
|
||||
readonly colno: number;
|
||||
@@ -368,12 +368,12 @@ interface ErrorEvent extends Event {
|
||||
declare var ErrorEvent: {
|
||||
prototype: ErrorEvent;
|
||||
new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface Event {
|
||||
readonly bubbles: boolean;
|
||||
cancelBubble: boolean;
|
||||
readonly cancelable: boolean;
|
||||
cancelBubble: boolean;
|
||||
readonly currentTarget: EventTarget;
|
||||
readonly defaultPrevented: boolean;
|
||||
readonly eventPhase: number;
|
||||
@@ -400,7 +400,7 @@ declare var Event: {
|
||||
readonly AT_TARGET: number;
|
||||
readonly BUBBLING_PHASE: number;
|
||||
readonly CAPTURING_PHASE: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface EventTarget {
|
||||
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
@@ -411,7 +411,7 @@ interface EventTarget {
|
||||
declare var EventTarget: {
|
||||
prototype: EventTarget;
|
||||
new(): EventTarget;
|
||||
}
|
||||
};
|
||||
|
||||
interface File extends Blob {
|
||||
readonly lastModifiedDate: any;
|
||||
@@ -422,7 +422,7 @@ interface File extends Blob {
|
||||
declare var File: {
|
||||
prototype: File;
|
||||
new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File;
|
||||
}
|
||||
};
|
||||
|
||||
interface FileList {
|
||||
readonly length: number;
|
||||
@@ -433,7 +433,7 @@ interface FileList {
|
||||
declare var FileList: {
|
||||
prototype: FileList;
|
||||
new(): FileList;
|
||||
}
|
||||
};
|
||||
|
||||
interface FileReader extends EventTarget, MSBaseReader {
|
||||
readonly error: DOMError;
|
||||
@@ -448,8 +448,17 @@ interface FileReader extends EventTarget, MSBaseReader {
|
||||
declare var FileReader: {
|
||||
prototype: FileReader;
|
||||
new(): FileReader;
|
||||
};
|
||||
|
||||
interface FormData {
|
||||
append(name: string, value: string | Blob, fileName?: string): void;
|
||||
}
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
};
|
||||
|
||||
interface Headers {
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string): void;
|
||||
@@ -462,7 +471,7 @@ interface Headers {
|
||||
declare var Headers: {
|
||||
prototype: Headers;
|
||||
new(init?: any): Headers;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBCursor {
|
||||
readonly direction: IDBCursorDirection;
|
||||
@@ -486,7 +495,7 @@ declare var IDBCursor: {
|
||||
readonly NEXT_NO_DUPLICATE: string;
|
||||
readonly PREV: string;
|
||||
readonly PREV_NO_DUPLICATE: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBCursorWithValue extends IDBCursor {
|
||||
readonly value: any;
|
||||
@@ -495,7 +504,7 @@ interface IDBCursorWithValue extends IDBCursor {
|
||||
declare var IDBCursorWithValue: {
|
||||
prototype: IDBCursorWithValue;
|
||||
new(): IDBCursorWithValue;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBDatabaseEventMap {
|
||||
"abort": Event;
|
||||
@@ -512,7 +521,7 @@ interface IDBDatabase extends EventTarget {
|
||||
close(): void;
|
||||
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: string | string[], mode?: string): IDBTransaction;
|
||||
transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction;
|
||||
addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -521,7 +530,7 @@ interface IDBDatabase extends EventTarget {
|
||||
declare var IDBDatabase: {
|
||||
prototype: IDBDatabase;
|
||||
new(): IDBDatabase;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBFactory {
|
||||
cmp(first: any, second: any): number;
|
||||
@@ -532,7 +541,7 @@ interface IDBFactory {
|
||||
declare var IDBFactory: {
|
||||
prototype: IDBFactory;
|
||||
new(): IDBFactory;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBIndex {
|
||||
keyPath: string | string[];
|
||||
@@ -543,14 +552,14 @@ interface IDBIndex {
|
||||
count(key?: IDBKeyRange | IDBValidKey): IDBRequest;
|
||||
get(key: IDBKeyRange | IDBValidKey): IDBRequest;
|
||||
getKey(key: IDBKeyRange | IDBValidKey): IDBRequest;
|
||||
openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest;
|
||||
openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest;
|
||||
openCursor(range?: IDBKeyRange | IDBValidKey, direction?: IDBCursorDirection): IDBRequest;
|
||||
openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: IDBCursorDirection): IDBRequest;
|
||||
}
|
||||
|
||||
declare var IDBIndex: {
|
||||
prototype: IDBIndex;
|
||||
new(): IDBIndex;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBKeyRange {
|
||||
readonly lower: any;
|
||||
@@ -566,7 +575,7 @@ declare var IDBKeyRange: {
|
||||
lowerBound(lower: any, open?: boolean): IDBKeyRange;
|
||||
only(value: any): IDBKeyRange;
|
||||
upperBound(upper: any, open?: boolean): IDBKeyRange;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBObjectStore {
|
||||
readonly indexNames: DOMStringList;
|
||||
@@ -582,14 +591,14 @@ interface IDBObjectStore {
|
||||
deleteIndex(indexName: string): void;
|
||||
get(key: any): IDBRequest;
|
||||
index(name: string): IDBIndex;
|
||||
openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest;
|
||||
openCursor(range?: IDBKeyRange | IDBValidKey, direction?: IDBCursorDirection): IDBRequest;
|
||||
put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest;
|
||||
}
|
||||
|
||||
declare var IDBObjectStore: {
|
||||
prototype: IDBObjectStore;
|
||||
new(): IDBObjectStore;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBOpenDBRequestEventMap extends IDBRequestEventMap {
|
||||
"blocked": Event;
|
||||
@@ -606,7 +615,7 @@ interface IDBOpenDBRequest extends IDBRequest {
|
||||
declare var IDBOpenDBRequest: {
|
||||
prototype: IDBOpenDBRequest;
|
||||
new(): IDBOpenDBRequest;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBRequestEventMap {
|
||||
"error": Event;
|
||||
@@ -614,7 +623,7 @@ interface IDBRequestEventMap {
|
||||
}
|
||||
|
||||
interface IDBRequest extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
readonly error: DOMException;
|
||||
onerror: (this: IDBRequest, ev: Event) => any;
|
||||
onsuccess: (this: IDBRequest, ev: Event) => any;
|
||||
readonly readyState: IDBRequestReadyState;
|
||||
@@ -628,7 +637,7 @@ interface IDBRequest extends EventTarget {
|
||||
declare var IDBRequest: {
|
||||
prototype: IDBRequest;
|
||||
new(): IDBRequest;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBTransactionEventMap {
|
||||
"abort": Event;
|
||||
@@ -638,7 +647,7 @@ interface IDBTransactionEventMap {
|
||||
|
||||
interface IDBTransaction extends EventTarget {
|
||||
readonly db: IDBDatabase;
|
||||
readonly error: DOMError;
|
||||
readonly error: DOMException;
|
||||
readonly mode: IDBTransactionMode;
|
||||
onabort: (this: IDBTransaction, ev: Event) => any;
|
||||
oncomplete: (this: IDBTransaction, ev: Event) => any;
|
||||
@@ -658,7 +667,7 @@ declare var IDBTransaction: {
|
||||
readonly READ_ONLY: string;
|
||||
readonly READ_WRITE: string;
|
||||
readonly VERSION_CHANGE: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface IDBVersionChangeEvent extends Event {
|
||||
readonly newVersion: number | null;
|
||||
@@ -668,7 +677,7 @@ interface IDBVersionChangeEvent extends Event {
|
||||
declare var IDBVersionChangeEvent: {
|
||||
prototype: IDBVersionChangeEvent;
|
||||
new(): IDBVersionChangeEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface ImageData {
|
||||
data: Uint8ClampedArray;
|
||||
@@ -680,7 +689,7 @@ declare var ImageData: {
|
||||
prototype: ImageData;
|
||||
new(width: number, height: number): ImageData;
|
||||
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
|
||||
}
|
||||
};
|
||||
|
||||
interface MessageChannel {
|
||||
readonly port1: MessagePort;
|
||||
@@ -690,7 +699,7 @@ interface MessageChannel {
|
||||
declare var MessageChannel: {
|
||||
prototype: MessageChannel;
|
||||
new(): MessageChannel;
|
||||
}
|
||||
};
|
||||
|
||||
interface MessageEvent extends Event {
|
||||
readonly data: any;
|
||||
@@ -703,7 +712,7 @@ interface MessageEvent extends Event {
|
||||
declare var MessageEvent: {
|
||||
prototype: MessageEvent;
|
||||
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface MessagePortEventMap {
|
||||
"message": MessageEvent;
|
||||
@@ -721,7 +730,7 @@ interface MessagePort extends EventTarget {
|
||||
declare var MessagePort: {
|
||||
prototype: MessagePort;
|
||||
new(): MessagePort;
|
||||
}
|
||||
};
|
||||
|
||||
interface NotificationEventMap {
|
||||
"click": Event;
|
||||
@@ -751,7 +760,7 @@ declare var Notification: {
|
||||
prototype: Notification;
|
||||
new(title: string, options?: NotificationOptions): Notification;
|
||||
requestPermission(callback?: NotificationPermissionCallback): Promise<NotificationPermission>;
|
||||
}
|
||||
};
|
||||
|
||||
interface Performance {
|
||||
readonly navigation: PerformanceNavigation;
|
||||
@@ -774,7 +783,7 @@ interface Performance {
|
||||
declare var Performance: {
|
||||
prototype: Performance;
|
||||
new(): Performance;
|
||||
}
|
||||
};
|
||||
|
||||
interface PerformanceNavigation {
|
||||
readonly redirectCount: number;
|
||||
@@ -793,18 +802,18 @@ declare var PerformanceNavigation: {
|
||||
readonly TYPE_NAVIGATE: number;
|
||||
readonly TYPE_RELOAD: number;
|
||||
readonly TYPE_RESERVED: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface PerformanceTiming {
|
||||
readonly connectEnd: number;
|
||||
readonly connectStart: number;
|
||||
readonly domainLookupEnd: number;
|
||||
readonly domainLookupStart: number;
|
||||
readonly domComplete: number;
|
||||
readonly domContentLoadedEventEnd: number;
|
||||
readonly domContentLoadedEventStart: number;
|
||||
readonly domInteractive: number;
|
||||
readonly domLoading: number;
|
||||
readonly domainLookupEnd: number;
|
||||
readonly domainLookupStart: number;
|
||||
readonly fetchStart: number;
|
||||
readonly loadEventEnd: number;
|
||||
readonly loadEventStart: number;
|
||||
@@ -824,7 +833,7 @@ interface PerformanceTiming {
|
||||
declare var PerformanceTiming: {
|
||||
prototype: PerformanceTiming;
|
||||
new(): PerformanceTiming;
|
||||
}
|
||||
};
|
||||
|
||||
interface Position {
|
||||
readonly coords: Coordinates;
|
||||
@@ -834,7 +843,7 @@ interface Position {
|
||||
declare var Position: {
|
||||
prototype: Position;
|
||||
new(): Position;
|
||||
}
|
||||
};
|
||||
|
||||
interface PositionError {
|
||||
readonly code: number;
|
||||
@@ -851,7 +860,7 @@ declare var PositionError: {
|
||||
readonly PERMISSION_DENIED: number;
|
||||
readonly POSITION_UNAVAILABLE: number;
|
||||
readonly TIMEOUT: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface ProgressEvent extends Event {
|
||||
readonly lengthComputable: boolean;
|
||||
@@ -863,7 +872,7 @@ interface ProgressEvent extends Event {
|
||||
declare var ProgressEvent: {
|
||||
prototype: ProgressEvent;
|
||||
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface PushManager {
|
||||
getSubscription(): Promise<PushSubscription>;
|
||||
@@ -874,7 +883,7 @@ interface PushManager {
|
||||
declare var PushManager: {
|
||||
prototype: PushManager;
|
||||
new(): PushManager;
|
||||
}
|
||||
};
|
||||
|
||||
interface PushSubscription {
|
||||
readonly endpoint: USVString;
|
||||
@@ -887,7 +896,7 @@ interface PushSubscription {
|
||||
declare var PushSubscription: {
|
||||
prototype: PushSubscription;
|
||||
new(): PushSubscription;
|
||||
}
|
||||
};
|
||||
|
||||
interface PushSubscriptionOptions {
|
||||
readonly applicationServerKey: ArrayBuffer | null;
|
||||
@@ -897,7 +906,7 @@ interface PushSubscriptionOptions {
|
||||
declare var PushSubscriptionOptions: {
|
||||
prototype: PushSubscriptionOptions;
|
||||
new(): PushSubscriptionOptions;
|
||||
}
|
||||
};
|
||||
|
||||
interface ReadableStream {
|
||||
readonly locked: boolean;
|
||||
@@ -908,7 +917,7 @@ interface ReadableStream {
|
||||
declare var ReadableStream: {
|
||||
prototype: ReadableStream;
|
||||
new(): ReadableStream;
|
||||
}
|
||||
};
|
||||
|
||||
interface ReadableStreamReader {
|
||||
cancel(): Promise<void>;
|
||||
@@ -919,7 +928,7 @@ interface ReadableStreamReader {
|
||||
declare var ReadableStreamReader: {
|
||||
prototype: ReadableStreamReader;
|
||||
new(): ReadableStreamReader;
|
||||
}
|
||||
};
|
||||
|
||||
interface Request extends Object, Body {
|
||||
readonly cache: RequestCache;
|
||||
@@ -941,7 +950,7 @@ interface Request extends Object, Body {
|
||||
declare var Request: {
|
||||
prototype: Request;
|
||||
new(input: Request | string, init?: RequestInit): Request;
|
||||
}
|
||||
};
|
||||
|
||||
interface Response extends Object, Body {
|
||||
readonly body: ReadableStream | null;
|
||||
@@ -957,7 +966,9 @@ interface Response extends Object, Body {
|
||||
declare var Response: {
|
||||
prototype: Response;
|
||||
new(body?: any, init?: ResponseInit): Response;
|
||||
}
|
||||
error: () => Response;
|
||||
redirect: (url: string, status?: number) => Response;
|
||||
};
|
||||
|
||||
interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
|
||||
"statechange": Event;
|
||||
@@ -975,7 +986,7 @@ interface ServiceWorker extends EventTarget, AbstractWorker {
|
||||
declare var ServiceWorker: {
|
||||
prototype: ServiceWorker;
|
||||
new(): ServiceWorker;
|
||||
}
|
||||
};
|
||||
|
||||
interface ServiceWorkerRegistrationEventMap {
|
||||
"updatefound": Event;
|
||||
@@ -1000,7 +1011,7 @@ interface ServiceWorkerRegistration extends EventTarget {
|
||||
declare var ServiceWorkerRegistration: {
|
||||
prototype: ServiceWorkerRegistration;
|
||||
new(): ServiceWorkerRegistration;
|
||||
}
|
||||
};
|
||||
|
||||
interface SyncManager {
|
||||
getTags(): any;
|
||||
@@ -1010,7 +1021,7 @@ interface SyncManager {
|
||||
declare var SyncManager: {
|
||||
prototype: SyncManager;
|
||||
new(): SyncManager;
|
||||
}
|
||||
};
|
||||
|
||||
interface URL {
|
||||
hash: string;
|
||||
@@ -1033,7 +1044,7 @@ declare var URL: {
|
||||
new(url: string, base?: string): URL;
|
||||
createObjectURL(object: any, options?: ObjectURLOptions): string;
|
||||
revokeObjectURL(url: string): void;
|
||||
}
|
||||
};
|
||||
|
||||
interface WebSocketEventMap {
|
||||
"close": CloseEvent;
|
||||
@@ -1070,7 +1081,7 @@ declare var WebSocket: {
|
||||
readonly CLOSING: number;
|
||||
readonly CONNECTING: number;
|
||||
readonly OPEN: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface WorkerEventMap extends AbstractWorkerEventMap {
|
||||
"message": MessageEvent;
|
||||
@@ -1087,7 +1098,7 @@ interface Worker extends EventTarget, AbstractWorker {
|
||||
declare var Worker: {
|
||||
prototype: Worker;
|
||||
new(stringUrl: string): Worker;
|
||||
}
|
||||
};
|
||||
|
||||
interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
|
||||
"readystatechange": Event;
|
||||
@@ -1133,7 +1144,7 @@ declare var XMLHttpRequest: {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
}
|
||||
};
|
||||
|
||||
interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget {
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
|
||||
@@ -1143,7 +1154,7 @@ interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget {
|
||||
declare var XMLHttpRequestUpload: {
|
||||
prototype: XMLHttpRequestUpload;
|
||||
new(): XMLHttpRequestUpload;
|
||||
}
|
||||
};
|
||||
|
||||
interface AbstractWorkerEventMap {
|
||||
"error": ErrorEvent;
|
||||
@@ -1258,7 +1269,7 @@ interface Client {
|
||||
declare var Client: {
|
||||
prototype: Client;
|
||||
new(): Client;
|
||||
}
|
||||
};
|
||||
|
||||
interface Clients {
|
||||
claim(): Promise<void>;
|
||||
@@ -1270,7 +1281,7 @@ interface Clients {
|
||||
declare var Clients: {
|
||||
prototype: Clients;
|
||||
new(): Clients;
|
||||
}
|
||||
};
|
||||
|
||||
interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
||||
"message": MessageEvent;
|
||||
@@ -1287,7 +1298,7 @@ interface DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
||||
declare var DedicatedWorkerGlobalScope: {
|
||||
prototype: DedicatedWorkerGlobalScope;
|
||||
new(): DedicatedWorkerGlobalScope;
|
||||
}
|
||||
};
|
||||
|
||||
interface ExtendableEvent extends Event {
|
||||
waitUntil(f: Promise<any>): void;
|
||||
@@ -1296,7 +1307,7 @@ interface ExtendableEvent extends Event {
|
||||
declare var ExtendableEvent: {
|
||||
prototype: ExtendableEvent;
|
||||
new(type: string, eventInitDict?: ExtendableEventInit): ExtendableEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface ExtendableMessageEvent extends ExtendableEvent {
|
||||
readonly data: any;
|
||||
@@ -1309,7 +1320,7 @@ interface ExtendableMessageEvent extends ExtendableEvent {
|
||||
declare var ExtendableMessageEvent: {
|
||||
prototype: ExtendableMessageEvent;
|
||||
new(type: string, eventInitDict?: ExtendableMessageEventInit): ExtendableMessageEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface FetchEvent extends ExtendableEvent {
|
||||
readonly clientId: string | null;
|
||||
@@ -1321,7 +1332,7 @@ interface FetchEvent extends ExtendableEvent {
|
||||
declare var FetchEvent: {
|
||||
prototype: FetchEvent;
|
||||
new(type: string, eventInitDict: FetchEventInit): FetchEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface FileReaderSync {
|
||||
readAsArrayBuffer(blob: Blob): any;
|
||||
@@ -1333,7 +1344,7 @@ interface FileReaderSync {
|
||||
declare var FileReaderSync: {
|
||||
prototype: FileReaderSync;
|
||||
new(): FileReaderSync;
|
||||
}
|
||||
};
|
||||
|
||||
interface NotificationEvent extends ExtendableEvent {
|
||||
readonly action: string;
|
||||
@@ -1343,7 +1354,7 @@ interface NotificationEvent extends ExtendableEvent {
|
||||
declare var NotificationEvent: {
|
||||
prototype: NotificationEvent;
|
||||
new(type: string, eventInitDict: NotificationEventInit): NotificationEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface PushEvent extends ExtendableEvent {
|
||||
readonly data: PushMessageData | null;
|
||||
@@ -1352,7 +1363,7 @@ interface PushEvent extends ExtendableEvent {
|
||||
declare var PushEvent: {
|
||||
prototype: PushEvent;
|
||||
new(type: string, eventInitDict?: PushEventInit): PushEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface PushMessageData {
|
||||
arrayBuffer(): ArrayBuffer;
|
||||
@@ -1364,7 +1375,7 @@ interface PushMessageData {
|
||||
declare var PushMessageData: {
|
||||
prototype: PushMessageData;
|
||||
new(): PushMessageData;
|
||||
}
|
||||
};
|
||||
|
||||
interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
||||
"activate": ExtendableEvent;
|
||||
@@ -1398,7 +1409,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
||||
declare var ServiceWorkerGlobalScope: {
|
||||
prototype: ServiceWorkerGlobalScope;
|
||||
new(): ServiceWorkerGlobalScope;
|
||||
}
|
||||
};
|
||||
|
||||
interface SyncEvent extends ExtendableEvent {
|
||||
readonly lastChance: boolean;
|
||||
@@ -1408,7 +1419,7 @@ interface SyncEvent extends ExtendableEvent {
|
||||
declare var SyncEvent: {
|
||||
prototype: SyncEvent;
|
||||
new(type: string, init: SyncEventInit): SyncEvent;
|
||||
}
|
||||
};
|
||||
|
||||
interface WindowClient extends Client {
|
||||
readonly focused: boolean;
|
||||
@@ -1420,7 +1431,7 @@ interface WindowClient extends Client {
|
||||
declare var WindowClient: {
|
||||
prototype: WindowClient;
|
||||
new(): WindowClient;
|
||||
}
|
||||
};
|
||||
|
||||
interface WorkerGlobalScopeEventMap {
|
||||
"error": ErrorEvent;
|
||||
@@ -1443,7 +1454,7 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo
|
||||
declare var WorkerGlobalScope: {
|
||||
prototype: WorkerGlobalScope;
|
||||
new(): WorkerGlobalScope;
|
||||
}
|
||||
};
|
||||
|
||||
interface WorkerLocation {
|
||||
readonly hash: string;
|
||||
@@ -1461,7 +1472,7 @@ interface WorkerLocation {
|
||||
declare var WorkerLocation: {
|
||||
prototype: WorkerLocation;
|
||||
new(): WorkerLocation;
|
||||
}
|
||||
};
|
||||
|
||||
interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware {
|
||||
readonly hardwareConcurrency: number;
|
||||
@@ -1470,7 +1481,7 @@ interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine, Navigato
|
||||
declare var WorkerNavigator: {
|
||||
prototype: WorkerNavigator;
|
||||
new(): WorkerNavigator;
|
||||
}
|
||||
};
|
||||
|
||||
interface WorkerUtils extends Object, WindowBase64 {
|
||||
readonly indexedDB: IDBFactory;
|
||||
@@ -1513,38 +1524,38 @@ interface ImageBitmap {
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Appends a specified key/value pair as a new search parameter.
|
||||
*/
|
||||
* Appends a specified key/value pair as a new search parameter.
|
||||
*/
|
||||
append(name: string, value: string): void;
|
||||
/**
|
||||
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
|
||||
*/
|
||||
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
|
||||
*/
|
||||
delete(name: string): void;
|
||||
/**
|
||||
* Returns the first value associated to the given search parameter.
|
||||
*/
|
||||
* Returns the first value associated to the given search parameter.
|
||||
*/
|
||||
get(name: string): string | null;
|
||||
/**
|
||||
* Returns all the values association with a given search parameter.
|
||||
*/
|
||||
* Returns all the values association with a given search parameter.
|
||||
*/
|
||||
getAll(name: string): string[];
|
||||
/**
|
||||
* Returns a Boolean indicating if such a search parameter exists.
|
||||
*/
|
||||
* Returns a Boolean indicating if such a search parameter exists.
|
||||
*/
|
||||
has(name: string): boolean;
|
||||
/**
|
||||
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
|
||||
*/
|
||||
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
|
||||
*/
|
||||
set(name: string, value: string): void;
|
||||
}
|
||||
|
||||
declare var URLSearchParams: {
|
||||
prototype: URLSearchParams;
|
||||
/**
|
||||
* Constructor returning a URLSearchParams object.
|
||||
*/
|
||||
* Constructor returning a URLSearchParams object.
|
||||
*/
|
||||
new (init?: string | URLSearchParams): URLSearchParams;
|
||||
}
|
||||
};
|
||||
|
||||
interface BlobPropertyBag {
|
||||
type?: string;
|
||||
@@ -1751,8 +1762,23 @@ interface AddEventListenerOptions extends EventListenerOptions {
|
||||
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface DecodeErrorCallback {
|
||||
(error: DOMException): void;
|
||||
}
|
||||
interface DecodeSuccessCallback {
|
||||
(decodedData: AudioBuffer): void;
|
||||
}
|
||||
interface ErrorEventHandler {
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?: Error): void;
|
||||
}
|
||||
interface ForEachCallback {
|
||||
(keyId: any, status: MediaKeyStatus): void;
|
||||
}
|
||||
interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
}
|
||||
interface NotificationPermissionCallback {
|
||||
(permission: NotificationPermission): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
@@ -1760,21 +1786,6 @@ interface PositionCallback {
|
||||
interface PositionErrorCallback {
|
||||
(error: PositionError): void;
|
||||
}
|
||||
interface DecodeSuccessCallback {
|
||||
(decodedData: AudioBuffer): void;
|
||||
}
|
||||
interface DecodeErrorCallback {
|
||||
(error: DOMException): void;
|
||||
}
|
||||
interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
}
|
||||
interface ForEachCallback {
|
||||
(keyId: any, status: MediaKeyStatus): void;
|
||||
}
|
||||
interface NotificationPermissionCallback {
|
||||
(permission: NotificationPermission): void;
|
||||
}
|
||||
declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any;
|
||||
declare function close(): void;
|
||||
declare function postMessage(message: any, transfer?: any[]): void;
|
||||
|
||||
+46
-6
@@ -224,7 +224,7 @@ namespace ts.server {
|
||||
return { name, kind, kindModifiers, sortText, replacementSpan: convertedSpan };
|
||||
}
|
||||
|
||||
return entry as { name: string, kind: string, kindModifiers: string, sortText: string };
|
||||
return entry as { name: string, kind: ScriptElementKind, kindModifiers: string, sortText: string };
|
||||
})
|
||||
};
|
||||
}
|
||||
@@ -265,7 +265,7 @@ namespace ts.server {
|
||||
return {
|
||||
name: entry.name,
|
||||
containerName: entry.containerName || "",
|
||||
containerKind: entry.containerKind || "",
|
||||
containerKind: entry.containerKind || ScriptElementKind.unknown,
|
||||
kind: entry.kind,
|
||||
kindModifiers: entry.kindModifiers,
|
||||
matchKind: entry.matchKind,
|
||||
@@ -330,11 +330,11 @@ namespace ts.server {
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerKind: ScriptElementKind.unknown,
|
||||
containerName: "",
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
kind: "",
|
||||
kind: ScriptElementKind.unknown,
|
||||
name: ""
|
||||
};
|
||||
});
|
||||
@@ -356,11 +356,11 @@ namespace ts.server {
|
||||
const start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
const end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerKind: ScriptElementKind.unknown,
|
||||
containerName: "",
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
kind: "",
|
||||
kind: ScriptElementKind.unknown,
|
||||
name: ""
|
||||
};
|
||||
});
|
||||
@@ -695,6 +695,46 @@ namespace ts.server {
|
||||
return response.body.map(entry => this.convertCodeActions(entry, fileName));
|
||||
}
|
||||
|
||||
private createFileLocationOrRangeRequestArgs(positionOrRange: number | TextRange, fileName: string): protocol.FileLocationOrRangeRequestArgs {
|
||||
if (typeof positionOrRange === "number") {
|
||||
const { line, offset } = this.positionToOneBasedLineOffset(fileName, positionOrRange);
|
||||
return <protocol.FileLocationRequestArgs>{ file: fileName, line, offset };
|
||||
}
|
||||
const { line: startLine, offset: startOffset } = this.positionToOneBasedLineOffset(fileName, positionOrRange.pos);
|
||||
const { line: endLine, offset: endOffset } = this.positionToOneBasedLineOffset(fileName, positionOrRange.end);
|
||||
return <protocol.FileRangeRequestArgs>{
|
||||
file: fileName,
|
||||
startLine,
|
||||
startOffset,
|
||||
endLine,
|
||||
endOffset
|
||||
};
|
||||
}
|
||||
|
||||
getApplicableRefactors(fileName: string, positionOrRange: number | TextRange): ApplicableRefactorInfo[] {
|
||||
const args = this.createFileLocationOrRangeRequestArgs(positionOrRange, fileName);
|
||||
|
||||
const request = this.processRequest<protocol.GetApplicableRefactorsRequest>(CommandNames.GetApplicableRefactors, args);
|
||||
const response = this.processResponse<protocol.GetApplicableRefactorsResponse>(request);
|
||||
return response.body;
|
||||
}
|
||||
|
||||
getRefactorCodeActions(
|
||||
fileName: string,
|
||||
_formatOptions: FormatCodeSettings,
|
||||
positionOrRange: number | TextRange,
|
||||
refactorName: string) {
|
||||
|
||||
const args = this.createFileLocationOrRangeRequestArgs(positionOrRange, fileName) as protocol.GetRefactorCodeActionsRequestArgs;
|
||||
args.refactorName = refactorName;
|
||||
|
||||
const request = this.processRequest<protocol.GetRefactorCodeActionsRequest>(CommandNames.GetRefactorCodeActions, args);
|
||||
const response = this.processResponse<protocol.GetRefactorCodeActionsResponse>(request);
|
||||
const codeActions = response.body.actions;
|
||||
|
||||
return map(codeActions, codeAction => this.convertCodeActions(codeAction, fileName));
|
||||
}
|
||||
|
||||
convertCodeActions(entry: protocol.CodeAction, fileName: string): CodeAction {
|
||||
return {
|
||||
description: entry.description,
|
||||
|
||||
@@ -283,6 +283,7 @@ namespace ts.server {
|
||||
throttleWaitMilliseconds?: number;
|
||||
globalPlugins?: string[];
|
||||
pluginProbeLocations?: string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
}
|
||||
|
||||
export class ProjectService {
|
||||
@@ -342,6 +343,7 @@ namespace ts.server {
|
||||
|
||||
public readonly globalPlugins: ReadonlyArray<string>;
|
||||
public readonly pluginProbeLocations: ReadonlyArray<string>;
|
||||
public readonly allowLocalPluginLoads: boolean;
|
||||
|
||||
constructor(opts: ProjectServiceOptions) {
|
||||
this.host = opts.host;
|
||||
@@ -353,6 +355,7 @@ namespace ts.server {
|
||||
this.eventHandler = opts.eventHandler;
|
||||
this.globalPlugins = opts.globalPlugins || emptyArray;
|
||||
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
|
||||
this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads;
|
||||
|
||||
Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService");
|
||||
|
||||
|
||||
@@ -13,13 +13,6 @@ namespace ts.server {
|
||||
External
|
||||
}
|
||||
|
||||
function remove<T>(items: T[], item: T) {
|
||||
const index = items.indexOf(item);
|
||||
if (index >= 0) {
|
||||
items.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function countEachFileTypes(infos: ScriptInfo[]): { js: number, jsx: number, ts: number, tsx: number, dts: number } {
|
||||
const result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 };
|
||||
for (const info of infos) {
|
||||
@@ -732,7 +725,7 @@ namespace ts.server {
|
||||
|
||||
// remove a root file from project
|
||||
protected removeRoot(info: ScriptInfo): void {
|
||||
remove(this.rootFiles, info);
|
||||
orderedRemoveItem(this.rootFiles, info);
|
||||
this.rootFilesMap.remove(info.path);
|
||||
}
|
||||
}
|
||||
@@ -873,6 +866,12 @@ namespace ts.server {
|
||||
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
||||
const searchPaths = [combinePaths(host.getExecutingFilePath(), "../../.."), ...this.projectService.pluginProbeLocations];
|
||||
|
||||
if (this.projectService.allowLocalPluginLoads) {
|
||||
const local = getDirectoryPath(this.canonicalConfigFilePath);
|
||||
this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`);
|
||||
searchPaths.unshift(local);
|
||||
}
|
||||
|
||||
// Enable tsconfig-specified plugins
|
||||
if (options.plugins) {
|
||||
for (const pluginConfigEntry of options.plugins) {
|
||||
|
||||
+166
-123
@@ -2,99 +2,104 @@
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
namespace ts.server.protocol {
|
||||
export namespace CommandTypes {
|
||||
export type Brace = "brace";
|
||||
// NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`.
|
||||
export const enum CommandTypes {
|
||||
Brace = "brace",
|
||||
/* @internal */
|
||||
export type BraceFull = "brace-full";
|
||||
export type BraceCompletion = "braceCompletion";
|
||||
export type Change = "change";
|
||||
export type Close = "close";
|
||||
export type Completions = "completions";
|
||||
BraceFull = "brace-full",
|
||||
BraceCompletion = "braceCompletion",
|
||||
Change = "change",
|
||||
Close = "close",
|
||||
Completions = "completions",
|
||||
/* @internal */
|
||||
export type CompletionsFull = "completions-full";
|
||||
export type CompletionDetails = "completionEntryDetails";
|
||||
export type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
|
||||
export type CompileOnSaveEmitFile = "compileOnSaveEmitFile";
|
||||
export type Configure = "configure";
|
||||
export type Definition = "definition";
|
||||
CompletionsFull = "completions-full",
|
||||
CompletionDetails = "completionEntryDetails",
|
||||
CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList",
|
||||
CompileOnSaveEmitFile = "compileOnSaveEmitFile",
|
||||
Configure = "configure",
|
||||
Definition = "definition",
|
||||
/* @internal */
|
||||
export type DefinitionFull = "definition-full";
|
||||
export type Implementation = "implementation";
|
||||
DefinitionFull = "definition-full",
|
||||
Implementation = "implementation",
|
||||
/* @internal */
|
||||
export type ImplementationFull = "implementation-full";
|
||||
export type Exit = "exit";
|
||||
export type Format = "format";
|
||||
export type Formatonkey = "formatonkey";
|
||||
ImplementationFull = "implementation-full",
|
||||
Exit = "exit",
|
||||
Format = "format",
|
||||
Formatonkey = "formatonkey",
|
||||
/* @internal */
|
||||
export type FormatFull = "format-full";
|
||||
FormatFull = "format-full",
|
||||
/* @internal */
|
||||
export type FormatonkeyFull = "formatonkey-full";
|
||||
FormatonkeyFull = "formatonkey-full",
|
||||
/* @internal */
|
||||
export type FormatRangeFull = "formatRange-full";
|
||||
export type Geterr = "geterr";
|
||||
export type GeterrForProject = "geterrForProject";
|
||||
export type SemanticDiagnosticsSync = "semanticDiagnosticsSync";
|
||||
export type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
|
||||
export type NavBar = "navbar";
|
||||
FormatRangeFull = "formatRange-full",
|
||||
Geterr = "geterr",
|
||||
GeterrForProject = "geterrForProject",
|
||||
SemanticDiagnosticsSync = "semanticDiagnosticsSync",
|
||||
SyntacticDiagnosticsSync = "syntacticDiagnosticsSync",
|
||||
NavBar = "navbar",
|
||||
/* @internal */
|
||||
export type NavBarFull = "navbar-full";
|
||||
export type Navto = "navto";
|
||||
NavBarFull = "navbar-full",
|
||||
Navto = "navto",
|
||||
/* @internal */
|
||||
export type NavtoFull = "navto-full";
|
||||
export type NavTree = "navtree";
|
||||
export type NavTreeFull = "navtree-full";
|
||||
export type Occurrences = "occurrences";
|
||||
export type DocumentHighlights = "documentHighlights";
|
||||
NavtoFull = "navto-full",
|
||||
NavTree = "navtree",
|
||||
NavTreeFull = "navtree-full",
|
||||
Occurrences = "occurrences",
|
||||
DocumentHighlights = "documentHighlights",
|
||||
/* @internal */
|
||||
export type DocumentHighlightsFull = "documentHighlights-full";
|
||||
export type Open = "open";
|
||||
export type Quickinfo = "quickinfo";
|
||||
DocumentHighlightsFull = "documentHighlights-full",
|
||||
Open = "open",
|
||||
Quickinfo = "quickinfo",
|
||||
/* @internal */
|
||||
export type QuickinfoFull = "quickinfo-full";
|
||||
export type References = "references";
|
||||
QuickinfoFull = "quickinfo-full",
|
||||
References = "references",
|
||||
/* @internal */
|
||||
export type ReferencesFull = "references-full";
|
||||
export type Reload = "reload";
|
||||
export type Rename = "rename";
|
||||
ReferencesFull = "references-full",
|
||||
Reload = "reload",
|
||||
Rename = "rename",
|
||||
/* @internal */
|
||||
export type RenameInfoFull = "rename-full";
|
||||
RenameInfoFull = "rename-full",
|
||||
/* @internal */
|
||||
export type RenameLocationsFull = "renameLocations-full";
|
||||
export type Saveto = "saveto";
|
||||
export type SignatureHelp = "signatureHelp";
|
||||
RenameLocationsFull = "renameLocations-full",
|
||||
Saveto = "saveto",
|
||||
SignatureHelp = "signatureHelp",
|
||||
/* @internal */
|
||||
export type SignatureHelpFull = "signatureHelp-full";
|
||||
export type TypeDefinition = "typeDefinition";
|
||||
export type ProjectInfo = "projectInfo";
|
||||
export type ReloadProjects = "reloadProjects";
|
||||
export type Unknown = "unknown";
|
||||
export type OpenExternalProject = "openExternalProject";
|
||||
export type OpenExternalProjects = "openExternalProjects";
|
||||
export type CloseExternalProject = "closeExternalProject";
|
||||
SignatureHelpFull = "signatureHelp-full",
|
||||
TypeDefinition = "typeDefinition",
|
||||
ProjectInfo = "projectInfo",
|
||||
ReloadProjects = "reloadProjects",
|
||||
Unknown = "unknown",
|
||||
OpenExternalProject = "openExternalProject",
|
||||
OpenExternalProjects = "openExternalProjects",
|
||||
CloseExternalProject = "closeExternalProject",
|
||||
/* @internal */
|
||||
export type SynchronizeProjectList = "synchronizeProjectList";
|
||||
SynchronizeProjectList = "synchronizeProjectList",
|
||||
/* @internal */
|
||||
export type ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
|
||||
ApplyChangedToOpenFiles = "applyChangedToOpenFiles",
|
||||
/* @internal */
|
||||
export type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
|
||||
EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full",
|
||||
/* @internal */
|
||||
export type Cleanup = "cleanup";
|
||||
Cleanup = "cleanup",
|
||||
/* @internal */
|
||||
export type OutliningSpans = "outliningSpans";
|
||||
export type TodoComments = "todoComments";
|
||||
export type Indentation = "indentation";
|
||||
export type DocCommentTemplate = "docCommentTemplate";
|
||||
OutliningSpans = "outliningSpans",
|
||||
TodoComments = "todoComments",
|
||||
Indentation = "indentation",
|
||||
DocCommentTemplate = "docCommentTemplate",
|
||||
/* @internal */
|
||||
export type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
|
||||
CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full",
|
||||
/* @internal */
|
||||
export type NameOrDottedNameSpan = "nameOrDottedNameSpan";
|
||||
NameOrDottedNameSpan = "nameOrDottedNameSpan",
|
||||
/* @internal */
|
||||
export type BreakpointStatement = "breakpointStatement";
|
||||
export type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
|
||||
export type GetCodeFixes = "getCodeFixes";
|
||||
BreakpointStatement = "breakpointStatement",
|
||||
CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects",
|
||||
GetCodeFixes = "getCodeFixes",
|
||||
/* @internal */
|
||||
export type GetCodeFixesFull = "getCodeFixes-full";
|
||||
export type GetSupportedCodeFixes = "getSupportedCodeFixes";
|
||||
GetCodeFixesFull = "getCodeFixes-full",
|
||||
GetSupportedCodeFixes = "getSupportedCodeFixes",
|
||||
|
||||
GetApplicableRefactors = "getApplicableRefactors",
|
||||
GetRefactorCodeActions = "getRefactorCodeActions",
|
||||
GetRefactorCodeActionsFull = "getRefactorCodeActions-full",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,6 +399,54 @@ namespace ts.server.protocol {
|
||||
position?: number;
|
||||
}
|
||||
|
||||
export type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs;
|
||||
|
||||
export interface GetApplicableRefactorsRequest extends Request {
|
||||
command: CommandTypes.GetApplicableRefactors;
|
||||
arguments: GetApplicableRefactorsRequestArgs;
|
||||
}
|
||||
|
||||
export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs;
|
||||
|
||||
export interface ApplicableRefactorInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface GetApplicableRefactorsResponse extends Response {
|
||||
body?: ApplicableRefactorInfo[];
|
||||
}
|
||||
|
||||
export interface GetRefactorCodeActionsRequest extends Request {
|
||||
command: CommandTypes.GetRefactorCodeActions;
|
||||
arguments: GetRefactorCodeActionsRequestArgs;
|
||||
}
|
||||
|
||||
export type GetRefactorCodeActionsRequestArgs = FileLocationOrRangeRequestArgs & {
|
||||
/* The kind of the applicable refactor */
|
||||
refactorName: string;
|
||||
};
|
||||
|
||||
export type RefactorCodeActions = {
|
||||
actions: protocol.CodeAction[];
|
||||
renameLocation?: number
|
||||
};
|
||||
|
||||
/* @internal */
|
||||
export type RefactorCodeActionsFull = {
|
||||
actions: ts.CodeAction[];
|
||||
renameLocation?: number
|
||||
};
|
||||
|
||||
export interface GetRefactorCodeActionsResponse extends Response {
|
||||
body: RefactorCodeActions;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface GetRefactorCodeActionsFullResponse extends Response {
|
||||
body: RefactorCodeActionsFull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request for the available codefixes at a specific position.
|
||||
*/
|
||||
@@ -402,10 +455,7 @@ namespace ts.server.protocol {
|
||||
arguments: CodeFixRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instances of this interface specify errorcodes on a specific location in a sourcefile.
|
||||
*/
|
||||
export interface CodeFixRequestArgs extends FileRequestArgs {
|
||||
export interface FileRangeRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* The line number for the request (1-based).
|
||||
*/
|
||||
@@ -437,7 +487,12 @@ namespace ts.server.protocol {
|
||||
*/
|
||||
/* @internal */
|
||||
endPosition?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instances of this interface specify errorcodes on a specific location in a sourcefile.
|
||||
*/
|
||||
export interface CodeFixRequestArgs extends FileRangeRequestArgs {
|
||||
/**
|
||||
* Errorcodes we want to get the fixes for.
|
||||
*/
|
||||
@@ -644,10 +699,9 @@ namespace ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Span augmented with extra information that denotes the kind of the highlighting to be used for span.
|
||||
* Kind is taken from HighlightSpanKind type.
|
||||
*/
|
||||
export interface HighlightSpan extends TextSpan {
|
||||
kind: string;
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -784,7 +838,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The items's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
@@ -1298,7 +1352,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
@@ -1517,7 +1571,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
@@ -1545,7 +1599,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
@@ -2004,7 +2058,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
|
||||
/**
|
||||
* exact, substring, or prefix.
|
||||
@@ -2045,7 +2099,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Kind of symbol's container symbol (if any).
|
||||
*/
|
||||
containerKind?: string;
|
||||
containerKind?: ScriptElementKind;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2118,7 +2172,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
@@ -2144,7 +2198,7 @@ namespace ts.server.protocol {
|
||||
/** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */
|
||||
export interface NavigationTree {
|
||||
text: string;
|
||||
kind: string;
|
||||
kind: ScriptElementKind;
|
||||
kindModifiers: string;
|
||||
spans: TextSpan[];
|
||||
childItems?: NavigationTree[];
|
||||
@@ -2238,14 +2292,12 @@ namespace ts.server.protocol {
|
||||
body?: NavigationTree;
|
||||
}
|
||||
|
||||
export namespace IndentStyle {
|
||||
export type None = "None";
|
||||
export type Block = "Block";
|
||||
export type Smart = "Smart";
|
||||
export const enum IndentStyle {
|
||||
None = "None",
|
||||
Block = "Block",
|
||||
Smart = "Smart",
|
||||
}
|
||||
|
||||
export type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart;
|
||||
|
||||
export interface EditorSettings {
|
||||
baseIndentSize?: number;
|
||||
indentSize?: number;
|
||||
@@ -2267,6 +2319,7 @@ namespace ts.server.protocol {
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
|
||||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
||||
insertSpaceAfterTypeAssertion?: boolean;
|
||||
insertSpaceBeforeFunctionParenthesis?: boolean;
|
||||
placeOpenBraceOnNewLineForFunctions?: boolean;
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
@@ -2341,47 +2394,37 @@ namespace ts.server.protocol {
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
|
||||
export namespace JsxEmit {
|
||||
export type None = "None";
|
||||
export type Preserve = "Preserve";
|
||||
export type ReactNative = "ReactNative";
|
||||
export type React = "React";
|
||||
export const enum JsxEmit {
|
||||
None = "None",
|
||||
Preserve = "Preserve",
|
||||
ReactNative = "ReactNative",
|
||||
React = "React",
|
||||
}
|
||||
|
||||
export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative;
|
||||
|
||||
export namespace ModuleKind {
|
||||
export type None = "None";
|
||||
export type CommonJS = "CommonJS";
|
||||
export type AMD = "AMD";
|
||||
export type UMD = "UMD";
|
||||
export type System = "System";
|
||||
export type ES6 = "ES6";
|
||||
export type ES2015 = "ES2015";
|
||||
export const enum ModuleKind {
|
||||
None = "None",
|
||||
CommonJS = "CommonJS",
|
||||
AMD = "AMD",
|
||||
UMD = "UMD",
|
||||
System = "System",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
}
|
||||
|
||||
export type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015;
|
||||
|
||||
export namespace ModuleResolutionKind {
|
||||
export type Classic = "Classic";
|
||||
export type Node = "Node";
|
||||
export const enum ModuleResolutionKind {
|
||||
Classic = "Classic",
|
||||
Node = "Node",
|
||||
}
|
||||
|
||||
export type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node;
|
||||
|
||||
export namespace NewLineKind {
|
||||
export type Crlf = "Crlf";
|
||||
export type Lf = "Lf";
|
||||
export const enum NewLineKind {
|
||||
Crlf = "Crlf",
|
||||
Lf = "Lf",
|
||||
}
|
||||
|
||||
export type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf;
|
||||
|
||||
export namespace ScriptTarget {
|
||||
export type ES3 = "ES3";
|
||||
export type ES5 = "ES5";
|
||||
export type ES6 = "ES6";
|
||||
export type ES2015 = "ES2015";
|
||||
export const enum ScriptTarget {
|
||||
ES3 = "ES3",
|
||||
ES5 = "ES5",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
}
|
||||
|
||||
export type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace ts.server {
|
||||
telemetryEnabled: boolean;
|
||||
globalPlugins: string[];
|
||||
pluginProbeLocations: string[];
|
||||
allowLocalPluginLoads: boolean;
|
||||
}
|
||||
|
||||
const net: {
|
||||
@@ -403,7 +404,8 @@ namespace ts.server {
|
||||
logger,
|
||||
canUseEvents,
|
||||
globalPlugins: options.globalPlugins,
|
||||
pluginProbeLocations: options.pluginProbeLocations});
|
||||
pluginProbeLocations: options.pluginProbeLocations,
|
||||
allowLocalPluginLoads: options.allowLocalPluginLoads });
|
||||
|
||||
if (telemetryEnabled && typingsInstaller) {
|
||||
typingsInstaller.setTelemetrySender(this);
|
||||
@@ -708,12 +710,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
sys.require = (initialDir: string, moduleName: string): RequireResult => {
|
||||
const result = nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, /*cache*/ undefined, /*jsOnly*/ true);
|
||||
try {
|
||||
return { module: require(result.resolvedModule.resolvedFileName), error: undefined };
|
||||
return { module: require(resolveJavaScriptModule(moduleName, initialDir, sys)), error: undefined };
|
||||
}
|
||||
catch (e) {
|
||||
return { module: undefined, error: e };
|
||||
catch (error) {
|
||||
return { module: undefined, error };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -744,6 +745,7 @@ namespace ts.server {
|
||||
|
||||
const globalPlugins = (findArgument("--globalPlugins") || "").split(",");
|
||||
const pluginProbeLocations = (findArgument("--pluginProbeLocations") || "").split(",");
|
||||
const allowLocalPluginLoads = hasArgument("--allowLocalPluginLoads");
|
||||
|
||||
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
|
||||
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
|
||||
@@ -761,7 +763,8 @@ namespace ts.server {
|
||||
telemetryEnabled,
|
||||
logger,
|
||||
globalPlugins,
|
||||
pluginProbeLocations
|
||||
pluginProbeLocations,
|
||||
allowLocalPluginLoads
|
||||
};
|
||||
|
||||
const ioSession = new IOSession(options);
|
||||
|
||||
+98
-113
@@ -100,7 +100,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export interface EventSender {
|
||||
event(payload: any, eventName: string): void;
|
||||
event<T>(payload: T, eventName: string): void;
|
||||
}
|
||||
|
||||
function allEditsBeforePos(edits: ts.TextChange[], pos: number) {
|
||||
@@ -112,100 +112,7 @@ namespace ts.server {
|
||||
return true;
|
||||
}
|
||||
|
||||
export namespace CommandNames {
|
||||
export const Brace: protocol.CommandTypes.Brace = "brace";
|
||||
/* @internal */
|
||||
export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full";
|
||||
export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion";
|
||||
export const Change: protocol.CommandTypes.Change = "change";
|
||||
export const Close: protocol.CommandTypes.Close = "close";
|
||||
export const Completions: protocol.CommandTypes.Completions = "completions";
|
||||
/* @internal */
|
||||
export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full";
|
||||
export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails";
|
||||
export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
|
||||
export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile";
|
||||
export const Configure: protocol.CommandTypes.Configure = "configure";
|
||||
export const Definition: protocol.CommandTypes.Definition = "definition";
|
||||
/* @internal */
|
||||
export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full";
|
||||
export const Exit: protocol.CommandTypes.Exit = "exit";
|
||||
export const Format: protocol.CommandTypes.Format = "format";
|
||||
export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey";
|
||||
/* @internal */
|
||||
export const FormatFull: protocol.CommandTypes.FormatFull = "format-full";
|
||||
/* @internal */
|
||||
export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full";
|
||||
/* @internal */
|
||||
export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full";
|
||||
export const Geterr: protocol.CommandTypes.Geterr = "geterr";
|
||||
export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject";
|
||||
export const Implementation: protocol.CommandTypes.Implementation = "implementation";
|
||||
/* @internal */
|
||||
export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full";
|
||||
export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync";
|
||||
export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
|
||||
export const NavBar: protocol.CommandTypes.NavBar = "navbar";
|
||||
/* @internal */
|
||||
export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full";
|
||||
export const NavTree: protocol.CommandTypes.NavTree = "navtree";
|
||||
export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full";
|
||||
export const Navto: protocol.CommandTypes.Navto = "navto";
|
||||
/* @internal */
|
||||
export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full";
|
||||
export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences";
|
||||
export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights";
|
||||
/* @internal */
|
||||
export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full";
|
||||
export const Open: protocol.CommandTypes.Open = "open";
|
||||
export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo";
|
||||
/* @internal */
|
||||
export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full";
|
||||
export const References: protocol.CommandTypes.References = "references";
|
||||
/* @internal */
|
||||
export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full";
|
||||
export const Reload: protocol.CommandTypes.Reload = "reload";
|
||||
export const Rename: protocol.CommandTypes.Rename = "rename";
|
||||
/* @internal */
|
||||
export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full";
|
||||
/* @internal */
|
||||
export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full";
|
||||
export const Saveto: protocol.CommandTypes.Saveto = "saveto";
|
||||
export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp";
|
||||
/* @internal */
|
||||
export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full";
|
||||
export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition";
|
||||
export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo";
|
||||
export const ReloadProjects: protocol.CommandTypes.ReloadProjects = "reloadProjects";
|
||||
export const Unknown: protocol.CommandTypes.Unknown = "unknown";
|
||||
export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject";
|
||||
export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects";
|
||||
export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject";
|
||||
/* @internal */
|
||||
export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList";
|
||||
/* @internal */
|
||||
export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
|
||||
/* @internal */
|
||||
export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
|
||||
/* @internal */
|
||||
export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup";
|
||||
/* @internal */
|
||||
export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans";
|
||||
export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments";
|
||||
export const Indentation: protocol.CommandTypes.Indentation = "indentation";
|
||||
export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate";
|
||||
/* @internal */
|
||||
export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
|
||||
/* @internal */
|
||||
export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan";
|
||||
/* @internal */
|
||||
export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement";
|
||||
export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
|
||||
export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes";
|
||||
/* @internal */
|
||||
export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full";
|
||||
export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes";
|
||||
}
|
||||
export import CommandNames = protocol.CommandTypes;
|
||||
|
||||
export function formatMessage<T extends protocol.Message>(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string {
|
||||
const verboseLogging = logger.hasLevel(LogLevel.verbose);
|
||||
@@ -348,6 +255,7 @@ namespace ts.server {
|
||||
|
||||
globalPlugins?: string[];
|
||||
pluginProbeLocations?: string[];
|
||||
allowLocalPluginLoads?: boolean;
|
||||
}
|
||||
|
||||
export class Session implements EventSender {
|
||||
@@ -401,7 +309,8 @@ namespace ts.server {
|
||||
throttleWaitMilliseconds,
|
||||
eventHandler: this.eventHandler,
|
||||
globalPlugins: opts.globalPlugins,
|
||||
pluginProbeLocations: opts.pluginProbeLocations
|
||||
pluginProbeLocations: opts.pluginProbeLocations,
|
||||
allowLocalPluginLoads: opts.allowLocalPluginLoads
|
||||
};
|
||||
this.projectService = new ProjectService(settings);
|
||||
this.gcTimer = new GcTimer(this.host, /*delay*/ 7000, this.logger);
|
||||
@@ -430,7 +339,7 @@ namespace ts.server {
|
||||
break;
|
||||
case ProjectLanguageServiceStateEvent:
|
||||
const eventName: protocol.ProjectLanguageServiceStateEventName = "projectLanguageServiceState";
|
||||
this.event(<protocol.ProjectLanguageServiceStateEventBody>{
|
||||
this.event<protocol.ProjectLanguageServiceStateEventBody>({
|
||||
projectName: event.data.project.getProjectName(),
|
||||
languageServiceEnabled: event.data.languageServiceEnabled
|
||||
}, eventName);
|
||||
@@ -474,7 +383,7 @@ namespace ts.server {
|
||||
this.send(ev);
|
||||
}
|
||||
|
||||
public event(info: any, eventName: string) {
|
||||
public event<T>(info: T, eventName: string) {
|
||||
const ev: protocol.Event = {
|
||||
seq: 0,
|
||||
type: "event",
|
||||
@@ -509,7 +418,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag");
|
||||
this.event<protocol.DiagnosticEventBody>({ file: file, diagnostics: bakedDiags }, "semanticDiag");
|
||||
}
|
||||
catch (err) {
|
||||
this.logError(err, "semantic check");
|
||||
@@ -521,7 +430,7 @@ namespace ts.server {
|
||||
const diags = project.getLanguageService().getSyntacticDiagnostics(file);
|
||||
if (diags) {
|
||||
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
|
||||
this.event<protocol.DiagnosticEventBody>({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
@@ -1364,8 +1273,8 @@ namespace ts.server {
|
||||
return !items
|
||||
? undefined
|
||||
: simplifiedResult
|
||||
? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file))
|
||||
: items;
|
||||
? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file))
|
||||
: items;
|
||||
}
|
||||
|
||||
private decorateNavigationTree(tree: ts.NavigationTree, scriptInfo: ScriptInfo): protocol.NavigationTree {
|
||||
@@ -1391,8 +1300,8 @@ namespace ts.server {
|
||||
return !tree
|
||||
? undefined
|
||||
: simplifiedResult
|
||||
? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file))
|
||||
: tree;
|
||||
? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file))
|
||||
: tree;
|
||||
}
|
||||
|
||||
private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): protocol.NavtoItem[] | NavigateToItem[] {
|
||||
@@ -1479,6 +1388,60 @@ namespace ts.server {
|
||||
return ts.getSupportedCodeFixes();
|
||||
}
|
||||
|
||||
private isLocation(locationOrSpan: protocol.FileLocationOrRangeRequestArgs): locationOrSpan is protocol.FileLocationRequestArgs {
|
||||
return (<protocol.FileLocationRequestArgs>locationOrSpan).line !== undefined;
|
||||
}
|
||||
|
||||
private extractPositionAndRange(args: protocol.FileLocationOrRangeRequestArgs, scriptInfo: ScriptInfo): { position: number, textRange: TextRange } {
|
||||
let position: number = undefined;
|
||||
let textRange: TextRange;
|
||||
if (this.isLocation(args)) {
|
||||
position = getPosition(args);
|
||||
}
|
||||
else {
|
||||
const { startPosition, endPosition } = this.getStartAndEndPosition(args, scriptInfo);
|
||||
textRange = { pos: startPosition, end: endPosition };
|
||||
}
|
||||
return { position, textRange };
|
||||
|
||||
function getPosition(loc: protocol.FileLocationRequestArgs) {
|
||||
return loc.position !== undefined ? loc.position : scriptInfo.lineOffsetToPosition(loc.line, loc.offset);
|
||||
}
|
||||
}
|
||||
|
||||
private getApplicableRefactors(args: protocol.GetApplicableRefactorsRequestArgs): protocol.ApplicableRefactorInfo[] {
|
||||
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const { position, textRange } = this.extractPositionAndRange(args, scriptInfo);
|
||||
return project.getLanguageService().getApplicableRefactors(file, position || textRange);
|
||||
}
|
||||
|
||||
private getRefactorCodeActions(args: protocol.GetRefactorCodeActionsRequestArgs, simplifiedResult: boolean): protocol.RefactorCodeActions | protocol.RefactorCodeActionsFull {
|
||||
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const { position, textRange } = this.extractPositionAndRange(args, scriptInfo);
|
||||
|
||||
const result: ts.CodeAction[] = project.getLanguageService().getRefactorCodeActions(
|
||||
file,
|
||||
this.projectService.getFormatCodeOptions(),
|
||||
position || textRange,
|
||||
args.refactorName
|
||||
);
|
||||
|
||||
if (simplifiedResult) {
|
||||
// Not full
|
||||
return {
|
||||
actions: result.map(action => this.mapCodeAction(action, scriptInfo))
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Full
|
||||
return {
|
||||
actions: result
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): protocol.CodeAction[] | CodeAction[] {
|
||||
if (args.errorCodes.length === 0) {
|
||||
return undefined;
|
||||
@@ -1486,8 +1449,7 @@ namespace ts.server {
|
||||
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
|
||||
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const startPosition = getStartPosition();
|
||||
const endPosition = getEndPosition();
|
||||
const { startPosition, endPosition } = this.getStartAndEndPosition(args, scriptInfo);
|
||||
const formatOptions = this.projectService.getFormatCodeOptions(file);
|
||||
|
||||
const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions);
|
||||
@@ -1500,14 +1462,28 @@ namespace ts.server {
|
||||
else {
|
||||
return codeActions;
|
||||
}
|
||||
}
|
||||
|
||||
function getStartPosition() {
|
||||
return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset);
|
||||
private getStartAndEndPosition(args: protocol.FileRangeRequestArgs, scriptInfo: ScriptInfo) {
|
||||
let startPosition: number = undefined, endPosition: number = undefined;
|
||||
if (args.startPosition !== undefined) {
|
||||
startPosition = args.startPosition;
|
||||
}
|
||||
else {
|
||||
startPosition = scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset);
|
||||
// save the result so we don't always recompute
|
||||
args.startPosition = startPosition;
|
||||
}
|
||||
|
||||
function getEndPosition() {
|
||||
return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
|
||||
if (args.endPosition !== undefined) {
|
||||
endPosition = args.endPosition;
|
||||
}
|
||||
else {
|
||||
endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
|
||||
args.endPosition = endPosition;
|
||||
}
|
||||
|
||||
return { startPosition, endPosition };
|
||||
}
|
||||
|
||||
private mapCodeAction(codeAction: CodeAction, scriptInfo: ScriptInfo): protocol.CodeAction {
|
||||
@@ -1538,8 +1514,8 @@ namespace ts.server {
|
||||
return !spans
|
||||
? undefined
|
||||
: simplifiedResult
|
||||
? spans.map(span => this.decorateSpan(span, scriptInfo))
|
||||
: spans;
|
||||
? spans.map(span => this.decorateSpan(span, scriptInfo))
|
||||
: spans;
|
||||
}
|
||||
|
||||
private getDiagnosticsForProject(next: NextStep, delay: number, fileName: string): void {
|
||||
@@ -1844,6 +1820,15 @@ namespace ts.server {
|
||||
},
|
||||
[CommandNames.GetSupportedCodeFixes]: () => {
|
||||
return this.requiredResponse(this.getSupportedCodeFixes());
|
||||
},
|
||||
[CommandNames.GetApplicableRefactors]: (request: protocol.GetApplicableRefactorsRequest) => {
|
||||
return this.requiredResponse(this.getApplicableRefactors(request.arguments));
|
||||
},
|
||||
[CommandNames.GetRefactorCodeActions]: (request: protocol.GetRefactorCodeActionsRequest) => {
|
||||
return this.requiredResponse(this.getRefactorCodeActions(request.arguments, /*simplifiedResult*/ true));
|
||||
},
|
||||
[CommandNames.GetRefactorCodeActionsFull]: (request: protocol.GetRefactorCodeActionsRequest) => {
|
||||
return this.requiredResponse(this.getRefactorCodeActions(request.arguments, /*simplifiedResult*/ false));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1901,7 +1886,7 @@ namespace ts.server {
|
||||
let request: protocol.Request;
|
||||
try {
|
||||
request = <protocol.Request>JSON.parse(message);
|
||||
const {response, responseRequired} = this.executeCommand(request);
|
||||
const { response, responseRequired } = this.executeCommand(request);
|
||||
|
||||
if (this.logger.hasLevel(LogLevel.requestTime)) {
|
||||
const elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4);
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace ts.server.typingsInstaller {
|
||||
this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`);
|
||||
}
|
||||
this.execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" });
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Updated ${TypesRegistryPackageName} npm package`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (this.log.isEnabled()) {
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ts.BreakpointResolver {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
let tokenAtLocation = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
const lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) {
|
||||
// Get previous token if the token is returned starts on new line
|
||||
|
||||
@@ -573,7 +573,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getClassificationTypeName(type: ClassificationType) {
|
||||
function getClassificationTypeName(type: ClassificationType): ClassificationTypeNames {
|
||||
switch (type) {
|
||||
case ClassificationType.comment: return ClassificationTypeNames.comment;
|
||||
case ClassificationType.identifier: return ClassificationTypeNames.identifier;
|
||||
|
||||
@@ -19,14 +19,14 @@ namespace ts {
|
||||
export namespace codefix {
|
||||
const codeFixes: CodeFix[][] = [];
|
||||
|
||||
export function registerCodeFix(action: CodeFix) {
|
||||
forEach(action.errorCodes, error => {
|
||||
export function registerCodeFix(codeFix: CodeFix) {
|
||||
forEach(codeFix.errorCodes, error => {
|
||||
let fixes = codeFixes[error];
|
||||
if (!fixes) {
|
||||
fixes = [];
|
||||
codeFixes[error] = fixes;
|
||||
}
|
||||
fixes.push(action);
|
||||
fixes.push(codeFix);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ts.codefix {
|
||||
// We also want to check if the previous line holds a comment for a node on the next line
|
||||
// if so, we do not want to separate the node from its comment if we can.
|
||||
if (!isInComment(sourceFile, startPosition) && !isInString(sourceFile, startPosition) && !isInTemplateString(sourceFile, startPosition)) {
|
||||
const token = getTouchingToken(sourceFile, startPosition);
|
||||
const token = getTouchingToken(sourceFile, startPosition, /*includeJsDocComment*/ false);
|
||||
const tokenLeadingCommnets = getLeadingCommentRangesOfNode(token, sourceFile);
|
||||
if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) {
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code],
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
||||
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code],
|
||||
getCodeActions: getActionsForAddMissingMember
|
||||
});
|
||||
|
||||
@@ -12,7 +13,7 @@ namespace ts.codefix {
|
||||
// This is the identifier of the missing property. eg:
|
||||
// this.missing = 1;
|
||||
// ^^^^^^^
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
|
||||
|
||||
if (token.kind !== SyntaxKind.Identifier) {
|
||||
return undefined;
|
||||
@@ -110,16 +111,16 @@ namespace ts.codefix {
|
||||
if (!isStatic) {
|
||||
const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword);
|
||||
const indexingParameter = createParameter(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"x",
|
||||
/*questionToken*/ undefined,
|
||||
/*questionToken*/ undefined,
|
||||
stringTypeNode,
|
||||
/*initializer*/ undefined);
|
||||
const indexSignature = createIndexSignatureDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*initializer*/ undefined);
|
||||
const indexSignature = createIndexSignature(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
[indexingParameter],
|
||||
typeNode);
|
||||
|
||||
@@ -135,4 +136,4 @@ namespace ts.codefix {
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts.codefix {
|
||||
const start = context.span.start;
|
||||
// This is the identifier in the case of a class declaration
|
||||
// or the class keyword token in the case of a class expression.
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
|
||||
const checker = context.program.getTypeChecker();
|
||||
|
||||
if (isClassLike(token.parent)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ts.codefix {
|
||||
function getActionForClassLikeIncorrectImplementsInterface(context: CodeFixContext): CodeAction[] | undefined {
|
||||
const sourceFile = context.sourceFile;
|
||||
const start = context.span.start;
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
|
||||
const checker = context.program.getTypeChecker();
|
||||
|
||||
const classDeclaration = getContainingClass(token);
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts.codefix {
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false);
|
||||
if (token.kind !== SyntaxKind.ThisKeyword) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ts.codefix {
|
||||
errorCodes: [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false);
|
||||
|
||||
if (token.kind !== SyntaxKind.ConstructorKeyword) {
|
||||
return undefined;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts.codefix {
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const start = context.span.start;
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
|
||||
const classDeclNode = getContainingClass(token);
|
||||
if (!(token.kind === SyntaxKind.Identifier && isClassLike(classDeclNode))) {
|
||||
return undefined;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ts.codefix {
|
||||
errorCodes: [Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false);
|
||||
if (token.kind !== SyntaxKind.Identifier) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code],
|
||||
getCodeActions: getActionsForCorrectSpelling
|
||||
});
|
||||
|
||||
function getActionsForCorrectSpelling(context: CodeFixContext): CodeAction[] | undefined {
|
||||
const sourceFile = context.sourceFile;
|
||||
|
||||
// This is the identifier of the misspelled word. eg:
|
||||
// this.speling = 1;
|
||||
// ^^^^^^^
|
||||
const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); // TODO: GH#15852
|
||||
const checker = context.program.getTypeChecker();
|
||||
let suggestion: string;
|
||||
if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) {
|
||||
const containingType = checker.getTypeAtLocation(node.parent.expression);
|
||||
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
|
||||
}
|
||||
else {
|
||||
const meaning = getMeaningFromLocation(node);
|
||||
suggestion = checker.getSuggestionForNonexistentSymbol(node, getTextOfNode(node), convertSemanticMeaningToSymbolFlags(meaning));
|
||||
}
|
||||
if (suggestion) {
|
||||
return [{
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]),
|
||||
changes: [{
|
||||
fileName: sourceFile.fileName,
|
||||
textChanges: [{
|
||||
span: { start: node.getStart(), length: node.getWidth() },
|
||||
newText: suggestion
|
||||
}],
|
||||
}],
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFlags {
|
||||
let flags = 0;
|
||||
if (meaning & SemanticMeaning.Namespace) {
|
||||
flags |= SymbolFlags.Namespace;
|
||||
}
|
||||
if (meaning & SemanticMeaning.Type) {
|
||||
flags |= SymbolFlags.Type;
|
||||
}
|
||||
if (meaning & SemanticMeaning.Value) {
|
||||
flags |= SymbolFlags.Value;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="fixClassIncorrectlyImplementsInterface.ts" />
|
||||
/// <reference path="fixAddMissingMember.ts" />
|
||||
/// <reference path="fixSpelling.ts" />
|
||||
/// <reference path="fixClassDoesntImplementInheritedAbstractMember.ts" />
|
||||
/// <reference path="fixClassSuperMustPrecedeThisAccess.ts" />
|
||||
/// <reference path="fixConstructorForDerivedNeedSuperCall.ts" />
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts.codefix {
|
||||
|
||||
const declaration = declarations[0] as Declaration;
|
||||
// Clone name to remove leading trivia.
|
||||
const name = getSynthesizedClone(<PropertyName>declaration.name);
|
||||
const name = getSynthesizedClone(getNameOfDeclaration(declaration)) as PropertyName;
|
||||
const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration));
|
||||
const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined;
|
||||
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
||||
@@ -130,7 +130,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) {
|
||||
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration);
|
||||
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.SuppressAnyReturnType);
|
||||
if (signatureDeclaration) {
|
||||
signatureDeclaration.decorators = undefined;
|
||||
signatureDeclaration.modifiers = modifiers;
|
||||
@@ -200,7 +200,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) {
|
||||
return createMethodDeclaration(
|
||||
return createMethod(
|
||||
/*decorators*/ undefined,
|
||||
modifiers,
|
||||
/*asteriskToken*/ undefined,
|
||||
@@ -231,4 +231,4 @@ namespace ts.codefix {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Cannot_find_name_0.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
||||
Diagnostics.Cannot_find_namespace_0.code,
|
||||
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
|
||||
],
|
||||
@@ -127,7 +128,7 @@ namespace ts.codefix {
|
||||
const allSourceFiles = context.program.getSourceFiles();
|
||||
const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false;
|
||||
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false);
|
||||
const name = token.getText();
|
||||
const symbolIdActionMap = new ImportCodeActionMap();
|
||||
|
||||
@@ -522,7 +523,7 @@ namespace ts.codefix {
|
||||
catch (e) { }
|
||||
}
|
||||
|
||||
return relativeFileName;
|
||||
return getPackageNameFromAtTypesDirectory(relativeFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace ts.codefix {
|
||||
const sourceFile = context.sourceFile;
|
||||
const start = context.span.start;
|
||||
|
||||
let token = getTokenAtPosition(sourceFile, start);
|
||||
let token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
|
||||
|
||||
// this handles var ["computed"] = 12;
|
||||
if (token.kind === SyntaxKind.OpenBracketToken) {
|
||||
token = getTokenAtPosition(sourceFile, start + 1);
|
||||
token = getTokenAtPosition(sourceFile, start + 1, /*includeJsDocComment*/ false);
|
||||
}
|
||||
|
||||
switch (token.kind) {
|
||||
@@ -48,11 +48,11 @@ namespace ts.codefix {
|
||||
case SyntaxKind.TypeParameter:
|
||||
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
|
||||
if (typeParameters.length === 1) {
|
||||
const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1);
|
||||
const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false);
|
||||
if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
const nextToken = getTokenAtPosition(sourceFile, typeParameters.end);
|
||||
const nextToken = getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false);
|
||||
if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace ts.codefix {
|
||||
else {
|
||||
// import |d,| * as ns from './file'
|
||||
const start = importClause.name.getStart(sourceFile);
|
||||
const nextToken = getTokenAtPosition(sourceFile, importClause.name.end);
|
||||
const nextToken = getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false);
|
||||
if (nextToken && nextToken.kind === SyntaxKind.CommaToken) {
|
||||
// shift first non-whitespace position after comma to the start position of the node
|
||||
return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) });
|
||||
@@ -116,7 +116,7 @@ namespace ts.codefix {
|
||||
return deleteNode(importDecl);
|
||||
}
|
||||
else {
|
||||
const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1);
|
||||
const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1, /*includeJsDocComment*/ false);
|
||||
if (previousToken && previousToken.kind === SyntaxKind.CommaToken) {
|
||||
const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart);
|
||||
return deleteRange({ pos: startPosition, end: namespaceImport.end });
|
||||
|
||||
+238
-38
@@ -18,7 +18,7 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag } = completionData;
|
||||
const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords } = completionData;
|
||||
|
||||
if (requestJsDocTagName) {
|
||||
// If the current position is a jsDoc tag name, only tag names should be provided for completion
|
||||
@@ -52,7 +52,7 @@ namespace ts.Completions {
|
||||
sortText: "0",
|
||||
});
|
||||
}
|
||||
else {
|
||||
else if (!hasFilteredClassMemberKeywords) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,11 @@ namespace ts.Completions {
|
||||
getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log);
|
||||
}
|
||||
|
||||
if (hasFilteredClassMemberKeywords) {
|
||||
addRange(entries, classMemberKeywordCompletions);
|
||||
}
|
||||
// Add keywords if this is not a member completion list
|
||||
if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) {
|
||||
else if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) {
|
||||
addRange(entries, keywordCompletions);
|
||||
}
|
||||
|
||||
@@ -221,11 +224,12 @@ namespace ts.Completions {
|
||||
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined {
|
||||
const candidates: Signature[] = [];
|
||||
const entries: CompletionEntry[] = [];
|
||||
const uniques = createMap<true>();
|
||||
|
||||
typeChecker.getResolvedSignature(argumentInfo.invocation, candidates);
|
||||
|
||||
for (const candidate of candidates) {
|
||||
addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker);
|
||||
addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker, uniques);
|
||||
}
|
||||
|
||||
if (entries.length) {
|
||||
@@ -258,25 +262,29 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: Push<CompletionEntry>, typeChecker: TypeChecker): void {
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: Push<CompletionEntry>, typeChecker: TypeChecker, uniques = createMap<true>()): void {
|
||||
if (type && type.flags & TypeFlags.TypeParameter) {
|
||||
type = typeChecker.getApparentType(type);
|
||||
type = typeChecker.getBaseConstraintOfType(type);
|
||||
}
|
||||
if (!type) {
|
||||
return;
|
||||
}
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
for (const t of (<UnionType>type).types) {
|
||||
addStringLiteralCompletionsFromType(t, result, typeChecker);
|
||||
addStringLiteralCompletionsFromType(t, result, typeChecker, uniques);
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.StringLiteral) {
|
||||
result.push({
|
||||
name: (<LiteralType>type).text,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
sortText: "0"
|
||||
});
|
||||
const name = (<StringLiteralType>type).value;
|
||||
if (!uniques.has(name)) {
|
||||
uniques.set(name, true);
|
||||
result.push({
|
||||
name,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
sortText: "0"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,12 +354,12 @@ namespace ts.Completions {
|
||||
let requestJsDocTag = false;
|
||||
|
||||
let start = timestamp();
|
||||
const currentToken = getTokenAtPosition(sourceFile, position);
|
||||
const currentToken = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853
|
||||
log("getCompletionData: Get current token: " + (timestamp() - start));
|
||||
|
||||
start = timestamp();
|
||||
// Completion not allowed inside comments, bail out if this is the case
|
||||
const insideComment = isInsideComment(sourceFile, currentToken, position);
|
||||
const insideComment = isInComment(sourceFile, position, currentToken);
|
||||
log("getCompletionData: Is inside comment: " + (timestamp() - start));
|
||||
|
||||
if (insideComment) {
|
||||
@@ -406,7 +414,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (requestJsDocTagName || requestJsDocTag) {
|
||||
return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag };
|
||||
return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords: false };
|
||||
}
|
||||
|
||||
if (!insideJsDocTagExpression) {
|
||||
@@ -441,7 +449,7 @@ namespace ts.Completions {
|
||||
let isRightOfOpenTag = false;
|
||||
let isStartingCloseTag = false;
|
||||
|
||||
let location = getTouchingPropertyName(sourceFile, position);
|
||||
let location = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853
|
||||
if (contextToken) {
|
||||
// Bail out if this is a known invalid completion location
|
||||
if (isCompletionListBlocker(contextToken)) {
|
||||
@@ -505,6 +513,7 @@ namespace ts.Completions {
|
||||
let isGlobalCompletion = false;
|
||||
let isMemberCompletion: boolean;
|
||||
let isNewIdentifierLocation: boolean;
|
||||
let hasFilteredClassMemberKeywords = false;
|
||||
let symbols: Symbol[] = [];
|
||||
|
||||
if (isRightOfDot) {
|
||||
@@ -542,7 +551,7 @@ namespace ts.Completions {
|
||||
|
||||
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
||||
|
||||
return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag };
|
||||
return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords };
|
||||
|
||||
function getTypeScriptMemberSymbols(): void {
|
||||
// Right of dot member completion list
|
||||
@@ -599,6 +608,7 @@ namespace ts.Completions {
|
||||
function tryGetGlobalSymbols(): boolean {
|
||||
let objectLikeContainer: ObjectLiteralExpression | BindingPattern;
|
||||
let namedImportsOrExports: NamedImportsOrExports;
|
||||
let classLikeContainer: ClassLikeDeclaration;
|
||||
let jsxContainer: JsxOpeningLikeElement;
|
||||
|
||||
if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) {
|
||||
@@ -611,6 +621,12 @@ namespace ts.Completions {
|
||||
return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports);
|
||||
}
|
||||
|
||||
if (classLikeContainer = tryGetClassLikeCompletionContainer(contextToken)) {
|
||||
// cursor inside class declaration
|
||||
getGetClassLikeCompletionSymbols(classLikeContainer);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (jsxContainer = tryGetContainingJsxElement(contextToken)) {
|
||||
let attrsType: Type;
|
||||
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
|
||||
@@ -813,19 +829,16 @@ namespace ts.Completions {
|
||||
// We're looking up possible property names from contextual/inferred/declared type.
|
||||
isMemberCompletion = true;
|
||||
|
||||
let typeForObject: Type;
|
||||
let typeMembers: Symbol[];
|
||||
let existingMembers: Declaration[];
|
||||
|
||||
if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
// We are completing on contextual types, but may also include properties
|
||||
// other than those within the declared type.
|
||||
isNewIdentifierLocation = true;
|
||||
|
||||
// If the object literal is being assigned to something of type 'null | { hello: string }',
|
||||
// it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible.
|
||||
typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
|
||||
typeForObject = typeForObject && typeForObject.getNonNullableType();
|
||||
|
||||
const typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
|
||||
if (!typeForObject) return false;
|
||||
typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject);
|
||||
existingMembers = (<ObjectLiteralExpression>objectLikeContainer).properties;
|
||||
}
|
||||
else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
@@ -849,7 +862,10 @@ namespace ts.Completions {
|
||||
}
|
||||
}
|
||||
if (canGetType) {
|
||||
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
|
||||
const typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
|
||||
if (!typeForObject) return false;
|
||||
// In a binding pattern, get only known properties. Everywhere else we will get all possible properties.
|
||||
typeMembers = typeChecker.getPropertiesOfType(typeForObject);
|
||||
existingMembers = (<ObjectBindingPattern>objectLikeContainer).elements;
|
||||
}
|
||||
}
|
||||
@@ -861,11 +877,6 @@ namespace ts.Completions {
|
||||
Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind);
|
||||
}
|
||||
|
||||
if (!typeForObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const typeMembers = typeChecker.getPropertiesOfType(typeForObject);
|
||||
if (typeMembers && typeMembers.length > 0) {
|
||||
// Add filtered items to the completion list
|
||||
symbols = filterObjectMembersList(typeMembers, existingMembers);
|
||||
@@ -913,6 +924,62 @@ namespace ts.Completions {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates relevant symbols for completion in class declaration
|
||||
* Relevant symbols are stored in the captured 'symbols' variable.
|
||||
*/
|
||||
function getGetClassLikeCompletionSymbols(classLikeDeclaration: ClassLikeDeclaration) {
|
||||
// We're looking up possible property names from parent type.
|
||||
isMemberCompletion = true;
|
||||
// Declaring new property/method/accessor
|
||||
isNewIdentifierLocation = true;
|
||||
// Has keywords for class elements
|
||||
hasFilteredClassMemberKeywords = true;
|
||||
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(classLikeDeclaration);
|
||||
const implementsTypeNodes = getClassImplementsHeritageClauseElements(classLikeDeclaration);
|
||||
if (baseTypeNode || implementsTypeNodes) {
|
||||
const classElement = contextToken.parent;
|
||||
let classElementModifierFlags = isClassElement(classElement) && getModifierFlags(classElement);
|
||||
// If this is context token is not something we are editing now, consider if this would lead to be modifier
|
||||
if (contextToken.kind === SyntaxKind.Identifier && !isCurrentlyEditingNode(contextToken)) {
|
||||
switch (contextToken.getText()) {
|
||||
case "private":
|
||||
classElementModifierFlags = classElementModifierFlags | ModifierFlags.Private;
|
||||
break;
|
||||
case "static":
|
||||
classElementModifierFlags = classElementModifierFlags | ModifierFlags.Static;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No member list for private methods
|
||||
if (!(classElementModifierFlags & ModifierFlags.Private)) {
|
||||
let baseClassTypeToGetPropertiesFrom: Type;
|
||||
if (baseTypeNode) {
|
||||
baseClassTypeToGetPropertiesFrom = typeChecker.getTypeAtLocation(baseTypeNode);
|
||||
if (classElementModifierFlags & ModifierFlags.Static) {
|
||||
// Use static class to get property symbols from
|
||||
baseClassTypeToGetPropertiesFrom = typeChecker.getTypeOfSymbolAtLocation(
|
||||
baseClassTypeToGetPropertiesFrom.symbol, classLikeDeclaration);
|
||||
}
|
||||
}
|
||||
const implementedInterfaceTypePropertySymbols = (classElementModifierFlags & ModifierFlags.Static) ?
|
||||
undefined :
|
||||
flatMap(implementsTypeNodes, typeNode => typeChecker.getPropertiesOfType(typeChecker.getTypeAtLocation(typeNode)));
|
||||
|
||||
// List of property symbols of base type that are not private and already implemented
|
||||
symbols = filterClassMembersList(
|
||||
baseClassTypeToGetPropertiesFrom ?
|
||||
typeChecker.getPropertiesOfType(baseClassTypeToGetPropertiesFrom) :
|
||||
undefined,
|
||||
implementedInterfaceTypePropertySymbols,
|
||||
classLikeDeclaration.members,
|
||||
classElementModifierFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the immediate owning object literal or binding pattern of a context token,
|
||||
* on the condition that one exists and that the context implies completion should be given.
|
||||
@@ -953,6 +1020,49 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isFromClassElementDeclaration(node: Node) {
|
||||
return isClassElement(node.parent) && isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the immediate owning class declaration of a context token,
|
||||
* on the condition that one exists and that the context implies completion should be given.
|
||||
*/
|
||||
function tryGetClassLikeCompletionContainer(contextToken: Node): ClassLikeDeclaration {
|
||||
if (contextToken) {
|
||||
switch (contextToken.kind) {
|
||||
case SyntaxKind.OpenBraceToken: // class c { |
|
||||
if (isClassLike(contextToken.parent)) {
|
||||
return contextToken.parent;
|
||||
}
|
||||
break;
|
||||
|
||||
// class c {getValue(): number; | }
|
||||
case SyntaxKind.CommaToken:
|
||||
case SyntaxKind.SemicolonToken:
|
||||
// class c { method() { } | }
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
if (isClassLike(location)) {
|
||||
return location;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isFromClassElementDeclaration(contextToken) &&
|
||||
(isClassMemberCompletionKeyword(contextToken.kind) ||
|
||||
isClassMemberCompletionKeywordText(contextToken.getText()))) {
|
||||
return contextToken.parent.parent as ClassLikeDeclaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// class c { method() { } | method2() { } }
|
||||
if (location && location.kind === SyntaxKind.SyntaxList && isClassLike(location.parent)) {
|
||||
return location.parent;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement {
|
||||
if (contextToken) {
|
||||
const parent = contextToken.parent;
|
||||
@@ -1081,7 +1191,7 @@ namespace ts.Completions {
|
||||
isFunction(containingNodeKind);
|
||||
|
||||
case SyntaxKind.StaticKeyword:
|
||||
return containingNodeKind === SyntaxKind.PropertyDeclaration;
|
||||
return containingNodeKind === SyntaxKind.PropertyDeclaration && !isClassLike(contextToken.parent.parent);
|
||||
|
||||
case SyntaxKind.DotDotDotToken:
|
||||
return containingNodeKind === SyntaxKind.Parameter ||
|
||||
@@ -1098,13 +1208,17 @@ namespace ts.Completions {
|
||||
containingNodeKind === SyntaxKind.ExportSpecifier ||
|
||||
containingNodeKind === SyntaxKind.NamespaceImport;
|
||||
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
if (isFromClassElementDeclaration(contextToken)) {
|
||||
return false;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
case SyntaxKind.LetKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
@@ -1113,6 +1227,13 @@ namespace ts.Completions {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the previous token is keyword correspoding to class member completion keyword
|
||||
// there will be completion available here
|
||||
if (isClassMemberCompletionKeywordText(contextToken.getText()) &&
|
||||
isFromClassElementDeclaration(contextToken)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Previous token may have been a keyword that was converted to an identifier.
|
||||
switch (contextToken.getText()) {
|
||||
case "abstract":
|
||||
@@ -1159,7 +1280,7 @@ namespace ts.Completions {
|
||||
|
||||
for (const element of namedImportsOrExports) {
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (element.getStart() <= position && position <= element.getEnd()) {
|
||||
if (isCurrentlyEditingNode(element)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1198,7 +1319,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (m.getStart() <= position && position <= m.getEnd()) {
|
||||
if (isCurrentlyEditingNode(m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1214,7 +1335,7 @@ namespace ts.Completions {
|
||||
// TODO(jfreeman): Account for computed property name
|
||||
// NOTE: if one only performs this step when m.name is an identifier,
|
||||
// things like '__proto__' are not filtered out.
|
||||
existingName = (<Identifier>m.name).text;
|
||||
existingName = (getNameOfDeclaration(m) as Identifier).text;
|
||||
}
|
||||
|
||||
existingMemberNames.set(existingName, true);
|
||||
@@ -1223,6 +1344,58 @@ namespace ts.Completions {
|
||||
return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out completion suggestions for class elements.
|
||||
*
|
||||
* @returns Symbols to be suggested in an class element depending on existing memebers and symbol flags
|
||||
*/
|
||||
function filterClassMembersList(baseSymbols: Symbol[], implementingTypeSymbols: Symbol[], existingMembers: ClassElement[], currentClassElementModifierFlags: ModifierFlags): Symbol[] {
|
||||
const existingMemberNames = createMap<boolean>();
|
||||
for (const m of existingMembers) {
|
||||
// Ignore omitted expressions for missing members
|
||||
if (m.kind !== SyntaxKind.PropertyDeclaration &&
|
||||
m.kind !== SyntaxKind.MethodDeclaration &&
|
||||
m.kind !== SyntaxKind.GetAccessor &&
|
||||
m.kind !== SyntaxKind.SetAccessor) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (isCurrentlyEditingNode(m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Dont filter member even if the name matches if it is declared private in the list
|
||||
if (hasModifier(m, ModifierFlags.Private)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not filter it out if the static presence doesnt match
|
||||
const mIsStatic = hasModifier(m, ModifierFlags.Static);
|
||||
const currentElementIsStatic = !!(currentClassElementModifierFlags & ModifierFlags.Static);
|
||||
if ((mIsStatic && !currentElementIsStatic) ||
|
||||
(!mIsStatic && currentElementIsStatic)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const existingName = getPropertyNameForPropertyNameNode(m.name);
|
||||
if (existingName) {
|
||||
existingMemberNames.set(existingName, true);
|
||||
}
|
||||
}
|
||||
|
||||
return concatenate(
|
||||
filter(baseSymbols, baseProperty => isValidProperty(baseProperty, ModifierFlags.Private)),
|
||||
filter(implementingTypeSymbols, implementingProperty => isValidProperty(implementingProperty, ModifierFlags.NonPublicAccessibilityModifier))
|
||||
);
|
||||
|
||||
function isValidProperty(propertySymbol: Symbol, inValidModifierFlags: ModifierFlags) {
|
||||
return !existingMemberNames.get(propertySymbol.name) &&
|
||||
propertySymbol.getDeclarations() &&
|
||||
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & inValidModifierFlags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out completion suggestions from 'symbols' according to existing JSX attributes.
|
||||
*
|
||||
@@ -1233,7 +1406,7 @@ namespace ts.Completions {
|
||||
const seenNames = createMap<boolean>();
|
||||
for (const attr of attributes) {
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (attr.getStart() <= position && position <= attr.getEnd()) {
|
||||
if (isCurrentlyEditingNode(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1244,6 +1417,10 @@ namespace ts.Completions {
|
||||
|
||||
return filter(symbols, a => !seenNames.get(a.name));
|
||||
}
|
||||
|
||||
function isCurrentlyEditingNode(node: Node): boolean {
|
||||
return node.getStart() <= position && position <= node.getEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1306,6 +1483,29 @@ namespace ts.Completions {
|
||||
});
|
||||
}
|
||||
|
||||
function isClassMemberCompletionKeyword(kind: SyntaxKind) {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function isClassMemberCompletionKeywordText(text: string) {
|
||||
return isClassMemberCompletionKeyword(stringToToken(text));
|
||||
}
|
||||
|
||||
const classMemberKeywordCompletions = filter(keywordCompletions, entry =>
|
||||
isClassMemberCompletionKeywordText(entry.name));
|
||||
|
||||
function isEqualityExpression(node: Node): node is BinaryExpression {
|
||||
return isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* @internal */
|
||||
namespace ts.DocumentHighlights {
|
||||
export function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] {
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile));
|
||||
export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] {
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
return node && (getSemanticDocumentHighlights(node, program, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile));
|
||||
}
|
||||
|
||||
function getHighlightSpanForNode(node: Node, sourceFile: SourceFile): HighlightSpan {
|
||||
@@ -16,8 +16,8 @@ namespace ts.DocumentHighlights {
|
||||
};
|
||||
}
|
||||
|
||||
function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] {
|
||||
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(node, sourceFilesToSearch, typeChecker, cancellationToken);
|
||||
function getSemanticDocumentHighlights(node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] {
|
||||
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(node, program, sourceFilesToSearch, cancellationToken);
|
||||
return referenceEntries && convertReferencedSymbols(referenceEntries);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,14 +41,15 @@ namespace ts.FindAllReferences {
|
||||
readonly implementations?: boolean;
|
||||
}
|
||||
|
||||
export function findReferencedSymbols(checker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined {
|
||||
const referencedSymbols = findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position);
|
||||
export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined {
|
||||
const referencedSymbols = findAllReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position);
|
||||
|
||||
if (!referencedSymbols || !referencedSymbols.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const out: ReferencedSymbol[] = [];
|
||||
const checker = program.getTypeChecker();
|
||||
for (const { definition, references } of referencedSymbols) {
|
||||
// Only include referenced symbols that have a valid definition.
|
||||
if (definition) {
|
||||
@@ -59,44 +60,51 @@ namespace ts.FindAllReferences {
|
||||
return out;
|
||||
}
|
||||
|
||||
export function getImplementationsAtPosition(checker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ImplementationLocation[] {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
const referenceEntries = getImplementationReferenceEntries(checker, cancellationToken, sourceFiles, node);
|
||||
export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number): ImplementationLocation[] {
|
||||
// A node in a JSDoc comment can't have an implementation anyway.
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
const referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node);
|
||||
const checker = program.getTypeChecker();
|
||||
return map(referenceEntries, entry => toImplementationLocation(entry, checker));
|
||||
}
|
||||
|
||||
function getImplementationReferenceEntries(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): Entry[] | undefined {
|
||||
function getImplementationReferenceEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): Entry[] | undefined {
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
// If invoked directly on a shorthand property assignment, then return
|
||||
// the declaration of the symbol being assigned (not the symbol being assigned to).
|
||||
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const result: NodeEntry[] = [];
|
||||
Core.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, node => result.push(nodeEntry(node)));
|
||||
Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, node => result.push(nodeEntry(node)));
|
||||
return result;
|
||||
}
|
||||
else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) {
|
||||
// References to and accesses on the super keyword only have one possible implementation, so no
|
||||
// need to "Find all References"
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
return symbol.valueDeclaration && [nodeEntry(symbol.valueDeclaration)];
|
||||
}
|
||||
else {
|
||||
// Perform "Find all References" and retrieve only those that are implementations
|
||||
return getReferenceEntriesForNode(node, sourceFiles, typeChecker, cancellationToken, { implementations: true });
|
||||
return getReferenceEntriesForNode(node, program, sourceFiles, cancellationToken, { implementations: true });
|
||||
}
|
||||
}
|
||||
|
||||
export function findReferencedEntries(checker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined {
|
||||
const x = flattenEntries(findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options));
|
||||
export function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined {
|
||||
const x = flattenEntries(findAllReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position, options));
|
||||
return map(x, toReferenceEntry);
|
||||
}
|
||||
|
||||
export function getReferenceEntriesForNode(node: Node, sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, options: Options = {}): Entry[] | undefined {
|
||||
return flattenEntries(Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options));
|
||||
export function getReferenceEntriesForNode(node: Node, program: Program, sourceFiles: SourceFile[], cancellationToken: CancellationToken, options: Options = {}): Entry[] | undefined {
|
||||
return flattenEntries(Core.getReferencedSymbolsForNode(node, program, sourceFiles, cancellationToken, options));
|
||||
}
|
||||
|
||||
function findAllReferencedSymbols(checker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): SymbolAndEntries[] | undefined {
|
||||
function findAllReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, options?: Options): SymbolAndEntries[] | undefined {
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
return Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options);
|
||||
return Core.getReferencedSymbolsForNode(node, program, sourceFiles, cancellationToken, options);
|
||||
}
|
||||
|
||||
function flattenEntries(referenceSymbols: SymbolAndEntries[]): Entry[] {
|
||||
@@ -108,10 +116,6 @@ namespace ts.FindAllReferences {
|
||||
switch (def.type) {
|
||||
case "symbol": {
|
||||
const { symbol, node } = def;
|
||||
const declarations = symbol.declarations;
|
||||
if (!declarations || declarations.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const { displayParts, kind } = getDefinitionKindAndDisplayParts(symbol, node, checker);
|
||||
const name = displayParts.map(p => p.text).join("");
|
||||
return { node, name, kind, displayParts };
|
||||
@@ -146,7 +150,7 @@ namespace ts.FindAllReferences {
|
||||
const { node, name, kind, displayParts } = info;
|
||||
const sourceFile = node.getSourceFile();
|
||||
return {
|
||||
containerKind: "",
|
||||
containerKind: ScriptElementKind.unknown,
|
||||
containerName: "",
|
||||
fileName: sourceFile.fileName,
|
||||
kind,
|
||||
@@ -156,7 +160,7 @@ namespace ts.FindAllReferences {
|
||||
};
|
||||
}
|
||||
|
||||
function getDefinitionKindAndDisplayParts(symbol: Symbol, node: Node, checker: TypeChecker): { displayParts: SymbolDisplayPart[], kind: string } {
|
||||
function getDefinitionKindAndDisplayParts(symbol: Symbol, node: Node, checker: TypeChecker): { displayParts: SymbolDisplayPart[], kind: ScriptElementKind } {
|
||||
const { displayParts, symbolKind } =
|
||||
SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), getContainerNode(node), node);
|
||||
return { displayParts, kind: symbolKind };
|
||||
@@ -172,7 +176,7 @@ namespace ts.FindAllReferences {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: getTextSpan(node),
|
||||
isWriteAccess: isWriteAccess(node),
|
||||
isDefinition: isDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node),
|
||||
isDefinition: isAnyDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node),
|
||||
isInString
|
||||
};
|
||||
}
|
||||
@@ -187,7 +191,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
}
|
||||
|
||||
function implementationKindDisplayParts(node: ts.Node, checker: ts.TypeChecker): { kind: string, displayParts: SymbolDisplayPart[] } {
|
||||
function implementationKindDisplayParts(node: ts.Node, checker: ts.TypeChecker): { kind: ScriptElementKind, displayParts: SymbolDisplayPart[] } {
|
||||
const symbol = checker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node);
|
||||
if (symbol) {
|
||||
return getDefinitionKindAndDisplayParts(symbol, node, checker);
|
||||
@@ -238,22 +242,20 @@ namespace ts.FindAllReferences {
|
||||
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
function isWriteAccess(node: Node): boolean {
|
||||
if (node.kind === SyntaxKind.Identifier && isDeclarationName(node)) {
|
||||
if (isAnyDeclarationName(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const parent = node.parent;
|
||||
if (parent) {
|
||||
if (parent.kind === SyntaxKind.PostfixUnaryExpression || parent.kind === SyntaxKind.PrefixUnaryExpression) {
|
||||
const { parent } = node;
|
||||
switch (parent && parent.kind) {
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return true;
|
||||
}
|
||||
else if (parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>parent).left === node) {
|
||||
const operator = (<BinaryExpression>parent).operatorToken.kind;
|
||||
return SyntaxKind.FirstAssignment <= operator && operator <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return (<BinaryExpression>parent).left === node && isAssignmentOperator((<BinaryExpression>parent).operatorToken.kind);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ namespace ts.FindAllReferences {
|
||||
/* @internal */
|
||||
namespace ts.FindAllReferences.Core {
|
||||
/** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */
|
||||
export function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, options: Options = {}): SymbolAndEntries[] | undefined {
|
||||
export function getReferencedSymbolsForNode(node: Node, program: Program, sourceFiles: SourceFile[], cancellationToken: CancellationToken, options: Options = {}): SymbolAndEntries[] | undefined {
|
||||
if (node.kind === ts.SyntaxKind.SourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -273,6 +275,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
}
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. unknown identifier
|
||||
@@ -285,14 +288,65 @@ namespace ts.FindAllReferences.Core {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// The symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
||||
if (!symbol.declarations || !symbol.declarations.length) {
|
||||
return undefined;
|
||||
if (symbol.flags & SymbolFlags.Module && isModuleReferenceLocation(node)) {
|
||||
return getReferencedSymbolsForModule(program, symbol, sourceFiles);
|
||||
}
|
||||
|
||||
return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options);
|
||||
}
|
||||
|
||||
function isModuleReferenceLocation(node: ts.Node): boolean {
|
||||
if (node.kind !== SyntaxKind.StringLiteral) {
|
||||
return false;
|
||||
}
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.CallExpression:
|
||||
return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteral*/ false);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForModule(program: Program, symbol: Symbol, sourceFiles: SourceFile[]): SymbolAndEntries[] {
|
||||
Debug.assert(!!symbol.valueDeclaration);
|
||||
|
||||
const references = findModuleReferences(program, sourceFiles, symbol).map<Entry>(reference => {
|
||||
if (reference.kind === "import") {
|
||||
return { type: "node", node: reference.literal };
|
||||
}
|
||||
else {
|
||||
return {
|
||||
type: "span",
|
||||
fileName: reference.referencingFile.fileName,
|
||||
textSpan: createTextSpanFromRange(reference.ref),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
for (const decl of symbol.declarations) {
|
||||
switch (decl.kind) {
|
||||
case ts.SyntaxKind.SourceFile:
|
||||
// Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
|
||||
break;
|
||||
case ts.SyntaxKind.ModuleDeclaration:
|
||||
references.push({ type: "node", node: (decl as ts.ModuleDeclaration).name });
|
||||
break;
|
||||
default:
|
||||
Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
|
||||
}
|
||||
}
|
||||
|
||||
return [{
|
||||
definition: { type: "symbol", symbol, node: symbol.valueDeclaration },
|
||||
references
|
||||
}];
|
||||
}
|
||||
|
||||
/** getReferencedSymbols for special node kinds. */
|
||||
function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
if (isTypeKeyword(node.kind)) {
|
||||
@@ -559,7 +613,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean {
|
||||
const bindingElement = <BindingElement>getDeclarationOfKind(symbol, SyntaxKind.BindingElement);
|
||||
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||
return bindingElement &&
|
||||
bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern &&
|
||||
!bindingElement.propertyName;
|
||||
@@ -567,7 +621,7 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined {
|
||||
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
|
||||
const bindingElement = <BindingElement>getDeclarationOfKind(symbol, SyntaxKind.BindingElement);
|
||||
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||
const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent);
|
||||
return typeOfPattern && checker.getPropertyOfType(typeOfPattern, (<Identifier>bindingElement.name).text);
|
||||
}
|
||||
@@ -646,7 +700,9 @@ namespace ts.FindAllReferences.Core {
|
||||
return parent ? scope.getSourceFile() : scope;
|
||||
}
|
||||
|
||||
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number): number[] {
|
||||
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile, fullStart = false): number[] {
|
||||
const start = fullStart ? container.getFullStart() : container.getStart(sourceFile);
|
||||
const end = container.getEnd();
|
||||
const positions: number[] = [];
|
||||
|
||||
/// TODO: Cache symbol existence for files to save text search
|
||||
@@ -685,16 +741,11 @@ namespace ts.FindAllReferences.Core {
|
||||
const references: Entry[] = [];
|
||||
const sourceFile = container.getSourceFile();
|
||||
const labelName = targetLabel.text;
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd());
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container);
|
||||
for (const position of possiblePositions) {
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
if (!node || node.getWidth() !== labelName.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
// Only pick labels that are either the target label, or have a target that is the target label
|
||||
if (node === targetLabel ||
|
||||
(isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) {
|
||||
if (node && (node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel))) {
|
||||
references.push(nodeEntry(node));
|
||||
}
|
||||
}
|
||||
@@ -706,15 +757,14 @@ namespace ts.FindAllReferences.Core {
|
||||
// Compare the length so we filter out strict superstrings of the symbol we are looking for
|
||||
switch (node && node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return node.getWidth() === searchSymbolName.length;
|
||||
return unescapeIdentifier((node as Identifier).text).length === searchSymbolName.length;
|
||||
|
||||
case SyntaxKind.StringLiteral:
|
||||
return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) &&
|
||||
// For string literals we have two additional chars for the quotes
|
||||
node.getWidth() === searchSymbolName.length + 2;
|
||||
(node as StringLiteral).text.length === searchSymbolName.length;
|
||||
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length;
|
||||
return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && (node as NumericLiteral).text.length === searchSymbolName.length;
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -731,9 +781,10 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, references: Push<NodeEntry>): void {
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd());
|
||||
// Want fullStart so we can find the symbol in JSDoc comments
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile, /*fullStart*/ true);
|
||||
for (const position of possiblePositions) {
|
||||
const referenceLocation = getTouchingPropertyName(sourceFile, position);
|
||||
const referenceLocation = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
if (referenceLocation.kind === kind) {
|
||||
references.push(nodeEntry(referenceLocation));
|
||||
}
|
||||
@@ -755,15 +806,13 @@ namespace ts.FindAllReferences.Core {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = state.findInComments ? container.getFullStart() : container.getStart();
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd());
|
||||
for (const position of possiblePositions) {
|
||||
for (const position of getPossibleSymbolReferencePositions(sourceFile, search.text, container, /*fullStart*/ state.findInComments || container.jsDoc !== undefined)) {
|
||||
getReferencesAtLocation(sourceFile, position, search, state);
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencesAtLocation(sourceFile: SourceFile, position: number, search: Search, state: State): void {
|
||||
const referenceLocation = getTouchingPropertyName(sourceFile, position);
|
||||
const referenceLocation = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
|
||||
if (!isValidReferencePosition(referenceLocation, search.text)) {
|
||||
// This wasn't the start of a token. Check to see if it might be a
|
||||
@@ -908,7 +957,7 @@ namespace ts.FindAllReferences.Core {
|
||||
* position of property accessing, the referenceEntry of such position will be handled in the first case.
|
||||
*/
|
||||
if (!(flags & SymbolFlags.Transient) && search.includes(shorthandValueSymbol)) {
|
||||
addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state);
|
||||
addReference(getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, search.location, state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1201,9 +1250,9 @@ namespace ts.FindAllReferences.Core {
|
||||
const references: Entry[] = [];
|
||||
|
||||
const sourceFile = searchSpaceNode.getSourceFile();
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd());
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode);
|
||||
for (const position of possiblePositions) {
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
|
||||
if (!node || node.kind !== SyntaxKind.SuperKeyword) {
|
||||
continue;
|
||||
@@ -1263,13 +1312,13 @@ namespace ts.FindAllReferences.Core {
|
||||
if (searchSpaceNode.kind === SyntaxKind.SourceFile) {
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd());
|
||||
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this");
|
||||
getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references);
|
||||
});
|
||||
}
|
||||
else {
|
||||
const sourceFile = searchSpaceNode.getSourceFile();
|
||||
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd());
|
||||
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode);
|
||||
getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references);
|
||||
}
|
||||
|
||||
@@ -1280,7 +1329,7 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: Entry[]): void {
|
||||
forEach(possiblePositions, position => {
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
if (!node || !isThis(node)) {
|
||||
return;
|
||||
}
|
||||
@@ -1323,7 +1372,7 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
for (const sourceFile of sourceFiles) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd());
|
||||
const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text);
|
||||
getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references);
|
||||
}
|
||||
|
||||
@@ -1334,7 +1383,7 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchText: string, possiblePositions: number[], references: Push<NodeEntry>): void {
|
||||
for (const position of possiblePositions) {
|
||||
const node = getTouchingWord(sourceFile, position);
|
||||
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
if (node && node.kind === SyntaxKind.StringLiteral && (node as StringLiteral).text === searchText) {
|
||||
references.push(nodeEntry(node, /*isInString*/ true));
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ namespace ts.formatting {
|
||||
// falls through
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
return (<Declaration>node).name.kind;
|
||||
return getNameOfDeclaration(<Declaration>node).kind;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ namespace ts.formatting {
|
||||
child => {
|
||||
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false);
|
||||
},
|
||||
(nodes: NodeArray<Node>) => {
|
||||
nodes => {
|
||||
processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation);
|
||||
});
|
||||
|
||||
|
||||
@@ -341,10 +341,7 @@ namespace ts.formatting {
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
if (node.parent && (
|
||||
node.parent.kind === SyntaxKind.CallExpression ||
|
||||
node.parent.kind === SyntaxKind.NewExpression) &&
|
||||
(<CallExpression>node.parent).expression !== node) {
|
||||
if (node.parent && isCallOrNewExpression(node.parent) && (<CallExpression>node.parent).expression !== node) {
|
||||
|
||||
const fullCallOrNewExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
const startingExpression = getStartingExpression(fullCallOrNewExpression);
|
||||
|
||||
@@ -3,23 +3,13 @@
|
||||
/* @internal */
|
||||
namespace ts.formatting {
|
||||
export namespace Shared {
|
||||
export interface ITokenAccess {
|
||||
GetTokens(): SyntaxKind[];
|
||||
Contains(token: SyntaxKind): boolean;
|
||||
isSpecific(): boolean;
|
||||
const allTokens: SyntaxKind[] = [];
|
||||
for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) {
|
||||
allTokens.push(token);
|
||||
}
|
||||
|
||||
export class TokenRangeAccess implements ITokenAccess {
|
||||
private tokens: SyntaxKind[];
|
||||
|
||||
constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]) {
|
||||
this.tokens = [];
|
||||
for (let token = from; token <= to; token++) {
|
||||
if (ts.indexOf(except, token) < 0) {
|
||||
this.tokens.push(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
class TokenValuesAccess implements TokenRange {
|
||||
constructor(private readonly tokens: SyntaxKind[] = []) { }
|
||||
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return this.tokens;
|
||||
@@ -32,27 +22,8 @@ namespace ts.formatting {
|
||||
public isSpecific() { return true; }
|
||||
}
|
||||
|
||||
export class TokenValuesAccess implements ITokenAccess {
|
||||
private tokens: SyntaxKind[];
|
||||
|
||||
constructor(tks: SyntaxKind[]) {
|
||||
this.tokens = tks && tks.length ? tks : <SyntaxKind[]>[];
|
||||
}
|
||||
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return this.tokens;
|
||||
}
|
||||
|
||||
public Contains(token: SyntaxKind): boolean {
|
||||
return this.tokens.indexOf(token) >= 0;
|
||||
}
|
||||
|
||||
public isSpecific() { return true; }
|
||||
}
|
||||
|
||||
export class TokenSingleValueAccess implements ITokenAccess {
|
||||
constructor(public token: SyntaxKind) {
|
||||
}
|
||||
class TokenSingleValueAccess implements TokenRange {
|
||||
constructor(private readonly token: SyntaxKind) {}
|
||||
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return [this.token];
|
||||
@@ -65,12 +36,7 @@ namespace ts.formatting {
|
||||
public isSpecific() { return true; }
|
||||
}
|
||||
|
||||
const allTokens: SyntaxKind[] = [];
|
||||
for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) {
|
||||
allTokens.push(token);
|
||||
}
|
||||
|
||||
export class TokenAllAccess implements ITokenAccess {
|
||||
class TokenAllAccess implements TokenRange {
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return allTokens;
|
||||
}
|
||||
@@ -86,8 +52,8 @@ namespace ts.formatting {
|
||||
public isSpecific() { return false; }
|
||||
}
|
||||
|
||||
export class TokenAllExceptAccess implements ITokenAccess {
|
||||
constructor(readonly except: SyntaxKind) {}
|
||||
class TokenAllExceptAccess implements TokenRange {
|
||||
constructor(private readonly except: SyntaxKind) {}
|
||||
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return allTokens.filter(t => t !== this.except);
|
||||
@@ -100,55 +66,58 @@ namespace ts.formatting {
|
||||
public isSpecific() { return false; }
|
||||
}
|
||||
|
||||
export class TokenRange {
|
||||
constructor(public tokenAccess: ITokenAccess) {
|
||||
export interface TokenRange {
|
||||
GetTokens(): SyntaxKind[];
|
||||
Contains(token: SyntaxKind): boolean;
|
||||
isSpecific(): boolean;
|
||||
}
|
||||
|
||||
export namespace TokenRange {
|
||||
export function FromToken(token: SyntaxKind): TokenRange {
|
||||
return new TokenSingleValueAccess(token);
|
||||
}
|
||||
|
||||
static FromToken(token: SyntaxKind): TokenRange {
|
||||
return new TokenRange(new TokenSingleValueAccess(token));
|
||||
export function FromTokens(tokens: SyntaxKind[]): TokenRange {
|
||||
return new TokenValuesAccess(tokens);
|
||||
}
|
||||
|
||||
static FromTokens(tokens: SyntaxKind[]): TokenRange {
|
||||
return new TokenRange(new TokenValuesAccess(tokens));
|
||||
export function FromRange(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[] = []): TokenRange {
|
||||
const tokens: SyntaxKind[] = [];
|
||||
for (let token = from; token <= to; token++) {
|
||||
if (ts.indexOf(except, token) < 0) {
|
||||
tokens.push(token);
|
||||
}
|
||||
}
|
||||
return new TokenValuesAccess(tokens);
|
||||
}
|
||||
|
||||
static FromRange(f: SyntaxKind, to: SyntaxKind, except: SyntaxKind[] = []): TokenRange {
|
||||
return new TokenRange(new TokenRangeAccess(f, to, except));
|
||||
export function AnyExcept(token: SyntaxKind): TokenRange {
|
||||
return new TokenAllExceptAccess(token);
|
||||
}
|
||||
|
||||
static AnyExcept(token: SyntaxKind): TokenRange {
|
||||
return new TokenRange(new TokenAllExceptAccess(token));
|
||||
}
|
||||
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
return this.tokenAccess.GetTokens();
|
||||
}
|
||||
|
||||
public Contains(token: SyntaxKind): boolean {
|
||||
return this.tokenAccess.Contains(token);
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
return this.tokenAccess.toString();
|
||||
}
|
||||
|
||||
public isSpecific() {
|
||||
return this.tokenAccess.isSpecific();
|
||||
}
|
||||
|
||||
static Any: TokenRange = new TokenRange(new TokenAllAccess());
|
||||
static AnyIncludingMultilineComments = TokenRange.FromTokens([...allTokens, SyntaxKind.MultiLineCommentTrivia]);
|
||||
static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword);
|
||||
static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator);
|
||||
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]);
|
||||
static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]);
|
||||
static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPostincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
|
||||
static UnaryPredecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPostdecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
|
||||
static Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]);
|
||||
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
|
||||
export const Any: TokenRange = new TokenAllAccess();
|
||||
export const AnyIncludingMultilineComments = TokenRange.FromTokens([...allTokens, SyntaxKind.MultiLineCommentTrivia]);
|
||||
export const Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword);
|
||||
export const BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator);
|
||||
export const BinaryKeywordOperators = TokenRange.FromTokens([
|
||||
SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]);
|
||||
export const UnaryPrefixOperators = TokenRange.FromTokens([
|
||||
SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]);
|
||||
export const UnaryPrefixExpressions = TokenRange.FromTokens([
|
||||
SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken,
|
||||
SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
export const UnaryPreincrementExpressions = TokenRange.FromTokens([
|
||||
SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
export const UnaryPostincrementExpressions = TokenRange.FromTokens([
|
||||
SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
|
||||
export const UnaryPredecrementExpressions = TokenRange.FromTokens([
|
||||
SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
export const UnaryPostdecrementExpressions = TokenRange.FromTokens([
|
||||
SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
|
||||
export const Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]);
|
||||
export const TypeNames = TokenRange.FromTokens([
|
||||
SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword,
|
||||
SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ts.GoToDefinition {
|
||||
[getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)];
|
||||
}
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -50,19 +50,10 @@ namespace ts.GoToDefinition {
|
||||
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
||||
// import {A, B} from "mod";
|
||||
// to jump to the implementation directly.
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
const declaration = symbol.declarations[0];
|
||||
|
||||
// Go to the original declaration for cases:
|
||||
//
|
||||
// (1) when the aliased symbol was declared in the location(parent).
|
||||
// (2) when the aliased symbol is originating from a named import.
|
||||
//
|
||||
if (node.kind === SyntaxKind.Identifier &&
|
||||
(node.parent === declaration ||
|
||||
(declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) {
|
||||
|
||||
symbol = typeChecker.getAliasedSymbol(symbol);
|
||||
if (symbol.flags & SymbolFlags.Alias && shouldSkipAlias(node, symbol.declarations[0])) {
|
||||
const aliased = typeChecker.getAliasedSymbol(symbol);
|
||||
if (aliased.declarations) {
|
||||
symbol = aliased;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,17 +76,6 @@ namespace ts.GoToDefinition {
|
||||
declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
|
||||
}
|
||||
|
||||
if (isJsxOpeningLikeElement(node.parent)) {
|
||||
// If there are errors when trying to figure out stateless component function, just return the first declaration
|
||||
// For example:
|
||||
// declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element;
|
||||
// declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element;
|
||||
// declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element;
|
||||
// let opt = <Main/*firstTarget*/Button />; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration
|
||||
const {symbolName, symbolKind, containerName} = getSymbolInfo(typeChecker, symbol, node);
|
||||
return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)];
|
||||
}
|
||||
|
||||
// If the current location we want to find its definition is in an object literal, try to get the contextual type for the
|
||||
// object literal, lookup the property symbol in the contextual type, and use this for goto-definition.
|
||||
// For example
|
||||
@@ -106,22 +86,16 @@ namespace ts.GoToDefinition {
|
||||
// function Foo(arg: Props) {}
|
||||
// Foo( { pr/*1*/op1: 10, prop2: true })
|
||||
const element = getContainingObjectLiteralElement(node);
|
||||
if (element) {
|
||||
if (typeChecker.getContextualType(element.parent as Expression)) {
|
||||
const result: DefinitionInfo[] = [];
|
||||
const propertySymbols = getPropertySymbolsFromContextualType(typeChecker, element);
|
||||
for (const propertySymbol of propertySymbols) {
|
||||
result.push(...getDefinitionFromSymbol(typeChecker, propertySymbol, node));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (element && typeChecker.getContextualType(element.parent as Expression)) {
|
||||
return flatMap(getPropertySymbolsFromContextualType(typeChecker, element), propertySymbol =>
|
||||
getDefinitionFromSymbol(typeChecker, propertySymbol, node));
|
||||
}
|
||||
return getDefinitionFromSymbol(typeChecker, symbol, node);
|
||||
}
|
||||
|
||||
/// Goto type
|
||||
export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[] {
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true);
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -153,6 +127,29 @@ namespace ts.GoToDefinition {
|
||||
return getDefinitionFromSymbol(typeChecker, type.symbol, node);
|
||||
}
|
||||
|
||||
// Go to the original declaration for cases:
|
||||
//
|
||||
// (1) when the aliased symbol was declared in the location(parent).
|
||||
// (2) when the aliased symbol is originating from an import.
|
||||
//
|
||||
function shouldSkipAlias(node: Node, declaration: Node): boolean {
|
||||
if (node.kind !== SyntaxKind.Identifier) {
|
||||
return false;
|
||||
}
|
||||
if (node.parent === declaration) {
|
||||
return true;
|
||||
}
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return declaration.parent.kind === SyntaxKind.NamedImports;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getDefinitionFromSymbol(typeChecker: TypeChecker, symbol: Symbol, node: Node): DefinitionInfo[] {
|
||||
const result: DefinitionInfo[] = [];
|
||||
const declarations = symbol.getDeclarations();
|
||||
@@ -168,7 +165,7 @@ namespace ts.GoToDefinition {
|
||||
|
||||
return result;
|
||||
|
||||
function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
||||
// and in either case the symbol has a construct signature definition, i.e. class
|
||||
if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) {
|
||||
@@ -176,12 +173,8 @@ namespace ts.GoToDefinition {
|
||||
// Find the first class-like declaration and try to get the construct signature.
|
||||
for (const declaration of symbol.getDeclarations()) {
|
||||
if (isClassLike(declaration)) {
|
||||
return tryAddSignature(declaration.members,
|
||||
/*selectConstructors*/ true,
|
||||
symbolKind,
|
||||
symbolName,
|
||||
containerName,
|
||||
result);
|
||||
return tryAddSignature(
|
||||
declaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,14 +184,14 @@ namespace ts.GoToDefinition {
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
|
||||
return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
if (!signatureDeclarations) {
|
||||
return false;
|
||||
}
|
||||
@@ -234,12 +227,12 @@ namespace ts.GoToDefinition {
|
||||
}
|
||||
|
||||
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
||||
function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName);
|
||||
function createDefinitionInfo(node: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo {
|
||||
return createDefinitionInfoFromName(getNameOfDeclaration(node) || node, symbolKind, symbolName, containerName);
|
||||
}
|
||||
|
||||
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
||||
function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
function createDefinitionInfoFromName(name: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo {
|
||||
const sourceFile = name.getSourceFile();
|
||||
return {
|
||||
fileName: sourceFile.fileName,
|
||||
@@ -266,7 +259,7 @@ namespace ts.GoToDefinition {
|
||||
|
||||
function findReferenceInPosition(refs: FileReference[], pos: number): FileReference {
|
||||
for (const ref of refs) {
|
||||
if (ref.pos <= pos && pos < ref.end) {
|
||||
if (ref.pos <= pos && pos <= ref.end) {
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,6 +300,40 @@ namespace ts.FindAllReferences {
|
||||
});
|
||||
}
|
||||
|
||||
export type ModuleReference =
|
||||
/** "import" also includes require() calls. */
|
||||
| { kind: "import", literal: StringLiteral }
|
||||
/** <reference path> or <reference types> */
|
||||
| { kind: "reference", referencingFile: SourceFile, ref: FileReference };
|
||||
export function findModuleReferences(program: Program, sourceFiles: SourceFile[], searchModuleSymbol: Symbol): ModuleReference[] {
|
||||
const refs: ModuleReference[] = [];
|
||||
const checker = program.getTypeChecker();
|
||||
for (const referencingFile of sourceFiles) {
|
||||
const searchSourceFile = searchModuleSymbol.valueDeclaration;
|
||||
if (searchSourceFile.kind === ts.SyntaxKind.SourceFile) {
|
||||
for (const ref of referencingFile.referencedFiles) {
|
||||
if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) {
|
||||
refs.push({ kind: "reference", referencingFile, ref });
|
||||
}
|
||||
}
|
||||
for (const ref of referencingFile.typeReferenceDirectives) {
|
||||
const referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
||||
if (referenced !== undefined && referenced.resolvedFileName === (searchSourceFile as ts.SourceFile).fileName) {
|
||||
refs.push({ kind: "reference", referencingFile, ref });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEachImport(referencingFile, (_importDecl, moduleSpecifier) => {
|
||||
const moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
|
||||
if (moduleSymbol === searchModuleSymbol) {
|
||||
refs.push({ kind: "import", literal: moduleSpecifier });
|
||||
}
|
||||
});
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
/** Returns a map from a module symbol Id to all import statements that directly reference the module. */
|
||||
function getDirectImportsMap(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken): Map<ImporterOrCallExpression[]> {
|
||||
const map = createMap<ImporterOrCallExpression[]>();
|
||||
@@ -330,7 +364,7 @@ namespace ts.FindAllReferences {
|
||||
|
||||
/** Calls `action` for each import, re-export, or require() in a file. */
|
||||
function forEachImport(sourceFile: SourceFile, action: (importStatement: ImporterOrCallExpression, imported: StringLiteral) => void): void {
|
||||
if (sourceFile.externalModuleIndicator) {
|
||||
if (sourceFile.externalModuleIndicator || sourceFile.imports !== undefined) {
|
||||
for (const moduleSpecifier of sourceFile.imports) {
|
||||
action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier);
|
||||
}
|
||||
@@ -358,27 +392,21 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (sourceFile.flags & NodeFlags.JavaScriptFile) {
|
||||
// Find all 'require()' calls.
|
||||
sourceFile.forEachChild(function recur(node: Node): void {
|
||||
if (isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
|
||||
action(node, node.arguments[0] as StringLiteral);
|
||||
} else {
|
||||
node.forEachChild(recur);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function importerFromModuleSpecifier(moduleSpecifier: StringLiteral): Importer {
|
||||
function importerFromModuleSpecifier(moduleSpecifier: StringLiteral): ImporterOrCallExpression {
|
||||
const decl = moduleSpecifier.parent;
|
||||
if (decl.kind === SyntaxKind.ImportDeclaration || decl.kind === SyntaxKind.ExportDeclaration) {
|
||||
return decl as ImportDeclaration | ExportDeclaration;
|
||||
switch (decl.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return decl as ImportDeclaration | ExportDeclaration | CallExpression;
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
return (decl as ExternalModuleReference).parent;
|
||||
default:
|
||||
Debug.fail(`Unexpected module specifier parent: ${decl.kind}`);
|
||||
}
|
||||
Debug.assert(decl.kind === SyntaxKind.ExternalModuleReference);
|
||||
return (decl as ExternalModuleReference).parent;
|
||||
}
|
||||
|
||||
export interface ImportedSymbol {
|
||||
@@ -532,14 +560,18 @@ namespace ts.FindAllReferences {
|
||||
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
|
||||
}
|
||||
|
||||
function symbolName(symbol: Symbol): string {
|
||||
function symbolName(symbol: Symbol): string | undefined {
|
||||
if (symbol.name !== "default") {
|
||||
return symbol.name;
|
||||
}
|
||||
|
||||
const name = forEach(symbol.declarations, ({ name }) => name && name.kind === SyntaxKind.Identifier && name.text);
|
||||
Debug.assert(!!name);
|
||||
return name;
|
||||
return forEach(symbol.declarations, decl => {
|
||||
if (isExportAssignment(decl)) {
|
||||
return isIdentifier(decl.expression) ? decl.expression.text : undefined;
|
||||
}
|
||||
const name = getNameOfDeclaration(decl);
|
||||
return name && name.kind === SyntaxKind.Identifier && name.text;
|
||||
});
|
||||
}
|
||||
|
||||
/** If at an export specifier, go to the symbol it refers to. */
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace ts.JsDoc {
|
||||
"namespace",
|
||||
"param",
|
||||
"private",
|
||||
"prop",
|
||||
"property",
|
||||
"public",
|
||||
"requires",
|
||||
@@ -38,14 +39,12 @@ namespace ts.JsDoc {
|
||||
"throws",
|
||||
"type",
|
||||
"typedef",
|
||||
"property",
|
||||
"prop",
|
||||
"version"
|
||||
];
|
||||
let jsDocTagNameCompletionEntries: CompletionEntry[];
|
||||
let jsDocTagCompletionEntries: CompletionEntry[];
|
||||
|
||||
export function getJsDocCommentsFromDeclarations(declarations: Declaration[]) {
|
||||
export function getJsDocCommentsFromDeclarations(declarations?: Declaration[]) {
|
||||
// Only collect doc comments from duplicate declarations once:
|
||||
// In case of a union property there might be same declaration multiple times
|
||||
// which only varies in type parameter
|
||||
@@ -70,7 +69,7 @@ namespace ts.JsDoc {
|
||||
return documentationComment;
|
||||
}
|
||||
|
||||
export function getJsDocTagsFromDeclarations(declarations: Declaration[]) {
|
||||
export function getJsDocTagsFromDeclarations(declarations?: Declaration[]) {
|
||||
// Only collect doc comments from duplicate declarations once.
|
||||
const tags: JSDocTagInfo[] = [];
|
||||
forEachUnique(declarations, declaration => {
|
||||
@@ -159,7 +158,7 @@ namespace ts.JsDoc {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const tokenAtPos = getTokenAtPosition(sourceFile, position);
|
||||
const tokenAtPos = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false);
|
||||
const tokenStart = tokenAtPos.getStart();
|
||||
if (!tokenAtPos || tokenStart < position) {
|
||||
return undefined;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user