2019-11-27 22:44:31 +01:00
|
|
|
namespace ts {
|
2020-01-07 01:38:46 +01:00
|
|
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
|
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
2020-04-27 23:09:58 +02:00
|
|
|
export const versionMajorMinor = "4.0";
|
2019-11-27 22:44:31 +01:00
|
|
|
/** The version of the TypeScript compiler release */
|
|
|
|
export const version = `${versionMajorMinor}.0-dev`;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of objects whose values are all of the same type.
|
|
|
|
* The `in` and `for-in` operators can *not* be safely used,
|
|
|
|
* since `Object.prototype` may be modified by outside code.
|
|
|
|
*/
|
|
|
|
export interface MapLike<T> {
|
|
|
|
[index: string]: T;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
|
|
|
|
" __sortedArrayBrand": any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SortedArray<T> extends Array<T> {
|
|
|
|
" __sortedArrayBrand": any;
|
|
|
|
}
|
|
|
|
|
2020-06-26 19:12:47 +02:00
|
|
|
/** Common read methods for ES6 Map/Set. */
|
|
|
|
export interface ReadonlyCollection<K> {
|
2019-11-27 22:44:31 +01:00
|
|
|
readonly size: number;
|
2020-06-26 19:12:47 +02:00
|
|
|
has(key: K): boolean;
|
|
|
|
keys(): Iterator<K>;
|
2019-11-27 22:44:31 +01:00
|
|
|
}
|
|
|
|
|
2020-06-26 19:12:47 +02:00
|
|
|
/** Common write methods for ES6 Map/Set. */
|
|
|
|
export interface Collection<K> extends ReadonlyCollection<K> {
|
|
|
|
delete(key: K): boolean;
|
2019-11-27 22:44:31 +01:00
|
|
|
clear(): void;
|
|
|
|
}
|
|
|
|
|
2020-06-26 19:12:47 +02:00
|
|
|
/** ES6 Map interface, only read methods included. */
|
|
|
|
export interface ReadonlyMap<K, V> extends ReadonlyCollection<K> {
|
|
|
|
get(key: K): V | undefined;
|
|
|
|
values(): Iterator<V>;
|
|
|
|
entries(): Iterator<[K, V]>;
|
|
|
|
forEach(action: (value: V, key: K) => void): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** ES6 Map interface. */
|
|
|
|
export interface Map<K, V> extends ReadonlyMap<K, V>, Collection<K> {
|
|
|
|
set(key: K, value: V): this;
|
|
|
|
}
|
|
|
|
|
2019-11-27 22:44:31 +01:00
|
|
|
/* @internal */
|
|
|
|
export interface MapConstructor {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
2020-06-26 19:12:47 +02:00
|
|
|
new <K, V>(iterable?: readonly (readonly [K, V])[] | ReadonlyMap<K, V>): Map<K, V>;
|
2019-11-27 22:44:31 +01:00
|
|
|
}
|
|
|
|
|
2020-06-26 19:12:47 +02:00
|
|
|
/** ES6 Set interface, only read methods included. */
|
|
|
|
export interface ReadonlySet<T> extends ReadonlyCollection<T> {
|
|
|
|
has(value: T): boolean;
|
|
|
|
values(): Iterator<T>;
|
|
|
|
entries(): Iterator<[T, T]>;
|
|
|
|
forEach(action: (value: T, key: T) => void): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** ES6 Set interface. */
|
|
|
|
export interface Set<T> extends ReadonlySet<T>, Collection<T> {
|
|
|
|
add(value: T): this;
|
|
|
|
delete(value: T): boolean;
|
2019-12-07 00:20:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* @internal */
|
2020-06-26 19:12:47 +02:00
|
|
|
export interface SetConstructor {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
|
|
new <T>(iterable?: readonly T[] | ReadonlySet<T>): Set<T>;
|
|
|
|
}
|
2019-12-07 00:20:49 +01:00
|
|
|
|
2019-11-27 22:44:31 +01:00
|
|
|
/** ES6 Iterator type. */
|
|
|
|
export interface Iterator<T> {
|
|
|
|
next(): { value: T, done?: false } | { value: never, done: true };
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Array that is only intended to be pushed to, never read. */
|
|
|
|
export interface Push<T> {
|
|
|
|
push(...values: T[]): void;
|
2020-06-17 01:55:03 +02:00
|
|
|
/* @internal*/ readonly length: number;
|
2019-11-27 22:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* @internal */
|
|
|
|
export type EqualityComparer<T> = (a: T, b: T) => boolean;
|
|
|
|
|
|
|
|
/* @internal */
|
|
|
|
export type Comparer<T> = (a: T, b: T) => Comparison;
|
|
|
|
|
|
|
|
/* @internal */
|
|
|
|
export const enum Comparison {
|
|
|
|
LessThan = -1,
|
|
|
|
EqualTo = 0,
|
|
|
|
GreaterThan = 1
|
|
|
|
}
|
2020-06-26 19:12:47 +02:00
|
|
|
|
|
|
|
/* @internal */
|
|
|
|
export namespace NativeCollections {
|
|
|
|
declare const Map: MapConstructor | undefined;
|
|
|
|
declare const Set: SetConstructor | undefined;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
|
|
|
|
*/
|
|
|
|
export function tryGetNativeMap(): MapConstructor | undefined {
|
|
|
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
|
|
// eslint-disable-next-line no-in-operator
|
|
|
|
return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the native Set implementation if it is available and compatible (i.e. supports iteration).
|
|
|
|
*/
|
|
|
|
export function tryGetNativeSet(): SetConstructor | undefined {
|
|
|
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
|
|
// eslint-disable-next-line no-in-operator
|
|
|
|
return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
|
|
|
|
}
|
|
|
|
}
|
2019-11-27 22:44:31 +01:00
|
|
|
}
|