mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into watchImprovements
This commit is contained in:
+3
-2
@@ -978,8 +978,9 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
|
||||
.pipe(gulp.dest(builtLocalDirectory));
|
||||
});
|
||||
|
||||
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
|
||||
exec(host, [instrumenterJsPath, "record", "iocapture", builtLocalCompiler], done, done);
|
||||
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js - run with --test=[testname]", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
|
||||
const test = cmdLineOptions["tests"] || "iocapture";
|
||||
exec(host, [instrumenterJsPath, "record", test, builtLocalCompiler], done, done);
|
||||
});
|
||||
|
||||
gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", serverFile], () => {
|
||||
|
||||
+7
-3
@@ -139,7 +139,10 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"projectErrors.ts",
|
||||
"matchFiles.ts",
|
||||
"initializeTSConfig.ts",
|
||||
"extractMethods.ts",
|
||||
"extractConstants.ts",
|
||||
"extractFunctions.ts",
|
||||
"extractRanges.ts",
|
||||
"extractTestHelpers.ts",
|
||||
"printer.ts",
|
||||
"textChanges.ts",
|
||||
"telemetry.ts",
|
||||
@@ -1104,9 +1107,10 @@ var instrumenterPath = harnessDirectory + 'instrumenter.ts';
|
||||
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
|
||||
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"], noOutFile: true, outDir: builtLocalDirectory });
|
||||
|
||||
desc("Builds an instrumented tsc.js");
|
||||
desc("Builds an instrumented tsc.js - run with test=[testname]");
|
||||
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () {
|
||||
var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename;
|
||||
var test = process.env.test || process.env.tests || process.env.t || "iocapture";
|
||||
var cmd = host + ' ' + instrumenterJsPath + " record " + test + " " + builtLocalDirectory + compilerFilename;
|
||||
console.log(cmd);
|
||||
var ex = jake.createExec([cmd]);
|
||||
ex.addListener("cmdEnd", function () {
|
||||
|
||||
Vendored
+235
-163
File diff suppressed because it is too large
Load Diff
Vendored
+171
-110
@@ -24,11 +24,11 @@ and limitations under the License.
|
||||
/////////////////////////////
|
||||
|
||||
interface Account {
|
||||
displayName?: string;
|
||||
id?: string;
|
||||
displayName: string;
|
||||
id: string;
|
||||
imageURL?: string;
|
||||
name?: string;
|
||||
rpDisplayName?: string;
|
||||
rpDisplayName: string;
|
||||
}
|
||||
|
||||
interface Algorithm {
|
||||
@@ -55,11 +55,11 @@ interface CacheQueryOptions {
|
||||
}
|
||||
|
||||
interface ClientData {
|
||||
challenge?: string;
|
||||
challenge: string;
|
||||
extensions?: WebAuthnExtensions;
|
||||
hashAlg?: string | Algorithm;
|
||||
origin?: string;
|
||||
rpId?: string;
|
||||
hashAlg: string | Algorithm;
|
||||
origin: string;
|
||||
rpId: string;
|
||||
tokenBinding?: string;
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ interface CustomEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface DeviceAccelerationDict {
|
||||
x?: number;
|
||||
y?: number;
|
||||
z?: number;
|
||||
x?: number | null;
|
||||
y?: number | null;
|
||||
z?: number | null;
|
||||
}
|
||||
|
||||
interface DeviceLightEventInit extends EventInit {
|
||||
@@ -117,30 +117,30 @@ interface DeviceLightEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface DeviceMotionEventInit extends EventInit {
|
||||
acceleration?: DeviceAccelerationDict;
|
||||
accelerationIncludingGravity?: DeviceAccelerationDict;
|
||||
interval?: number;
|
||||
rotationRate?: DeviceRotationRateDict;
|
||||
acceleration?: DeviceAccelerationDict | null;
|
||||
accelerationIncludingGravity?: DeviceAccelerationDict | null;
|
||||
interval?: number | null;
|
||||
rotationRate?: DeviceRotationRateDict | null;
|
||||
}
|
||||
|
||||
interface DeviceOrientationEventInit extends EventInit {
|
||||
absolute?: boolean;
|
||||
alpha?: number;
|
||||
beta?: number;
|
||||
gamma?: number;
|
||||
alpha?: number | null;
|
||||
beta?: number | null;
|
||||
gamma?: number | null;
|
||||
}
|
||||
|
||||
interface DeviceRotationRateDict {
|
||||
alpha?: number;
|
||||
beta?: number;
|
||||
gamma?: number;
|
||||
alpha?: number | null;
|
||||
beta?: number | null;
|
||||
gamma?: number | null;
|
||||
}
|
||||
|
||||
interface DOMRectInit {
|
||||
height?: any;
|
||||
width?: any;
|
||||
x?: any;
|
||||
y?: any;
|
||||
height?: number;
|
||||
width?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
}
|
||||
|
||||
interface DoubleRange {
|
||||
@@ -181,15 +181,15 @@ interface EventModifierInit extends UIEventInit {
|
||||
}
|
||||
|
||||
interface ExceptionInformation {
|
||||
domain?: string;
|
||||
domain?: string | null;
|
||||
}
|
||||
|
||||
interface FocusEventInit extends UIEventInit {
|
||||
relatedTarget?: EventTarget;
|
||||
relatedTarget?: EventTarget | null;
|
||||
}
|
||||
|
||||
interface FocusNavigationEventInit extends EventInit {
|
||||
navigationReason?: string;
|
||||
navigationReason?: string | null;
|
||||
originHeight?: number;
|
||||
originLeft?: number;
|
||||
originTop?: number;
|
||||
@@ -204,7 +204,7 @@ interface FocusNavigationOrigin {
|
||||
}
|
||||
|
||||
interface GamepadEventInit extends EventInit {
|
||||
gamepad?: Gamepad;
|
||||
gamepad?: Gamepad | null;
|
||||
}
|
||||
|
||||
interface GetNotificationOptions {
|
||||
@@ -212,8 +212,8 @@ interface GetNotificationOptions {
|
||||
}
|
||||
|
||||
interface HashChangeEventInit extends EventInit {
|
||||
newURL?: string;
|
||||
oldURL?: string;
|
||||
newURL?: string | null;
|
||||
oldURL?: string | null;
|
||||
}
|
||||
|
||||
interface IDBIndexParameters {
|
||||
@@ -223,19 +223,20 @@ interface IDBIndexParameters {
|
||||
|
||||
interface IDBObjectStoreParameters {
|
||||
autoIncrement?: boolean;
|
||||
keyPath?: IDBKeyPath;
|
||||
keyPath?: IDBKeyPath | null;
|
||||
}
|
||||
|
||||
interface IntersectionObserverEntryInit {
|
||||
boundingClientRect?: DOMRectInit;
|
||||
intersectionRect?: DOMRectInit;
|
||||
rootBounds?: DOMRectInit;
|
||||
target?: Element;
|
||||
time?: number;
|
||||
isIntersecting: boolean;
|
||||
boundingClientRect: DOMRectInit;
|
||||
intersectionRect: DOMRectInit;
|
||||
rootBounds: DOMRectInit;
|
||||
target: Element;
|
||||
time: number;
|
||||
}
|
||||
|
||||
interface IntersectionObserverInit {
|
||||
root?: Element;
|
||||
root?: Element | null;
|
||||
rootMargin?: string;
|
||||
threshold?: number | number[];
|
||||
}
|
||||
@@ -257,12 +258,12 @@ interface LongRange {
|
||||
}
|
||||
|
||||
interface MediaEncryptedEventInit extends EventInit {
|
||||
initData?: ArrayBuffer;
|
||||
initData?: ArrayBuffer | null;
|
||||
initDataType?: string;
|
||||
}
|
||||
|
||||
interface MediaKeyMessageEventInit extends EventInit {
|
||||
message?: ArrayBuffer;
|
||||
message?: ArrayBuffer | null;
|
||||
messageType?: MediaKeyMessageType;
|
||||
}
|
||||
|
||||
@@ -285,7 +286,7 @@ interface MediaStreamConstraints {
|
||||
}
|
||||
|
||||
interface MediaStreamErrorEventInit extends EventInit {
|
||||
error?: MediaStreamError;
|
||||
error?: MediaStreamError | null;
|
||||
}
|
||||
|
||||
interface MediaStreamEventInit extends EventInit {
|
||||
@@ -293,7 +294,7 @@ interface MediaStreamEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface MediaStreamTrackEventInit extends EventInit {
|
||||
track?: MediaStreamTrack;
|
||||
track?: MediaStreamTrack | null;
|
||||
}
|
||||
|
||||
interface MediaTrackCapabilities {
|
||||
@@ -370,7 +371,7 @@ interface MouseEventInit extends EventModifierInit {
|
||||
buttons?: number;
|
||||
clientX?: number;
|
||||
clientY?: number;
|
||||
relatedTarget?: EventTarget;
|
||||
relatedTarget?: EventTarget | null;
|
||||
screenX?: number;
|
||||
screenY?: number;
|
||||
}
|
||||
@@ -378,8 +379,8 @@ interface MouseEventInit extends EventModifierInit {
|
||||
interface MSAccountInfo {
|
||||
accountImageUri?: string;
|
||||
accountName?: string;
|
||||
rpDisplayName?: string;
|
||||
userDisplayName?: string;
|
||||
rpDisplayName: string;
|
||||
userDisplayName: string;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
@@ -462,7 +463,7 @@ interface MSCredentialParameters {
|
||||
|
||||
interface MSCredentialSpec {
|
||||
id?: string;
|
||||
type?: MSCredentialType;
|
||||
type: MSCredentialType;
|
||||
}
|
||||
|
||||
interface MSDelay {
|
||||
@@ -672,8 +673,8 @@ interface MsZoomToOptions {
|
||||
contentX?: number;
|
||||
contentY?: number;
|
||||
scaleFactor?: number;
|
||||
viewportX?: string;
|
||||
viewportY?: string;
|
||||
viewportX?: string | null;
|
||||
viewportY?: string | null;
|
||||
}
|
||||
|
||||
interface MutationObserverInit {
|
||||
@@ -699,9 +700,9 @@ interface ObjectURLOptions {
|
||||
}
|
||||
|
||||
interface PaymentCurrencyAmount {
|
||||
currency?: string;
|
||||
currency: string;
|
||||
currencySystem?: string;
|
||||
value?: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface PaymentDetails {
|
||||
@@ -715,19 +716,19 @@ interface PaymentDetails {
|
||||
interface PaymentDetailsModifier {
|
||||
additionalDisplayItems?: PaymentItem[];
|
||||
data?: any;
|
||||
supportedMethods?: string[];
|
||||
supportedMethods: string[];
|
||||
total?: PaymentItem;
|
||||
}
|
||||
|
||||
interface PaymentItem {
|
||||
amount?: PaymentCurrencyAmount;
|
||||
label?: string;
|
||||
amount: PaymentCurrencyAmount;
|
||||
label: string;
|
||||
pending?: boolean;
|
||||
}
|
||||
|
||||
interface PaymentMethodData {
|
||||
data?: any;
|
||||
supportedMethods?: string[];
|
||||
supportedMethods: string[];
|
||||
}
|
||||
|
||||
interface PaymentOptions {
|
||||
@@ -742,9 +743,9 @@ interface PaymentRequestUpdateEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface PaymentShippingOption {
|
||||
amount?: PaymentCurrencyAmount;
|
||||
id?: string;
|
||||
label?: string;
|
||||
amount: PaymentCurrencyAmount;
|
||||
id: string;
|
||||
label: string;
|
||||
selected?: boolean;
|
||||
}
|
||||
|
||||
@@ -792,7 +793,7 @@ interface RequestInit {
|
||||
body?: any;
|
||||
cache?: RequestCache;
|
||||
credentials?: RequestCredentials;
|
||||
headers?: any;
|
||||
headers?: Headers | string[][];
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
method?: string;
|
||||
@@ -804,7 +805,7 @@ interface RequestInit {
|
||||
}
|
||||
|
||||
interface ResponseInit {
|
||||
headers?: any;
|
||||
headers?: Headers | string[][];
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
}
|
||||
@@ -889,15 +890,15 @@ interface RTCIceGatherOptions {
|
||||
}
|
||||
|
||||
interface RTCIceParameters {
|
||||
iceLite?: boolean;
|
||||
iceLite?: boolean | null;
|
||||
password?: string;
|
||||
usernameFragment?: string;
|
||||
}
|
||||
|
||||
interface RTCIceServer {
|
||||
credential?: string;
|
||||
credential?: string | null;
|
||||
urls?: any;
|
||||
username?: string;
|
||||
username?: string | null;
|
||||
}
|
||||
|
||||
interface RTCInboundRTPStreamStats extends RTCRTPStreamStats {
|
||||
@@ -1107,9 +1108,9 @@ interface RTCTransportStats extends RTCStats {
|
||||
}
|
||||
|
||||
interface ScopedCredentialDescriptor {
|
||||
id?: any;
|
||||
id: any;
|
||||
transports?: Transport[];
|
||||
type?: ScopedCredentialType;
|
||||
type: ScopedCredentialType;
|
||||
}
|
||||
|
||||
interface ScopedCredentialOptions {
|
||||
@@ -1120,29 +1121,29 @@ interface ScopedCredentialOptions {
|
||||
}
|
||||
|
||||
interface ScopedCredentialParameters {
|
||||
algorithm?: string | Algorithm;
|
||||
type?: ScopedCredentialType;
|
||||
algorithm: string | Algorithm;
|
||||
type: ScopedCredentialType;
|
||||
}
|
||||
|
||||
interface ServiceWorkerMessageEventInit extends EventInit {
|
||||
data?: any;
|
||||
lastEventId?: string;
|
||||
origin?: string;
|
||||
ports?: MessagePort[];
|
||||
source?: ServiceWorker | MessagePort;
|
||||
ports?: MessagePort[] | null;
|
||||
source?: ServiceWorker | MessagePort | null;
|
||||
}
|
||||
|
||||
interface SpeechSynthesisEventInit extends EventInit {
|
||||
charIndex?: number;
|
||||
elapsedTime?: number;
|
||||
name?: string;
|
||||
utterance?: SpeechSynthesisUtterance;
|
||||
utterance?: SpeechSynthesisUtterance | null;
|
||||
}
|
||||
|
||||
interface StoreExceptionsInformation extends ExceptionInformation {
|
||||
detailURI?: string;
|
||||
explanationString?: string;
|
||||
siteName?: string;
|
||||
detailURI?: string | null;
|
||||
explanationString?: string | null;
|
||||
siteName?: string | null;
|
||||
}
|
||||
|
||||
interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation {
|
||||
@@ -1150,7 +1151,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat
|
||||
}
|
||||
|
||||
interface TrackEventInit extends EventInit {
|
||||
track?: VideoTrack | AudioTrack | TextTrack;
|
||||
track?: VideoTrack | AudioTrack | TextTrack | null;
|
||||
}
|
||||
|
||||
interface TransitionEventInit extends EventInit {
|
||||
@@ -1160,7 +1161,7 @@ interface TransitionEventInit extends EventInit {
|
||||
|
||||
interface UIEventInit extends EventInit {
|
||||
detail?: number;
|
||||
view?: Window;
|
||||
view?: Window | null;
|
||||
}
|
||||
|
||||
interface WebAuthnExtensions {
|
||||
@@ -1540,9 +1541,9 @@ interface Cache {
|
||||
add(request: RequestInfo): Promise<void>;
|
||||
addAll(requests: RequestInfo[]): Promise<void>;
|
||||
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
|
||||
keys(request?: RequestInfo, options?: CacheQueryOptions): any;
|
||||
keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<Request[]>;
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
|
||||
matchAll(request?: RequestInfo, options?: CacheQueryOptions): any;
|
||||
matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<Response[]>;
|
||||
put(request: RequestInfo, response: Response): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1554,7 +1555,7 @@ declare var Cache: {
|
||||
interface CacheStorage {
|
||||
delete(cacheName: string): Promise<boolean>;
|
||||
has(cacheName: string): Promise<boolean>;
|
||||
keys(): any;
|
||||
keys(): Promise<string[]>;
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<any>;
|
||||
open(cacheName: string): Promise<Cache>;
|
||||
}
|
||||
@@ -2659,7 +2660,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
*/
|
||||
readonly compatMode: string;
|
||||
cookie: string;
|
||||
readonly currentScript: HTMLScriptElement | SVGScriptElement;
|
||||
readonly currentScript: HTMLScriptElement | SVGScriptElement | null;
|
||||
readonly defaultView: Window;
|
||||
/**
|
||||
* Sets or gets a value that indicates whether the document can be edited.
|
||||
@@ -3398,7 +3399,7 @@ interface DOMException {
|
||||
|
||||
declare var DOMException: {
|
||||
prototype: DOMException;
|
||||
new(): DOMException;
|
||||
new(message?: string, name?: string): DOMException;
|
||||
readonly ABORT_ERR: number;
|
||||
readonly DATA_CLONE_ERR: number;
|
||||
readonly DOMSTRING_SIZE_ERR: number;
|
||||
@@ -3904,7 +3905,7 @@ interface Headers {
|
||||
|
||||
declare var Headers: {
|
||||
prototype: Headers;
|
||||
new(init?: any): Headers;
|
||||
new(init?: Headers | string[][] | object): Headers;
|
||||
};
|
||||
|
||||
interface History {
|
||||
@@ -4064,7 +4065,7 @@ interface HTMLAppletElement extends HTMLElement {
|
||||
* Sets or retrieves a character string that can be used to implement your own declare functionality for the object.
|
||||
*/
|
||||
declare: boolean;
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the height of the object.
|
||||
*/
|
||||
@@ -4302,7 +4303,7 @@ interface HTMLButtonElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Overrides the action attribute (where the data on a form is sent) on the parent form element.
|
||||
*/
|
||||
@@ -4735,7 +4736,7 @@ interface HTMLFieldSetElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
name: string;
|
||||
/**
|
||||
* Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting.
|
||||
@@ -5314,7 +5315,7 @@ interface HTMLInputElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Overrides the action attribute (where the data on a form is sent) on the parent form element.
|
||||
*/
|
||||
@@ -5481,7 +5482,7 @@ interface HTMLLabelElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the object to which the given label object is assigned.
|
||||
*/
|
||||
@@ -5503,7 +5504,7 @@ interface HTMLLegendElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -5937,7 +5938,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the height of the object.
|
||||
*/
|
||||
@@ -6036,7 +6037,7 @@ interface HTMLOptGroupElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the ordinal position of an option in a list box.
|
||||
*/
|
||||
@@ -6075,7 +6076,7 @@ interface HTMLOptionElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the ordinal position of an option in a list box.
|
||||
*/
|
||||
@@ -6119,7 +6120,7 @@ declare var HTMLOptionsCollection: {
|
||||
|
||||
interface HTMLOutputElement extends HTMLElement {
|
||||
defaultValue: string;
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
readonly htmlFor: DOMSettableTokenList;
|
||||
name: string;
|
||||
readonly type: string;
|
||||
@@ -6208,7 +6209,7 @@ interface HTMLProgressElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Defines the maximum, or "done" value for a progress element.
|
||||
*/
|
||||
@@ -6294,7 +6295,7 @@ interface HTMLSelectElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the number of objects in a collection.
|
||||
*/
|
||||
@@ -6765,7 +6766,7 @@ interface HTMLTextAreaElement extends HTMLElement {
|
||||
/**
|
||||
* Retrieves a reference to the form that the object is embedded in.
|
||||
*/
|
||||
readonly form: HTMLFormElement;
|
||||
readonly form: HTMLFormElement | null;
|
||||
/**
|
||||
* Sets or retrieves the maximum number of characters that the user can enter in a text control.
|
||||
*/
|
||||
@@ -7231,6 +7232,7 @@ interface IntersectionObserverEntry {
|
||||
readonly rootBounds: ClientRect;
|
||||
readonly target: Element;
|
||||
readonly time: number;
|
||||
readonly isIntersecting: boolean;
|
||||
}
|
||||
|
||||
declare var IntersectionObserverEntry: {
|
||||
@@ -7332,7 +7334,7 @@ interface MediaDevicesEventMap {
|
||||
|
||||
interface MediaDevices extends EventTarget {
|
||||
ondevicechange: (this: MediaDevices, ev: Event) => any;
|
||||
enumerateDevices(): any;
|
||||
enumerateDevices(): Promise<MediaDeviceInfo[]>;
|
||||
getSupportedConstraints(): MediaTrackSupportedConstraints;
|
||||
getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
||||
addEventListener<K extends keyof MediaDevicesEventMap>(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void;
|
||||
@@ -9078,6 +9080,7 @@ interface Response extends Object, Body {
|
||||
readonly statusText: string;
|
||||
readonly type: ResponseType;
|
||||
readonly url: string;
|
||||
readonly redirected: boolean;
|
||||
clone(): Response;
|
||||
}
|
||||
|
||||
@@ -9531,8 +9534,8 @@ interface ServiceWorkerContainer extends EventTarget {
|
||||
oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any;
|
||||
onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any;
|
||||
readonly ready: Promise<ServiceWorkerRegistration>;
|
||||
getRegistration(clientURL?: USVString): Promise<any>;
|
||||
getRegistrations(): any;
|
||||
getRegistration(): Promise<ServiceWorkerRegistration | undefined>;
|
||||
getRegistrations(): Promise<ServiceWorkerRegistration[]>;
|
||||
register(scriptURL: USVString, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
|
||||
addEventListener<K extends keyof ServiceWorkerContainerEventMap>(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -9568,7 +9571,7 @@ interface ServiceWorkerRegistration extends EventTarget {
|
||||
readonly scope: USVString;
|
||||
readonly sync: SyncManager;
|
||||
readonly waiting: ServiceWorker | null;
|
||||
getNotifications(filter?: GetNotificationOptions): any;
|
||||
getNotifications(filter?: GetNotificationOptions): Promise<Notification[]>;
|
||||
showNotification(title: string, options?: NotificationOptions): Promise<void>;
|
||||
unregister(): Promise<boolean>;
|
||||
update(): Promise<void>;
|
||||
@@ -11593,7 +11596,7 @@ declare var SVGZoomEvent: {
|
||||
};
|
||||
|
||||
interface SyncManager {
|
||||
getTags(): any;
|
||||
getTags(): Promise<string[]>;
|
||||
register(tag: string): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -11901,6 +11904,7 @@ interface ValidityState {
|
||||
readonly typeMismatch: boolean;
|
||||
readonly valid: boolean;
|
||||
readonly valueMissing: boolean;
|
||||
readonly tooShort: boolean;
|
||||
}
|
||||
|
||||
declare var ValidityState: {
|
||||
@@ -13762,13 +13766,13 @@ interface NavigatorUserMedia {
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null;
|
||||
querySelector(selectors: string): Element | null;
|
||||
querySelector<E extends Element = Element>(selectors: string): E | null;
|
||||
querySelectorAll<K extends keyof ElementListTagNameMap>(selectors: K): ElementListTagNameMap[K];
|
||||
querySelectorAll(selectors: string): NodeListOf<Element>;
|
||||
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
||||
}
|
||||
|
||||
interface RandomSource {
|
||||
getRandomValues(array: ArrayBufferView): ArrayBufferView;
|
||||
getRandomValues<T extends Int8Array | Uint8ClampedArray | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array>(array: T): T;
|
||||
}
|
||||
|
||||
interface SVGAnimatedPoints {
|
||||
@@ -13843,17 +13847,37 @@ interface XMLHttpRequestEventTargetEventMap {
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTarget {
|
||||
onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any;
|
||||
onload: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
onabort: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any;
|
||||
onload: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
interface BroadcastChannel extends EventTarget {
|
||||
readonly name: string;
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onmessageerror: (ev: MessageEvent) => any;
|
||||
close(): void;
|
||||
postMessage(message: any): void;
|
||||
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
declare var BroadcastChannel: {
|
||||
prototype: BroadcastChannel;
|
||||
new(name: string): BroadcastChannel;
|
||||
};
|
||||
|
||||
interface BroadcastChannelEventMap {
|
||||
message: MessageEvent;
|
||||
messageerror: MessageEvent;
|
||||
}
|
||||
|
||||
interface ErrorEventInit {
|
||||
message?: string;
|
||||
filename?: string;
|
||||
@@ -13944,8 +13968,7 @@ interface BlobPropertyBag {
|
||||
endings?: string;
|
||||
}
|
||||
|
||||
interface FilePropertyBag {
|
||||
type?: string;
|
||||
interface FilePropertyBag extends BlobPropertyBag {
|
||||
lastModified?: number;
|
||||
}
|
||||
|
||||
@@ -14221,6 +14244,44 @@ interface TouchEventInit extends EventModifierInit {
|
||||
changedTouches?: Touch[];
|
||||
}
|
||||
|
||||
interface HTMLDialogElement extends HTMLElement {
|
||||
open: boolean;
|
||||
returnValue: string;
|
||||
close(returnValue?: string): void;
|
||||
show(): void;
|
||||
showModal(): void;
|
||||
}
|
||||
|
||||
declare var HTMLDialogElement: {
|
||||
prototype: HTMLDialogElement;
|
||||
new(): HTMLDialogElement;
|
||||
};
|
||||
|
||||
interface HTMLMainElement extends HTMLElement {
|
||||
}
|
||||
|
||||
declare var HTMLMainElement: {
|
||||
prototype: HTMLMainElement;
|
||||
new(): HTMLMainElement;
|
||||
};
|
||||
|
||||
interface HTMLDetailsElement extends HTMLElement {
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
declare var HTMLDetailsElement: {
|
||||
prototype: HTMLDetailsElement;
|
||||
new(): HTMLDetailsElement;
|
||||
};
|
||||
|
||||
interface HTMLSummaryElement extends HTMLElement {
|
||||
}
|
||||
|
||||
declare var HTMLSummaryElement: {
|
||||
prototype: HTMLSummaryElement;
|
||||
new(): HTMLSummaryElement;
|
||||
};
|
||||
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface DecodeErrorCallback {
|
||||
@@ -14710,7 +14771,7 @@ type GLsizeiptr = number;
|
||||
type GLubyte = number;
|
||||
type GLuint = number;
|
||||
type GLushort = number;
|
||||
type HeadersInit = any;
|
||||
type HeadersInit = Headers | string[][];
|
||||
type IDBKeyPath = string;
|
||||
type KeyFormat = string;
|
||||
type KeyType = string;
|
||||
|
||||
Vendored
+7
-24
@@ -30,9 +30,7 @@ interface Array<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean): T | undefined;
|
||||
find(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean, thisArg: undefined): T | undefined;
|
||||
find<Z>(predicate: (this: Z, value: T, index: number, obj: Array<T>) => boolean, thisArg: Z): T | undefined;
|
||||
find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -43,9 +41,7 @@ interface Array<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean): number;
|
||||
findIndex(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean, thisArg: undefined): number;
|
||||
findIndex<Z>(predicate: (this: Z, value: T, index: number, obj: Array<T>) => boolean, thisArg: Z): number;
|
||||
findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
@@ -76,22 +72,13 @@ interface ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (this: void, v: T, k: number) => U): Array<U>;
|
||||
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array<U>;
|
||||
from<Z, T, U>(arrayLike: ArrayLike<T>, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array<U>;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
*/
|
||||
from<T>(arrayLike: ArrayLike<T>): Array<T>;
|
||||
from<T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
|
||||
|
||||
/**
|
||||
* Returns a new array from a set of elements.
|
||||
* @param items A set of elements to include in the new array object.
|
||||
*/
|
||||
of<T>(...items: T[]): Array<T>;
|
||||
of<T>(...items: T[]): T[];
|
||||
}
|
||||
|
||||
interface DateConstructor {
|
||||
@@ -360,7 +347,7 @@ interface ObjectConstructor {
|
||||
* @param o Object that contains the property.
|
||||
* @param p Name of the property.
|
||||
*/
|
||||
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined;
|
||||
|
||||
/**
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
@@ -383,9 +370,7 @@ interface ReadonlyArray<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray<T>) => boolean): T | undefined;
|
||||
find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg: undefined): T | undefined;
|
||||
find<Z>(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg: Z): T | undefined;
|
||||
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -396,9 +381,7 @@ interface ReadonlyArray<T> {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean): number;
|
||||
findIndex(predicate: (this: void, value: T, index: number, obj: Array<T>) => boolean, thisArg: undefined): number;
|
||||
findIndex<Z>(predicate: (this: Z, value: T, index: number, obj: Array<T>) => boolean, thisArg: Z): number;
|
||||
findIndex(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): number;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
|
||||
Vendored
+10
-90
@@ -74,15 +74,7 @@ interface ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(iterable: Iterable<T>, mapfn: (this: void, v: T, k: number) => U): Array<U>;
|
||||
from<T, U>(iterable: Iterable<T>, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array<U>;
|
||||
from<Z, T, U>(iterable: Iterable<T>, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array<U>;
|
||||
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
*/
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
from<T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
@@ -237,10 +229,6 @@ interface String {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -266,17 +254,9 @@ interface Int8ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Int8Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Int8Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -302,17 +282,9 @@ interface Uint8ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Uint8Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Uint8Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -341,17 +313,9 @@ interface Uint8ClampedArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray;
|
||||
|
||||
from(arrayLike: Iterable<number>): Uint8ClampedArray;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -379,17 +343,9 @@ interface Int16ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Int16Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Int16Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -415,17 +371,9 @@ interface Uint16ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Uint16Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Uint16Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -451,17 +399,9 @@ interface Int32ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Int32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Int32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -487,17 +427,9 @@ interface Uint32ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Uint32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Uint32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -523,17 +455,9 @@ interface Float32ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Float32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Float32Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
@@ -559,9 +483,5 @@ interface Float64ArrayConstructor {
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number): Float64Array;
|
||||
from(arrayLike: Iterable<number>, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array;
|
||||
from<Z>(arrayLike: Iterable<number>, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array;
|
||||
|
||||
from(arrayLike: Iterable<number>): Float64Array;
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -24,11 +24,11 @@ declare namespace Reflect {
|
||||
function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
|
||||
function get(target: object, propertyKey: PropertyKey, receiver?: any): any;
|
||||
function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined;
|
||||
function getPrototypeOf(target: object): object;
|
||||
function has(target: object, propertyKey: PropertyKey): boolean;
|
||||
function isExtensible(target: object): boolean;
|
||||
function ownKeys(target: object): Array<PropertyKey>;
|
||||
function ownKeys(target: object): PropertyKey[];
|
||||
function preventExtensions(target: object): boolean;
|
||||
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: object, proto: any): boolean;
|
||||
|
||||
Vendored
-42
@@ -260,12 +260,6 @@ interface String {
|
||||
split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a raw buffer of binary data, which is used to store data for the
|
||||
* different typed arrays. ArrayBuffers cannot be read from or written to directly,
|
||||
* but can be passed to a typed array or DataView Object to interpret the raw
|
||||
* buffer as needed.
|
||||
*/
|
||||
interface ArrayBuffer {
|
||||
readonly [Symbol.toStringTag]: "ArrayBuffer";
|
||||
}
|
||||
@@ -274,74 +268,38 @@ interface DataView {
|
||||
readonly [Symbol.toStringTag]: "DataView";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
readonly [Symbol.toStringTag]: "UInt8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
|
||||
Vendored
+208
-275
File diff suppressed because it is too large
Load Diff
Vendored
+208
-275
File diff suppressed because it is too large
Load Diff
Vendored
+6
@@ -42,4 +42,10 @@ interface ObjectConstructor {
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries(o: any): [string, any][];
|
||||
|
||||
/**
|
||||
* Returns an object containing all own property descriptors of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
getOwnPropertyDescriptors<T>(o: T): {[P in keyof T]: TypedPropertyDescriptor<T[P]>} & { [x: string]: PropertyDescriptor };
|
||||
}
|
||||
|
||||
Vendored
+46
-46
@@ -147,7 +147,7 @@ interface ObjectConstructor {
|
||||
* @param o Object that contains the property.
|
||||
* @param p Name of the property.
|
||||
*/
|
||||
getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined;
|
||||
|
||||
/**
|
||||
* Returns the names of the own properties of an object. The own properties of an object are those that are defined directly
|
||||
@@ -1597,7 +1597,7 @@ interface Int8Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -1608,7 +1608,7 @@ interface Int8Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -1655,7 +1655,7 @@ interface Int8Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array;
|
||||
map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -1764,8 +1764,8 @@ interface Int8Array {
|
||||
interface Int8ArrayConstructor {
|
||||
readonly prototype: Int8Array;
|
||||
new(length: number): Int8Array;
|
||||
new(array: ArrayLike<number>): Int8Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Int8Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -1864,7 +1864,7 @@ interface Uint8Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -1875,7 +1875,7 @@ interface Uint8Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -1922,7 +1922,7 @@ interface Uint8Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array;
|
||||
map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -2032,8 +2032,8 @@ interface Uint8Array {
|
||||
interface Uint8ArrayConstructor {
|
||||
readonly prototype: Uint8Array;
|
||||
new(length: number): Uint8Array;
|
||||
new(array: ArrayLike<number>): Uint8Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Uint8Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2131,7 +2131,7 @@ interface Uint8ClampedArray {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -2142,7 +2142,7 @@ interface Uint8ClampedArray {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2189,7 +2189,7 @@ interface Uint8ClampedArray {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray;
|
||||
map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -2299,8 +2299,8 @@ interface Uint8ClampedArray {
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
readonly prototype: Uint8ClampedArray;
|
||||
new(length: number): Uint8ClampedArray;
|
||||
new(array: ArrayLike<number>): Uint8ClampedArray;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Uint8ClampedArray;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2386,7 +2386,7 @@ interface Int16Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array;
|
||||
filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
@@ -2397,7 +2397,7 @@ interface Int16Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -2408,7 +2408,7 @@ interface Int16Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2454,7 +2454,7 @@ interface Int16Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array;
|
||||
map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -2564,8 +2564,8 @@ interface Int16Array {
|
||||
interface Int16ArrayConstructor {
|
||||
readonly prototype: Int16Array;
|
||||
new(length: number): Int16Array;
|
||||
new(array: ArrayLike<number>): Int16Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Int16Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2664,7 +2664,7 @@ interface Uint16Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -2675,7 +2675,7 @@ interface Uint16Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -2722,7 +2722,7 @@ interface Uint16Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array;
|
||||
map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -2832,8 +2832,8 @@ interface Uint16Array {
|
||||
interface Uint16ArrayConstructor {
|
||||
readonly prototype: Uint16Array;
|
||||
new(length: number): Uint16Array;
|
||||
new(array: ArrayLike<number>): Uint16Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Uint16Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -2931,7 +2931,7 @@ interface Int32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -2942,7 +2942,7 @@ interface Int32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3099,8 +3099,8 @@ interface Int32Array {
|
||||
interface Int32ArrayConstructor {
|
||||
readonly prototype: Int32Array;
|
||||
new(length: number): Int32Array;
|
||||
new(array: ArrayLike<number>): Int32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Int32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3198,7 +3198,7 @@ interface Uint32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -3209,7 +3209,7 @@ interface Uint32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3255,7 +3255,7 @@ interface Uint32Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array;
|
||||
map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -3365,8 +3365,8 @@ interface Uint32Array {
|
||||
interface Uint32ArrayConstructor {
|
||||
readonly prototype: Uint32Array;
|
||||
new(length: number): Uint32Array;
|
||||
new(array: ArrayLike<number>): Uint32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Uint32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3464,7 +3464,7 @@ interface Float32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -3475,7 +3475,7 @@ interface Float32Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3522,7 +3522,7 @@ interface Float32Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array;
|
||||
map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -3632,8 +3632,8 @@ interface Float32Array {
|
||||
interface Float32ArrayConstructor {
|
||||
readonly prototype: Float32Array;
|
||||
new(length: number): Float32Array;
|
||||
new(array: ArrayLike<number>): Float32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Float32Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
@@ -3732,7 +3732,7 @@ interface Float64Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
|
||||
find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
@@ -3743,7 +3743,7 @@ interface Float64Array {
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
|
||||
findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
@@ -3790,7 +3790,7 @@ interface Float64Array {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array;
|
||||
map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
@@ -3900,8 +3900,8 @@ interface Float64Array {
|
||||
interface Float64ArrayConstructor {
|
||||
readonly prototype: Float64Array;
|
||||
new(length: number): Float64Array;
|
||||
new(array: ArrayLike<number>): Float64Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array;
|
||||
new(arrayOrArrayBuffer: ArrayLike<number> | ArrayBufferLike): Float64Array;
|
||||
new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* The size in bytes of each element in the array.
|
||||
|
||||
Vendored
+254
-321
File diff suppressed because it is too large
Load Diff
Vendored
+208
-275
File diff suppressed because it is too large
Load Diff
Vendored
+18
-7
@@ -221,10 +221,18 @@ declare var WScript: {
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an Automation SAFEARRAY
|
||||
*/
|
||||
declare class SafeArray<T = any> {
|
||||
private constructor();
|
||||
private SafeArray_typekey: SafeArray<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows enumerating over a COM collection, which may not have indexed item access.
|
||||
*/
|
||||
interface Enumerator<T> {
|
||||
interface Enumerator<T = any> {
|
||||
/**
|
||||
* Returns true if the current item is the last one in the collection, or the collection is empty,
|
||||
* or the current item is undefined.
|
||||
@@ -250,8 +258,9 @@ interface Enumerator<T> {
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <T>(collection: any): Enumerator<T>;
|
||||
new (collection: any): Enumerator<any>;
|
||||
new <T = any>(safearray: SafeArray<T>): Enumerator<T>;
|
||||
new <T = any>(collection: { Item(index: any): T }): Enumerator<T>;
|
||||
new <T = any>(collection: any): Enumerator<T>;
|
||||
}
|
||||
|
||||
declare var Enumerator: EnumeratorConstructor;
|
||||
@@ -259,7 +268,7 @@ declare var Enumerator: EnumeratorConstructor;
|
||||
/**
|
||||
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
||||
*/
|
||||
interface VBArray<T> {
|
||||
interface VBArray<T = any> {
|
||||
/**
|
||||
* Returns the number of dimensions (1-based).
|
||||
*/
|
||||
@@ -291,8 +300,7 @@ interface VBArray<T> {
|
||||
}
|
||||
|
||||
interface VBArrayConstructor {
|
||||
new <T>(safeArray: any): VBArray<T>;
|
||||
new (safeArray: any): VBArray<any>;
|
||||
new <T = any>(safeArray: SafeArray<T>): VBArray<T>;
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
@@ -300,7 +308,10 @@ declare var VBArray: VBArrayConstructor;
|
||||
/**
|
||||
* Automation date (VT_DATE)
|
||||
*/
|
||||
interface VarDate { }
|
||||
declare class VarDate {
|
||||
private constructor();
|
||||
private VarDate_typekey: VarDate;
|
||||
}
|
||||
|
||||
interface DateConstructor {
|
||||
new (vd: VarDate): Date;
|
||||
|
||||
Vendored
+46
-26
@@ -57,7 +57,7 @@ interface IDBIndexParameters {
|
||||
|
||||
interface IDBObjectStoreParameters {
|
||||
autoIncrement?: boolean;
|
||||
keyPath?: IDBKeyPath;
|
||||
keyPath?: IDBKeyPath | null;
|
||||
}
|
||||
|
||||
interface KeyAlgorithm {
|
||||
@@ -94,7 +94,7 @@ interface RequestInit {
|
||||
body?: any;
|
||||
cache?: RequestCache;
|
||||
credentials?: RequestCredentials;
|
||||
headers?: any;
|
||||
headers?: Headers | string[][];
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
method?: string;
|
||||
@@ -106,7 +106,7 @@ interface RequestInit {
|
||||
}
|
||||
|
||||
interface ResponseInit {
|
||||
headers?: any;
|
||||
headers?: Headers | string[][];
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
}
|
||||
@@ -123,18 +123,18 @@ interface ExtendableMessageEventInit extends ExtendableEventInit {
|
||||
data?: any;
|
||||
origin?: string;
|
||||
lastEventId?: string;
|
||||
source?: Client | ServiceWorker | MessagePort;
|
||||
ports?: MessagePort[];
|
||||
source?: Client | ServiceWorker | MessagePort | null;
|
||||
ports?: MessagePort[] | null;
|
||||
}
|
||||
|
||||
interface FetchEventInit extends ExtendableEventInit {
|
||||
request?: Request;
|
||||
clientId?: string;
|
||||
request: Request;
|
||||
clientId?: string | null;
|
||||
isReload?: boolean;
|
||||
}
|
||||
|
||||
interface NotificationEventInit extends ExtendableEventInit {
|
||||
notification?: Notification;
|
||||
notification: Notification;
|
||||
action?: string;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ interface PushEventInit extends ExtendableEventInit {
|
||||
}
|
||||
|
||||
interface SyncEventInit extends ExtendableEventInit {
|
||||
tag?: string;
|
||||
tag: string;
|
||||
lastChance?: boolean;
|
||||
}
|
||||
|
||||
@@ -195,9 +195,9 @@ interface Cache {
|
||||
add(request: RequestInfo): Promise<void>;
|
||||
addAll(requests: RequestInfo[]): Promise<void>;
|
||||
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
|
||||
keys(request?: RequestInfo, options?: CacheQueryOptions): any;
|
||||
keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<Request[]>;
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
|
||||
matchAll(request?: RequestInfo, options?: CacheQueryOptions): any;
|
||||
matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<Response[]>;
|
||||
put(request: RequestInfo, response: Response): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ declare var Cache: {
|
||||
interface CacheStorage {
|
||||
delete(cacheName: string): Promise<boolean>;
|
||||
has(cacheName: string): Promise<boolean>;
|
||||
keys(): any;
|
||||
keys(): Promise<string[]>;
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<any>;
|
||||
open(cacheName: string): Promise<Cache>;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ interface DOMException {
|
||||
|
||||
declare var DOMException: {
|
||||
prototype: DOMException;
|
||||
new(): DOMException;
|
||||
new(message?: string, name?: string): DOMException;
|
||||
readonly ABORT_ERR: number;
|
||||
readonly DATA_CLONE_ERR: number;
|
||||
readonly DOMSTRING_SIZE_ERR: number;
|
||||
@@ -490,7 +490,7 @@ interface Headers {
|
||||
|
||||
declare var Headers: {
|
||||
prototype: Headers;
|
||||
new(init?: any): Headers;
|
||||
new(init?: Headers | string[][] | object): Headers;
|
||||
};
|
||||
|
||||
interface IDBCursor {
|
||||
@@ -980,6 +980,7 @@ interface Response extends Object, Body {
|
||||
readonly statusText: string;
|
||||
readonly type: ResponseType;
|
||||
readonly url: string;
|
||||
readonly redirected: boolean;
|
||||
clone(): Response;
|
||||
}
|
||||
|
||||
@@ -1020,7 +1021,7 @@ interface ServiceWorkerRegistration extends EventTarget {
|
||||
readonly scope: USVString;
|
||||
readonly sync: SyncManager;
|
||||
readonly waiting: ServiceWorker | null;
|
||||
getNotifications(filter?: GetNotificationOptions): any;
|
||||
getNotifications(filter?: GetNotificationOptions): Promise<Notification[]>;
|
||||
showNotification(title: string, options?: NotificationOptions): Promise<void>;
|
||||
unregister(): Promise<boolean>;
|
||||
update(): Promise<void>;
|
||||
@@ -1034,7 +1035,7 @@ declare var ServiceWorkerRegistration: {
|
||||
};
|
||||
|
||||
interface SyncManager {
|
||||
getTags(): any;
|
||||
getTags(): Promise<string[]>;
|
||||
register(tag: string): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1268,13 +1269,13 @@ interface XMLHttpRequestEventTargetEventMap {
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTarget {
|
||||
onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any;
|
||||
onload: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
onabort: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any;
|
||||
onload: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: XMLHttpRequest, ev: Event) => any;
|
||||
onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any;
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -1294,7 +1295,7 @@ declare var Client: {
|
||||
interface Clients {
|
||||
claim(): Promise<void>;
|
||||
get(id: string): Promise<any>;
|
||||
matchAll(options?: ClientQueryOptions): any;
|
||||
matchAll(options?: ClientQueryOptions): Promise<Client[]>;
|
||||
openWindow(url: USVString): Promise<WindowClient>;
|
||||
}
|
||||
|
||||
@@ -1519,6 +1520,26 @@ interface WorkerUtils extends Object, WindowBase64 {
|
||||
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
|
||||
}
|
||||
|
||||
interface BroadcastChannel extends EventTarget {
|
||||
readonly name: string;
|
||||
onmessage: (ev: MessageEvent) => any;
|
||||
onmessageerror: (ev: MessageEvent) => any;
|
||||
close(): void;
|
||||
postMessage(message: any): void;
|
||||
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
declare var BroadcastChannel: {
|
||||
prototype: BroadcastChannel;
|
||||
new(name: string): BroadcastChannel;
|
||||
};
|
||||
|
||||
interface BroadcastChannelEventMap {
|
||||
message: MessageEvent;
|
||||
messageerror: MessageEvent;
|
||||
}
|
||||
|
||||
interface ErrorEventInit {
|
||||
message?: string;
|
||||
filename?: string;
|
||||
@@ -1582,8 +1603,7 @@ interface BlobPropertyBag {
|
||||
endings?: string;
|
||||
}
|
||||
|
||||
interface FilePropertyBag {
|
||||
type?: string;
|
||||
interface FilePropertyBag extends BlobPropertyBag {
|
||||
lastModified?: number;
|
||||
}
|
||||
|
||||
|
||||
+1632
-1290
File diff suppressed because it is too large
Load Diff
+2750
-2043
File diff suppressed because it is too large
Load Diff
Vendored
+120
-79
@@ -435,6 +435,9 @@ declare namespace ts {
|
||||
modifiers?: ModifiersArray;
|
||||
parent?: Node;
|
||||
}
|
||||
interface JSDocContainer {
|
||||
}
|
||||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken;
|
||||
interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange {
|
||||
hasTrailingComma?: boolean;
|
||||
}
|
||||
@@ -447,7 +450,7 @@ declare namespace ts {
|
||||
type EqualsToken = Token<SyntaxKind.EqualsToken>;
|
||||
type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
|
||||
type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
|
||||
type AtToken = Token<SyntaxKind.AtToken>;
|
||||
type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
|
||||
type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
@@ -485,6 +488,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Decorator extends Node {
|
||||
kind: SyntaxKind.Decorator;
|
||||
parent?: NamedDeclaration;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
@@ -495,16 +499,18 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SignatureDeclaration["kind"];
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
type?: TypeNode;
|
||||
type: TypeNode | undefined;
|
||||
}
|
||||
interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
@@ -520,7 +526,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -537,14 +543,14 @@ declare namespace ts {
|
||||
name: BindingName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertySignature extends TypeElement {
|
||||
interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertySignature;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyDeclaration extends ClassElement {
|
||||
interface PropertyDeclaration extends ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertyDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
name: PropertyName;
|
||||
@@ -556,27 +562,30 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
}
|
||||
type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
|
||||
interface PropertyAssignment extends ObjectLiteralElement {
|
||||
interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.PropertyAssignment;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
initializer: Expression;
|
||||
}
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.ShorthandPropertyAssignment;
|
||||
name: Identifier;
|
||||
questionToken?: QuestionToken;
|
||||
equalsToken?: Token<SyntaxKind.EqualsToken>;
|
||||
objectAssignmentInitializer?: Expression;
|
||||
}
|
||||
interface SpreadAssignment extends ObjectLiteralElement {
|
||||
interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name?: DeclarationName;
|
||||
name: DeclarationName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
@@ -596,7 +605,7 @@ declare namespace ts {
|
||||
}
|
||||
type BindingPattern = ObjectBindingPattern | ArrayBindingPattern;
|
||||
type ArrayBindingElement = BindingElement | OmittedExpression;
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclaration {
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclarationBase {
|
||||
_functionLikeDeclarationBrand: any;
|
||||
asteriskToken?: AsteriskToken;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -609,16 +618,16 @@ declare namespace ts {
|
||||
name?: Identifier;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface MethodSignature extends SignatureDeclaration, TypeElement {
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.MethodSignature;
|
||||
name: PropertyName;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.MethodDeclaration;
|
||||
name: PropertyName;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.Constructor;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
body?: FunctionBody;
|
||||
@@ -627,20 +636,20 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SemicolonClassElement;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
}
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.GetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.SetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement {
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
kind: SyntaxKind.IndexSignature;
|
||||
parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode;
|
||||
}
|
||||
@@ -654,10 +663,10 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ThisType;
|
||||
}
|
||||
type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode;
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments;
|
||||
@@ -668,6 +677,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent?: SignatureDeclaration;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -712,7 +722,6 @@ declare namespace ts {
|
||||
}
|
||||
interface MappedTypeNode extends TypeNode, Declaration {
|
||||
kind: SyntaxKind.MappedType;
|
||||
parent?: TypeAliasDeclaration;
|
||||
readonlyToken?: ReadonlyToken;
|
||||
typeParameter: TypeParameterDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -720,7 +729,7 @@ declare namespace ts {
|
||||
}
|
||||
interface LiteralTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.LiteralType;
|
||||
literal: Expression;
|
||||
literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression;
|
||||
}
|
||||
interface StringLiteral extends LiteralExpression {
|
||||
kind: SyntaxKind.StringLiteral;
|
||||
@@ -854,12 +863,12 @@ declare namespace ts {
|
||||
}
|
||||
type FunctionBody = Block;
|
||||
type ConciseBody = FunctionBody | Expression;
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase {
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.FunctionExpression;
|
||||
name?: Identifier;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase {
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.ArrowFunction;
|
||||
equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
body: ConciseBody;
|
||||
@@ -905,7 +914,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
literal: TemplateMiddle | TemplateTail;
|
||||
}
|
||||
interface ParenthesizedExpression extends PrimaryExpression {
|
||||
interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer {
|
||||
kind: SyntaxKind.ParenthesizedExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -915,6 +924,7 @@ declare namespace ts {
|
||||
}
|
||||
interface SpreadElement extends Expression {
|
||||
kind: SyntaxKind.SpreadElement;
|
||||
parent?: ArrayLiteralExpression | CallExpression | NewExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration {
|
||||
@@ -1072,11 +1082,11 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Block;
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
interface VariableStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.VariableStatement;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
interface ExpressionStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.ExpressionStatement;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -1157,7 +1167,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
||||
interface LabeledStatement extends Statement {
|
||||
interface LabeledStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.LabeledStatement;
|
||||
label: Identifier;
|
||||
statement: Statement;
|
||||
@@ -1179,19 +1189,21 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement {
|
||||
interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.ClassDeclaration;
|
||||
name?: Identifier;
|
||||
}
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
type ClassLikeDeclaration = ClassDeclaration | ClassExpression;
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
@@ -1201,7 +1213,7 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
}
|
||||
interface InterfaceDeclaration extends DeclarationStatement {
|
||||
interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.InterfaceDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@@ -1214,26 +1226,26 @@ declare namespace ts {
|
||||
token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends DeclarationStatement {
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.TypeAliasDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
interface EnumMember extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface EnumDeclaration extends DeclarationStatement {
|
||||
interface EnumDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.EnumDeclaration;
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
type ModuleName = Identifier | StringLiteral;
|
||||
type ModuleBody = NamespaceBody | JSDocNamespaceBody;
|
||||
interface ModuleDeclaration extends DeclarationStatement {
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ModuleDeclaration;
|
||||
parent?: ModuleBody | SourceFile;
|
||||
name: ModuleName;
|
||||
@@ -1255,7 +1267,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
type ModuleReference = EntityName | ExternalModuleReference;
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement {
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ImportEqualsDeclaration;
|
||||
parent?: SourceFile | ModuleBlock;
|
||||
name: Identifier;
|
||||
@@ -1365,7 +1377,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocOptionalType;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
@@ -1375,6 +1387,7 @@ declare namespace ts {
|
||||
type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
interface JSDoc extends Node {
|
||||
kind: SyntaxKind.JSDocComment;
|
||||
parent?: HasJSDoc;
|
||||
tags: NodeArray<JSDocTag> | undefined;
|
||||
comment: string | undefined;
|
||||
}
|
||||
@@ -1429,7 +1442,6 @@ declare namespace ts {
|
||||
interface JSDocTypeLiteral extends JSDocType {
|
||||
kind: SyntaxKind.JSDocTypeLiteral;
|
||||
jsDocPropertyTags?: ReadonlyArray<JSDocPropertyLikeTag>;
|
||||
jsDocTypeTag?: JSDocTypeTag;
|
||||
isArrayType?: boolean;
|
||||
}
|
||||
const enum FlowFlags {
|
||||
@@ -1503,10 +1515,10 @@ declare namespace ts {
|
||||
endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
fileName: string;
|
||||
text: string;
|
||||
amdDependencies: AmdDependency[];
|
||||
amdDependencies: ReadonlyArray<AmdDependency>;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
referencedFiles: ReadonlyArray<FileReference>;
|
||||
typeReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
hasNoDefaultLib: boolean;
|
||||
@@ -1514,7 +1526,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Bundle extends Node {
|
||||
kind: SyntaxKind.Bundle;
|
||||
sourceFiles: SourceFile[];
|
||||
sourceFiles: ReadonlyArray<SourceFile>;
|
||||
}
|
||||
interface JsonSourceFile extends SourceFile {
|
||||
jsonObject?: ObjectLiteralExpression;
|
||||
@@ -1533,7 +1545,7 @@ declare namespace ts {
|
||||
readFile(path: string): string | undefined;
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray<SourceFile>): void;
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
|
||||
}
|
||||
class OperationCanceledException {
|
||||
}
|
||||
@@ -1542,15 +1554,16 @@ declare namespace ts {
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getRootFileNames(): string[];
|
||||
getSourceFiles(): SourceFile[];
|
||||
getRootFileNames(): ReadonlyArray<string>;
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getTypeChecker(): TypeChecker;
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
}
|
||||
interface CustomTransformers {
|
||||
before?: TransformerFactory<SourceFile>[];
|
||||
@@ -1583,7 +1596,7 @@ declare namespace ts {
|
||||
}
|
||||
interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
diagnostics: Diagnostic[];
|
||||
diagnostics: ReadonlyArray<Diagnostic>;
|
||||
emittedFiles: string[];
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -1857,6 +1870,7 @@ declare namespace ts {
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 224,
|
||||
Unit = 6368,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
@@ -2032,7 +2046,7 @@ declare namespace ts {
|
||||
interface PluginImport {
|
||||
name: string;
|
||||
}
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | null | undefined;
|
||||
interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
@@ -2199,6 +2213,7 @@ declare namespace ts {
|
||||
}
|
||||
interface PackageId {
|
||||
name: string;
|
||||
subModuleName: string;
|
||||
version: string;
|
||||
}
|
||||
const enum Extension {
|
||||
@@ -2214,14 +2229,15 @@ declare namespace ts {
|
||||
interface ResolvedTypeReferenceDirective {
|
||||
primary: boolean;
|
||||
resolvedFileName?: string;
|
||||
packageId?: PackageId;
|
||||
}
|
||||
interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective;
|
||||
failedLookupLocations: string[];
|
||||
}
|
||||
interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
@@ -2283,7 +2299,8 @@ declare namespace ts {
|
||||
SourceFile = 0,
|
||||
Expression = 1,
|
||||
IdentifierName = 2,
|
||||
Unspecified = 3,
|
||||
MappedTypeParameter = 3,
|
||||
Unspecified = 4,
|
||||
}
|
||||
interface TransformationContext {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
@@ -2343,6 +2360,9 @@ declare namespace ts {
|
||||
const versionMajorMinor = "2.6";
|
||||
const version: string;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isExternalModuleNameRelative(moduleName: string): boolean;
|
||||
}
|
||||
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
|
||||
declare function clearTimeout(handle: any): void;
|
||||
declare namespace ts {
|
||||
@@ -2433,7 +2453,18 @@ declare namespace ts {
|
||||
function getParseTreeNode<T extends Node>(node: Node, nodeTest?: (node: Node) => node is T): T;
|
||||
function unescapeLeadingUnderscores(identifier: __String): string;
|
||||
function unescapeIdentifier(id: string): string;
|
||||
function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined;
|
||||
function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined;
|
||||
function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray<JSDocParameterTag> | undefined;
|
||||
function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean;
|
||||
function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined;
|
||||
function getJSDocClassTag(node: Node): JSDocClassTag | undefined;
|
||||
function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined;
|
||||
function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined;
|
||||
function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined;
|
||||
function getJSDocType(node: Node): TypeNode | undefined;
|
||||
function getJSDocReturnType(node: Node): TypeNode | undefined;
|
||||
function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> | undefined;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isNumericLiteral(node: Node): node is NumericLiteral;
|
||||
@@ -2805,8 +2836,8 @@ declare namespace ts {
|
||||
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 createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ReadonlyArray<ArrayBindingElement>): ArrayBindingPattern;
|
||||
@@ -2835,6 +2866,7 @@ declare namespace ts {
|
||||
function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray<Modifier> | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: Block): FunctionExpression;
|
||||
function createArrowFunction(modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>, body: ConciseBody): ArrowFunction;
|
||||
function createDelete(expression: Expression): DeleteExpression;
|
||||
function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression;
|
||||
function createTypeOf(expression: Expression): TypeOfExpression;
|
||||
@@ -2852,8 +2884,13 @@ declare namespace ts {
|
||||
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;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token<SyntaxKind.QuestionToken>, whenTrue: Expression, colonToken: Token<SyntaxKind.ColonToken>, whenFalse: Expression): ConditionalExpression;
|
||||
function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function createTemplateHead(text: string): TemplateHead;
|
||||
function createTemplateMiddle(text: string): TemplateMiddle;
|
||||
function createTemplateTail(text: string): TemplateTail;
|
||||
function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral;
|
||||
function createYield(expression?: Expression): YieldExpression;
|
||||
function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression;
|
||||
function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression;
|
||||
@@ -2992,10 +3029,12 @@ declare namespace ts {
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createBundle(sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
function createLessThan(left: Expression, right: Expression): Expression;
|
||||
function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
||||
@@ -3062,10 +3101,10 @@ declare namespace ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
interface Node {
|
||||
@@ -3121,7 +3160,7 @@ declare namespace ts {
|
||||
interface SourceFile {
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineEndOfPosition(pos: number): number;
|
||||
getLineStarts(): number[];
|
||||
getLineStarts(): ReadonlyArray<number>;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
@@ -3273,15 +3312,15 @@ declare namespace ts {
|
||||
inlineable?: boolean;
|
||||
actions: RefactorActionInfo[];
|
||||
}
|
||||
type RefactorActionInfo = {
|
||||
interface RefactorActionInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
type RefactorEditInfo = {
|
||||
}
|
||||
interface RefactorEditInfo {
|
||||
edits: FileTextChanges[];
|
||||
renameFilename?: string;
|
||||
renameLocation?: number;
|
||||
};
|
||||
renameFilename: string | undefined;
|
||||
renameLocation: number | undefined;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
caretOffset: number;
|
||||
@@ -4041,10 +4080,10 @@ declare namespace ts.server.protocol {
|
||||
inlineable?: boolean;
|
||||
actions: RefactorActionInfo[];
|
||||
}
|
||||
type RefactorActionInfo = {
|
||||
interface RefactorActionInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
interface GetEditsForRefactorRequest extends Request {
|
||||
command: CommandTypes.GetEditsForRefactor;
|
||||
arguments: GetEditsForRefactorRequestArgs;
|
||||
@@ -4052,15 +4091,16 @@ declare namespace ts.server.protocol {
|
||||
type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & {
|
||||
refactor: string;
|
||||
action: string;
|
||||
formatOptions?: FormatCodeSettings;
|
||||
};
|
||||
interface GetEditsForRefactorResponse extends Response {
|
||||
body?: RefactorEditInfo;
|
||||
}
|
||||
type RefactorEditInfo = {
|
||||
interface RefactorEditInfo {
|
||||
edits: FileCodeEdits[];
|
||||
renameLocation?: Location;
|
||||
renameFilename?: string;
|
||||
};
|
||||
}
|
||||
interface CodeFixRequest extends Request {
|
||||
command: CommandTypes.GetCodeFixes;
|
||||
arguments: CodeFixRequestArgs;
|
||||
@@ -4943,13 +4983,14 @@ declare namespace ts.server {
|
||||
readonly fileName: NormalizedPath;
|
||||
readonly scriptKind: ScriptKind;
|
||||
hasMixedContent: boolean;
|
||||
isDynamic: boolean;
|
||||
readonly containingProjects: Project[];
|
||||
private formatCodeSettings;
|
||||
readonly path: Path;
|
||||
private fileWatcher;
|
||||
private textStorage;
|
||||
private isOpen;
|
||||
constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean);
|
||||
constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean, isDynamic?: boolean);
|
||||
isScriptOpen(): boolean;
|
||||
open(newText: string): void;
|
||||
close(): void;
|
||||
@@ -5295,7 +5336,7 @@ declare namespace ts.server {
|
||||
interface SafeList {
|
||||
[name: string]: {
|
||||
match: RegExp;
|
||||
exclude?: Array<Array<string | number>>;
|
||||
exclude?: (string | number)[][];
|
||||
types?: string[];
|
||||
};
|
||||
}
|
||||
@@ -5412,7 +5453,7 @@ declare namespace ts.server {
|
||||
getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo;
|
||||
getScriptInfo(uncheckedFileName: string): ScriptInfo;
|
||||
watchClosedScriptInfo(info: ScriptInfo): void;
|
||||
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo;
|
||||
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, isDynamic?: boolean): ScriptInfo;
|
||||
getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo;
|
||||
getScriptInfoForPath(fileName: Path): ScriptInfo;
|
||||
setHostConfiguration(args: protocol.ConfigureRequestArguments): void;
|
||||
|
||||
+2679
-2028
File diff suppressed because it is too large
Load Diff
Vendored
+158
-73
@@ -446,6 +446,9 @@ declare namespace ts {
|
||||
modifiers?: ModifiersArray;
|
||||
parent?: Node;
|
||||
}
|
||||
interface JSDocContainer {
|
||||
}
|
||||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken;
|
||||
interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange {
|
||||
hasTrailingComma?: boolean;
|
||||
}
|
||||
@@ -458,7 +461,7 @@ declare namespace ts {
|
||||
type EqualsToken = Token<SyntaxKind.EqualsToken>;
|
||||
type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
|
||||
type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
|
||||
type AtToken = Token<SyntaxKind.AtToken>;
|
||||
type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
|
||||
type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
@@ -500,6 +503,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Decorator extends Node {
|
||||
kind: SyntaxKind.Decorator;
|
||||
parent?: NamedDeclaration;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
@@ -510,16 +514,18 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SignatureDeclaration["kind"];
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
type?: TypeNode;
|
||||
type: TypeNode | undefined;
|
||||
}
|
||||
interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
@@ -535,7 +541,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -552,14 +558,14 @@ declare namespace ts {
|
||||
name: BindingName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertySignature extends TypeElement {
|
||||
interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertySignature;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyDeclaration extends ClassElement {
|
||||
interface PropertyDeclaration extends ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertyDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
name: PropertyName;
|
||||
@@ -571,27 +577,30 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
}
|
||||
type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
|
||||
interface PropertyAssignment extends ObjectLiteralElement {
|
||||
interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.PropertyAssignment;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
initializer: Expression;
|
||||
}
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.ShorthandPropertyAssignment;
|
||||
name: Identifier;
|
||||
questionToken?: QuestionToken;
|
||||
equalsToken?: Token<SyntaxKind.EqualsToken>;
|
||||
objectAssignmentInitializer?: Expression;
|
||||
}
|
||||
interface SpreadAssignment extends ObjectLiteralElement {
|
||||
interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name?: DeclarationName;
|
||||
name: DeclarationName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
@@ -619,7 +628,7 @@ declare namespace ts {
|
||||
* - MethodDeclaration
|
||||
* - AccessorDeclaration
|
||||
*/
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclaration {
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclarationBase {
|
||||
_functionLikeDeclarationBrand: any;
|
||||
asteriskToken?: AsteriskToken;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -632,16 +641,16 @@ declare namespace ts {
|
||||
name?: Identifier;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface MethodSignature extends SignatureDeclaration, TypeElement {
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.MethodSignature;
|
||||
name: PropertyName;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.MethodDeclaration;
|
||||
name: PropertyName;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.Constructor;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
body?: FunctionBody;
|
||||
@@ -651,20 +660,20 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SemicolonClassElement;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
}
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.GetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.SetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement {
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
kind: SyntaxKind.IndexSignature;
|
||||
parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode;
|
||||
}
|
||||
@@ -678,10 +687,10 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ThisType;
|
||||
}
|
||||
type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode;
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments;
|
||||
@@ -692,6 +701,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent?: SignatureDeclaration;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -736,7 +746,6 @@ declare namespace ts {
|
||||
}
|
||||
interface MappedTypeNode extends TypeNode, Declaration {
|
||||
kind: SyntaxKind.MappedType;
|
||||
parent?: TypeAliasDeclaration;
|
||||
readonlyToken?: ReadonlyToken;
|
||||
typeParameter: TypeParameterDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -744,7 +753,7 @@ declare namespace ts {
|
||||
}
|
||||
interface LiteralTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.LiteralType;
|
||||
literal: Expression;
|
||||
literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression;
|
||||
}
|
||||
interface StringLiteral extends LiteralExpression {
|
||||
kind: SyntaxKind.StringLiteral;
|
||||
@@ -879,12 +888,12 @@ declare namespace ts {
|
||||
}
|
||||
type FunctionBody = Block;
|
||||
type ConciseBody = FunctionBody | Expression;
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase {
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.FunctionExpression;
|
||||
name?: Identifier;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase {
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.ArrowFunction;
|
||||
equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
body: ConciseBody;
|
||||
@@ -930,7 +939,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
literal: TemplateMiddle | TemplateTail;
|
||||
}
|
||||
interface ParenthesizedExpression extends PrimaryExpression {
|
||||
interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer {
|
||||
kind: SyntaxKind.ParenthesizedExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -940,6 +949,7 @@ declare namespace ts {
|
||||
}
|
||||
interface SpreadElement extends Expression {
|
||||
kind: SyntaxKind.SpreadElement;
|
||||
parent?: ArrayLiteralExpression | CallExpression | NewExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
/**
|
||||
@@ -1107,11 +1117,11 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Block;
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
interface VariableStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.VariableStatement;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
interface ExpressionStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.ExpressionStatement;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -1192,7 +1202,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
||||
interface LabeledStatement extends Statement {
|
||||
interface LabeledStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.LabeledStatement;
|
||||
label: Identifier;
|
||||
statement: Statement;
|
||||
@@ -1214,19 +1224,21 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement {
|
||||
interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.ClassDeclaration;
|
||||
name?: Identifier;
|
||||
}
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
type ClassLikeDeclaration = ClassDeclaration | ClassExpression;
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
@@ -1236,7 +1248,7 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
}
|
||||
interface InterfaceDeclaration extends DeclarationStatement {
|
||||
interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.InterfaceDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@@ -1249,26 +1261,26 @@ declare namespace ts {
|
||||
token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends DeclarationStatement {
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.TypeAliasDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
interface EnumMember extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface EnumDeclaration extends DeclarationStatement {
|
||||
interface EnumDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.EnumDeclaration;
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
type ModuleName = Identifier | StringLiteral;
|
||||
type ModuleBody = NamespaceBody | JSDocNamespaceBody;
|
||||
interface ModuleDeclaration extends DeclarationStatement {
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ModuleDeclaration;
|
||||
parent?: ModuleBody | SourceFile;
|
||||
name: ModuleName;
|
||||
@@ -1295,7 +1307,7 @@ declare namespace ts {
|
||||
* - import x = require("mod");
|
||||
* - import x = M.x;
|
||||
*/
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement {
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ImportEqualsDeclaration;
|
||||
parent?: SourceFile | ModuleBlock;
|
||||
name: Identifier;
|
||||
@@ -1407,7 +1419,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocOptionalType;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
@@ -1417,6 +1429,7 @@ declare namespace ts {
|
||||
type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
interface JSDoc extends Node {
|
||||
kind: SyntaxKind.JSDocComment;
|
||||
parent?: HasJSDoc;
|
||||
tags: NodeArray<JSDocTag> | undefined;
|
||||
comment: string | undefined;
|
||||
}
|
||||
@@ -1472,7 +1485,6 @@ declare namespace ts {
|
||||
interface JSDocTypeLiteral extends JSDocType {
|
||||
kind: SyntaxKind.JSDocTypeLiteral;
|
||||
jsDocPropertyTags?: ReadonlyArray<JSDocPropertyLikeTag>;
|
||||
jsDocTypeTag?: JSDocTypeTag;
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
isArrayType?: boolean;
|
||||
}
|
||||
@@ -1547,10 +1559,10 @@ declare namespace ts {
|
||||
endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
fileName: string;
|
||||
text: string;
|
||||
amdDependencies: AmdDependency[];
|
||||
amdDependencies: ReadonlyArray<AmdDependency>;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
referencedFiles: ReadonlyArray<FileReference>;
|
||||
typeReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
/**
|
||||
@@ -1566,7 +1578,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Bundle extends Node {
|
||||
kind: SyntaxKind.Bundle;
|
||||
sourceFiles: SourceFile[];
|
||||
sourceFiles: ReadonlyArray<SourceFile>;
|
||||
}
|
||||
interface JsonSourceFile extends SourceFile {
|
||||
jsonObject?: ObjectLiteralExpression;
|
||||
@@ -1589,7 +1601,7 @@ declare namespace ts {
|
||||
readFile(path: string): string | undefined;
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray<SourceFile>): void;
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
|
||||
}
|
||||
class OperationCanceledException {
|
||||
}
|
||||
@@ -1602,11 +1614,11 @@ declare namespace ts {
|
||||
/**
|
||||
* Get a list of root file names that were passed to a 'createProgram'
|
||||
*/
|
||||
getRootFileNames(): string[];
|
||||
getRootFileNames(): ReadonlyArray<string>;
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
*/
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
/**
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
@@ -1618,15 +1630,16 @@ declare namespace ts {
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
* Gets a type checker that can be used to semantically analyze source files in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
}
|
||||
interface CustomTransformers {
|
||||
/** Custom transformers to evaluate before built-in transformations. */
|
||||
@@ -1669,7 +1682,7 @@ declare namespace ts {
|
||||
interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: Diagnostic[];
|
||||
diagnostics: ReadonlyArray<Diagnostic>;
|
||||
emittedFiles: string[];
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -1970,6 +1983,7 @@ declare namespace ts {
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 224,
|
||||
Unit = 6368,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
@@ -2172,7 +2186,7 @@ declare namespace ts {
|
||||
interface PluginImport {
|
||||
name: string;
|
||||
}
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | null | undefined;
|
||||
interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
@@ -2372,6 +2386,11 @@ declare namespace ts {
|
||||
* If accessing a non-index file, this should include its name e.g. "foo/bar".
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Name of a submodule within this package.
|
||||
* May be "".
|
||||
*/
|
||||
subModuleName: string;
|
||||
/** Version of the package, e.g. "1.2.3" */
|
||||
version: string;
|
||||
}
|
||||
@@ -2388,14 +2407,15 @@ declare namespace ts {
|
||||
interface ResolvedTypeReferenceDirective {
|
||||
primary: boolean;
|
||||
resolvedFileName?: string;
|
||||
packageId?: PackageId;
|
||||
}
|
||||
interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective;
|
||||
failedLookupLocations: string[];
|
||||
}
|
||||
interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
@@ -2460,7 +2480,8 @@ declare namespace ts {
|
||||
SourceFile = 0,
|
||||
Expression = 1,
|
||||
IdentifierName = 2,
|
||||
Unspecified = 3,
|
||||
MappedTypeParameter = 3,
|
||||
Unspecified = 4,
|
||||
}
|
||||
interface TransformationContext {
|
||||
/** Gets the compiler options supplied to the transformer. */
|
||||
@@ -2639,6 +2660,9 @@ declare namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isExternalModuleNameRelative(moduleName: string): boolean;
|
||||
}
|
||||
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
|
||||
declare function clearTimeout(handle: any): void;
|
||||
declare namespace ts {
|
||||
@@ -2834,7 +2858,60 @@ declare namespace ts {
|
||||
* @returns The unescaped identifier text.
|
||||
*/
|
||||
function unescapeIdentifier(id: string): string;
|
||||
function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined;
|
||||
function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined;
|
||||
/**
|
||||
* Gets the JSDoc parameter tags for the node if present.
|
||||
*
|
||||
* @remarks Returns any JSDoc param tag that matches the provided
|
||||
* parameter, whether a param tag on a containing function
|
||||
* expression, or a param tag on a variable declaration whose
|
||||
* initializer is the containing function. The tags closest to the
|
||||
* node are returned first, so in the previous example, the param
|
||||
* tag on the containing function expression would be first.
|
||||
*
|
||||
* Does not return tags for binding patterns, because JSDoc matches
|
||||
* parameters by name and binding patterns do not have a name.
|
||||
*/
|
||||
function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray<JSDocParameterTag> | undefined;
|
||||
/**
|
||||
* Return true if the node has JSDoc parameter tags.
|
||||
*
|
||||
* @remarks Includes parameter tags that are not directly on the node,
|
||||
* for example on a variable declaration whose initializer is a function expression.
|
||||
*/
|
||||
function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean;
|
||||
/** Gets the JSDoc augments tag for the node if present */
|
||||
function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined;
|
||||
/** Gets the JSDoc class tag for the node if present */
|
||||
function getJSDocClassTag(node: Node): JSDocClassTag | undefined;
|
||||
/** Gets the JSDoc return tag for the node if present */
|
||||
function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined;
|
||||
/** Gets the JSDoc template tag for the node if present */
|
||||
function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined;
|
||||
/** Gets the JSDoc type tag for the node if present and valid */
|
||||
function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined;
|
||||
/**
|
||||
* Gets the type node for the node if provided via JSDoc.
|
||||
*
|
||||
* @remarks The search includes any JSDoc param tag that relates
|
||||
* to the provided parameter, for example a type tag on the
|
||||
* parameter itself, or a param tag on a containing function
|
||||
* expression, or a param tag on a variable declaration whose
|
||||
* initializer is the containing function. The tags closest to the
|
||||
* node are examined first, so in the previous example, the type
|
||||
* tag directly on the node would be returned.
|
||||
*/
|
||||
function getJSDocType(node: Node): TypeNode | undefined;
|
||||
/**
|
||||
* Gets the return type node for the node if provided via JSDoc's return tag.
|
||||
*
|
||||
* @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function
|
||||
* gets the type from inside the braces.
|
||||
*/
|
||||
function getJSDocReturnType(node: Node): TypeNode | undefined;
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> | undefined;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isNumericLiteral(node: Node): node is NumericLiteral;
|
||||
@@ -3184,8 +3261,8 @@ declare namespace ts {
|
||||
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 createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ReadonlyArray<ArrayBindingElement>): ArrayBindingPattern;
|
||||
@@ -3214,6 +3291,7 @@ declare namespace ts {
|
||||
function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray<Modifier> | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: Block): FunctionExpression;
|
||||
function createArrowFunction(modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>, body: ConciseBody): ArrowFunction;
|
||||
function createDelete(expression: Expression): DeleteExpression;
|
||||
function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression;
|
||||
function createTypeOf(expression: Expression): TypeOfExpression;
|
||||
@@ -3231,8 +3309,13 @@ declare namespace ts {
|
||||
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;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token<SyntaxKind.QuestionToken>, whenTrue: Expression, colonToken: Token<SyntaxKind.ColonToken>, whenFalse: Expression): ConditionalExpression;
|
||||
function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function createTemplateHead(text: string): TemplateHead;
|
||||
function createTemplateMiddle(text: string): TemplateMiddle;
|
||||
function createTemplateTail(text: string): TemplateTail;
|
||||
function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral;
|
||||
function createYield(expression?: Expression): YieldExpression;
|
||||
function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression;
|
||||
function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression;
|
||||
@@ -3388,10 +3471,12 @@ declare namespace ts {
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createBundle(sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
function createLessThan(left: Expression, right: Expression): Expression;
|
||||
function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
||||
@@ -3575,8 +3660,8 @@ declare namespace ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
/**
|
||||
* Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
|
||||
@@ -3591,7 +3676,7 @@ declare namespace ts {
|
||||
* @param oldProgram - Reuses an old program structure.
|
||||
* @returns A 'Program' object.
|
||||
*/
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
function parseCommandLine(commandLine: ReadonlyArray<string>, readFile?: (path: string) => string | undefined): ParsedCommandLine;
|
||||
@@ -3700,7 +3785,7 @@ declare namespace ts {
|
||||
interface SourceFile {
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineEndOfPosition(pos: number): number;
|
||||
getLineStarts(): number[];
|
||||
getLineStarts(): ReadonlyArray<number>;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
@@ -3917,7 +4002,7 @@ declare namespace ts {
|
||||
* Represents a single refactoring action - for example, the "Extract Method..." refactor might
|
||||
* offer several actions, each corresponding to a surround class or closure to extract into.
|
||||
*/
|
||||
type RefactorActionInfo = {
|
||||
interface RefactorActionInfo {
|
||||
/**
|
||||
* The programmatic name of the refactoring action
|
||||
*/
|
||||
@@ -3928,16 +4013,16 @@ declare namespace ts {
|
||||
* so this description should make sense by itself if the parent is inlineable=true
|
||||
*/
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A set of edits to make in response to a refactor action, plus an optional
|
||||
* location where renaming should be invoked from
|
||||
*/
|
||||
type RefactorEditInfo = {
|
||||
interface RefactorEditInfo {
|
||||
edits: FileTextChanges[];
|
||||
renameFilename?: string;
|
||||
renameLocation?: number;
|
||||
};
|
||||
renameFilename: string | undefined;
|
||||
renameLocation: number | undefined;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
/** The position in newText the caret should point to after the insertion. */
|
||||
|
||||
+2896
-2113
File diff suppressed because it is too large
Load Diff
Vendored
+158
-73
@@ -446,6 +446,9 @@ declare namespace ts {
|
||||
modifiers?: ModifiersArray;
|
||||
parent?: Node;
|
||||
}
|
||||
interface JSDocContainer {
|
||||
}
|
||||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken;
|
||||
interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange {
|
||||
hasTrailingComma?: boolean;
|
||||
}
|
||||
@@ -458,7 +461,7 @@ declare namespace ts {
|
||||
type EqualsToken = Token<SyntaxKind.EqualsToken>;
|
||||
type AsteriskToken = Token<SyntaxKind.AsteriskToken>;
|
||||
type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken>;
|
||||
type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer;
|
||||
type AtToken = Token<SyntaxKind.AtToken>;
|
||||
type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>;
|
||||
type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
@@ -500,6 +503,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Decorator extends Node {
|
||||
kind: SyntaxKind.Decorator;
|
||||
parent?: NamedDeclaration;
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
@@ -510,16 +514,18 @@ declare namespace ts {
|
||||
default?: TypeNode;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface SignatureDeclaration extends NamedDeclaration {
|
||||
interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SignatureDeclaration["kind"];
|
||||
name?: PropertyName;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
type?: TypeNode;
|
||||
type: TypeNode | undefined;
|
||||
}
|
||||
interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement {
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
@@ -535,7 +541,7 @@ declare namespace ts {
|
||||
parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement;
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends NamedDeclaration {
|
||||
interface ParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.Parameter;
|
||||
parent?: SignatureDeclaration;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
@@ -552,14 +558,14 @@ declare namespace ts {
|
||||
name: BindingName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertySignature extends TypeElement {
|
||||
interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertySignature;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface PropertyDeclaration extends ClassElement {
|
||||
interface PropertyDeclaration extends ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.PropertyDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
name: PropertyName;
|
||||
@@ -571,27 +577,30 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
}
|
||||
type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
|
||||
interface PropertyAssignment extends ObjectLiteralElement {
|
||||
interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.PropertyAssignment;
|
||||
name: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
initializer: Expression;
|
||||
}
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement {
|
||||
interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.ShorthandPropertyAssignment;
|
||||
name: Identifier;
|
||||
questionToken?: QuestionToken;
|
||||
equalsToken?: Token<SyntaxKind.EqualsToken>;
|
||||
objectAssignmentInitializer?: Expression;
|
||||
}
|
||||
interface SpreadAssignment extends ObjectLiteralElement {
|
||||
interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer {
|
||||
parent: ObjectLiteralExpression;
|
||||
kind: SyntaxKind.SpreadAssignment;
|
||||
expression: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends NamedDeclaration {
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: DotDotDotToken;
|
||||
name?: DeclarationName;
|
||||
name: DeclarationName;
|
||||
questionToken?: QuestionToken;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
@@ -619,7 +628,7 @@ declare namespace ts {
|
||||
* - MethodDeclaration
|
||||
* - AccessorDeclaration
|
||||
*/
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclaration {
|
||||
interface FunctionLikeDeclarationBase extends SignatureDeclarationBase {
|
||||
_functionLikeDeclarationBrand: any;
|
||||
asteriskToken?: AsteriskToken;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -632,16 +641,16 @@ declare namespace ts {
|
||||
name?: Identifier;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface MethodSignature extends SignatureDeclaration, TypeElement {
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
kind: SyntaxKind.MethodSignature;
|
||||
name: PropertyName;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.MethodDeclaration;
|
||||
name: PropertyName;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
kind: SyntaxKind.Constructor;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
body?: FunctionBody;
|
||||
@@ -651,20 +660,20 @@ declare namespace ts {
|
||||
kind: SyntaxKind.SemicolonClassElement;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
}
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.GetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement {
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
kind: SyntaxKind.SetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement {
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
kind: SyntaxKind.IndexSignature;
|
||||
parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode;
|
||||
}
|
||||
@@ -678,10 +687,10 @@ declare namespace ts {
|
||||
kind: SyntaxKind.ThisType;
|
||||
}
|
||||
type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode;
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments;
|
||||
@@ -692,6 +701,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent?: SignatureDeclaration;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -736,7 +746,6 @@ declare namespace ts {
|
||||
}
|
||||
interface MappedTypeNode extends TypeNode, Declaration {
|
||||
kind: SyntaxKind.MappedType;
|
||||
parent?: TypeAliasDeclaration;
|
||||
readonlyToken?: ReadonlyToken;
|
||||
typeParameter: TypeParameterDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -744,7 +753,7 @@ declare namespace ts {
|
||||
}
|
||||
interface LiteralTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.LiteralType;
|
||||
literal: Expression;
|
||||
literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression;
|
||||
}
|
||||
interface StringLiteral extends LiteralExpression {
|
||||
kind: SyntaxKind.StringLiteral;
|
||||
@@ -879,12 +888,12 @@ declare namespace ts {
|
||||
}
|
||||
type FunctionBody = Block;
|
||||
type ConciseBody = FunctionBody | Expression;
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase {
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.FunctionExpression;
|
||||
name?: Identifier;
|
||||
body: FunctionBody;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase {
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
kind: SyntaxKind.ArrowFunction;
|
||||
equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
body: ConciseBody;
|
||||
@@ -930,7 +939,7 @@ declare namespace ts {
|
||||
expression: Expression;
|
||||
literal: TemplateMiddle | TemplateTail;
|
||||
}
|
||||
interface ParenthesizedExpression extends PrimaryExpression {
|
||||
interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer {
|
||||
kind: SyntaxKind.ParenthesizedExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -940,6 +949,7 @@ declare namespace ts {
|
||||
}
|
||||
interface SpreadElement extends Expression {
|
||||
kind: SyntaxKind.SpreadElement;
|
||||
parent?: ArrayLiteralExpression | CallExpression | NewExpression;
|
||||
expression: Expression;
|
||||
}
|
||||
/**
|
||||
@@ -1107,11 +1117,11 @@ declare namespace ts {
|
||||
kind: SyntaxKind.Block;
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
interface VariableStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.VariableStatement;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
interface ExpressionStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.ExpressionStatement;
|
||||
expression: Expression;
|
||||
}
|
||||
@@ -1192,7 +1202,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
||||
interface LabeledStatement extends Statement {
|
||||
interface LabeledStatement extends Statement, JSDocContainer {
|
||||
kind: SyntaxKind.LabeledStatement;
|
||||
label: Identifier;
|
||||
statement: Statement;
|
||||
@@ -1214,19 +1224,21 @@ declare namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
|
||||
interface ClassLikeDeclaration extends NamedDeclaration {
|
||||
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement {
|
||||
interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.ClassDeclaration;
|
||||
name?: Identifier;
|
||||
}
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression {
|
||||
kind: SyntaxKind.ClassExpression;
|
||||
}
|
||||
type ClassLikeDeclaration = ClassDeclaration | ClassExpression;
|
||||
interface ClassElement extends NamedDeclaration {
|
||||
_classElementBrand: any;
|
||||
name?: PropertyName;
|
||||
@@ -1236,7 +1248,7 @@ declare namespace ts {
|
||||
name?: PropertyName;
|
||||
questionToken?: QuestionToken;
|
||||
}
|
||||
interface InterfaceDeclaration extends DeclarationStatement {
|
||||
interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.InterfaceDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@@ -1249,26 +1261,26 @@ declare namespace ts {
|
||||
token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends DeclarationStatement {
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.TypeAliasDeclaration;
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends NamedDeclaration {
|
||||
interface EnumMember extends NamedDeclaration, JSDocContainer {
|
||||
kind: SyntaxKind.EnumMember;
|
||||
parent?: EnumDeclaration;
|
||||
name: PropertyName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface EnumDeclaration extends DeclarationStatement {
|
||||
interface EnumDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.EnumDeclaration;
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
type ModuleName = Identifier | StringLiteral;
|
||||
type ModuleBody = NamespaceBody | JSDocNamespaceBody;
|
||||
interface ModuleDeclaration extends DeclarationStatement {
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ModuleDeclaration;
|
||||
parent?: ModuleBody | SourceFile;
|
||||
name: ModuleName;
|
||||
@@ -1295,7 +1307,7 @@ declare namespace ts {
|
||||
* - import x = require("mod");
|
||||
* - import x = M.x;
|
||||
*/
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement {
|
||||
interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
kind: SyntaxKind.ImportEqualsDeclaration;
|
||||
parent?: SourceFile | ModuleBlock;
|
||||
name: Identifier;
|
||||
@@ -1407,7 +1419,7 @@ declare namespace ts {
|
||||
kind: SyntaxKind.JSDocOptionalType;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
@@ -1417,6 +1429,7 @@ declare namespace ts {
|
||||
type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
interface JSDoc extends Node {
|
||||
kind: SyntaxKind.JSDocComment;
|
||||
parent?: HasJSDoc;
|
||||
tags: NodeArray<JSDocTag> | undefined;
|
||||
comment: string | undefined;
|
||||
}
|
||||
@@ -1472,7 +1485,6 @@ declare namespace ts {
|
||||
interface JSDocTypeLiteral extends JSDocType {
|
||||
kind: SyntaxKind.JSDocTypeLiteral;
|
||||
jsDocPropertyTags?: ReadonlyArray<JSDocPropertyLikeTag>;
|
||||
jsDocTypeTag?: JSDocTypeTag;
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
isArrayType?: boolean;
|
||||
}
|
||||
@@ -1547,10 +1559,10 @@ declare namespace ts {
|
||||
endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
fileName: string;
|
||||
text: string;
|
||||
amdDependencies: AmdDependency[];
|
||||
amdDependencies: ReadonlyArray<AmdDependency>;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
referencedFiles: ReadonlyArray<FileReference>;
|
||||
typeReferenceDirectives: ReadonlyArray<FileReference>;
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
/**
|
||||
@@ -1566,7 +1578,7 @@ declare namespace ts {
|
||||
}
|
||||
interface Bundle extends Node {
|
||||
kind: SyntaxKind.Bundle;
|
||||
sourceFiles: SourceFile[];
|
||||
sourceFiles: ReadonlyArray<SourceFile>;
|
||||
}
|
||||
interface JsonSourceFile extends SourceFile {
|
||||
jsonObject?: ObjectLiteralExpression;
|
||||
@@ -1589,7 +1601,7 @@ declare namespace ts {
|
||||
readFile(path: string): string | undefined;
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray<SourceFile>): void;
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
|
||||
}
|
||||
class OperationCanceledException {
|
||||
}
|
||||
@@ -1602,11 +1614,11 @@ declare namespace ts {
|
||||
/**
|
||||
* Get a list of root file names that were passed to a 'createProgram'
|
||||
*/
|
||||
getRootFileNames(): string[];
|
||||
getRootFileNames(): ReadonlyArray<string>;
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
*/
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFiles(): ReadonlyArray<SourceFile>;
|
||||
/**
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
@@ -1618,15 +1630,16 @@ declare namespace ts {
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
* Gets a type checker that can be used to semantically analyze source files in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
}
|
||||
interface CustomTransformers {
|
||||
/** Custom transformers to evaluate before built-in transformations. */
|
||||
@@ -1669,7 +1682,7 @@ declare namespace ts {
|
||||
interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: Diagnostic[];
|
||||
diagnostics: ReadonlyArray<Diagnostic>;
|
||||
emittedFiles: string[];
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -1970,6 +1983,7 @@ declare namespace ts {
|
||||
IndexedAccess = 524288,
|
||||
NonPrimitive = 16777216,
|
||||
Literal = 224,
|
||||
Unit = 6368,
|
||||
StringOrNumberLiteral = 96,
|
||||
PossiblyFalsy = 7406,
|
||||
StringLike = 262178,
|
||||
@@ -2172,7 +2186,7 @@ declare namespace ts {
|
||||
interface PluginImport {
|
||||
name: string;
|
||||
}
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];
|
||||
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | null | undefined;
|
||||
interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
@@ -2372,6 +2386,11 @@ declare namespace ts {
|
||||
* If accessing a non-index file, this should include its name e.g. "foo/bar".
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Name of a submodule within this package.
|
||||
* May be "".
|
||||
*/
|
||||
subModuleName: string;
|
||||
/** Version of the package, e.g. "1.2.3" */
|
||||
version: string;
|
||||
}
|
||||
@@ -2388,14 +2407,15 @@ declare namespace ts {
|
||||
interface ResolvedTypeReferenceDirective {
|
||||
primary: boolean;
|
||||
resolvedFileName?: string;
|
||||
packageId?: PackageId;
|
||||
}
|
||||
interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective;
|
||||
failedLookupLocations: string[];
|
||||
}
|
||||
interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
@@ -2460,7 +2480,8 @@ declare namespace ts {
|
||||
SourceFile = 0,
|
||||
Expression = 1,
|
||||
IdentifierName = 2,
|
||||
Unspecified = 3,
|
||||
MappedTypeParameter = 3,
|
||||
Unspecified = 4,
|
||||
}
|
||||
interface TransformationContext {
|
||||
/** Gets the compiler options supplied to the transformer. */
|
||||
@@ -2639,6 +2660,9 @@ declare namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isExternalModuleNameRelative(moduleName: string): boolean;
|
||||
}
|
||||
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any;
|
||||
declare function clearTimeout(handle: any): void;
|
||||
declare namespace ts {
|
||||
@@ -2834,7 +2858,60 @@ declare namespace ts {
|
||||
* @returns The unescaped identifier text.
|
||||
*/
|
||||
function unescapeIdentifier(id: string): string;
|
||||
function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined;
|
||||
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined;
|
||||
function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined;
|
||||
/**
|
||||
* Gets the JSDoc parameter tags for the node if present.
|
||||
*
|
||||
* @remarks Returns any JSDoc param tag that matches the provided
|
||||
* parameter, whether a param tag on a containing function
|
||||
* expression, or a param tag on a variable declaration whose
|
||||
* initializer is the containing function. The tags closest to the
|
||||
* node are returned first, so in the previous example, the param
|
||||
* tag on the containing function expression would be first.
|
||||
*
|
||||
* Does not return tags for binding patterns, because JSDoc matches
|
||||
* parameters by name and binding patterns do not have a name.
|
||||
*/
|
||||
function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray<JSDocParameterTag> | undefined;
|
||||
/**
|
||||
* Return true if the node has JSDoc parameter tags.
|
||||
*
|
||||
* @remarks Includes parameter tags that are not directly on the node,
|
||||
* for example on a variable declaration whose initializer is a function expression.
|
||||
*/
|
||||
function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean;
|
||||
/** Gets the JSDoc augments tag for the node if present */
|
||||
function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined;
|
||||
/** Gets the JSDoc class tag for the node if present */
|
||||
function getJSDocClassTag(node: Node): JSDocClassTag | undefined;
|
||||
/** Gets the JSDoc return tag for the node if present */
|
||||
function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined;
|
||||
/** Gets the JSDoc template tag for the node if present */
|
||||
function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined;
|
||||
/** Gets the JSDoc type tag for the node if present and valid */
|
||||
function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined;
|
||||
/**
|
||||
* Gets the type node for the node if provided via JSDoc.
|
||||
*
|
||||
* @remarks The search includes any JSDoc param tag that relates
|
||||
* to the provided parameter, for example a type tag on the
|
||||
* parameter itself, or a param tag on a containing function
|
||||
* expression, or a param tag on a variable declaration whose
|
||||
* initializer is the containing function. The tags closest to the
|
||||
* node are examined first, so in the previous example, the type
|
||||
* tag directly on the node would be returned.
|
||||
*/
|
||||
function getJSDocType(node: Node): TypeNode | undefined;
|
||||
/**
|
||||
* Gets the return type node for the node if provided via JSDoc's return tag.
|
||||
*
|
||||
* @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function
|
||||
* gets the type from inside the braces.
|
||||
*/
|
||||
function getJSDocReturnType(node: Node): TypeNode | undefined;
|
||||
/** Get all JSDoc tags related to a node, including those on parent nodes. */
|
||||
function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> | undefined;
|
||||
}
|
||||
declare namespace ts {
|
||||
function isNumericLiteral(node: Node): node is NumericLiteral;
|
||||
@@ -3184,8 +3261,8 @@ declare namespace ts {
|
||||
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 createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
||||
function createObjectBindingPattern(elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray<BindingElement>): ObjectBindingPattern;
|
||||
function createArrayBindingPattern(elements: ReadonlyArray<ArrayBindingElement>): ArrayBindingPattern;
|
||||
@@ -3214,6 +3291,7 @@ declare namespace ts {
|
||||
function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray<Modifier> | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: Block): FunctionExpression;
|
||||
function createArrowFunction(modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, body: ConciseBody): ArrowFunction;
|
||||
function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray<Modifier> | undefined, typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined, parameters: ReadonlyArray<ParameterDeclaration>, type: TypeNode | undefined, equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>, body: ConciseBody): ArrowFunction;
|
||||
function createDelete(expression: Expression): DeleteExpression;
|
||||
function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression;
|
||||
function createTypeOf(expression: Expression): TypeOfExpression;
|
||||
@@ -3231,8 +3309,13 @@ declare namespace ts {
|
||||
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;
|
||||
function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token<SyntaxKind.QuestionToken>, whenTrue: Expression, colonToken: Token<SyntaxKind.ColonToken>, whenFalse: Expression): ConditionalExpression;
|
||||
function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray<TemplateSpan>): TemplateExpression;
|
||||
function createTemplateHead(text: string): TemplateHead;
|
||||
function createTemplateMiddle(text: string): TemplateMiddle;
|
||||
function createTemplateTail(text: string): TemplateTail;
|
||||
function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral;
|
||||
function createYield(expression?: Expression): YieldExpression;
|
||||
function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression;
|
||||
function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression;
|
||||
@@ -3388,10 +3471,12 @@ declare namespace ts {
|
||||
function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
||||
function createCommaList(elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function updateCommaList(node: CommaListExpression, elements: ReadonlyArray<Expression>): CommaListExpression;
|
||||
function createBundle(sourceFiles: SourceFile[]): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle;
|
||||
function createBundle(sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function updateBundle(node: Bundle, sourceFiles: ReadonlyArray<SourceFile>): Bundle;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression;
|
||||
function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
function createComma(left: Expression, right: Expression): Expression;
|
||||
function createLessThan(left: Expression, right: Expression): Expression;
|
||||
function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
||||
@@ -3575,8 +3660,8 @@ declare namespace ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
}
|
||||
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string;
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
/**
|
||||
* Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
|
||||
@@ -3591,7 +3676,7 @@ declare namespace ts {
|
||||
* @param oldProgram - Reuses an old program structure.
|
||||
* @returns A 'Program' object.
|
||||
*/
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
function createProgram(rootNames: ReadonlyArray<string>, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
function parseCommandLine(commandLine: ReadonlyArray<string>, readFile?: (path: string) => string | undefined): ParsedCommandLine;
|
||||
@@ -3700,7 +3785,7 @@ declare namespace ts {
|
||||
interface SourceFile {
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineEndOfPosition(pos: number): number;
|
||||
getLineStarts(): number[];
|
||||
getLineStarts(): ReadonlyArray<number>;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
@@ -3917,7 +4002,7 @@ declare namespace ts {
|
||||
* Represents a single refactoring action - for example, the "Extract Method..." refactor might
|
||||
* offer several actions, each corresponding to a surround class or closure to extract into.
|
||||
*/
|
||||
type RefactorActionInfo = {
|
||||
interface RefactorActionInfo {
|
||||
/**
|
||||
* The programmatic name of the refactoring action
|
||||
*/
|
||||
@@ -3928,16 +4013,16 @@ declare namespace ts {
|
||||
* so this description should make sense by itself if the parent is inlineable=true
|
||||
*/
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A set of edits to make in response to a refactor action, plus an optional
|
||||
* location where renaming should be invoked from
|
||||
*/
|
||||
type RefactorEditInfo = {
|
||||
interface RefactorEditInfo {
|
||||
edits: FileTextChanges[];
|
||||
renameFilename?: string;
|
||||
renameLocation?: number;
|
||||
};
|
||||
renameFilename: string | undefined;
|
||||
renameLocation: number | undefined;
|
||||
}
|
||||
interface TextInsertion {
|
||||
newText: string;
|
||||
/** The position in newText the caret should point to after the insertion. */
|
||||
|
||||
+2896
-2113
File diff suppressed because it is too large
Load Diff
+606
-366
File diff suppressed because it is too large
Load Diff
@@ -244,7 +244,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName(unescapeLeadingUnderscores((<PropertyAccessExpression>nameExpression).name.escapedText));
|
||||
return getPropertyNameForKnownSymbolName(idText((<PropertyAccessExpression>nameExpression).name));
|
||||
}
|
||||
return getEscapedTextOfIdentifierOrLiteral(<Identifier | LiteralExpression>name);
|
||||
}
|
||||
@@ -1777,7 +1777,7 @@ namespace ts {
|
||||
// otherwise report generic error message.
|
||||
const span = getErrorSpanForNode(file, name);
|
||||
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length,
|
||||
getStrictModeEvalOrArgumentsMessage(contextNode), unescapeLeadingUnderscores(identifier.escapedText)));
|
||||
getStrictModeEvalOrArgumentsMessage(contextNode), idText(identifier)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2431,7 +2431,7 @@ namespace ts {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
}
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(prototypeSymbol.escapedName)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, symbolName(prototypeSymbol)));
|
||||
}
|
||||
symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
|
||||
prototypeSymbol.parent = symbol;
|
||||
|
||||
+133
-102
@@ -227,8 +227,8 @@ namespace ts {
|
||||
getApparentType,
|
||||
isArrayLikeType,
|
||||
getAllPossiblePropertiesOfTypes,
|
||||
getSuggestionForNonexistentProperty: (node, type) => unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)),
|
||||
getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)),
|
||||
getSuggestionForNonexistentProperty: (node, type) => getSuggestionForNonexistentProperty(node, type),
|
||||
getSuggestionForNonexistentSymbol: (location, name, meaning) => getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning),
|
||||
getBaseConstraintOfType,
|
||||
resolveName(name, location, meaning) {
|
||||
return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
@@ -1144,11 +1144,11 @@ namespace ts {
|
||||
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
||||
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
||||
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) {
|
||||
let suggestion: __String | undefined;
|
||||
let suggestion: string | undefined;
|
||||
if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
|
||||
suggestion = getSuggestionForNonexistentSymbol(originalLocation, name, meaning);
|
||||
if (suggestion) {
|
||||
error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), unescapeLeadingUnderscores(suggestion));
|
||||
error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestion);
|
||||
}
|
||||
}
|
||||
if (!suggestion) {
|
||||
@@ -2904,7 +2904,7 @@ namespace ts {
|
||||
parameterDeclaration.name.kind === SyntaxKind.Identifier ?
|
||||
setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) :
|
||||
cloneBindingName(parameterDeclaration.name) :
|
||||
unescapeLeadingUnderscores(parameterSymbol.escapedName);
|
||||
symbolName(parameterSymbol);
|
||||
const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined;
|
||||
|
||||
let parameterType = getTypeOfSymbol(parameterSymbol);
|
||||
@@ -3118,7 +3118,7 @@ namespace ts {
|
||||
return `"${escapeString(stringValue, CharacterCodes.doubleQuote)}"`;
|
||||
}
|
||||
}
|
||||
return unescapeLeadingUnderscores(symbol.escapedName);
|
||||
return symbolName(symbol);
|
||||
}
|
||||
|
||||
function getSymbolDisplayBuilder(): SymbolDisplayBuilder {
|
||||
@@ -3577,7 +3577,7 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
if (getDeclarationModifierFlagsFromSymbol(p) & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
writer.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(p.escapedName));
|
||||
writer.reportPrivateInBaseOfClassExpression(symbolName(p));
|
||||
}
|
||||
}
|
||||
const t = getTypeOfSymbol(p);
|
||||
@@ -4882,7 +4882,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments {
|
||||
return getClassExtendsHeritageClauseElement(<ClassLikeDeclaration>type.symbol.valueDeclaration);
|
||||
const decl = <ClassLikeDeclaration>type.symbol.valueDeclaration;
|
||||
if (isInJavaScriptFile(decl)) {
|
||||
// Prefer an @augments tag because it may have type parameters.
|
||||
const tag = getJSDocAugmentsTag(decl);
|
||||
if (tag) {
|
||||
return tag.class;
|
||||
}
|
||||
}
|
||||
|
||||
return getClassExtendsHeritageClauseElement(decl);
|
||||
}
|
||||
|
||||
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode>, location: Node): Signature[] {
|
||||
@@ -4986,15 +4995,6 @@ namespace ts {
|
||||
baseType = getReturnTypeOfSignature(constructors[0]);
|
||||
}
|
||||
|
||||
// In a JS file, you can use the @augments jsdoc tag to specify a base type with type parameters
|
||||
const valueDecl = type.symbol.valueDeclaration;
|
||||
if (valueDecl && isInJavaScriptFile(valueDecl)) {
|
||||
const augTag = getJSDocAugmentsTag(type.symbol.valueDeclaration);
|
||||
if (augTag && augTag.typeExpression && augTag.typeExpression.type) {
|
||||
baseType = getTypeFromTypeNode(augTag.typeExpression.type);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseType === unknownType) {
|
||||
return;
|
||||
}
|
||||
@@ -5003,7 +5003,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
if (type === baseType || hasBaseType(baseType, type)) {
|
||||
error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
||||
error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
||||
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType));
|
||||
return;
|
||||
}
|
||||
@@ -5252,6 +5252,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfSymbol(symbol: Symbol): Type {
|
||||
return tryGetDeclaredTypeOfSymbol(symbol) || unknownType;
|
||||
}
|
||||
|
||||
function tryGetDeclaredTypeOfSymbol(symbol: Symbol): Type | undefined {
|
||||
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
|
||||
return getDeclaredTypeOfClassOrInterface(symbol);
|
||||
}
|
||||
@@ -5270,7 +5274,7 @@ namespace ts {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
return getDeclaredTypeOfAlias(symbol);
|
||||
}
|
||||
return unknownType;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// A type reference is considered independent if each type argument is considered independent.
|
||||
@@ -6872,17 +6876,6 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type from reference to named type that cannot be generic (enum or type parameter)
|
||||
*/
|
||||
function getTypeFromNonGenericTypeReference(node: TypeReferenceType, symbol: Symbol): Type {
|
||||
if (node.typeArguments) {
|
||||
error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol));
|
||||
return unknownType;
|
||||
}
|
||||
return getDeclaredTypeOfSymbol(symbol);
|
||||
}
|
||||
|
||||
function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
@@ -6919,24 +6912,34 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
if (symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node)) {
|
||||
// A jsdoc TypeReference may have resolved to a value (as opposed to a type). If
|
||||
// the symbol is a constructor function, return the inferred class type; otherwise,
|
||||
// the type of this reference is just the type of the value we resolved to.
|
||||
const valueType = getTypeOfSymbol(symbol);
|
||||
if (valueType.symbol && !isInferredClassType(valueType)) {
|
||||
const referenceType = getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments);
|
||||
if (referenceType) {
|
||||
return referenceType;
|
||||
}
|
||||
// Get type from reference to named type that cannot be generic (enum or type parameter)
|
||||
const res = tryGetDeclaredTypeOfSymbol(symbol);
|
||||
if (res !== undefined) {
|
||||
if (typeArguments) {
|
||||
error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol));
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// Resolve the type reference as a Type for the purpose of reporting errors.
|
||||
resolveTypeReferenceName(getTypeReferenceName(node), SymbolFlags.Type);
|
||||
return valueType;
|
||||
return res;
|
||||
}
|
||||
|
||||
return getTypeFromNonGenericTypeReference(node, symbol);
|
||||
if (!(symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node))) {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// A jsdoc TypeReference may have resolved to a value (as opposed to a type). If
|
||||
// the symbol is a constructor function, return the inferred class type; otherwise,
|
||||
// the type of this reference is just the type of the value we resolved to.
|
||||
const valueType = getTypeOfSymbol(symbol);
|
||||
if (valueType.symbol && !isInferredClassType(valueType)) {
|
||||
const referenceType = getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments);
|
||||
if (referenceType) {
|
||||
return referenceType;
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve the type reference as a Type for the purpose of reporting errors.
|
||||
resolveTypeReferenceName(getTypeReferenceName(node), SymbolFlags.Type);
|
||||
return valueType;
|
||||
}
|
||||
|
||||
function getTypeReferenceTypeWorker(node: TypeReferenceType, symbol: Symbol, typeArguments: Type[]): Type | undefined {
|
||||
@@ -7060,11 +7063,11 @@ namespace ts {
|
||||
}
|
||||
const type = getDeclaredTypeOfSymbol(symbol);
|
||||
if (!(type.flags & TypeFlags.Object)) {
|
||||
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, unescapeLeadingUnderscores(symbol.escapedName));
|
||||
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbolName(symbol));
|
||||
return arity ? emptyGenericType : emptyObjectType;
|
||||
}
|
||||
if (length((<InterfaceType>type).typeParameters) !== arity) {
|
||||
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, unescapeLeadingUnderscores(symbol.escapedName), arity);
|
||||
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbolName(symbol), arity);
|
||||
return arity ? emptyGenericType : emptyObjectType;
|
||||
}
|
||||
return <ObjectType>type;
|
||||
@@ -7577,7 +7580,7 @@ namespace ts {
|
||||
function getLiteralTypeFromPropertyName(prop: Symbol) {
|
||||
return getDeclarationModifierFlagsFromSymbol(prop) & ModifierFlags.NonPublicAccessibilityModifier || startsWith(prop.escapedName as string, "__@") ?
|
||||
neverType :
|
||||
getLiteralType(unescapeLeadingUnderscores(prop.escapedName));
|
||||
getLiteralType(symbolName(prop));
|
||||
}
|
||||
|
||||
function getLiteralTypeFromPropertyNames(type: Type) {
|
||||
@@ -7616,7 +7619,7 @@ namespace ts {
|
||||
const propName = indexType.flags & TypeFlags.StringOrNumberLiteral ?
|
||||
escapeLeadingUnderscores("" + (<LiteralType>indexType).value) :
|
||||
accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ?
|
||||
getPropertyNameForKnownSymbolName(unescapeLeadingUnderscores((<Identifier>(<PropertyAccessExpression>accessExpression.argumentExpression).name).escapedText)) :
|
||||
getPropertyNameForKnownSymbolName(idText((<Identifier>(<PropertyAccessExpression>accessExpression.argumentExpression).name))) :
|
||||
undefined;
|
||||
if (propName !== undefined) {
|
||||
const prop = getPropertyOfType(objectType, propName);
|
||||
@@ -8570,8 +8573,8 @@ namespace ts {
|
||||
if (!related) {
|
||||
if (reportErrors) {
|
||||
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
|
||||
unescapeLeadingUnderscores(sourceParams[i < sourceMax ? i : sourceMax].escapedName),
|
||||
unescapeLeadingUnderscores(targetParams[i < targetMax ? i : targetMax].escapedName));
|
||||
symbolName(sourceParams[i < sourceMax ? i : sourceMax]),
|
||||
symbolName(targetParams[i < targetMax ? i : targetMax]));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
@@ -8725,7 +8728,7 @@ namespace ts {
|
||||
const targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
|
||||
if (!targetProperty || !(targetProperty.flags & SymbolFlags.EnumMember)) {
|
||||
if (errorReporter) {
|
||||
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, unescapeLeadingUnderscores(property.escapedName),
|
||||
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(property),
|
||||
typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
|
||||
}
|
||||
enumRelation.set(id, false);
|
||||
@@ -9074,7 +9077,7 @@ namespace ts {
|
||||
|
||||
if (suggestion !== undefined) {
|
||||
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2,
|
||||
symbolToString(prop), typeToString(target), unescapeLeadingUnderscores(suggestion));
|
||||
symbolToString(prop), typeToString(target), suggestion);
|
||||
}
|
||||
else {
|
||||
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
|
||||
@@ -10285,7 +10288,7 @@ namespace ts {
|
||||
const t = getTypeOfSymbol(p);
|
||||
if (t.flags & TypeFlags.ContainsWideningType) {
|
||||
if (!reportWideningErrorsInType(t)) {
|
||||
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, unescapeLeadingUnderscores(p.escapedName), typeToString(getWidenedType(t)));
|
||||
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolName(p), typeToString(getWidenedType(t)));
|
||||
}
|
||||
errorReported = true;
|
||||
}
|
||||
@@ -10889,7 +10892,7 @@ namespace ts {
|
||||
}
|
||||
if (node.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const key = getFlowCacheKey((<PropertyAccessExpression>node).expression);
|
||||
return key && key + "." + unescapeLeadingUnderscores((<PropertyAccessExpression>node).name.escapedText);
|
||||
return key && key + "." + idText((<PropertyAccessExpression>node).name);
|
||||
}
|
||||
if (node.kind === SyntaxKind.BindingElement) {
|
||||
const container = (node as BindingElement).parent.parent;
|
||||
@@ -10906,7 +10909,7 @@ namespace ts {
|
||||
const name = element.propertyName || element.name;
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return unescapeLeadingUnderscores(name.escapedText);
|
||||
return idText(name);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined;
|
||||
case SyntaxKind.StringLiteral:
|
||||
@@ -14002,7 +14005,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Wasn't found
|
||||
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(node.tagName.escapedText), "JSX." + JsxNames.IntrinsicElements);
|
||||
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
|
||||
return links.resolvedSymbol = unknownSymbol;
|
||||
}
|
||||
else {
|
||||
@@ -14257,8 +14260,8 @@ namespace ts {
|
||||
// <CustomTag> Hello World </CustomTag>
|
||||
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
|
||||
if (intrinsicElementsType !== unknownType) {
|
||||
const stringLiteralTypeName = escapeLeadingUnderscores((<StringLiteralType>elementType).value);
|
||||
const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
|
||||
const stringLiteralTypeName = (<StringLiteralType>elementType).value;
|
||||
const intrinsicProp = getPropertyOfType(intrinsicElementsType, escapeLeadingUnderscores(stringLiteralTypeName));
|
||||
if (intrinsicProp) {
|
||||
return getTypeOfSymbol(intrinsicProp);
|
||||
}
|
||||
@@ -14266,7 +14269,7 @@ namespace ts {
|
||||
if (indexSignatureType) {
|
||||
return indexSignatureType;
|
||||
}
|
||||
error(openingLikeElement, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(stringLiteralTypeName), "JSX." + JsxNames.IntrinsicElements);
|
||||
error(openingLikeElement, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
|
||||
}
|
||||
// If we need to report an error, we already done so here. So just return any to prevent any more error downstream
|
||||
return anyType;
|
||||
@@ -14560,7 +14563,7 @@ namespace ts {
|
||||
if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) {
|
||||
for (const attribute of openingLikeElement.attributes.properties) {
|
||||
if (isJsxAttribute(attribute) && !isKnownProperty(targetAttributesType, attribute.name.escapedText, /*isComparingJsxAttributes*/ true)) {
|
||||
error(attribute, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(attribute.name.escapedText), typeToString(targetAttributesType));
|
||||
error(attribute, Diagnostics.Property_0_does_not_exist_on_type_1, idText(attribute.name), typeToString(targetAttributesType));
|
||||
// We break here so that errors won't be cascading
|
||||
break;
|
||||
}
|
||||
@@ -14573,7 +14576,7 @@ namespace ts {
|
||||
if (node.expression) {
|
||||
const type = checkExpression(node.expression, checkMode);
|
||||
if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
|
||||
error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type));
|
||||
error(node, Diagnostics.JSX_spread_child_must_be_an_array_type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -14759,7 +14762,7 @@ namespace ts {
|
||||
|
||||
if (assignmentKind) {
|
||||
if (isReferenceToReadonlyEntity(<Expression>node, prop) || isReferenceThroughNamespaceImport(<Expression>node)) {
|
||||
error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, unescapeLeadingUnderscores(right.escapedText));
|
||||
error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, idText(right));
|
||||
return unknownType;
|
||||
}
|
||||
}
|
||||
@@ -14785,13 +14788,13 @@ namespace ts {
|
||||
if (isInPropertyInitializer(node) &&
|
||||
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
|
||||
&& !isPropertyDeclaredInAncestorClass(prop)) {
|
||||
error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText));
|
||||
error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, idText(right));
|
||||
}
|
||||
else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration &&
|
||||
node.parent.kind !== SyntaxKind.TypeReference &&
|
||||
!isInAmbientContext(valueDeclaration) &&
|
||||
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
||||
error(right, Diagnostics.Class_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText));
|
||||
error(right, Diagnostics.Class_0_used_before_its_declaration, idText(right));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14848,7 +14851,7 @@ namespace ts {
|
||||
}
|
||||
const suggestion = getSuggestionForNonexistentProperty(propNode, containingType);
|
||||
if (suggestion !== undefined) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), unescapeLeadingUnderscores(suggestion));
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion);
|
||||
}
|
||||
else {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
@@ -14856,25 +14859,20 @@ namespace ts {
|
||||
diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo));
|
||||
}
|
||||
|
||||
function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): __String | undefined {
|
||||
const suggestion = getSpellingSuggestionForName(unescapeLeadingUnderscores(node.escapedText), getPropertiesOfType(containingType), SymbolFlags.Value);
|
||||
return suggestion && suggestion.escapedName;
|
||||
function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined {
|
||||
const suggestion = getSpellingSuggestionForName(idText(node), getPropertiesOfType(containingType), SymbolFlags.Value);
|
||||
return suggestion && symbolName(suggestion);
|
||||
}
|
||||
|
||||
function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String {
|
||||
function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): string {
|
||||
const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, (symbols, name, meaning) => {
|
||||
const symbol = getSymbol(symbols, name, meaning);
|
||||
if (symbol) {
|
||||
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
|
||||
// So the table *contains* `x` but `x` isn't actually in scope.
|
||||
// However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion.
|
||||
return symbol;
|
||||
}
|
||||
return getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning);
|
||||
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
|
||||
// So the table *contains* `x` but `x` isn't actually in scope.
|
||||
// However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion.
|
||||
return symbol || getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning);
|
||||
});
|
||||
if (result) {
|
||||
return result.escapedName;
|
||||
}
|
||||
return result && symbolName(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14904,7 +14902,7 @@ namespace ts {
|
||||
}
|
||||
name = name.toLowerCase();
|
||||
for (const candidate of symbols) {
|
||||
let candidateName = unescapeLeadingUnderscores(candidate.escapedName);
|
||||
let candidateName = symbolName(candidate);
|
||||
if (candidate.flags & meaning &&
|
||||
candidateName &&
|
||||
Math.abs(candidateName.length - name.length) < maximumLengthDifference) {
|
||||
@@ -15712,7 +15710,7 @@ namespace ts {
|
||||
const element = <ClassElement>node;
|
||||
switch (element.name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return getLiteralType(unescapeLeadingUnderscores(element.name.escapedText));
|
||||
return getLiteralType(idText(element.name));
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getLiteralType(element.name.text);
|
||||
@@ -18590,7 +18588,7 @@ namespace ts {
|
||||
memberName = member.name.text;
|
||||
break;
|
||||
case SyntaxKind.Identifier:
|
||||
memberName = unescapeLeadingUnderscores(member.name.escapedText);
|
||||
memberName = idText(member.name);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
@@ -19569,7 +19567,7 @@ namespace ts {
|
||||
const collidingSymbol = getSymbol(node.locals, rootName.escapedText, SymbolFlags.Value);
|
||||
if (collidingSymbol) {
|
||||
error(collidingSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions,
|
||||
unescapeLeadingUnderscores(rootName.escapedText),
|
||||
idText(rootName),
|
||||
entityNameToString(promiseConstructorName));
|
||||
return unknownType;
|
||||
}
|
||||
@@ -19789,14 +19787,47 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkJSDocComment(node: JSDoc) {
|
||||
if ((node as JSDoc).tags) {
|
||||
for (const tag of (node as JSDoc).tags) {
|
||||
checkSourceElement(tag);
|
||||
function checkJSDocParameterTag(node: JSDocParameterTag) {
|
||||
checkSourceElement(node.typeExpression);
|
||||
if (!getParameterSymbolFromJSDoc(node)) {
|
||||
error(node.name,
|
||||
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name,
|
||||
unescapeLeadingUnderscores((node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name).escapedText));
|
||||
}
|
||||
}
|
||||
|
||||
function checkJSDocAugmentsTag(node: JSDocAugmentsTag): void {
|
||||
const cls = getJSDocHost(node);
|
||||
if (!isClassDeclaration(cls) && !isClassExpression(cls)) {
|
||||
error(cls, Diagnostics.JSDoc_augments_is_not_attached_to_a_class_declaration);
|
||||
return;
|
||||
}
|
||||
|
||||
const name = getIdentifierFromEntityNameExpression(node.class.expression);
|
||||
const extend = getClassExtendsHeritageClauseElement(cls);
|
||||
if (extend) {
|
||||
const className = getIdentifierFromEntityNameExpression(extend.expression);
|
||||
if (className && name.escapedText !== className.escapedText) {
|
||||
error(name, Diagnostics.JSDoc_augments_0_does_not_match_the_extends_1_clause,
|
||||
unescapeLeadingUnderscores(name.escapedText),
|
||||
unescapeLeadingUnderscores(className.escapedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getIdentifierFromEntityNameExpression(node: Identifier | PropertyAccessExpression): Identifier;
|
||||
function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined;
|
||||
function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return node as Identifier;
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return (node as PropertyAccessExpression).name;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFunctionOrMethodDeclaration(node: FunctionDeclaration | MethodDeclaration): void {
|
||||
checkDecorators(node);
|
||||
checkSignatureDeclaration(node);
|
||||
@@ -19935,11 +19966,11 @@ namespace ts {
|
||||
!isParameterPropertyDeclaration(parameter) &&
|
||||
!parameterIsThisKeyword(parameter) &&
|
||||
!parameterNameStartsWithUnderscore(name)) {
|
||||
error(name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(local.escapedName));
|
||||
error(name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(local));
|
||||
}
|
||||
}
|
||||
else if (compilerOptions.noUnusedLocals) {
|
||||
forEach(local.declarations, d => errorUnusedLocal(d, unescapeLeadingUnderscores(local.escapedName)));
|
||||
forEach(local.declarations, d => errorUnusedLocal(d, symbolName(local)));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -19974,7 +20005,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isIdentifierThatStartsWithUnderScore(node: Node) {
|
||||
return node.kind === SyntaxKind.Identifier && unescapeLeadingUnderscores((<Identifier>node).escapedText).charCodeAt(0) === CharacterCodes._;
|
||||
return node.kind === SyntaxKind.Identifier && idText(<Identifier>node).charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
|
||||
function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void {
|
||||
@@ -19983,13 +20014,13 @@ namespace ts {
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
|
||||
if (!member.symbol.isReferenced && hasModifier(member, ModifierFlags.Private)) {
|
||||
error(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(member.symbol.escapedName));
|
||||
error(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(member.symbol));
|
||||
}
|
||||
}
|
||||
else if (member.kind === SyntaxKind.Constructor) {
|
||||
for (const parameter of (<ConstructorDeclaration>member).parameters) {
|
||||
if (!parameter.symbol.isReferenced && hasModifier(parameter, ModifierFlags.Private)) {
|
||||
error(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(parameter.symbol.escapedName));
|
||||
error(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20010,7 +20041,7 @@ namespace ts {
|
||||
}
|
||||
for (const typeParameter of node.typeParameters) {
|
||||
if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
|
||||
error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName));
|
||||
error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(typeParameter.symbol));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20023,7 +20054,7 @@ namespace ts {
|
||||
if (!local.isReferenced && !local.exportSymbol) {
|
||||
for (const declaration of local.declarations) {
|
||||
if (!isAmbientModule(declaration)) {
|
||||
errorUnusedLocal(declaration, unescapeLeadingUnderscores(local.escapedName));
|
||||
errorUnusedLocal(declaration, symbolName(local));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22318,7 +22349,7 @@ namespace ts {
|
||||
const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias,
|
||||
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
|
||||
error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, unescapeLeadingUnderscores(exportedName.escapedText));
|
||||
error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, idText(exportedName));
|
||||
}
|
||||
else {
|
||||
markExportAsReferenced(node);
|
||||
@@ -22432,8 +22463,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isInJavaScriptFile(node) && (node as JSDocContainer).jsDoc) {
|
||||
for (const jsdoc of (node as JSDocContainer).jsDoc) {
|
||||
checkJSDocComment(jsdoc);
|
||||
for (const { tags } of (node as JSDocContainer).jsDoc) {
|
||||
forEach(tags, checkSourceElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22491,12 +22522,12 @@ namespace ts {
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
case SyntaxKind.TypeOperator:
|
||||
return checkSourceElement((<ParenthesizedTypeNode | TypeOperatorNode>node).type);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
return checkJSDocAugmentsTag(node as JSDocAugmentsTag);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
return checkJSDocTypedefTag(node as JSDocTypedefTag);
|
||||
case SyntaxKind.JSDocComment:
|
||||
return checkJSDocComment(node as JSDoc);
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
return checkSourceElement((node as JSDocParameterTag).typeExpression);
|
||||
return checkJSDocParameterTag(node as JSDocParameterTag);
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
checkSignatureDeclaration(node as JSDocFunctionType);
|
||||
// falls through
|
||||
@@ -24986,7 +25017,7 @@ namespace ts {
|
||||
|
||||
function checkESModuleMarker(name: Identifier | BindingPattern): boolean {
|
||||
if (name.kind === SyntaxKind.Identifier) {
|
||||
if (unescapeLeadingUnderscores(name.escapedText) === "__esModule") {
|
||||
if (idText(name) === "__esModule") {
|
||||
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3507,6 +3507,18 @@
|
||||
"category": "Error",
|
||||
"code": 8021
|
||||
},
|
||||
"JSDoc '@augments' is not attached to a class declaration.": {
|
||||
"category": "Error",
|
||||
"code": 8022
|
||||
},
|
||||
"JSDoc '@augments {0}' does not match the 'extends {1}' clause.": {
|
||||
"category": "Error",
|
||||
"code": 8023
|
||||
},
|
||||
"JSDoc '@param' tag has name '{0}', but there is no parameter with that name.": {
|
||||
"category": "Error",
|
||||
"code": 8024
|
||||
},
|
||||
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
@@ -3685,6 +3697,10 @@
|
||||
"category": "Message",
|
||||
"code": 90026
|
||||
},
|
||||
"Declare static property '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 90027
|
||||
},
|
||||
|
||||
"Convert function to an ES2015 class": {
|
||||
"category": "Message",
|
||||
@@ -3695,7 +3711,7 @@
|
||||
"code": 95002
|
||||
},
|
||||
|
||||
"Extract function": {
|
||||
"Extract symbol": {
|
||||
"category": "Message",
|
||||
"code": 95003
|
||||
},
|
||||
@@ -3703,5 +3719,15 @@
|
||||
"Extract to {0}": {
|
||||
"category": "Message",
|
||||
"code": 95004
|
||||
},
|
||||
|
||||
"Extract function": {
|
||||
"category": "Message",
|
||||
"code": 95005
|
||||
},
|
||||
|
||||
"Extract constant": {
|
||||
"category": "Message",
|
||||
"code": 95006
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2766,7 +2766,7 @@ namespace ts {
|
||||
return generateName(node);
|
||||
}
|
||||
else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent)) {
|
||||
return unescapeLeadingUnderscores(node.escapedText);
|
||||
return idText(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
||||
return getTextOfNode((<StringLiteral>node).textSourceNode, includeTrivia);
|
||||
@@ -2986,7 +2986,7 @@ namespace ts {
|
||||
case GeneratedIdentifierKind.Loop:
|
||||
return makeTempVariableName(TempFlags._i);
|
||||
case GeneratedIdentifierKind.Unique:
|
||||
return makeUniqueName(unescapeLeadingUnderscores(name.escapedText));
|
||||
return makeUniqueName(idText(name));
|
||||
}
|
||||
|
||||
Debug.fail("Unsupported GeneratedIdentifierKind.");
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace ts {
|
||||
|
||||
export function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode> | undefined): Identifier {
|
||||
return node.typeArguments !== typeArguments
|
||||
? updateNode(createIdentifier(unescapeLeadingUnderscores(node.escapedText), typeArguments), node)
|
||||
? updateNode(createIdentifier(idText(node), typeArguments), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
@@ -2951,12 +2951,12 @@ namespace ts {
|
||||
function createJsxFactoryExpressionFromEntityName(jsxFactory: EntityName, parent: JsxOpeningLikeElement): Expression {
|
||||
if (isQualifiedName(jsxFactory)) {
|
||||
const left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
|
||||
const right = createIdentifier(unescapeLeadingUnderscores(jsxFactory.right.escapedText));
|
||||
const right = createIdentifier(idText(jsxFactory.right));
|
||||
right.escapedText = jsxFactory.right.escapedText;
|
||||
return createPropertyAccess(left, right);
|
||||
}
|
||||
else {
|
||||
return createReactNamespace(unescapeLeadingUnderscores(jsxFactory.escapedText), parent);
|
||||
return createReactNamespace(idText(jsxFactory), parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-8
@@ -424,7 +424,7 @@ namespace ts {
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
return visitNode(cbNode, (<JSDocTypeTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
return visitNode(cbNode, (<JSDocAugmentsTag>node).typeExpression);
|
||||
return visitNode(cbNode, (<JSDocAugmentsTag>node).class);
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
return visitNodes(cbNode, cbNodes, (<JSDocTemplateTag>node).typeParameters);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
@@ -5624,13 +5624,16 @@ namespace ts {
|
||||
function parseExpressionWithTypeArguments(): ExpressionWithTypeArguments {
|
||||
const node = <ExpressionWithTypeArguments>createNode(SyntaxKind.ExpressionWithTypeArguments);
|
||||
node.expression = parseLeftHandSideExpressionOrHigher();
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
}
|
||||
|
||||
node.typeArguments = tryParseTypeArguments();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function tryParseTypeArguments(): NodeArray<TypeNode> | undefined {
|
||||
return token() === SyntaxKind.LessThanToken
|
||||
? parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function isHeritageClause(): boolean {
|
||||
return token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword;
|
||||
}
|
||||
@@ -6604,15 +6607,36 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag {
|
||||
const typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true);
|
||||
|
||||
const result = <JSDocAugmentsTag>createNode(SyntaxKind.JSDocAugmentsTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = typeExpression;
|
||||
result.class = parseExpressionWithTypeArgumentsForAugments();
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseExpressionWithTypeArgumentsForAugments(): ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression } {
|
||||
const usedBrace = parseOptional(SyntaxKind.OpenBraceToken);
|
||||
const node = createNode(SyntaxKind.ExpressionWithTypeArguments) as ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression };
|
||||
node.expression = parsePropertyAccessEntityNameExpression();
|
||||
node.typeArguments = tryParseTypeArguments();
|
||||
const res = finishNode(node);
|
||||
if (usedBrace) {
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function parsePropertyAccessEntityNameExpression() {
|
||||
let node: Identifier | PropertyAccessEntityNameExpression = parseJSDocIdentifierName(/*createIfMissing*/ true);
|
||||
while (token() === SyntaxKind.DotToken) {
|
||||
const prop: PropertyAccessEntityNameExpression = createNode(SyntaxKind.PropertyAccessExpression, node.pos) as PropertyAccessEntityNameExpression;
|
||||
prop.expression = node;
|
||||
prop.name = parseJSDocIdentifierName();
|
||||
node = finishNode(prop);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function parseClassTag(atToken: AtToken, tagName: Identifier): JSDocClassTag {
|
||||
const tag = <JSDocClassTag>createNode(SyntaxKind.JSDocClassTag, atToken.pos);
|
||||
tag.atToken = atToken;
|
||||
|
||||
Regular → Executable
+19
-14
@@ -278,6 +278,7 @@ namespace ts {
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, host: FormatDiagnosticsHost): string {
|
||||
let output = "";
|
||||
for (const diagnostic of diagnostics) {
|
||||
let context = "";
|
||||
if (diagnostic.file) {
|
||||
const { start, length, file } = diagnostic;
|
||||
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start);
|
||||
@@ -291,12 +292,12 @@ namespace ts {
|
||||
gutterWidth = Math.max(ellipsis.length, gutterWidth);
|
||||
}
|
||||
|
||||
output += host.getNewLine();
|
||||
context += host.getNewLine();
|
||||
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 + host.getNewLine();
|
||||
context += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
|
||||
i = lastLine - 1;
|
||||
}
|
||||
|
||||
@@ -307,30 +308,28 @@ namespace ts {
|
||||
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 + host.getNewLine();
|
||||
context += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
context += lineContent + host.getNewLine();
|
||||
|
||||
// Output the gutter and the error span for the line using tildes.
|
||||
output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += redForegroundEscapeSequence;
|
||||
context += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
context += 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, "~");
|
||||
context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
|
||||
context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
|
||||
}
|
||||
else if (i === lastLine) {
|
||||
output += lineContent.slice(0, lastLineChar).replace(/./g, "~");
|
||||
context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
|
||||
}
|
||||
else {
|
||||
// Squiggle the entire line.
|
||||
output += lineContent.replace(/./g, "~");
|
||||
context += lineContent.replace(/./g, "~");
|
||||
}
|
||||
output += resetEscapeSequence;
|
||||
|
||||
output += host.getNewLine();
|
||||
context += resetEscapeSequence;
|
||||
}
|
||||
|
||||
output += host.getNewLine();
|
||||
@@ -340,6 +339,12 @@ namespace ts {
|
||||
const categoryColor = getCategoryFormat(diagnostic.category);
|
||||
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }`;
|
||||
|
||||
if (diagnostic.file) {
|
||||
output += host.getNewLine();
|
||||
output += context;
|
||||
}
|
||||
|
||||
output += host.getNewLine();
|
||||
}
|
||||
return output;
|
||||
@@ -1684,7 +1689,7 @@ namespace ts {
|
||||
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);
|
||||
fail(Diagnostics.A_file_cannot_have_a_reference_to_itself);
|
||||
}
|
||||
}
|
||||
return sourceFile;
|
||||
|
||||
@@ -1856,6 +1856,12 @@ namespace ts {
|
||||
case CharacterCodes.closeBracket:
|
||||
pos++;
|
||||
return token = SyntaxKind.CloseBracketToken;
|
||||
case CharacterCodes.lessThan:
|
||||
pos++;
|
||||
return token = SyntaxKind.LessThanToken;
|
||||
case CharacterCodes.greaterThan:
|
||||
pos++;
|
||||
return token = SyntaxKind.GreaterThanToken;
|
||||
case CharacterCodes.equals:
|
||||
pos++;
|
||||
return token = SyntaxKind.EqualsToken;
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace ts {
|
||||
return createElementAccess(value, argumentExpression);
|
||||
}
|
||||
else {
|
||||
const name = createIdentifier(unescapeLeadingUnderscores(propertyName.escapedText));
|
||||
const name = createIdentifier(idText(propertyName));
|
||||
return createPropertyAccess(value, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ namespace ts {
|
||||
// - break/continue is non-labeled and located in non-converted loop/switch statement
|
||||
const jump = node.kind === SyntaxKind.BreakStatement ? Jump.Break : Jump.Continue;
|
||||
const canUseBreakOrContinue =
|
||||
(node.label && convertedLoopState.labels && convertedLoopState.labels.get(unescapeLeadingUnderscores(node.label.escapedText))) ||
|
||||
(node.label && convertedLoopState.labels && convertedLoopState.labels.get(idText(node.label))) ||
|
||||
(!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
|
||||
|
||||
if (!canUseBreakOrContinue) {
|
||||
@@ -628,11 +628,11 @@ namespace ts {
|
||||
else {
|
||||
if (node.kind === SyntaxKind.BreakStatement) {
|
||||
labelMarker = `break-${node.label.escapedText}`;
|
||||
setLabeledJump(convertedLoopState, /*isBreak*/ true, unescapeLeadingUnderscores(node.label.escapedText), labelMarker);
|
||||
setLabeledJump(convertedLoopState, /*isBreak*/ true, idText(node.label), labelMarker);
|
||||
}
|
||||
else {
|
||||
labelMarker = `continue-${node.label.escapedText}`;
|
||||
setLabeledJump(convertedLoopState, /*isBreak*/ false, unescapeLeadingUnderscores(node.label.escapedText), labelMarker);
|
||||
setLabeledJump(convertedLoopState, /*isBreak*/ false, idText(node.label), labelMarker);
|
||||
}
|
||||
}
|
||||
let returnExpression: Expression = createLiteral(labelMarker);
|
||||
@@ -2187,11 +2187,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function recordLabel(node: LabeledStatement) {
|
||||
convertedLoopState.labels.set(unescapeLeadingUnderscores(node.label.escapedText), true);
|
||||
convertedLoopState.labels.set(idText(node.label), true);
|
||||
}
|
||||
|
||||
function resetLabel(node: LabeledStatement) {
|
||||
convertedLoopState.labels.set(unescapeLeadingUnderscores(node.label.escapedText), false);
|
||||
convertedLoopState.labels.set(idText(node.label), false);
|
||||
}
|
||||
|
||||
function visitLabeledStatement(node: LabeledStatement): VisitResult<Statement> {
|
||||
@@ -3004,7 +3004,7 @@ namespace ts {
|
||||
else {
|
||||
loopParameters.push(createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
|
||||
if (resolver.getNodeCheckFlags(decl) & NodeCheckFlags.NeedsLoopOutParameter) {
|
||||
const outParamName = createUniqueName("out_" + unescapeLeadingUnderscores(name.escapedText));
|
||||
const outParamName = createUniqueName("out_" + idText(name));
|
||||
loopOutParameters.push({ originalName: name, outParamName });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace ts {
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(unescapeLeadingUnderscores(node.name.escapedText)),
|
||||
createLiteral(idText(node.name)),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace ts {
|
||||
* @param name An Identifier
|
||||
*/
|
||||
function trySubstituteReservedName(name: Identifier) {
|
||||
const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(unescapeLeadingUnderscores(name.escapedText)) : undefined);
|
||||
const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(idText(name)) : undefined);
|
||||
if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) {
|
||||
return setTextRange(createLiteral(name), name);
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ namespace ts {
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(unescapeLeadingUnderscores(node.name.escapedText)),
|
||||
createLiteral(idText(node.name)),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1634,7 +1634,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function transformAndEmitContinueStatement(node: ContinueStatement): void {
|
||||
const label = findContinueTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined);
|
||||
const label = findContinueTarget(node.label ? idText(node.label) : undefined);
|
||||
if (label > 0) {
|
||||
emitBreak(label, /*location*/ node);
|
||||
}
|
||||
@@ -1646,7 +1646,7 @@ namespace ts {
|
||||
|
||||
function visitContinueStatement(node: ContinueStatement): Statement {
|
||||
if (inStatementContainingYield) {
|
||||
const label = findContinueTarget(node.label && unescapeLeadingUnderscores(node.label.escapedText));
|
||||
const label = findContinueTarget(node.label && idText(node.label));
|
||||
if (label > 0) {
|
||||
return createInlineBreak(label, /*location*/ node);
|
||||
}
|
||||
@@ -1656,7 +1656,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function transformAndEmitBreakStatement(node: BreakStatement): void {
|
||||
const label = findBreakTarget(node.label ? unescapeLeadingUnderscores(node.label.escapedText) : undefined);
|
||||
const label = findBreakTarget(node.label ? idText(node.label) : undefined);
|
||||
if (label > 0) {
|
||||
emitBreak(label, /*location*/ node);
|
||||
}
|
||||
@@ -1668,7 +1668,7 @@ namespace ts {
|
||||
|
||||
function visitBreakStatement(node: BreakStatement): Statement {
|
||||
if (inStatementContainingYield) {
|
||||
const label = findBreakTarget(node.label && unescapeLeadingUnderscores(node.label.escapedText));
|
||||
const label = findBreakTarget(node.label && idText(node.label));
|
||||
if (label > 0) {
|
||||
return createInlineBreak(label, /*location*/ node);
|
||||
}
|
||||
@@ -1847,7 +1847,7 @@ namespace ts {
|
||||
// /*body*/
|
||||
// .endlabeled
|
||||
// .mark endLabel
|
||||
beginLabeledBlock(unescapeLeadingUnderscores(node.label.escapedText));
|
||||
beginLabeledBlock(idText(node.label));
|
||||
transformAndEmitEmbeddedStatement(node.statement);
|
||||
endLabeledBlock();
|
||||
}
|
||||
@@ -1858,7 +1858,7 @@ namespace ts {
|
||||
|
||||
function visitLabeledStatement(node: LabeledStatement) {
|
||||
if (inStatementContainingYield) {
|
||||
beginScriptLabeledBlock(unescapeLeadingUnderscores(node.label.escapedText));
|
||||
beginScriptLabeledBlock(idText(node.label));
|
||||
}
|
||||
|
||||
node = visitEachChild(node, visitor, context);
|
||||
@@ -1959,7 +1959,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function substituteExpressionIdentifier(node: Identifier) {
|
||||
if (!isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(unescapeLeadingUnderscores(node.escapedText))) {
|
||||
if (!isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(idText(node))) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original) && original.parent) {
|
||||
const declaration = resolver.getReferencedValueDeclaration(original);
|
||||
@@ -2128,7 +2128,7 @@ namespace ts {
|
||||
hoistVariableDeclaration(variable.name);
|
||||
}
|
||||
else {
|
||||
const text = unescapeLeadingUnderscores((<Identifier>variable.name).escapedText);
|
||||
const text = idText(<Identifier>variable.name);
|
||||
name = declareLocal(text);
|
||||
if (!renamedCatchVariables) {
|
||||
renamedCatchVariables = createMap<boolean>();
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace ts {
|
||||
else {
|
||||
const name = (<JsxOpeningLikeElement>node).tagName;
|
||||
if (isIdentifier(name) && isIntrinsicJsxName(name.escapedText)) {
|
||||
return createLiteral(unescapeLeadingUnderscores(name.escapedText));
|
||||
return createLiteral(idText(name));
|
||||
}
|
||||
else {
|
||||
return createExpressionFromEntityName(name);
|
||||
@@ -268,11 +268,12 @@ namespace ts {
|
||||
*/
|
||||
function getAttributeName(node: JsxAttribute): StringLiteral | Identifier {
|
||||
const name = node.name;
|
||||
if (/^[A-Za-z_]\w*$/.test(unescapeLeadingUnderscores(name.escapedText))) {
|
||||
const text = idText(name);
|
||||
if (/^[A-Za-z_]\w*$/.test(text)) {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
return createLiteral(unescapeLeadingUnderscores(name.escapedText));
|
||||
return createLiteral(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1231,7 +1231,7 @@ namespace ts {
|
||||
*/
|
||||
function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration): Statement[] | undefined {
|
||||
const name = getDeclarationName(decl);
|
||||
const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(unescapeLeadingUnderscores(name.escapedText));
|
||||
const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(idText(name));
|
||||
if (exportSpecifiers) {
|
||||
for (const exportSpecifier of exportSpecifiers) {
|
||||
statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name);
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace ts {
|
||||
// write name of indirectly exported entry, i.e. 'export {x} from ...'
|
||||
exportedNames.push(
|
||||
createPropertyAssignment(
|
||||
createLiteral(unescapeLeadingUnderscores((element.name || element.propertyName).escapedText)),
|
||||
createLiteral(idText(element.name || element.propertyName)),
|
||||
createTrue()
|
||||
)
|
||||
);
|
||||
@@ -504,10 +504,10 @@ namespace ts {
|
||||
for (const e of (<ExportDeclaration>entry).exportClause.elements) {
|
||||
properties.push(
|
||||
createPropertyAssignment(
|
||||
createLiteral(unescapeLeadingUnderscores(e.name.escapedText)),
|
||||
createLiteral(idText(e.name)),
|
||||
createElementAccess(
|
||||
parameterName,
|
||||
createLiteral(unescapeLeadingUnderscores((e.propertyName || e.name).escapedText))
|
||||
createLiteral(idText(e.propertyName || e.name))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -1028,7 +1028,7 @@ namespace ts {
|
||||
let excludeName: string;
|
||||
if (exportSelf) {
|
||||
statements = appendExportStatement(statements, decl.name, getLocalName(decl));
|
||||
excludeName = unescapeLeadingUnderscores(decl.name.escapedText);
|
||||
excludeName = idText(decl.name);
|
||||
}
|
||||
|
||||
statements = appendExportsOfDeclaration(statements, decl, excludeName);
|
||||
@@ -1080,7 +1080,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const name = getDeclarationName(decl);
|
||||
const exportSpecifiers = moduleInfo.exportSpecifiers.get(unescapeLeadingUnderscores(name.escapedText));
|
||||
const exportSpecifiers = moduleInfo.exportSpecifiers.get(idText(name));
|
||||
if (exportSpecifiers) {
|
||||
for (const exportSpecifier of exportSpecifiers) {
|
||||
if (exportSpecifier.name.escapedText !== excludeName) {
|
||||
|
||||
@@ -2038,7 +2038,7 @@ namespace ts {
|
||||
: (<ComputedPropertyName>name).expression;
|
||||
}
|
||||
else if (isIdentifier(name)) {
|
||||
return createLiteral(unescapeLeadingUnderscores(name.escapedText));
|
||||
return createLiteral(idText(name));
|
||||
}
|
||||
else {
|
||||
return getSynthesizedClone(name);
|
||||
@@ -3240,7 +3240,7 @@ namespace ts {
|
||||
function getClassAliasIfNeeded(node: ClassDeclaration) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) {
|
||||
enableSubstitutionForClassAliases();
|
||||
const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? unescapeLeadingUnderscores(node.name.escapedText) : "default");
|
||||
const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? idText(node.name) : "default");
|
||||
classAliases[getOriginalNodeId(node)] = classAlias;
|
||||
hoistVariableDeclaration(classAlias);
|
||||
return classAlias;
|
||||
|
||||
@@ -58,9 +58,9 @@ namespace ts {
|
||||
else {
|
||||
// export { x, y }
|
||||
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
|
||||
if (!uniqueExports.get(unescapeLeadingUnderscores(specifier.name.escapedText))) {
|
||||
if (!uniqueExports.get(idText(specifier.name))) {
|
||||
const name = specifier.propertyName || specifier.name;
|
||||
exportSpecifiers.add(unescapeLeadingUnderscores(name.escapedText), specifier);
|
||||
exportSpecifiers.add(idText(name), specifier);
|
||||
|
||||
const decl = resolver.getReferencedImportDeclaration(name)
|
||||
|| resolver.getReferencedValueDeclaration(name);
|
||||
@@ -69,7 +69,7 @@ namespace ts {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
|
||||
}
|
||||
|
||||
uniqueExports.set(unescapeLeadingUnderscores(specifier.name.escapedText), true);
|
||||
uniqueExports.set(idText(specifier.name), true);
|
||||
exportedNames = append(exportedNames, specifier.name);
|
||||
}
|
||||
}
|
||||
@@ -103,9 +103,9 @@ namespace ts {
|
||||
else {
|
||||
// export function x() { }
|
||||
const name = (<FunctionDeclaration>node).name;
|
||||
if (!uniqueExports.get(unescapeLeadingUnderscores(name.escapedText))) {
|
||||
if (!uniqueExports.get(idText(name))) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
|
||||
uniqueExports.set(unescapeLeadingUnderscores(name.escapedText), true);
|
||||
uniqueExports.set(idText(name), true);
|
||||
exportedNames = append(exportedNames, name);
|
||||
}
|
||||
}
|
||||
@@ -124,9 +124,9 @@ namespace ts {
|
||||
else {
|
||||
// export class x { }
|
||||
const name = (<ClassDeclaration>node).name;
|
||||
if (name && !uniqueExports.get(unescapeLeadingUnderscores(name.escapedText))) {
|
||||
if (name && !uniqueExports.get(idText(name))) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
|
||||
uniqueExports.set(unescapeLeadingUnderscores(name.escapedText), true);
|
||||
uniqueExports.set(idText(name), true);
|
||||
exportedNames = append(exportedNames, name);
|
||||
}
|
||||
}
|
||||
@@ -158,8 +158,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (!isGeneratedIdentifier(decl.name)) {
|
||||
if (!uniqueExports.get(unescapeLeadingUnderscores(decl.name.escapedText))) {
|
||||
uniqueExports.set(unescapeLeadingUnderscores(decl.name.escapedText), true);
|
||||
const text = idText(decl.name);
|
||||
if (!uniqueExports.get(text)) {
|
||||
uniqueExports.set(text, true);
|
||||
exportedNames = append(exportedNames, decl.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2161,7 +2161,7 @@ namespace ts {
|
||||
|
||||
export interface JSDocAugmentsTag extends JSDocTag {
|
||||
kind: SyntaxKind.JSDocAugmentsTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression };
|
||||
}
|
||||
|
||||
export interface JSDocClassTag extends JSDocTag {
|
||||
@@ -2443,7 +2443,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray<SourceFile>): void;
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
|
||||
}
|
||||
|
||||
export class OperationCanceledException { }
|
||||
|
||||
@@ -563,7 +563,7 @@ namespace ts {
|
||||
export function entityNameToString(name: EntityNameOrEntityNameExpression): string {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return getFullWidth(name) === 0 ? unescapeLeadingUnderscores(name.escapedText) : getTextOfNode(name);
|
||||
return getFullWidth(name) === 0 ? idText(name) : getTextOfNode(name);
|
||||
case SyntaxKind.QualifiedName:
|
||||
return entityNameToString(name.left) + "." + entityNameToString(name.right);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
@@ -1404,11 +1404,10 @@ namespace ts {
|
||||
|
||||
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
||||
/// assignments we treat as special in the binder
|
||||
export function getSpecialPropertyAssignmentKind(expression: ts.BinaryExpression): SpecialPropertyAssignmentKind {
|
||||
if (!isInJavaScriptFile(expression)) {
|
||||
export function getSpecialPropertyAssignmentKind(expr: ts.BinaryExpression): SpecialPropertyAssignmentKind {
|
||||
if (!isInJavaScriptFile(expr)) {
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
const expr = <BinaryExpression>expression;
|
||||
if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || expr.left.kind !== SyntaxKind.PropertyAccessExpression) {
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
@@ -1584,8 +1583,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
const name = node.name.escapedText;
|
||||
Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment);
|
||||
const func = node.parent!.parent!;
|
||||
const func = getJSDocHost(node);
|
||||
if (!isFunctionLike(func)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1594,6 +1592,11 @@ namespace ts {
|
||||
return parameter && parameter.symbol;
|
||||
}
|
||||
|
||||
export function getJSDocHost(node: JSDocTag): HasJSDoc {
|
||||
Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment);
|
||||
return node.parent!.parent!;
|
||||
}
|
||||
|
||||
export function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { parent: JSDocTemplateTag }): TypeParameterDeclaration | undefined {
|
||||
const name = node.name.escapedText;
|
||||
const { typeParameters } = (node.parent.parent.parent as ts.SignatureDeclaration | ts.InterfaceDeclaration | ts.ClassDeclaration);
|
||||
@@ -1976,8 +1979,7 @@ namespace ts {
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = name.expression;
|
||||
if (isWellKnownSymbolSyntactically(nameExpression)) {
|
||||
const rightHandSideName = (<PropertyAccessExpression>nameExpression).name.escapedText;
|
||||
return getPropertyNameForKnownSymbolName(unescapeLeadingUnderscores(rightHandSideName));
|
||||
return getPropertyNameForKnownSymbolName(idText((<PropertyAccessExpression>nameExpression).name));
|
||||
}
|
||||
else if (nameExpression.kind === SyntaxKind.StringLiteral || nameExpression.kind === SyntaxKind.NumericLiteral) {
|
||||
return escapeLeadingUnderscores((<LiteralExpression>nameExpression).text);
|
||||
@@ -1990,7 +1992,7 @@ namespace ts {
|
||||
export function getTextOfIdentifierOrLiteral(node: Identifier | LiteralLikeNode) {
|
||||
if (node) {
|
||||
if (node.kind === SyntaxKind.Identifier) {
|
||||
return unescapeLeadingUnderscores((node as Identifier).escapedText);
|
||||
return idText(node as Identifier);
|
||||
}
|
||||
if (node.kind === SyntaxKind.StringLiteral ||
|
||||
node.kind === SyntaxKind.NumericLiteral) {
|
||||
@@ -4030,6 +4032,13 @@ namespace ts {
|
||||
return id.length >= 3 && id.charCodeAt(0) === CharacterCodes._ && id.charCodeAt(1) === CharacterCodes._ && id.charCodeAt(2) === CharacterCodes._ ? id.substr(1) : id;
|
||||
}
|
||||
|
||||
export function idText(identifier: Identifier): string {
|
||||
return unescapeLeadingUnderscores(identifier.escapedText);
|
||||
}
|
||||
export function symbolName(symbol: Symbol): string {
|
||||
return unescapeLeadingUnderscores(symbol.escapedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra underscore from escaped identifier text content.
|
||||
* @deprecated Use `id.text` for the unescaped text.
|
||||
|
||||
@@ -1037,8 +1037,7 @@ namespace FourSlash {
|
||||
|
||||
const refs = this.getReferencesAtCaret();
|
||||
if (refs && refs.length) {
|
||||
console.log(refs);
|
||||
this.raiseError("Expected getReferences to fail");
|
||||
this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1050,9 +1049,9 @@ namespace FourSlash {
|
||||
private assertObjectsEqual<T>(fullActual: T, fullExpected: T, msgPrefix = ""): void {
|
||||
const recur = <U>(actual: U, expected: U, path: string) => {
|
||||
const fail = (msg: string) => {
|
||||
console.log("Expected:", stringify(fullExpected));
|
||||
console.log("Actual: ", stringify(fullActual));
|
||||
this.raiseError(`${msgPrefix}At ${path}: ${msg}`);
|
||||
this.raiseError(`${msgPrefix} At ${path}: ${msg}
|
||||
Expected: ${stringify(fullExpected)}
|
||||
Actual: ${stringify(fullActual)}`);
|
||||
};
|
||||
|
||||
if ((actual === undefined) !== (expected === undefined)) {
|
||||
@@ -1084,9 +1083,9 @@ namespace FourSlash {
|
||||
if (fullActual === fullExpected) {
|
||||
return;
|
||||
}
|
||||
console.log("Expected:", stringify(fullExpected));
|
||||
console.log("Actual: ", stringify(fullActual));
|
||||
this.raiseError(msgPrefix);
|
||||
this.raiseError(`${msgPrefix}
|
||||
Expected: ${stringify(fullExpected)}
|
||||
Actual: ${stringify(fullActual)}`);
|
||||
}
|
||||
recur(fullActual, fullExpected, "");
|
||||
|
||||
@@ -2337,6 +2336,39 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCodeFix(options: FourSlashInterface.VerifyCodeFixOptions) {
|
||||
const fileName = this.activeFile.fileName;
|
||||
const actions = this.getCodeFixActions(fileName, options.errorCode);
|
||||
let index = options.index;
|
||||
if (index === undefined) {
|
||||
if (!(actions && actions.length === 1)) {
|
||||
this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found. ${actions ? actions.map(a => `${Harness.IO.newLine()} "${a.description}"`) : ""}`);
|
||||
}
|
||||
index = 0;
|
||||
}
|
||||
else {
|
||||
if (!(actions && actions.length >= index + 1)) {
|
||||
this.raiseError(`Should find at least ${index + 1} codefix(es), but ${actions ? actions.length : "none"} found.`);
|
||||
}
|
||||
}
|
||||
|
||||
const action = actions[index];
|
||||
|
||||
assert.equal(action.description, options.description);
|
||||
|
||||
for (const change of action.changes) {
|
||||
this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false);
|
||||
}
|
||||
|
||||
if (options.newFileContent) {
|
||||
assert(!options.newRangeContent);
|
||||
this.verifyCurrentFileContent(options.newFileContent);
|
||||
}
|
||||
else {
|
||||
this.verifyRangeIs(options.newRangeContent, /*includeWhitespace*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found.
|
||||
* @param fileName Path to file where error should be retrieved from.
|
||||
@@ -3716,6 +3748,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLineDiverges);
|
||||
}
|
||||
|
||||
public codeFix(options: FourSlashInterface.VerifyCodeFixOptions) {
|
||||
this.state.verifyCodeFix(options);
|
||||
}
|
||||
|
||||
public codeFixAvailable() {
|
||||
this.state.verifyCodeFixAvailable(this.negative);
|
||||
}
|
||||
@@ -4359,4 +4395,13 @@ namespace FourSlashInterface {
|
||||
export interface CompletionsAtOptions {
|
||||
isNewIdentifierLocation?: boolean;
|
||||
}
|
||||
|
||||
export interface VerifyCodeFixOptions {
|
||||
description: string;
|
||||
// One of these should be defined.
|
||||
newFileContent?: string;
|
||||
newRangeContent?: string;
|
||||
errorCode?: number;
|
||||
index?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1721,8 +1721,12 @@ namespace Harness {
|
||||
return resultName;
|
||||
}
|
||||
|
||||
function sanitizeTestFilePath(name: string) {
|
||||
return ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", Utils.canonicalizeForHarness);
|
||||
export function sanitizeTestFilePath(name: string) {
|
||||
const path = ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", Utils.canonicalizeForHarness);
|
||||
if (ts.startsWith(path, "/")) {
|
||||
return path.substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
// This does not need to exist strictly speaking, but many tests will need to be updated if it's removed
|
||||
@@ -2066,13 +2070,13 @@ namespace Harness {
|
||||
export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]>, opts?: BaselineOptions, referencedExtensions?: string[]): void {
|
||||
const gen = generateContent();
|
||||
const writtenFiles = ts.createMap<true>();
|
||||
/* tslint:disable-next-line:no-null-keyword */
|
||||
const errors: Error[] = [];
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
if (gen !== null) {
|
||||
for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) {
|
||||
const [name, content, count] = value as [string, string, number | undefined];
|
||||
if (count === 0) continue; // Allow error reporter to skip writing files without errors
|
||||
const relativeFileName = relativeFileBase + (ts.startsWith(name, "/") ? "" : "/") + name + extension;
|
||||
const relativeFileName = relativeFileBase + "/" + name + extension;
|
||||
const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
const comparison = compareToBaseline(content, relativeFileName, opts);
|
||||
try {
|
||||
|
||||
+76
-6
@@ -5,8 +5,10 @@
|
||||
/// <reference path="..\..\src\harness\typeWriter.ts" />
|
||||
|
||||
interface FileInformation {
|
||||
contents: string;
|
||||
contents?: string;
|
||||
contentsPath?: string;
|
||||
codepage: number;
|
||||
bom?: string;
|
||||
}
|
||||
|
||||
interface FindFileResult {
|
||||
@@ -27,13 +29,15 @@ interface IOLog {
|
||||
filesRead: IOLogFile[];
|
||||
filesWritten: {
|
||||
path: string;
|
||||
contents: string;
|
||||
contents?: string;
|
||||
contentsPath?: string;
|
||||
bom: boolean;
|
||||
}[];
|
||||
filesDeleted: string[];
|
||||
filesAppended: {
|
||||
path: string;
|
||||
contents: string;
|
||||
contents?: string;
|
||||
contentsPath?: string;
|
||||
}[];
|
||||
fileExists: {
|
||||
path: string;
|
||||
@@ -129,6 +133,72 @@ namespace Playback {
|
||||
};
|
||||
}
|
||||
|
||||
export function newStyleLogIntoOldStyleLog(log: IOLog, host: ts.System | Harness.IO, baseName: string) {
|
||||
for (const file of log.filesAppended) {
|
||||
if (file.contentsPath) {
|
||||
file.contents = host.readFile(ts.combinePaths(baseName, file.contentsPath));
|
||||
delete file.contentsPath;
|
||||
}
|
||||
}
|
||||
for (const file of log.filesWritten) {
|
||||
if (file.contentsPath) {
|
||||
file.contents = host.readFile(ts.combinePaths(baseName, file.contentsPath));
|
||||
delete file.contentsPath;
|
||||
}
|
||||
}
|
||||
for (const file of log.filesRead) {
|
||||
if (file.result.contentsPath) {
|
||||
// `readFile` strips away a BOM (and actually reinerprets the file contents according to the correct encoding)
|
||||
// - but this has the unfortunate sideeffect of removing the BOM from any outputs based on the file, so we readd it here.
|
||||
file.result.contents = (file.result.bom || "") + host.readFile(ts.combinePaths(baseName, file.result.contentsPath));
|
||||
delete file.result.contentsPath;
|
||||
}
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
export function oldStyleLogIntoNewStyleLog(log: IOLog, writeFile: typeof Harness.IO.writeFile, baseTestName: string) {
|
||||
if (log.filesAppended) {
|
||||
for (const file of log.filesAppended) {
|
||||
if (file.contents !== undefined) {
|
||||
file.contentsPath = ts.combinePaths("appended", Harness.Compiler.sanitizeTestFilePath(file.path));
|
||||
writeFile(ts.combinePaths(baseTestName, file.contentsPath), file.contents);
|
||||
delete file.contents;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log.filesWritten) {
|
||||
for (const file of log.filesWritten) {
|
||||
if (file.contents !== undefined) {
|
||||
file.contentsPath = ts.combinePaths("written", Harness.Compiler.sanitizeTestFilePath(file.path));
|
||||
writeFile(ts.combinePaths(baseTestName, file.contentsPath), file.contents);
|
||||
delete file.contents;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log.filesRead) {
|
||||
for (const file of log.filesRead) {
|
||||
const { contents } = file.result;
|
||||
if (contents !== undefined) {
|
||||
file.result.contentsPath = ts.combinePaths("read", Harness.Compiler.sanitizeTestFilePath(file.path));
|
||||
writeFile(ts.combinePaths(baseTestName, file.result.contentsPath), contents);
|
||||
const len = contents.length;
|
||||
if (len >= 2 && contents.charCodeAt(0) === 0xfeff) {
|
||||
file.result.bom = "\ufeff";
|
||||
}
|
||||
if (len >= 2 && contents.charCodeAt(0) === 0xfffe) {
|
||||
file.result.bom = "\ufffe";
|
||||
}
|
||||
if (len >= 3 && contents.charCodeAt(0) === 0xefbb && contents.charCodeAt(1) === 0xbf) {
|
||||
file.result.bom = "\uefbb\xbf";
|
||||
}
|
||||
delete file.result.contents;
|
||||
}
|
||||
}
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void;
|
||||
function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void;
|
||||
function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void {
|
||||
@@ -164,9 +234,9 @@ namespace Playback {
|
||||
wrapper.endRecord = () => {
|
||||
if (recordLog !== undefined) {
|
||||
let i = 0;
|
||||
const fn = () => recordLogFileNameBase + i + ".json";
|
||||
while (underlying.fileExists(fn())) i++;
|
||||
underlying.writeFile(fn(), JSON.stringify(recordLog));
|
||||
const fn = () => recordLogFileNameBase + i;
|
||||
while (underlying.fileExists(fn() + ".json")) i++;
|
||||
underlying.writeFile(ts.combinePaths(fn(), "test.json"), JSON.stringify(oldStyleLogIntoNewStyleLog(recordLog, (path, string) => underlying.writeFile(ts.combinePaths(fn(), path), string), fn()), null, 4)); // tslint:disable-line:no-null-keyword
|
||||
recordLog = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,8 +57,19 @@ namespace Harness.Parallel.Host {
|
||||
for (const file of files) {
|
||||
let size: number;
|
||||
if (!perfData) {
|
||||
size = statSync(file).size;
|
||||
|
||||
try {
|
||||
size = statSync(file).size;
|
||||
}
|
||||
catch {
|
||||
// May be a directory
|
||||
try {
|
||||
size = Harness.IO.listFiles(file, /.*/g, { recursive: true }).reduce((acc, elem) => acc + statSync(elem).size, 0);
|
||||
}
|
||||
catch {
|
||||
// Unknown test kind, just return 0 and let the historical analysis take over after one run
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const hashedName = hashName(runner.kind(), file);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace RWC {
|
||||
Subfolder: "rwc",
|
||||
Baselinefolder: "internal/baselines"
|
||||
};
|
||||
const baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
const baseName = ts.getBaseFileName(jsonPath);
|
||||
let currentDirectory: string;
|
||||
let useCustomLibraryFile: boolean;
|
||||
let skipTypeAndSymbolbaselines = false;
|
||||
@@ -61,7 +61,7 @@ namespace RWC {
|
||||
this.timeout(800000); // Allow long timeouts for RWC compilations
|
||||
let opts: ts.ParsedCommandLine;
|
||||
|
||||
const ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
const ioLog: IOLog = Playback.newStyleLogIntoOldStyleLog(JSON.parse(Harness.IO.readFile(`internal/cases/rwc/${jsonPath}/test.json`)), Harness.IO, `internal/cases/rwc/${baseName}`);
|
||||
currentDirectory = ioLog.currentDirectory;
|
||||
useCustomLibraryFile = ioLog.useCustomLibraryFile;
|
||||
skipTypeAndSymbolbaselines = ioLog.filesRead.reduce((acc, elem) => (elem && elem.result && elem.result.contents) ? acc + elem.result.contents.length : acc, 0) > typeAndSymbolSizeLimit;
|
||||
@@ -253,7 +253,7 @@ namespace RWC {
|
||||
|
||||
class RWCRunner extends RunnerBase {
|
||||
public enumerateTestFiles() {
|
||||
return Harness.IO.listFiles("internal/cases/rwc/", /.+\.json$/);
|
||||
return Harness.IO.getDirectories("internal/cases/rwc/");
|
||||
}
|
||||
|
||||
public kind(): TestRunnerKind {
|
||||
|
||||
@@ -130,7 +130,10 @@
|
||||
"./unittests/printer.ts",
|
||||
"./unittests/transform.ts",
|
||||
"./unittests/customTransforms.ts",
|
||||
"./unittests/extractMethods.ts",
|
||||
"./unittests/extractConstants.ts",
|
||||
"./unittests/extractFunctions.ts",
|
||||
"./unittests/extractRanges.ts",
|
||||
"./unittests/extractTestHelpers.ts",
|
||||
"./unittests/textChanges.ts",
|
||||
"./unittests/telemetry.ts",
|
||||
"./unittests/languageService.ts",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/// <reference path="extractTestHelpers.ts" />
|
||||
|
||||
namespace ts {
|
||||
describe("extractConstants", () => {
|
||||
testExtractConstant("extractConstant_TopLevel",
|
||||
`let x = [#|1|];`);
|
||||
|
||||
testExtractConstant("extractConstant_Namespace",
|
||||
`namespace N {
|
||||
let x = [#|1|];
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_Class",
|
||||
`class C {
|
||||
x = [#|1|];
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_Method",
|
||||
`class C {
|
||||
M() {
|
||||
let x = [#|1|];
|
||||
}
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_Function",
|
||||
`function F() {
|
||||
let x = [#|1|];
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_ExpressionStatement",
|
||||
`[#|"hello";|]`);
|
||||
|
||||
testExtractConstant("extractConstant_ExpressionStatementExpression",
|
||||
`[#|"hello"|];`);
|
||||
|
||||
testExtractConstant("extractConstant_BlockScopes_NoDependencies",
|
||||
`for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = [#|1|];
|
||||
}
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_ClassInsertionPosition",
|
||||
`class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = [#|1|];
|
||||
}
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_Parameters",
|
||||
`function F() {
|
||||
let w = 1;
|
||||
let x = [#|w + 1|];
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_TypeParameters",
|
||||
`function F<T>(t: T) {
|
||||
let x = [#|t + 1|];
|
||||
}`);
|
||||
|
||||
// TODO (acasey): handle repeated substitution
|
||||
// testExtractConstant("extractConstant_RepeatedSubstitution",
|
||||
// `namespace X {
|
||||
// export const j = 10;
|
||||
// export const y = [#|j * j|];
|
||||
// }`);
|
||||
|
||||
testExtractConstantFailed("extractConstant_BlockScopes_Dependencies",
|
||||
`for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = [#|i + 1|];
|
||||
}
|
||||
}`);
|
||||
});
|
||||
|
||||
function testExtractConstant(caption: string, text: string) {
|
||||
testExtractSymbol(caption, text, "extractConstant", Diagnostics.Extract_constant);
|
||||
}
|
||||
|
||||
function testExtractConstantFailed(caption: string, text: string) {
|
||||
testExtractSymbolFailed(caption, text, Diagnostics.Extract_constant);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
/// <reference path="extractTestHelpers.ts" />
|
||||
|
||||
namespace ts {
|
||||
describe("extractFunctions", () => {
|
||||
testExtractFunction("extractFunction1",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction2",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction3",
|
||||
`namespace A {
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function* a(z: number) {
|
||||
[#|
|
||||
let y = 5;
|
||||
yield z;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction4",
|
||||
`namespace A {
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
async function a(z: number, z1: any) {
|
||||
[#|
|
||||
let y = 5;
|
||||
if (z) {
|
||||
await z1;
|
||||
}
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction5",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction6",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction7",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export namespace C {
|
||||
export function foo() {
|
||||
}
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
return C.foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction8",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
namespace B {
|
||||
function a() {
|
||||
let a1 = 1;
|
||||
return 1 + [#|a1 + x|] + 100;
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction9",
|
||||
`namespace A {
|
||||
export interface I { x: number };
|
||||
namespace B {
|
||||
function a() {
|
||||
[#|let a1: I = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction10",
|
||||
`namespace A {
|
||||
export interface I { x: number };
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1: I = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction11",
|
||||
`namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractFunction("extractFunction12",
|
||||
`namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
b() {}
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
this.b();
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
// The "b" type parameters aren't used and shouldn't be passed to the extracted function.
|
||||
// Type parameters should be in syntactic order (i.e. in order or character offset from BOF).
|
||||
// In all cases, we could use type inference, rather than passing explicit type arguments.
|
||||
// Note the inclusion of arrow functions to ensure that some type parameters are not from
|
||||
// targetable scopes.
|
||||
testExtractFunction("extractFunction13",
|
||||
`<U1a, U1b>(u1a: U1a, u1b: U1b) => {
|
||||
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
|
||||
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
|
||||
[#|t1a.toString();
|
||||
t2a.toString();
|
||||
u1a.toString();
|
||||
u2a.toString();
|
||||
u3a.toString();|]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`);
|
||||
// This test is descriptive, rather than normative. The current implementation
|
||||
// doesn't handle type parameter shadowing.
|
||||
testExtractFunction("extractFunction14",
|
||||
`function F<T>(t1: T) {
|
||||
function G<T>(t2: T) {
|
||||
[#|t1.toString();
|
||||
t2.toString();|]
|
||||
}
|
||||
}`);
|
||||
// Confirm that the constraint is preserved.
|
||||
testExtractFunction("extractFunction15",
|
||||
`function F<T>(t1: T) {
|
||||
function G<U extends T[]>(t2: U) {
|
||||
[#|t2.toString();|]
|
||||
}
|
||||
}`);
|
||||
// Confirm that the contextual type of an extracted expression counts as a use.
|
||||
testExtractFunction("extractFunction16",
|
||||
`function F<T>() {
|
||||
const array: T[] = [#|[]|];
|
||||
}`);
|
||||
// Class type parameter
|
||||
testExtractFunction("extractFunction17",
|
||||
`class C<T1, T2> {
|
||||
M(t1: T1, t2: T2) {
|
||||
[#|t1.toString()|];
|
||||
}
|
||||
}`);
|
||||
// Function type parameter
|
||||
testExtractFunction("extractFunction18",
|
||||
`class C {
|
||||
M<T1, T2>(t1: T1, t2: T2) {
|
||||
[#|t1.toString()|];
|
||||
}
|
||||
}`);
|
||||
// Coupled constraints
|
||||
testExtractFunction("extractFunction19",
|
||||
`function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
[#|v.toString()|];
|
||||
}`);
|
||||
|
||||
testExtractFunction("extractFunction20",
|
||||
`const _ = class {
|
||||
a() {
|
||||
[#|let a1 = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}`);
|
||||
// Write + void return
|
||||
testExtractFunction("extractFunction21",
|
||||
`function foo() {
|
||||
let x = 10;
|
||||
[#|x++;
|
||||
return;|]
|
||||
}`);
|
||||
// Return in finally block
|
||||
testExtractFunction("extractFunction22",
|
||||
`function test() {
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
[#|return 1;|]
|
||||
}
|
||||
}`);
|
||||
// Extraction position - namespace
|
||||
testExtractFunction("extractFunction23",
|
||||
`namespace NS {
|
||||
function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }
|
||||
}`);
|
||||
// Extraction position - function
|
||||
testExtractFunction("extractFunction24",
|
||||
`function Outer() {
|
||||
function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }
|
||||
}`);
|
||||
// Extraction position - file
|
||||
testExtractFunction("extractFunction25",
|
||||
`function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }`);
|
||||
// Extraction position - class without ctor
|
||||
testExtractFunction("extractFunction26",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
M3() { }
|
||||
}`);
|
||||
// Extraction position - class with ctor in middle
|
||||
testExtractFunction("extractFunction27",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
constructor() { }
|
||||
M3() { }
|
||||
}`);
|
||||
// Extraction position - class with ctor at end
|
||||
testExtractFunction("extractFunction28",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
M3() { }
|
||||
constructor() { }
|
||||
}`);
|
||||
// Shorthand property names
|
||||
testExtractFunction("extractFunction29",
|
||||
`interface UnaryExpression {
|
||||
kind: "Unary";
|
||||
operator: string;
|
||||
operand: any;
|
||||
}
|
||||
|
||||
function parseUnaryExpression(operator: string): UnaryExpression {
|
||||
[#|return {
|
||||
kind: "Unary",
|
||||
operator,
|
||||
operand: parsePrimaryExpression(),
|
||||
};|]
|
||||
}
|
||||
|
||||
function parsePrimaryExpression(): any {
|
||||
throw "Not implemented";
|
||||
}`);
|
||||
// Type parameter as declared type
|
||||
testExtractFunction("extractFunction30",
|
||||
`function F<T>() {
|
||||
[#|let t: T;|]
|
||||
}`);
|
||||
// Return in nested function
|
||||
testExtractFunction("extractFunction31",
|
||||
`namespace N {
|
||||
|
||||
export const value = 1;
|
||||
|
||||
() => {
|
||||
var f: () => number;
|
||||
[#|f = function (): number {
|
||||
return value;
|
||||
}|]
|
||||
}
|
||||
}`);
|
||||
// Return in nested class
|
||||
testExtractFunction("extractFunction32",
|
||||
`namespace N {
|
||||
|
||||
export const value = 1;
|
||||
|
||||
() => {
|
||||
[#|var c = class {
|
||||
M() {
|
||||
return value;
|
||||
}
|
||||
}|]
|
||||
}
|
||||
}`);
|
||||
// Selection excludes leading trivia of declaration
|
||||
testExtractFunction("extractFunction33",
|
||||
`function F() {
|
||||
[#|function G() { }|]
|
||||
}`);
|
||||
|
||||
// TODO (acasey): handle repeated substitution
|
||||
// testExtractFunction("extractFunction_RepeatedSubstitution",
|
||||
// `namespace X {
|
||||
// export const j = 10;
|
||||
// export const y = [#|j * j|];
|
||||
// }`);
|
||||
});
|
||||
|
||||
function testExtractFunction(caption: string, text: string) {
|
||||
testExtractSymbol(caption, text, "extractFunction", Diagnostics.Extract_function);
|
||||
}
|
||||
}
|
||||
@@ -1,823 +0,0 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="tsserverProjectSystem.ts" />
|
||||
|
||||
namespace ts {
|
||||
interface Range {
|
||||
start: number;
|
||||
end: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Test {
|
||||
source: string;
|
||||
ranges: Map<Range>;
|
||||
}
|
||||
|
||||
function extractTest(source: string): Test {
|
||||
const activeRanges: Range[] = [];
|
||||
let text = "";
|
||||
let lastPos = 0;
|
||||
let pos = 0;
|
||||
const ranges = createMap<Range>();
|
||||
|
||||
while (pos < source.length) {
|
||||
if (source.charCodeAt(pos) === CharacterCodes.openBracket &&
|
||||
(source.charCodeAt(pos + 1) === CharacterCodes.hash || source.charCodeAt(pos + 1) === CharacterCodes.$)) {
|
||||
const saved = pos;
|
||||
pos += 2;
|
||||
const s = pos;
|
||||
consumeIdentifier();
|
||||
const e = pos;
|
||||
if (source.charCodeAt(pos) === CharacterCodes.bar) {
|
||||
pos++;
|
||||
text += source.substring(lastPos, saved);
|
||||
const name = s === e
|
||||
? source.charCodeAt(saved + 1) === CharacterCodes.hash ? "selection" : "extracted"
|
||||
: source.substring(s, e);
|
||||
activeRanges.push({ name, start: text.length, end: undefined });
|
||||
lastPos = pos;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
pos = saved;
|
||||
}
|
||||
}
|
||||
else if (source.charCodeAt(pos) === CharacterCodes.bar && source.charCodeAt(pos + 1) === CharacterCodes.closeBracket) {
|
||||
text += source.substring(lastPos, pos);
|
||||
activeRanges[activeRanges.length - 1].end = text.length;
|
||||
const range = activeRanges.pop();
|
||||
if (range.name in ranges) {
|
||||
throw new Error(`Duplicate name of range ${range.name}`);
|
||||
}
|
||||
ranges.set(range.name, range);
|
||||
pos += 2;
|
||||
lastPos = pos;
|
||||
continue;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
text += source.substring(lastPos, pos);
|
||||
|
||||
function consumeIdentifier() {
|
||||
while (isIdentifierPart(source.charCodeAt(pos), ScriptTarget.Latest)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return { source: text, ranges };
|
||||
}
|
||||
|
||||
const newLineCharacter = "\n";
|
||||
function getRuleProvider(action?: (opts: FormatCodeSettings) => void) {
|
||||
const options = {
|
||||
indentSize: 4,
|
||||
tabSize: 4,
|
||||
newLineCharacter,
|
||||
convertTabsToSpaces: true,
|
||||
indentStyle: ts.IndentStyle.Smart,
|
||||
insertSpaceAfterConstructor: false,
|
||||
insertSpaceAfterCommaDelimiter: true,
|
||||
insertSpaceAfterSemicolonInForStatements: true,
|
||||
insertSpaceBeforeAndAfterBinaryOperators: true,
|
||||
insertSpaceAfterKeywordsInControlFlowStatements: true,
|
||||
insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
|
||||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
|
||||
insertSpaceBeforeFunctionParenthesis: false,
|
||||
placeOpenBraceOnNewLineForFunctions: false,
|
||||
placeOpenBraceOnNewLineForControlBlocks: false,
|
||||
};
|
||||
if (action) {
|
||||
action(options);
|
||||
}
|
||||
const rulesProvider = new formatting.RulesProvider();
|
||||
rulesProvider.ensureUpToDate(options);
|
||||
return rulesProvider;
|
||||
}
|
||||
|
||||
function testExtractRangeFailed(caption: string, s: string, expectedErrors: string[]) {
|
||||
return it(caption, () => {
|
||||
const t = extractTest(s);
|
||||
const file = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${s} does not specify selection range`);
|
||||
}
|
||||
const result = refactor.extractMethod.getRangeToExtract(file, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
assert(result.targetRange === undefined, "failure expected");
|
||||
const sortedErrors = result.errors.map(e => <string>e.messageText).sort();
|
||||
assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors");
|
||||
});
|
||||
}
|
||||
|
||||
function testExtractRange(s: string): void {
|
||||
const t = extractTest(s);
|
||||
const f = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${s} does not specify selection range`);
|
||||
}
|
||||
const result = refactor.extractMethod.getRangeToExtract(f, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
const expectedRange = t.ranges.get("extracted");
|
||||
if (expectedRange) {
|
||||
let start: number, end: number;
|
||||
if (ts.isArray(result.targetRange.range)) {
|
||||
start = result.targetRange.range[0].getStart(f);
|
||||
end = ts.lastOrUndefined(result.targetRange.range).getEnd();
|
||||
}
|
||||
else {
|
||||
start = result.targetRange.range.getStart(f);
|
||||
end = result.targetRange.range.getEnd();
|
||||
}
|
||||
assert.equal(start, expectedRange.start, "incorrect start of range");
|
||||
assert.equal(end, expectedRange.end, "incorrect end of range");
|
||||
}
|
||||
else {
|
||||
assert.isTrue(!result.targetRange, `expected range to extract to be undefined`);
|
||||
}
|
||||
}
|
||||
|
||||
describe("extractMethods", () => {
|
||||
it("get extract range from selection", () => {
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|var x = 1;
|
||||
var y = 2;|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
var x = 1;
|
||||
var y = 2|];
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|var x = 1|];
|
||||
var y = 2;
|
||||
`);
|
||||
testExtractRange(`
|
||||
if ([#|[#extracted|a && b && c && d|]|]) {
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
if [#|(a && b && c && d|]) {
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
if (a && b && c && d) {
|
||||
[#| [$|var x = 1;
|
||||
console.log(x);|] |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
if (a) {
|
||||
return 100;
|
||||
} |]
|
||||
`);
|
||||
testExtractRange(`
|
||||
function foo() {
|
||||
[#| [$|if (a) {
|
||||
}
|
||||
return 100|] |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|l1:
|
||||
if (x) {
|
||||
break l1;
|
||||
}|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|l2:
|
||||
{
|
||||
if (x) {
|
||||
}
|
||||
break l2;
|
||||
}|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
while (true) {
|
||||
[#| if(x) {
|
||||
}
|
||||
break; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
while (true) {
|
||||
[#| if(x) {
|
||||
}
|
||||
continue; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
l3:
|
||||
{
|
||||
[#|
|
||||
if (x) {
|
||||
}
|
||||
break l3; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
if (x) {
|
||||
return;
|
||||
} |]
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
[$|if (x) {
|
||||
}
|
||||
return;|]
|
||||
|]
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [#| [$|1 + 2|] |]+ 3;
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [$|1 + [#|2 + 3|]|];
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [$|1 + 2 + [#|3 + 4|]|];
|
||||
}
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed1",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
return 10;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional return statement."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed2",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
break;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional break or continue statements."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed3",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional break or continue statements."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed4",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
l1: {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
break l1;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing labeled break or continue with target outside of the range."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed5",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
try {
|
||||
f2()
|
||||
return 10;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|]
|
||||
}
|
||||
function f2() {
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional return statement."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed6",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
try {
|
||||
f2()
|
||||
}
|
||||
catch (e) {
|
||||
return 10;
|
||||
}
|
||||
|]
|
||||
}
|
||||
function f2() {
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional return statement."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed7",
|
||||
`
|
||||
function test(x: number) {
|
||||
while (x) {
|
||||
x--;
|
||||
[#|break;|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional break or continue statements."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed8",
|
||||
`
|
||||
function test(x: number) {
|
||||
switch (x) {
|
||||
case 1:
|
||||
[#|break;|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
"Cannot extract range containing conditional break or continue statements."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed9",
|
||||
`var x = ([#||]1 + 2);`,
|
||||
[
|
||||
"Statement or expression expected."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single identifier."]);
|
||||
|
||||
testExtractMethod("extractMethod1",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod2",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod3",
|
||||
`namespace A {
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function* a(z: number) {
|
||||
[#|
|
||||
let y = 5;
|
||||
yield z;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod4",
|
||||
`namespace A {
|
||||
function foo() {
|
||||
}
|
||||
namespace B {
|
||||
async function a(z: number, z1: any) {
|
||||
[#|
|
||||
let y = 5;
|
||||
if (z) {
|
||||
await z1;
|
||||
}
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod5",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod6",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export function foo() {
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
return foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod7",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
export namespace C {
|
||||
export function foo() {
|
||||
}
|
||||
}
|
||||
namespace B {
|
||||
function a() {
|
||||
let a = 1;
|
||||
[#|
|
||||
let y = 5;
|
||||
let z = x;
|
||||
a = y;
|
||||
return C.foo();|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod8",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
namespace B {
|
||||
function a() {
|
||||
let a1 = 1;
|
||||
return 1 + [#|a1 + x|] + 100;
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod9",
|
||||
`namespace A {
|
||||
export interface I { x: number };
|
||||
namespace B {
|
||||
function a() {
|
||||
[#|let a1: I = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod10",
|
||||
`namespace A {
|
||||
export interface I { x: number };
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1: I = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod11",
|
||||
`namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
testExtractMethod("extractMethod12",
|
||||
`namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
b() {}
|
||||
a() {
|
||||
let z = 1;
|
||||
[#|let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
this.b();
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}
|
||||
}`);
|
||||
// The "b" type parameters aren't used and shouldn't be passed to the extracted function.
|
||||
// Type parameters should be in syntactic order (i.e. in order or character offset from BOF).
|
||||
// In all cases, we could use type inference, rather than passing explicit type arguments.
|
||||
// Note the inclusion of arrow functions to ensure that some type parameters are not from
|
||||
// targetable scopes.
|
||||
testExtractMethod("extractMethod13",
|
||||
`<U1a, U1b>(u1a: U1a, u1b: U1b) => {
|
||||
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
|
||||
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
|
||||
[#|t1a.toString();
|
||||
t2a.toString();
|
||||
u1a.toString();
|
||||
u2a.toString();
|
||||
u3a.toString();|]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`);
|
||||
// This test is descriptive, rather than normative. The current implementation
|
||||
// doesn't handle type parameter shadowing.
|
||||
testExtractMethod("extractMethod14",
|
||||
`function F<T>(t1: T) {
|
||||
function F<T>(t2: T) {
|
||||
[#|t1.toString();
|
||||
t2.toString();|]
|
||||
}
|
||||
}`);
|
||||
// Confirm that the constraint is preserved.
|
||||
testExtractMethod("extractMethod15",
|
||||
`function F<T>(t1: T) {
|
||||
function F<U extends T[]>(t2: U) {
|
||||
[#|t2.toString();|]
|
||||
}
|
||||
}`);
|
||||
// Confirm that the contextual type of an extracted expression counts as a use.
|
||||
testExtractMethod("extractMethod16",
|
||||
`function F<T>() {
|
||||
const array: T[] = [#|[]|];
|
||||
}`);
|
||||
// Class type parameter
|
||||
testExtractMethod("extractMethod17",
|
||||
`class C<T1, T2> {
|
||||
M(t1: T1, t2: T2) {
|
||||
[#|t1.toString()|];
|
||||
}
|
||||
}`);
|
||||
// Method type parameter
|
||||
testExtractMethod("extractMethod18",
|
||||
`class C {
|
||||
M<T1, T2>(t1: T1, t2: T2) {
|
||||
[#|t1.toString()|];
|
||||
}
|
||||
}`);
|
||||
// Coupled constraints
|
||||
testExtractMethod("extractMethod19",
|
||||
`function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
[#|v.toString()|];
|
||||
}`);
|
||||
|
||||
testExtractMethod("extractMethod20",
|
||||
`const _ = class {
|
||||
a() {
|
||||
[#|let a1 = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}`);
|
||||
// Write + void return
|
||||
testExtractMethod("extractMethod21",
|
||||
`function foo() {
|
||||
let x = 10;
|
||||
[#|x++;
|
||||
return;|]
|
||||
}`);
|
||||
// Return in finally block
|
||||
testExtractMethod("extractMethod22",
|
||||
`function test() {
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
[#|return 1;|]
|
||||
}
|
||||
}`);
|
||||
// Extraction position - namespace
|
||||
testExtractMethod("extractMethod23",
|
||||
`namespace NS {
|
||||
function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }
|
||||
}`);
|
||||
// Extraction position - function
|
||||
testExtractMethod("extractMethod24",
|
||||
`function Outer() {
|
||||
function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }
|
||||
}`);
|
||||
// Extraction position - file
|
||||
testExtractMethod("extractMethod25",
|
||||
`function M1() { }
|
||||
function M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
function M3() { }`);
|
||||
// Extraction position - class without ctor
|
||||
testExtractMethod("extractMethod26",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
M3() { }
|
||||
}`);
|
||||
// Extraction position - class with ctor in middle
|
||||
testExtractMethod("extractMethod27",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
constructor() { }
|
||||
M3() { }
|
||||
}`);
|
||||
// Extraction position - class with ctor at end
|
||||
testExtractMethod("extractMethod28",
|
||||
`class C {
|
||||
M1() { }
|
||||
M2() {
|
||||
[#|return 1;|]
|
||||
}
|
||||
M3() { }
|
||||
constructor() { }
|
||||
}`);
|
||||
// Shorthand property names
|
||||
testExtractMethod("extractMethod29",
|
||||
`interface UnaryExpression {
|
||||
kind: "Unary";
|
||||
operator: string;
|
||||
operand: any;
|
||||
}
|
||||
|
||||
function parseUnaryExpression(operator: string): UnaryExpression {
|
||||
[#|return {
|
||||
kind: "Unary",
|
||||
operator,
|
||||
operand: parsePrimaryExpression(),
|
||||
};|]
|
||||
}
|
||||
|
||||
function parsePrimaryExpression(): any {
|
||||
throw "Not implemented";
|
||||
}`);
|
||||
// Type parameter as declared type
|
||||
testExtractMethod("extractMethod30",
|
||||
`function F<T>() {
|
||||
[#|let t: T;|]
|
||||
}`);
|
||||
// Return in nested function
|
||||
testExtractMethod("extractMethod31",
|
||||
`namespace N {
|
||||
|
||||
export const value = 1;
|
||||
|
||||
() => {
|
||||
var f: () => number;
|
||||
[#|f = function (): number {
|
||||
return value;
|
||||
}|]
|
||||
}
|
||||
}`);
|
||||
// Return in nested class
|
||||
testExtractMethod("extractMethod32",
|
||||
`namespace N {
|
||||
|
||||
export const value = 1;
|
||||
|
||||
() => {
|
||||
[#|var c = class {
|
||||
M() {
|
||||
return value;
|
||||
}
|
||||
}|]
|
||||
}
|
||||
}`);
|
||||
// Selection excludes leading trivia of declaration
|
||||
testExtractMethod("extractMethod33",
|
||||
`function F() {
|
||||
[#|function G() { }|]
|
||||
}`);
|
||||
});
|
||||
|
||||
|
||||
function testExtractMethod(caption: string, text: string) {
|
||||
it(caption, () => {
|
||||
Harness.Baseline.runBaseline(`extractMethod/${caption}.ts`, () => {
|
||||
const t = extractTest(text);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${caption} does not specify selection range`);
|
||||
}
|
||||
const f = {
|
||||
path: "/a.ts",
|
||||
content: t.source
|
||||
};
|
||||
const host = projectSystem.createServerHost([f, projectSystem.libFile]);
|
||||
const projectService = projectSystem.createProjectService(host);
|
||||
projectService.openClientFile(f.path);
|
||||
const program = projectService.inferredProjects[0].getLanguageService().getProgram();
|
||||
const sourceFile = program.getSourceFile(f.path);
|
||||
const context: RefactorContext = {
|
||||
cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } },
|
||||
newLineCharacter,
|
||||
program,
|
||||
file: sourceFile,
|
||||
startPosition: -1,
|
||||
rulesProvider: getRuleProvider()
|
||||
};
|
||||
const result = refactor.extractMethod.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
assert.equal(result.errors, undefined, "expect no errors");
|
||||
const results = refactor.extractMethod.getPossibleExtractions(result.targetRange, context);
|
||||
const data: string[] = [];
|
||||
data.push(`// ==ORIGINAL==`);
|
||||
data.push(sourceFile.text);
|
||||
for (const r of results) {
|
||||
const { renameLocation, edits } = refactor.extractMethod.getExtractionAtIndex(result.targetRange, context, results.indexOf(r));
|
||||
assert.lengthOf(edits, 1);
|
||||
data.push(`// ==SCOPE::${r.scopeDescription}==`);
|
||||
const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges);
|
||||
const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation);
|
||||
data.push(newTextWithRename);
|
||||
}
|
||||
return data.join(newLineCharacter);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
/// <reference path="extractTestHelpers.ts" />
|
||||
|
||||
namespace ts {
|
||||
function testExtractRangeFailed(caption: string, s: string, expectedErrors: string[]) {
|
||||
return it(caption, () => {
|
||||
const t = extractTest(s);
|
||||
const file = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${s} does not specify selection range`);
|
||||
}
|
||||
const result = refactor.extractSymbol.getRangeToExtract(file, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
assert(result.targetRange === undefined, "failure expected");
|
||||
const sortedErrors = result.errors.map(e => <string>e.messageText).sort();
|
||||
assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors");
|
||||
});
|
||||
}
|
||||
|
||||
function testExtractRange(s: string): void {
|
||||
const t = extractTest(s);
|
||||
const f = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${s} does not specify selection range`);
|
||||
}
|
||||
const result = refactor.extractSymbol.getRangeToExtract(f, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
const expectedRange = t.ranges.get("extracted");
|
||||
if (expectedRange) {
|
||||
let start: number, end: number;
|
||||
if (ts.isArray(result.targetRange.range)) {
|
||||
start = result.targetRange.range[0].getStart(f);
|
||||
end = ts.lastOrUndefined(result.targetRange.range).getEnd();
|
||||
}
|
||||
else {
|
||||
start = result.targetRange.range.getStart(f);
|
||||
end = result.targetRange.range.getEnd();
|
||||
}
|
||||
assert.equal(start, expectedRange.start, "incorrect start of range");
|
||||
assert.equal(end, expectedRange.end, "incorrect end of range");
|
||||
}
|
||||
else {
|
||||
assert.isTrue(!result.targetRange, `expected range to extract to be undefined`);
|
||||
}
|
||||
}
|
||||
|
||||
describe("extractRanges", () => {
|
||||
it("get extract range from selection", () => {
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|var x = 1;
|
||||
var y = 2;|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
var x = 1;
|
||||
var y = 2|];
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|var x = 1|];
|
||||
var y = 2;
|
||||
`);
|
||||
testExtractRange(`
|
||||
if ([#|[#extracted|a && b && c && d|]|]) {
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
if [#|(a && b && c && d|]) {
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
if (a && b && c && d) {
|
||||
[#| [$|var x = 1;
|
||||
console.log(x);|] |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
if (a) {
|
||||
return 100;
|
||||
} |]
|
||||
`);
|
||||
testExtractRange(`
|
||||
function foo() {
|
||||
[#| [$|if (a) {
|
||||
}
|
||||
return 100|] |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|l1:
|
||||
if (x) {
|
||||
break l1;
|
||||
}|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
[#|
|
||||
[$|l2:
|
||||
{
|
||||
if (x) {
|
||||
}
|
||||
break l2;
|
||||
}|]|]
|
||||
`);
|
||||
testExtractRange(`
|
||||
while (true) {
|
||||
[#| if(x) {
|
||||
}
|
||||
break; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
while (true) {
|
||||
[#| if(x) {
|
||||
}
|
||||
continue; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
l3:
|
||||
{
|
||||
[#|
|
||||
if (x) {
|
||||
}
|
||||
break l3; |]
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
if (x) {
|
||||
return;
|
||||
} |]
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
[$|if (x) {
|
||||
}
|
||||
return;|]
|
||||
|]
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [#| [$|1 + 2|] |]+ 3;
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [$|1 + [#|2 + 3|]|];
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f() {
|
||||
return [$|1 + 2 + [#|3 + 4|]|];
|
||||
}
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed1",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
return 10;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed2",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
break;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed3",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
while (true) {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed4",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
l1: {
|
||||
[#|
|
||||
let x = 1
|
||||
if (x) {
|
||||
break l1;
|
||||
}
|
||||
|]
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed5",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
try {
|
||||
f2()
|
||||
return 10;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|]
|
||||
}
|
||||
function f2() {
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed6",
|
||||
`
|
||||
namespace A {
|
||||
function f() {
|
||||
[#|
|
||||
try {
|
||||
f2()
|
||||
}
|
||||
catch (e) {
|
||||
return 10;
|
||||
}
|
||||
|]
|
||||
}
|
||||
function f2() {
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed7",
|
||||
`
|
||||
function test(x: number) {
|
||||
while (x) {
|
||||
x--;
|
||||
[#|break;|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed8",
|
||||
`
|
||||
function test(x: number) {
|
||||
switch (x) {
|
||||
case 1:
|
||||
[#|break;|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed9",
|
||||
`var x = ([#||]1 + 2);`,
|
||||
[
|
||||
"Cannot extract empty range."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, [refactor.extractSymbol.Messages.CannotExtractIdentifier.message]);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="tsserverProjectSystem.ts" />
|
||||
|
||||
namespace ts {
|
||||
export interface Range {
|
||||
start: number;
|
||||
end: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Test {
|
||||
source: string;
|
||||
ranges: Map<Range>;
|
||||
}
|
||||
|
||||
export function extractTest(source: string): Test {
|
||||
const activeRanges: Range[] = [];
|
||||
let text = "";
|
||||
let lastPos = 0;
|
||||
let pos = 0;
|
||||
const ranges = createMap<Range>();
|
||||
|
||||
while (pos < source.length) {
|
||||
if (source.charCodeAt(pos) === CharacterCodes.openBracket &&
|
||||
(source.charCodeAt(pos + 1) === CharacterCodes.hash || source.charCodeAt(pos + 1) === CharacterCodes.$)) {
|
||||
const saved = pos;
|
||||
pos += 2;
|
||||
const s = pos;
|
||||
consumeIdentifier();
|
||||
const e = pos;
|
||||
if (source.charCodeAt(pos) === CharacterCodes.bar) {
|
||||
pos++;
|
||||
text += source.substring(lastPos, saved);
|
||||
const name = s === e
|
||||
? source.charCodeAt(saved + 1) === CharacterCodes.hash ? "selection" : "extracted"
|
||||
: source.substring(s, e);
|
||||
activeRanges.push({ name, start: text.length, end: undefined });
|
||||
lastPos = pos;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
pos = saved;
|
||||
}
|
||||
}
|
||||
else if (source.charCodeAt(pos) === CharacterCodes.bar && source.charCodeAt(pos + 1) === CharacterCodes.closeBracket) {
|
||||
text += source.substring(lastPos, pos);
|
||||
activeRanges[activeRanges.length - 1].end = text.length;
|
||||
const range = activeRanges.pop();
|
||||
if (range.name in ranges) {
|
||||
throw new Error(`Duplicate name of range ${range.name}`);
|
||||
}
|
||||
ranges.set(range.name, range);
|
||||
pos += 2;
|
||||
lastPos = pos;
|
||||
continue;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
text += source.substring(lastPos, pos);
|
||||
|
||||
function consumeIdentifier() {
|
||||
while (isIdentifierPart(source.charCodeAt(pos), ScriptTarget.Latest)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return { source: text, ranges };
|
||||
}
|
||||
|
||||
export const newLineCharacter = "\n";
|
||||
export function getRuleProvider(action?: (opts: FormatCodeSettings) => void) {
|
||||
const options = {
|
||||
indentSize: 4,
|
||||
tabSize: 4,
|
||||
newLineCharacter,
|
||||
convertTabsToSpaces: true,
|
||||
indentStyle: ts.IndentStyle.Smart,
|
||||
insertSpaceAfterConstructor: false,
|
||||
insertSpaceAfterCommaDelimiter: true,
|
||||
insertSpaceAfterSemicolonInForStatements: true,
|
||||
insertSpaceBeforeAndAfterBinaryOperators: true,
|
||||
insertSpaceAfterKeywordsInControlFlowStatements: true,
|
||||
insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
|
||||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
|
||||
insertSpaceBeforeFunctionParenthesis: false,
|
||||
placeOpenBraceOnNewLineForFunctions: false,
|
||||
placeOpenBraceOnNewLineForControlBlocks: false,
|
||||
};
|
||||
if (action) {
|
||||
action(options);
|
||||
}
|
||||
const rulesProvider = new formatting.RulesProvider();
|
||||
rulesProvider.ensureUpToDate(options);
|
||||
return rulesProvider;
|
||||
}
|
||||
|
||||
export function testExtractSymbol(caption: string, text: string, baselineFolder: string, description: DiagnosticMessage) {
|
||||
const t = extractTest(text);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${caption} does not specify selection range`);
|
||||
}
|
||||
|
||||
[Extension.Ts, Extension.Js].forEach(extension =>
|
||||
it(`${caption} [${extension}]`, () => runBaseline(extension)));
|
||||
|
||||
function runBaseline(extension: Extension) {
|
||||
const path = "/a" + extension;
|
||||
const program = makeProgram({ path, content: t.source });
|
||||
|
||||
if (hasSyntacticDiagnostics(program)) {
|
||||
// Don't bother generating JS baselines for inputs that aren't valid JS.
|
||||
assert.equal(Extension.Js, extension);
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceFile = program.getSourceFile(path);
|
||||
const context: RefactorContext = {
|
||||
cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } },
|
||||
newLineCharacter,
|
||||
program,
|
||||
file: sourceFile,
|
||||
startPosition: selectionRange.start,
|
||||
endPosition: selectionRange.end,
|
||||
rulesProvider: getRuleProvider()
|
||||
};
|
||||
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
assert.equal(rangeToExtract.errors, undefined, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText);
|
||||
const infos = refactor.extractSymbol.getAvailableActions(context);
|
||||
const actions = find(infos, info => info.description === description.message).actions;
|
||||
|
||||
Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, () => {
|
||||
const data: string[] = [];
|
||||
data.push(`// ==ORIGINAL==`);
|
||||
data.push(sourceFile.text);
|
||||
for (const action of actions) {
|
||||
const { renameLocation, edits } = refactor.extractSymbol.getEditsForAction(context, action.name);
|
||||
assert.lengthOf(edits, 1);
|
||||
data.push(`// ==SCOPE::${action.description}==`);
|
||||
const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges);
|
||||
const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation);
|
||||
data.push(newTextWithRename);
|
||||
|
||||
const diagProgram = makeProgram({ path, content: newText });
|
||||
assert.isFalse(hasSyntacticDiagnostics(diagProgram));
|
||||
}
|
||||
return data.join(newLineCharacter);
|
||||
});
|
||||
}
|
||||
|
||||
function makeProgram(f: {path: string, content: string }) {
|
||||
const host = projectSystem.createServerHost([f, projectSystem.libFile]);
|
||||
const projectService = projectSystem.createProjectService(host);
|
||||
projectService.openClientFile(f.path);
|
||||
const program = projectService.inferredProjects[0].getLanguageService().getProgram();
|
||||
return program;
|
||||
}
|
||||
|
||||
function hasSyntacticDiagnostics(program: Program) {
|
||||
const diags = program.getSyntacticDiagnostics();
|
||||
return length(diags) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function testExtractSymbolFailed(caption: string, text: string, description: DiagnosticMessage) {
|
||||
it(caption, () => {
|
||||
const t = extractTest(text);
|
||||
const selectionRange = t.ranges.get("selection");
|
||||
if (!selectionRange) {
|
||||
throw new Error(`Test ${caption} does not specify selection range`);
|
||||
}
|
||||
const f = {
|
||||
path: "/a.ts",
|
||||
content: t.source
|
||||
};
|
||||
const host = projectSystem.createServerHost([f, projectSystem.libFile]);
|
||||
const projectService = projectSystem.createProjectService(host);
|
||||
projectService.openClientFile(f.path);
|
||||
const program = projectService.inferredProjects[0].getLanguageService().getProgram();
|
||||
const sourceFile = program.getSourceFile(f.path);
|
||||
const context: RefactorContext = {
|
||||
cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } },
|
||||
newLineCharacter,
|
||||
program,
|
||||
file: sourceFile,
|
||||
startPosition: selectionRange.start,
|
||||
endPosition: selectionRange.end,
|
||||
rulesProvider: getRuleProvider()
|
||||
};
|
||||
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end));
|
||||
assert.isUndefined(rangeToExtract.errors, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText);
|
||||
const infos = refactor.extractSymbol.getAvailableActions(context);
|
||||
assert.isUndefined(find(infos, info => info.description === description.message));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -300,6 +300,11 @@ namespace ts {
|
||||
* @property {number} age
|
||||
* @property {string} name
|
||||
*/`);
|
||||
parsesCorrectly("less-than and greater-than characters",
|
||||
`/**
|
||||
* @param x hi
|
||||
< > still part of the previous comment
|
||||
*/`);
|
||||
});
|
||||
});
|
||||
describe("getFirstToken", () => {
|
||||
|
||||
@@ -156,8 +156,9 @@ namespace ts.codefix {
|
||||
const propertyChangeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter });
|
||||
|
||||
(actions || (actions = [])).push({
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Declare_property_0), [tokenName]),
|
||||
const diag = makeStatic ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0;
|
||||
actions = append(actions, {
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(diag), [tokenName]),
|
||||
changes: propertyChangeTracker.getChanges()
|
||||
});
|
||||
|
||||
@@ -197,11 +198,9 @@ namespace ts.codefix {
|
||||
|
||||
const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter });
|
||||
const diag = makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0;
|
||||
return {
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ?
|
||||
Diagnostics.Declare_method_0 :
|
||||
Diagnostics.Declare_static_method_0),
|
||||
[tokenName]),
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(diag), [tokenName]),
|
||||
changes: methodDeclarationChangeTracker.getChanges()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -581,11 +581,10 @@ namespace ts.Completions {
|
||||
|
||||
return { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters };
|
||||
|
||||
type JSDocTagWithTypeExpression = JSDocAugmentsTag | JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
|
||||
type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag;
|
||||
|
||||
function isTagWithTypeExpression(tag: JSDocTag): tag is JSDocTagWithTypeExpression {
|
||||
switch (tag.kind) {
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
|
||||
@@ -663,9 +663,10 @@ namespace ts.formatting {
|
||||
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line;
|
||||
}
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
// if child is a list item - try to get its indentation, only if parent is within the original range.
|
||||
let childIndentationAmount = Constants.Unknown;
|
||||
if (isListItem) {
|
||||
|
||||
if (isListItem && rangeContainsRange(originalRange, parent)) {
|
||||
childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation);
|
||||
if (childIndentationAmount !== Constants.Unknown) {
|
||||
inheritedIndentation = childIndentationAmount;
|
||||
|
||||
+342
-107
@@ -2,18 +2,21 @@
|
||||
/// <reference path="../../compiler/checker.ts" />
|
||||
|
||||
/* @internal */
|
||||
namespace ts.refactor.extractMethod {
|
||||
const extractMethod: Refactor = {
|
||||
name: "Extract Method",
|
||||
description: Diagnostics.Extract_function.message,
|
||||
namespace ts.refactor.extractSymbol {
|
||||
const extractSymbol: Refactor = {
|
||||
name: "Extract Symbol",
|
||||
description: Diagnostics.Extract_symbol.message,
|
||||
getAvailableActions,
|
||||
getEditsForAction,
|
||||
};
|
||||
|
||||
registerRefactor(extractMethod);
|
||||
registerRefactor(extractSymbol);
|
||||
|
||||
/** Compute the associated code actions */
|
||||
function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
|
||||
/**
|
||||
* Compute the associated code actions
|
||||
* Exported for tests.
|
||||
*/
|
||||
export function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
|
||||
const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) });
|
||||
|
||||
const targetRange: TargetRange = rangeToExtract.targetRange;
|
||||
@@ -27,63 +30,103 @@ namespace ts.refactor.extractMethod {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const actions: RefactorActionInfo[] = [];
|
||||
const usedNames: Map<boolean> = createMap();
|
||||
const functionActions: RefactorActionInfo[] = [];
|
||||
const usedFunctionNames: Map<boolean> = createMap();
|
||||
|
||||
const constantActions: RefactorActionInfo[] = [];
|
||||
const usedConstantNames: Map<boolean> = createMap();
|
||||
|
||||
let i = 0;
|
||||
for (const { scopeDescription, errors } of extractions) {
|
||||
for (const extraction of extractions) {
|
||||
// Skip these since we don't have a way to report errors yet
|
||||
if (errors.length) {
|
||||
continue;
|
||||
if (extraction.functionErrors.length === 0) {
|
||||
// Don't issue refactorings with duplicated names.
|
||||
// Scopes come back in "innermost first" order, so extractions will
|
||||
// preferentially go into nearer scopes
|
||||
const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extraction.functionDescription]);
|
||||
if (!usedFunctionNames.has(description)) {
|
||||
usedFunctionNames.set(description, true);
|
||||
functionActions.push({
|
||||
description,
|
||||
name: `function_scope_${i}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Don't issue refactorings with duplicated names.
|
||||
// Scopes come back in "innermost first" order, so extractions will
|
||||
// preferentially go into nearer scopes
|
||||
const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [scopeDescription]);
|
||||
if (!usedNames.has(description)) {
|
||||
usedNames.set(description, true);
|
||||
actions.push({
|
||||
description,
|
||||
name: `scope_${i}`
|
||||
});
|
||||
// Skip these since we don't have a way to report errors yet
|
||||
if (extraction.constantErrors.length === 0) {
|
||||
// Don't issue refactorings with duplicated names.
|
||||
// Scopes come back in "innermost first" order, so extractions will
|
||||
// preferentially go into nearer scopes
|
||||
const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extraction.constantDescription]);
|
||||
if (!usedConstantNames.has(description)) {
|
||||
usedConstantNames.set(description, true);
|
||||
constantActions.push({
|
||||
description,
|
||||
name: `constant_scope_${i}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// *do* increment i anyway because we'll look for the i-th scope
|
||||
// later when actually doing the refactoring if the user requests it
|
||||
i++;
|
||||
}
|
||||
|
||||
if (actions.length === 0) {
|
||||
return undefined;
|
||||
const infos: ApplicableRefactorInfo[] = [];
|
||||
|
||||
if (functionActions.length) {
|
||||
infos.push({
|
||||
name: extractSymbol.name,
|
||||
description: Diagnostics.Extract_function.message,
|
||||
actions: functionActions
|
||||
});
|
||||
}
|
||||
|
||||
return [{
|
||||
name: extractMethod.name,
|
||||
description: extractMethod.description,
|
||||
inlineable: true,
|
||||
actions
|
||||
}];
|
||||
if (constantActions.length) {
|
||||
infos.push({
|
||||
name: extractSymbol.name,
|
||||
description: Diagnostics.Extract_constant.message,
|
||||
actions: constantActions
|
||||
});
|
||||
}
|
||||
|
||||
return infos.length ? infos : undefined;
|
||||
}
|
||||
|
||||
function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined {
|
||||
/* Exported for tests */
|
||||
export function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined {
|
||||
const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) });
|
||||
const targetRange: TargetRange = rangeToExtract.targetRange;
|
||||
|
||||
const parsedIndexMatch = /^scope_(\d+)$/.exec(actionName);
|
||||
Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp");
|
||||
const index = +parsedIndexMatch[1];
|
||||
Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index");
|
||||
const parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
|
||||
if (parsedFunctionIndexMatch) {
|
||||
const index = +parsedFunctionIndexMatch[1];
|
||||
Debug.assert(isFinite(index), "Expected to parse a finite number from the function scope index");
|
||||
return getFunctionExtractionAtIndex(targetRange, context, index);
|
||||
}
|
||||
|
||||
return getExtractionAtIndex(targetRange, context, index);
|
||||
const parsedConstantIndexMatch = /^constant_scope_(\d+)$/.exec(actionName);
|
||||
if (parsedConstantIndexMatch) {
|
||||
const index = +parsedConstantIndexMatch[1];
|
||||
Debug.assert(isFinite(index), "Expected to parse a finite number from the constant scope index");
|
||||
return getConstantExtractionAtIndex(targetRange, context, index);
|
||||
}
|
||||
|
||||
Debug.fail("Unrecognized action name");
|
||||
}
|
||||
|
||||
// Move these into diagnostic messages if they become user-facing
|
||||
namespace Messages {
|
||||
export namespace Messages {
|
||||
function createMessage(message: string): DiagnosticMessage {
|
||||
return { message, code: 0, category: DiagnosticCategory.Message, key: message };
|
||||
}
|
||||
|
||||
export const CannotExtractFunction: DiagnosticMessage = createMessage("Cannot extract function.");
|
||||
export const CannotExtractRange: DiagnosticMessage = createMessage("Cannot extract range.");
|
||||
export const CannotExtractImport: DiagnosticMessage = createMessage("Cannot extract import statement.");
|
||||
export const CannotExtractSuper: DiagnosticMessage = createMessage("Cannot extract super call.");
|
||||
export const CannotExtractEmpty: DiagnosticMessage = createMessage("Cannot extract empty range.");
|
||||
export const ExpressionExpected: DiagnosticMessage = createMessage("expression expected.");
|
||||
export const StatementOrExpressionExpected: DiagnosticMessage = createMessage("Statement or expression expected.");
|
||||
export const CannotExtractRangeContainingConditionalBreakOrContinueStatements: DiagnosticMessage = createMessage("Cannot extract range containing conditional break or continue statements.");
|
||||
export const CannotExtractRangeContainingConditionalReturnStatement: DiagnosticMessage = createMessage("Cannot extract range containing conditional return statement.");
|
||||
@@ -91,11 +134,14 @@ namespace ts.refactor.extractMethod {
|
||||
export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators.");
|
||||
export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope.");
|
||||
export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope.");
|
||||
export const InsufficientSelection = createMessage("Select more than a single identifier.");
|
||||
export const CannotExtractIdentifier = createMessage("Select more than a single identifier.");
|
||||
export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration");
|
||||
export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns");
|
||||
export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor");
|
||||
export const CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts");
|
||||
export const CannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
||||
export const CannotExtractToOtherFunctionLike = createMessage("Cannot extract method to a function-like scope that is not a function");
|
||||
export const CannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
||||
}
|
||||
|
||||
enum RangeFacts {
|
||||
@@ -150,7 +196,7 @@ namespace ts.refactor.extractMethod {
|
||||
const { length } = span;
|
||||
|
||||
if (length === 0) {
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] };
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractEmpty)] };
|
||||
}
|
||||
|
||||
// Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span.
|
||||
@@ -167,7 +213,7 @@ namespace ts.refactor.extractMethod {
|
||||
|
||||
if (!start || !end) {
|
||||
// cannot find either start or end node
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] };
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] };
|
||||
}
|
||||
|
||||
if (start.parent !== end.parent) {
|
||||
@@ -193,13 +239,13 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
else {
|
||||
// start and end nodes belong to different subtrees
|
||||
return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction);
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] };
|
||||
}
|
||||
}
|
||||
if (start !== end) {
|
||||
// start and end should be statements and parent should be either block or a source file
|
||||
if (!isBlockLike(start.parent)) {
|
||||
return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction);
|
||||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] };
|
||||
}
|
||||
const statements: Statement[] = [];
|
||||
for (const statement of (<BlockLike>start.parent).statements) {
|
||||
@@ -216,22 +262,17 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
return { targetRange: { range: statements, facts: rangeFacts, declarations } };
|
||||
}
|
||||
else {
|
||||
// We have a single node (start)
|
||||
const errors = checkRootNode(start) || checkNode(start);
|
||||
if (errors) {
|
||||
return { errors };
|
||||
}
|
||||
return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations } };
|
||||
}
|
||||
|
||||
function createErrorResult(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage): RangeToExtract {
|
||||
return { errors: [createFileDiagnostic(sourceFile, start, length, message)] };
|
||||
// We have a single node (start)
|
||||
const errors = checkRootNode(start) || checkNode(start);
|
||||
if (errors) {
|
||||
return { errors };
|
||||
}
|
||||
return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations } };
|
||||
|
||||
function checkRootNode(node: Node): Diagnostic[] | undefined {
|
||||
if (isIdentifier(isExpressionStatement(node) ? node.expression : node)) {
|
||||
return [createDiagnosticForNode(node, Messages.InsufficientSelection)];
|
||||
return [createDiagnosticForNode(node, Messages.CannotExtractIdentifier)];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -309,7 +350,7 @@ namespace ts.refactor.extractMethod {
|
||||
// Some things can't be extracted in certain situations
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
(errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractFunction));
|
||||
(errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractImport));
|
||||
return true;
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// For a super *constructor call*, we have to be extracting the entire class,
|
||||
@@ -318,7 +359,7 @@ namespace ts.refactor.extractMethod {
|
||||
// Super constructor call
|
||||
const containingClass = getContainingClass(node);
|
||||
if (containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) {
|
||||
(errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractFunction));
|
||||
(errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractSuper));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -328,7 +369,7 @@ namespace ts.refactor.extractMethod {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!node || isFunctionLike(node) || isClassLike(node)) {
|
||||
if (!node || isFunctionLikeDeclaration(node) || isClassLike(node)) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@@ -439,9 +480,8 @@ namespace ts.refactor.extractMethod {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isValidExtractionTarget(node: Node): node is Scope {
|
||||
// Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method
|
||||
return (node.kind === SyntaxKind.FunctionDeclaration) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node);
|
||||
function isScope(node: Node): node is Scope {
|
||||
return isFunctionLikeDeclaration(node) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,14 +508,14 @@ namespace ts.refactor.extractMethod {
|
||||
// * Function declaration
|
||||
// * Class declaration or expression
|
||||
// * Module/namespace or source file
|
||||
if (current !== start && isValidExtractionTarget(current)) {
|
||||
if (current !== start && isScope(current)) {
|
||||
(scopes = scopes || []).push(current);
|
||||
}
|
||||
|
||||
// A function parameter's initializer is actually in the outer scope, not the function declaration
|
||||
if (current && current.parent && current.parent.kind === SyntaxKind.Parameter) {
|
||||
// Skip all the way to the outer scope of the function that declared this parameter
|
||||
current = findAncestor(current, parent => isFunctionLike(parent)).parent;
|
||||
current = findAncestor(current, parent => isFunctionLikeDeclaration(parent)).parent;
|
||||
}
|
||||
else {
|
||||
current = current.parent;
|
||||
@@ -485,29 +525,44 @@ namespace ts.refactor.extractMethod {
|
||||
return scopes;
|
||||
}
|
||||
|
||||
// exported only for tests
|
||||
export function getExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo {
|
||||
const { scopes, readsAndWrites: { target, usagesPerScope, errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?");
|
||||
function getFunctionExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo {
|
||||
const { scopes, readsAndWrites: { target, usagesPerScope, functionErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
Debug.assert(!functionErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?");
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context);
|
||||
}
|
||||
|
||||
function getConstantExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo {
|
||||
const { scopes, readsAndWrites: { target, usagesPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
Debug.assert(!constantErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?");
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
const expression = isExpression(target)
|
||||
? target
|
||||
: (target.statements[0] as ExpressionStatement).expression;
|
||||
return extractConstantInScope(expression, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange.facts, context);
|
||||
}
|
||||
|
||||
interface PossibleExtraction {
|
||||
readonly scopeDescription: string;
|
||||
readonly errors: ReadonlyArray<Diagnostic>;
|
||||
readonly functionDescription: string;
|
||||
readonly functionErrors: ReadonlyArray<Diagnostic>;
|
||||
readonly constantDescription: string;
|
||||
readonly constantErrors: ReadonlyArray<Diagnostic>;
|
||||
}
|
||||
/**
|
||||
* Given a piece of text to extract ('targetRange'), computes a list of possible extractions.
|
||||
* Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes
|
||||
* or an error explaining why we can't extract into that scope.
|
||||
*/
|
||||
// exported only for tests
|
||||
export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray<PossibleExtraction> | undefined {
|
||||
const { scopes, readsAndWrites: { errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray<PossibleExtraction> | undefined {
|
||||
const { scopes, readsAndWrites: { functionErrorsPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
|
||||
// Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547
|
||||
return scopes.map((scope, i): PossibleExtraction =>
|
||||
({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] }));
|
||||
const extractions = scopes.map((scope, i): PossibleExtraction => ({
|
||||
functionDescription: getDescriptionForFunctionInScope(scope),
|
||||
functionErrors: functionErrorsPerScope[i],
|
||||
constantDescription: getDescriptionForConstantInScope(scope),
|
||||
constantErrors: constantErrorsPerScope[i],
|
||||
}));
|
||||
return extractions;
|
||||
}
|
||||
|
||||
function getPossibleExtractionsWorker(targetRange: TargetRange, context: RefactorContext): { readonly scopes: Scope[], readonly readsAndWrites: ReadsAndWrites } {
|
||||
@@ -533,13 +588,20 @@ namespace ts.refactor.extractMethod {
|
||||
return { scopes, readsAndWrites };
|
||||
}
|
||||
|
||||
function getDescriptionForScope(scope: Scope): string {
|
||||
function getDescriptionForFunctionInScope(scope: Scope): string {
|
||||
return isFunctionLikeDeclaration(scope)
|
||||
? `inner function in ${getDescriptionForFunctionLikeDeclaration(scope)}`
|
||||
: isClassLike(scope)
|
||||
? `method in ${getDescriptionForClassLikeDeclaration(scope)}`
|
||||
: `function in ${getDescriptionForModuleLikeDeclaration(scope)}`;
|
||||
}
|
||||
function getDescriptionForConstantInScope(scope: Scope): string {
|
||||
return isFunctionLikeDeclaration(scope)
|
||||
? `constant in ${getDescriptionForFunctionLikeDeclaration(scope)}`
|
||||
: isClassLike(scope)
|
||||
? `readonly field in ${getDescriptionForClassLikeDeclaration(scope)}`
|
||||
: `constant in ${getDescriptionForModuleLikeDeclaration(scope)}`;
|
||||
}
|
||||
function getDescriptionForFunctionLikeDeclaration(scope: FunctionLikeDeclaration): string {
|
||||
switch (scope.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -573,12 +635,12 @@ namespace ts.refactor.extractMethod {
|
||||
: scope.externalModuleIndicator ? "module scope" : "global scope";
|
||||
}
|
||||
|
||||
function getUniqueName(fileText: string): string {
|
||||
let functionNameText = "newFunction";
|
||||
for (let i = 1; fileText.indexOf(functionNameText) !== -1; i++) {
|
||||
functionNameText = `newFunction_${i}`;
|
||||
function getUniqueName(baseName: string, fileText: string): string {
|
||||
let nameText = baseName;
|
||||
for (let i = 1; fileText.indexOf(nameText) !== -1; i++) {
|
||||
nameText = `${baseName}_${i}`;
|
||||
}
|
||||
return functionNameText;
|
||||
return nameText;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -596,7 +658,7 @@ namespace ts.refactor.extractMethod {
|
||||
|
||||
// Make a unique name for the extracted function
|
||||
const file = scope.getSourceFile();
|
||||
const functionNameText = getUniqueName(file.text);
|
||||
const functionNameText = getUniqueName(isClassLike(scope) ? "newMethod" : "newFunction", file.text);
|
||||
const isJS = isInJavaScriptFile(scope);
|
||||
|
||||
const functionName = createIdentifier(functionNameText);
|
||||
@@ -688,7 +750,7 @@ namespace ts.refactor.extractMethod {
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
const minInsertionPos = (isReadonlyArray(range.range) ? lastOrUndefined(range.range) : range.range).end;
|
||||
const nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope);
|
||||
const nodeToInsertBefore = getNodeToInsertFunctionBefore(minInsertionPos, scope);
|
||||
if (nodeToInsertBefore) {
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter });
|
||||
}
|
||||
@@ -774,27 +836,126 @@ namespace ts.refactor.extractMethod {
|
||||
const renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range;
|
||||
|
||||
const renameFilename = renameRange.getSourceFile().fileName;
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, functionNameText);
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, functionNameText, /*isDeclaredBeforeUse*/ false);
|
||||
return { renameFilename, renameLocation, edits };
|
||||
}
|
||||
|
||||
function getRenameLocation(edits: ReadonlyArray<FileTextChanges>, renameFilename: string, functionNameText: string): number {
|
||||
/**
|
||||
* Result of 'extractRange' operation for a specific scope.
|
||||
* Stores either a list of changes that should be applied to extract a range or a list of errors
|
||||
*/
|
||||
function extractConstantInScope(
|
||||
node: Expression,
|
||||
scope: Scope,
|
||||
{ substitutions }: ScopeUsages,
|
||||
rangeFacts: RangeFacts,
|
||||
context: RefactorContext): RefactorEditInfo {
|
||||
|
||||
const checker = context.program.getTypeChecker();
|
||||
|
||||
// Make a unique name for the extracted variable
|
||||
const file = scope.getSourceFile();
|
||||
const localNameText = getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file.text);
|
||||
const isJS = isInJavaScriptFile(scope);
|
||||
|
||||
const variableType = isJS
|
||||
? undefined
|
||||
: checker.typeToTypeNode(checker.getContextualType(node));
|
||||
|
||||
const initializer = transformConstantInitializer(node, substitutions);
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
|
||||
if (isClassLike(scope)) {
|
||||
Debug.assert(!isJS); // See CannotExtractToJSClass
|
||||
const modifiers: Modifier[] = [];
|
||||
modifiers.push(createToken(SyntaxKind.PrivateKeyword));
|
||||
if (rangeFacts & RangeFacts.InStaticRegion) {
|
||||
modifiers.push(createToken(SyntaxKind.StaticKeyword));
|
||||
}
|
||||
modifiers.push(createToken(SyntaxKind.ReadonlyKeyword));
|
||||
|
||||
const newVariable = createProperty(
|
||||
/*decorators*/ undefined,
|
||||
modifiers,
|
||||
localNameText,
|
||||
/*questionToken*/ undefined,
|
||||
variableType,
|
||||
initializer);
|
||||
|
||||
const localReference = createPropertyAccess(
|
||||
rangeFacts & RangeFacts.InStaticRegion
|
||||
? createIdentifier(scope.name.getText())
|
||||
: createThis(),
|
||||
createIdentifier(localNameText));
|
||||
|
||||
// Declare
|
||||
const minInsertionPos = node.end;
|
||||
const nodeToInsertBefore = getNodeToInsertConstantBefore(minInsertionPos, scope);
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, { suffix: context.newLineCharacter + context.newLineCharacter });
|
||||
|
||||
// Consume
|
||||
changeTracker.replaceNodeWithNodes(context.file, node, [localReference], { nodeSeparator: context.newLineCharacter });
|
||||
}
|
||||
else {
|
||||
const newVariable = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(
|
||||
[createVariableDeclaration(localNameText, variableType, initializer)],
|
||||
NodeFlags.Const));
|
||||
|
||||
// If the parent is an expression statement, replace the statement with the declaration
|
||||
if (node.parent.kind === SyntaxKind.ExpressionStatement) {
|
||||
changeTracker.replaceNodeWithNodes(context.file, node.parent, [newVariable], { nodeSeparator: context.newLineCharacter });
|
||||
}
|
||||
else {
|
||||
// Declare
|
||||
const minInsertionPos = node.end;
|
||||
const nodeToInsertBefore = getNodeToInsertConstantBefore(minInsertionPos, scope);
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, { suffix: context.newLineCharacter + context.newLineCharacter });
|
||||
|
||||
// Consume
|
||||
const localReference = createIdentifier(localNameText);
|
||||
changeTracker.replaceNodeWithNodes(context.file, node, [localReference], { nodeSeparator: context.newLineCharacter });
|
||||
}
|
||||
}
|
||||
|
||||
const edits = changeTracker.getChanges();
|
||||
|
||||
const renameFilename = node.getSourceFile().fileName;
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true);
|
||||
return { renameFilename, renameLocation, edits };
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The index of the (only) reference to the extracted symbol. We want the cursor
|
||||
* to be on the reference, rather than the declaration, because it's closer to where the
|
||||
* user was before extracting it.
|
||||
*/
|
||||
function getRenameLocation(edits: ReadonlyArray<FileTextChanges>, renameFilename: string, functionNameText: string, isDeclaredBeforeUse: boolean): number {
|
||||
let delta = 0;
|
||||
let lastPos = -1;
|
||||
for (const { fileName, textChanges } of edits) {
|
||||
Debug.assert(fileName === renameFilename);
|
||||
for (const change of textChanges) {
|
||||
const { span, newText } = change;
|
||||
// TODO(acasey): We are assuming that the call expression comes before the function declaration,
|
||||
// because we want the new cursor to be on the call expression,
|
||||
// which is closer to where the user was before extracting the function.
|
||||
const index = newText.indexOf(functionNameText);
|
||||
if (index !== -1) {
|
||||
return span.start + delta + index;
|
||||
lastPos = span.start + delta + index;
|
||||
|
||||
// If the reference comes first, return immediately.
|
||||
if (!isDeclaredBeforeUse) {
|
||||
return lastPos;
|
||||
}
|
||||
}
|
||||
delta += newText.length - span.length;
|
||||
}
|
||||
}
|
||||
throw new Error(); // Didn't find the text we inserted?
|
||||
|
||||
// If the declaration comes first, return the position of the last occurrence.
|
||||
Debug.assert(isDeclaredBeforeUse);
|
||||
Debug.assert(lastPos >= 0);
|
||||
return lastPos;
|
||||
}
|
||||
|
||||
function getFirstDeclaration(type: Type): Declaration | undefined {
|
||||
@@ -899,7 +1060,7 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
else {
|
||||
const oldIgnoreReturns = ignoreReturns;
|
||||
ignoreReturns = ignoreReturns || isFunctionLike(node) || isClassLike(node);
|
||||
ignoreReturns = ignoreReturns || isFunctionLikeDeclaration(node) || isClassLike(node);
|
||||
const substitution = substitutions.get(getNodeId(node).toString());
|
||||
const result = substitution || visitEachChild(node, visitor, nullTransformationContext);
|
||||
ignoreReturns = oldIgnoreReturns;
|
||||
@@ -908,8 +1069,19 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
}
|
||||
|
||||
function transformConstantInitializer(initializer: Expression, substitutions: ReadonlyMap<Node>): Expression {
|
||||
return substitutions.size
|
||||
? visitor(initializer) as Expression
|
||||
: initializer;
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
const substitution = substitutions.get(getNodeId(node).toString());
|
||||
return substitution || visitEachChild(node, visitor, nullTransformationContext);
|
||||
}
|
||||
}
|
||||
|
||||
function getStatementsOrClassElements(scope: Scope): ReadonlyArray<Statement> | ReadonlyArray<ClassElement> {
|
||||
if (isFunctionLike(scope)) {
|
||||
if (isFunctionLikeDeclaration(scope)) {
|
||||
const body = scope.body;
|
||||
if (isBlock(body)) {
|
||||
return body.statements;
|
||||
@@ -932,9 +1104,31 @@ namespace ts.refactor.extractMethod {
|
||||
* If `scope` contains a function after `minPos`, then return the first such function.
|
||||
* Otherwise, return `undefined`.
|
||||
*/
|
||||
function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined {
|
||||
function getNodeToInsertFunctionBefore(minPos: number, scope: Scope): Node | undefined {
|
||||
return find<Statement | ClassElement>(getStatementsOrClassElements(scope), child =>
|
||||
child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child));
|
||||
child.pos >= minPos && isFunctionLikeDeclaration(child) && !isConstructorDeclaration(child));
|
||||
}
|
||||
|
||||
// TODO (acasey): need to dig into nested statements
|
||||
// TODO (acasey): don't insert before pinned comments, directives, or triple-slash references
|
||||
function getNodeToInsertConstantBefore(maxPos: number, scope: Scope): Node {
|
||||
const children = getStatementsOrClassElements(scope);
|
||||
Debug.assert(children.length > 0); // There must be at least one child, since we extracted from one.
|
||||
|
||||
const isClassLikeScope = isClassLike(scope);
|
||||
let prevChild: Statement | ClassElement | undefined = undefined;
|
||||
for (const child of children) {
|
||||
if (child.pos >= maxPos) {
|
||||
break;
|
||||
}
|
||||
prevChild = child;
|
||||
if (isClassLikeScope && !isPropertyDeclaration(child)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(prevChild !== undefined);
|
||||
return prevChild;
|
||||
}
|
||||
|
||||
function getPropertyAssignmentsForWrites(writes: ReadonlyArray<UsageEntry>): ShorthandPropertyAssignment[] {
|
||||
@@ -982,7 +1176,8 @@ namespace ts.refactor.extractMethod {
|
||||
interface ReadsAndWrites {
|
||||
readonly target: Expression | Block;
|
||||
readonly usagesPerScope: ReadonlyArray<ScopeUsages>;
|
||||
readonly errorsPerScope: ReadonlyArray<ReadonlyArray<Diagnostic>>;
|
||||
readonly functionErrorsPerScope: ReadonlyArray<ReadonlyArray<Diagnostic>>;
|
||||
readonly constantErrorsPerScope: ReadonlyArray<ReadonlyArray<Diagnostic>>;
|
||||
}
|
||||
function collectReadsAndWrites(
|
||||
targetRange: TargetRange,
|
||||
@@ -995,14 +1190,33 @@ namespace ts.refactor.extractMethod {
|
||||
const allTypeParameterUsages = createMap<TypeParameter>(); // Key is type ID
|
||||
const usagesPerScope: ScopeUsages[] = [];
|
||||
const substitutionsPerScope: Map<Node>[] = [];
|
||||
const errorsPerScope: Diagnostic[][] = [];
|
||||
const functionErrorsPerScope: Diagnostic[][] = [];
|
||||
const constantErrorsPerScope: Diagnostic[][] = [];
|
||||
const visibleDeclarationsInExtractedRange: Symbol[] = [];
|
||||
|
||||
const expressionDiagnostic =
|
||||
isReadonlyArray(targetRange.range) && !(targetRange.range.length === 1 && isExpressionStatement(targetRange.range[0]))
|
||||
? ((start, end) => createFileDiagnostic(sourceFile, start, end - start, Messages.ExpressionExpected))(firstOrUndefined(targetRange.range).getStart(), lastOrUndefined(targetRange.range).end)
|
||||
: undefined;
|
||||
|
||||
// initialize results
|
||||
for (const _ of scopes) {
|
||||
for (const scope of scopes) {
|
||||
usagesPerScope.push({ usages: createMap<UsageEntry>(), typeParameterUsages: createMap<TypeParameter>(), substitutions: createMap<Expression>() });
|
||||
substitutionsPerScope.push(createMap<Expression>());
|
||||
errorsPerScope.push([]);
|
||||
|
||||
functionErrorsPerScope.push(
|
||||
isFunctionLikeDeclaration(scope) && scope.kind !== SyntaxKind.FunctionDeclaration
|
||||
? [createDiagnosticForNode(scope, Messages.CannotExtractToOtherFunctionLike)]
|
||||
: []);
|
||||
|
||||
const constantErrors = [];
|
||||
if (expressionDiagnostic) {
|
||||
constantErrors.push(expressionDiagnostic);
|
||||
}
|
||||
if (isClassLike(scope) && isInJavaScriptFile(scope)) {
|
||||
constantErrors.push(createDiagnosticForNode(scope, Messages.CannotExtractToJSClass));
|
||||
}
|
||||
constantErrorsPerScope.push(constantErrors);
|
||||
}
|
||||
|
||||
const seenUsages = createMap<Usage>();
|
||||
@@ -1054,6 +1268,13 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
|
||||
for (let i = 0; i < scopes.length; i++) {
|
||||
if (!isReadonlyArray(targetRange.range)) {
|
||||
const scopeUsages = usagesPerScope[i];
|
||||
if (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0) {
|
||||
constantErrorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotAccessVariablesFromNestedScopes));
|
||||
}
|
||||
}
|
||||
|
||||
let hasWrite = false;
|
||||
let readonlyClassPropertyWrite: Declaration | undefined = undefined;
|
||||
usagesPerScope[i].usages.forEach(value => {
|
||||
@@ -1068,10 +1289,14 @@ namespace ts.refactor.extractMethod {
|
||||
});
|
||||
|
||||
if (hasWrite && !isReadonlyArray(targetRange.range) && isExpression(targetRange.range)) {
|
||||
errorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns));
|
||||
const diag = createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns);
|
||||
functionErrorsPerScope[i].push(diag);
|
||||
constantErrorsPerScope[i].push(diag);
|
||||
}
|
||||
else if (readonlyClassPropertyWrite && i > 0) {
|
||||
errorsPerScope[i].push(createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor));
|
||||
const diag = createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor);
|
||||
functionErrorsPerScope[i].push(diag);
|
||||
constantErrorsPerScope[i].push(diag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,7 +1306,7 @@ namespace ts.refactor.extractMethod {
|
||||
forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
|
||||
}
|
||||
|
||||
return { target, usagesPerScope, errorsPerScope };
|
||||
return { target, usagesPerScope, functionErrorsPerScope, constantErrorsPerScope };
|
||||
|
||||
function hasTypeParameters(node: Node) {
|
||||
return isDeclarationWithTypeParameters(node) &&
|
||||
@@ -1157,9 +1382,9 @@ namespace ts.refactor.extractMethod {
|
||||
if (symbolId) {
|
||||
for (let i = 0; i < scopes.length; i++) {
|
||||
// push substitution from map<symbolId, subst> to map<nodeId, subst> to simplify rewriting
|
||||
const substitition = substitutionsPerScope[i].get(symbolId);
|
||||
if (substitition) {
|
||||
usagesPerScope[i].substitutions.set(getNodeId(n).toString(), substitition);
|
||||
const substitution = substitutionsPerScope[i].get(symbolId);
|
||||
if (substitution) {
|
||||
usagesPerScope[i].substitutions.set(getNodeId(n).toString(), substitution);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1211,8 +1436,12 @@ namespace ts.refactor.extractMethod {
|
||||
if (targetRange.facts & RangeFacts.IsGenerator && usage === Usage.Write) {
|
||||
// this is write to a reference located outside of the target scope and range is extracted into generator
|
||||
// currently this is unsupported scenario
|
||||
for (const errors of errorsPerScope) {
|
||||
errors.push(createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators));
|
||||
const diag = createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators);
|
||||
for (const errors of functionErrorsPerScope) {
|
||||
errors.push(diag);
|
||||
}
|
||||
for (const errors of constantErrorsPerScope) {
|
||||
errors.push(diag);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < scopes.length; i++) {
|
||||
@@ -1230,7 +1459,9 @@ namespace ts.refactor.extractMethod {
|
||||
// If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument
|
||||
// so there's no problem.
|
||||
if (!(symbol.flags & SymbolFlags.TypeParameter)) {
|
||||
errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope));
|
||||
const diag = createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope);
|
||||
functionErrorsPerScope[i].push(diag);
|
||||
constantErrorsPerScope[i].push(diag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1250,8 +1481,12 @@ namespace ts.refactor.extractMethod {
|
||||
// Otherwise check and recurse.
|
||||
const sym = checker.getSymbolAtLocation(node);
|
||||
if (sym && visibleDeclarationsInExtractedRange.some(d => d === sym)) {
|
||||
for (const scope of errorsPerScope) {
|
||||
scope.push(createDiagnosticForNode(node, Messages.CannotExtractExportedEntity));
|
||||
const diag = createDiagnosticForNode(node, Messages.CannotExtractExportedEntity);
|
||||
for (const errors of functionErrorsPerScope) {
|
||||
errors.push(diag);
|
||||
}
|
||||
for (const errors of constantErrorsPerScope) {
|
||||
errors.push(diag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
/// <reference path="convertFunctionToEs6Class.ts" />
|
||||
/// <reference path="extractMethod.ts" />
|
||||
/// <reference path="extractSymbol.ts" />
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return unescapeLeadingUnderscores(this.escapedName);
|
||||
return symbolName(this);
|
||||
}
|
||||
|
||||
getEscapedName(): __String {
|
||||
@@ -383,7 +383,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return unescapeLeadingUnderscores(this.escapedText);
|
||||
return idText(this);
|
||||
}
|
||||
}
|
||||
IdentifierObject.prototype.kind = SyntaxKind.Identifier;
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"pos": 0,
|
||||
"end": 61,
|
||||
"tags": {
|
||||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 7,
|
||||
"end": 16,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 7,
|
||||
"end": 8
|
||||
},
|
||||
"tagName": {
|
||||
"kind": "Identifier",
|
||||
"pos": 8,
|
||||
"end": 13,
|
||||
"escapedText": "param"
|
||||
},
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 14,
|
||||
"end": 15,
|
||||
"escapedText": "x"
|
||||
},
|
||||
"isNameFirst": true,
|
||||
"isBracketed": false,
|
||||
"comment": "hi\n< > still part of the previous comment"
|
||||
},
|
||||
"length": 1,
|
||||
"pos": 7,
|
||||
"end": 16
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// ==ORIGINAL==
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// ==ORIGINAL==
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10; j++) {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
x = 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
x = 1;
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
class C {
|
||||
private readonly newProperty = 1;
|
||||
|
||||
x = this./*RENAME*/newProperty;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in method 'M3==
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in method 'M3==
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
private readonly newProperty = 1;
|
||||
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = this./*RENAME*/newProperty;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
a = 1;
|
||||
b = 2;
|
||||
M1() { }
|
||||
M2() { }
|
||||
M3() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// ==ORIGINAL==
|
||||
"hello";
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const /*RENAME*/newLocal = "hello";
|
||||
@@ -0,0 +1,4 @@
|
||||
// ==ORIGINAL==
|
||||
"hello";
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const /*RENAME*/newLocal = "hello";
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// ==ORIGINAL==
|
||||
"hello";
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const /*RENAME*/newLocal = "hello";
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// ==ORIGINAL==
|
||||
"hello";
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const /*RENAME*/newLocal = "hello";
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
function F() {
|
||||
let x = 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in function 'F'==
|
||||
function F() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
function F() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
function F() {
|
||||
let x = 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in function 'F'==
|
||||
function F() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
function F() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
M() {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in method 'M==
|
||||
class C {
|
||||
M() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
M() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// ==ORIGINAL==
|
||||
class C {
|
||||
M() {
|
||||
let x = 1;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in method 'M==
|
||||
class C {
|
||||
M() {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
class C {
|
||||
private readonly newProperty = 1;
|
||||
|
||||
M() {
|
||||
let x = this./*RENAME*/newProperty;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
class C {
|
||||
M() {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
namespace N {
|
||||
let x = 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in namespace 'N'==
|
||||
namespace N {
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
namespace N {
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// ==ORIGINAL==
|
||||
function F() {
|
||||
let w = 1;
|
||||
let x = w + 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in function 'F'==
|
||||
function F() {
|
||||
let w = 1;
|
||||
const newLocal = w + 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// ==ORIGINAL==
|
||||
function F() {
|
||||
let w = 1;
|
||||
let x = w + 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in function 'F'==
|
||||
function F() {
|
||||
let w = 1;
|
||||
const newLocal = w + 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// ==ORIGINAL==
|
||||
let x = 1;
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
@@ -0,0 +1,6 @@
|
||||
// ==ORIGINAL==
|
||||
let x = 1;
|
||||
// ==SCOPE::Extract to constant in global scope==
|
||||
const newLocal = 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
@@ -0,0 +1,10 @@
|
||||
// ==ORIGINAL==
|
||||
function F<T>(t: T) {
|
||||
let x = t + 1;
|
||||
}
|
||||
// ==SCOPE::Extract to constant in function 'F'==
|
||||
function F<T>(t: T) {
|
||||
const newLocal = t + 1;
|
||||
|
||||
let x = /*RENAME*/newLocal;
|
||||
}
|
||||
+4
-4
@@ -14,7 +14,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'a'==
|
||||
// ==SCOPE::Extract to inner function in function 'a'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -34,7 +34,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'B'==
|
||||
// ==SCOPE::Extract to function in namespace 'B'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -55,7 +55,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'A'==
|
||||
// ==SCOPE::Extract to function in namespace 'A'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -76,7 +76,7 @@ namespace A {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
+5
-5
@@ -9,22 +9,22 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in class 'C'==
|
||||
// ==SCOPE::Extract to method in class 'C'==
|
||||
namespace A {
|
||||
export interface I { x: number };
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
return this./*RENAME*/newFunction();
|
||||
return this./*RENAME*/newMethod();
|
||||
}
|
||||
|
||||
private newFunction() {
|
||||
private newMethod() {
|
||||
let a1: I = { x: 1 };
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'A'==
|
||||
// ==SCOPE::Extract to function in namespace 'A'==
|
||||
namespace A {
|
||||
export interface I { x: number };
|
||||
class C {
|
||||
@@ -39,7 +39,7 @@ namespace A {
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
namespace A {
|
||||
export interface I { x: number };
|
||||
class C {
|
||||
+5
-5
@@ -11,18 +11,18 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in class 'C'==
|
||||
// ==SCOPE::Extract to method in class 'C'==
|
||||
namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
a() {
|
||||
let z = 1;
|
||||
var __return: any;
|
||||
({ __return, z } = this./*RENAME*/newFunction(z));
|
||||
({ __return, z } = this./*RENAME*/newMethod(z));
|
||||
return __return;
|
||||
}
|
||||
|
||||
private newFunction(z: number) {
|
||||
private newMethod(z: number) {
|
||||
let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
@@ -30,7 +30,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'A'==
|
||||
// ==SCOPE::Extract to function in namespace 'A'==
|
||||
namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
@@ -49,7 +49,7 @@ namespace A {
|
||||
return { __return: a1.x + 10, z };
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
+3
-3
@@ -13,7 +13,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in class 'C'==
|
||||
// ==SCOPE::Extract to method in class 'C'==
|
||||
namespace A {
|
||||
let y = 1;
|
||||
class C {
|
||||
@@ -21,11 +21,11 @@ namespace A {
|
||||
a() {
|
||||
let z = 1;
|
||||
var __return: any;
|
||||
({ __return, z } = this./*RENAME*/newFunction(z));
|
||||
({ __return, z } = this./*RENAME*/newMethod(z));
|
||||
return __return;
|
||||
}
|
||||
|
||||
private newFunction(z: number) {
|
||||
private newMethod(z: number) {
|
||||
let a1 = { x: 1 };
|
||||
y = 10;
|
||||
z = 42;
|
||||
+3
-3
@@ -14,7 +14,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F2'==
|
||||
// ==SCOPE::Extract to inner function in function 'F2'==
|
||||
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
|
||||
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F1'==
|
||||
// ==SCOPE::Extract to inner function in function 'F1'==
|
||||
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
|
||||
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
@@ -54,7 +54,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
<U1a, U1b>(u1a: U1a, u1b: U1b) => {
|
||||
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
// ==ORIGINAL==
|
||||
function F<T>(t1: T) {
|
||||
function F<T>(t2: T) {
|
||||
function G<T>(t2: T) {
|
||||
t1.toString();
|
||||
t2.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'G'==
|
||||
function F<T>(t1: T) {
|
||||
function F<T>(t2: T) {
|
||||
function G<T>(t2: T) {
|
||||
/*RENAME*/newFunction();
|
||||
|
||||
function newFunction() {
|
||||
@@ -16,9 +16,9 @@ function F<T>(t1: T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'F'==
|
||||
function F<T>(t1: T) {
|
||||
function F<T>(t2: T) {
|
||||
function G<T>(t2: T) {
|
||||
/*RENAME*/newFunction<T>(t2);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ function F<T>(t1: T) {
|
||||
t2.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
function F<T>(t1: T) {
|
||||
function F<T>(t2: T) {
|
||||
function G<T>(t2: T) {
|
||||
/*RENAME*/newFunction<T, T>(t1, t2);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,12 +1,12 @@
|
||||
// ==ORIGINAL==
|
||||
function F<T>(t1: T) {
|
||||
function F<U extends T[]>(t2: U) {
|
||||
function G<U extends T[]>(t2: U) {
|
||||
t2.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'G'==
|
||||
function F<T>(t1: T) {
|
||||
function F<U extends T[]>(t2: U) {
|
||||
function G<U extends T[]>(t2: U) {
|
||||
/*RENAME*/newFunction();
|
||||
|
||||
function newFunction() {
|
||||
@@ -14,9 +14,9 @@ function F<T>(t1: T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'F'==
|
||||
function F<T>(t1: T) {
|
||||
function F<U extends T[]>(t2: U) {
|
||||
function G<U extends T[]>(t2: U) {
|
||||
/*RENAME*/newFunction<U>(t2);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ function F<T>(t1: T) {
|
||||
t2.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
function F<T>(t1: T) {
|
||||
function F<U extends T[]>(t2: U) {
|
||||
function G<U extends T[]>(t2: U) {
|
||||
/*RENAME*/newFunction<T, U>(t2);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
function F<T>() {
|
||||
const array: T[] = [];
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'F'==
|
||||
function F<T>() {
|
||||
const array: T[] = /*RENAME*/newFunction();
|
||||
|
||||
@@ -10,7 +10,7 @@ function F<T>() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
function F<T>() {
|
||||
const array: T[] = /*RENAME*/newFunction<T>();
|
||||
}
|
||||
+4
-4
@@ -4,17 +4,17 @@ class C<T1, T2> {
|
||||
t1.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in class 'C'==
|
||||
// ==SCOPE::Extract to method in class 'C'==
|
||||
class C<T1, T2> {
|
||||
M(t1: T1, t2: T2) {
|
||||
this./*RENAME*/newFunction(t1);
|
||||
this./*RENAME*/newMethod(t1);
|
||||
}
|
||||
|
||||
private newFunction(t1: T1) {
|
||||
private newMethod(t1: T1) {
|
||||
t1.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
class C<T1, T2> {
|
||||
M(t1: T1, t2: T2) {
|
||||
/*RENAME*/newFunction<T1>(t1);
|
||||
+4
-4
@@ -4,17 +4,17 @@ class C {
|
||||
t1.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in class 'C'==
|
||||
// ==SCOPE::Extract to method in class 'C'==
|
||||
class C {
|
||||
M<T1, T2>(t1: T1, t2: T2) {
|
||||
this./*RENAME*/newFunction<T1>(t1);
|
||||
this./*RENAME*/newMethod<T1>(t1);
|
||||
}
|
||||
|
||||
private newFunction<T1>(t1: T1) {
|
||||
private newMethod<T1>(t1: T1) {
|
||||
t1.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
class C {
|
||||
M<T1, T2>(t1: T1, t2: T2) {
|
||||
/*RENAME*/newFunction<T1>(t1);
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
v.toString();
|
||||
}
|
||||
// ==SCOPE::inner function in function 'F'==
|
||||
// ==SCOPE::Extract to inner function in function 'F'==
|
||||
function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
/*RENAME*/newFunction();
|
||||
|
||||
@@ -10,7 +10,7 @@ function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
v.toString();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
function F<T, U extends T[], V extends U[]>(v: V) {
|
||||
/*RENAME*/newFunction<T, U, V>(v);
|
||||
}
|
||||
+4
-4
@@ -12,7 +12,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::inner function in function 'a'==
|
||||
// ==SCOPE::Extract to inner function in function 'a'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -30,7 +30,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'B'==
|
||||
// ==SCOPE::Extract to function in namespace 'B'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -48,7 +48,7 @@ namespace A {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in namespace 'A'==
|
||||
// ==SCOPE::Extract to function in namespace 'A'==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
@@ -66,7 +66,7 @@ namespace A {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
namespace A {
|
||||
let x = 1;
|
||||
function foo() {
|
||||
+4
-4
@@ -5,18 +5,18 @@ const _ = class {
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::method in anonymous class expression==
|
||||
// ==SCOPE::Extract to method in anonymous class expression==
|
||||
const _ = class {
|
||||
a() {
|
||||
return this./*RENAME*/newFunction();
|
||||
return this./*RENAME*/newMethod();
|
||||
}
|
||||
|
||||
private newFunction() {
|
||||
newMethod() {
|
||||
let a1 = { x: 1 };
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::function in global scope==
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
const _ = class {
|
||||
a() {
|
||||
return /*RENAME*/newFunction();
|
||||
@@ -0,0 +1,28 @@
|
||||
// ==ORIGINAL==
|
||||
const _ = class {
|
||||
a() {
|
||||
let a1 = { x: 1 };
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to method in anonymous class expression==
|
||||
const _ = class {
|
||||
a() {
|
||||
return this./*RENAME*/newMethod();
|
||||
}
|
||||
|
||||
private newMethod() {
|
||||
let a1 = { x: 1 };
|
||||
return a1.x + 10;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
const _ = class {
|
||||
a() {
|
||||
return /*RENAME*/newFunction();
|
||||
}
|
||||
}
|
||||
function newFunction() {
|
||||
let a1 = { x: 1 };
|
||||
return a1.x + 10;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// ==ORIGINAL==
|
||||
function foo() {
|
||||
let x = 10;
|
||||
x++;
|
||||
return;
|
||||
}
|
||||
// ==SCOPE::Extract to inner function in function 'foo'==
|
||||
function foo() {
|
||||
let x = 10;
|
||||
return /*RENAME*/newFunction();
|
||||
|
||||
function newFunction() {
|
||||
x++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
function foo() {
|
||||
let x = 10;
|
||||
x = /*RENAME*/newFunction(x);
|
||||
return;
|
||||
}
|
||||
function newFunction(x) {
|
||||
x++;
|
||||
return x;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user